History

Added instructions and two Limbo source files.

David Boddie committed 9 years agomaster

Commit 1b726d61 parent 9e7fadd3 files · +130 −0Browse files

Unified · Split

3 files
  1. README.txt +97 −0
  2. Tests/Limbo/count.b +17 −0
  3. Tests/Limbo/countmin.b +16 −0
README.txt+97−0
@@ -0,0 +1,97 @@
1Dis Virtual Machine Tools for Python
2====================================
3
4Introduction
5------------
6
7This package contains Python modules for reading and writing files for the Dis
8virtual machine[1], used by the Inferno operating system[2]. Although the aim
9of these modules was to create a toolchain for producing .dis files, they are
10more useful for reading existing ones.
11
12Reading a .dis File
13-------------------
14
15Sample .dis files are not provided, but you can compile the Limbo source code
16files from the Tests/Limbo directory to obtain simple .dis files to inspect.
17This is done using the limbo compiler supplied with Inferno.
18
19From within the package directory, or with the directory on the PYTHONPATH,
20you can run the Python interpreter and inspect the contents of an existing .dis
21file in the following way:
22
23 import dis
24 d = dis.Dis()
25 d.read(open("/tmp/countmin.dis"), "countmin.dis")
26 d.list()
27
28For the compiled version of the countmin.b file, the Python should produce
29output similar to the following:
30
31 0x0: load 0(mp), $0x0, 48(fp)
32 0x1: movw $0x0, 40(fp)
33 0x2: blew $0x7b, 40(fp), $0x5
34 0x3: addw $0x1, 40(fp)
35 0x4: jmp $0x2
36 0x5: ret
37
38 entry 0x0, 1
39 desc $0x0, 8, "c0"
40 desc $0x1, 56, "00c8"
41
42 var @mp, 8
43 string @mp+0, "$Sys"
44
45 module count
46
47 link 0x0, 1, 0x4244b354, "init"
48
49 ldts @ldt, 0
50
51 source "/tmp/countmin.b"
52
53The location of the source file when it was compiled by the limbo compiler will
54influence the value presented in the output of the list() method.
55
56Tests
57-----
58
59Some tests that write .dis files are included in the Tests directory. These
60will try to create the corresponding .dis files to their equivalent Limbo
61programs. Ensure that the package directory is on the PYTHONPATH and run them
62in the following way:
63
64 PYTHONPATH=. ./Tests/countmin.py /tmp/countmin.dis
65
66You should then be able to run them in the Inferno emulator and inspect them
67using the method described in the previous section.
68
69Authors and License
70-------------------
71
72David Boddie <david@boddie.org.uk>
73
74Unless indicated otherwise, the contents of this package are licensed under the
75GNU General Public License version 3 (or later).
76
77 Copyright (C) 2017 David Boddie <david@boddie.org.uk>
78
79 This program is free software: you can redistribute it and/or modify
80 it under the terms of the GNU General Public License as published by
81 the Free Software Foundation, either version 3 of the License, or
82 (at your option) any later version.
83
84 This program is distributed in the hope that it will be useful,
85 but WITHOUT ANY WARRANTY; without even the implied warranty of
86 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
87 GNU General Public License for more details.
88
89 You should have received a copy of the GNU General Public License
90 along with this program. If not, see <http://www.gnu.org/licenses/>.
91
92References
93----------
94
95[1] http://inferno-os.org/inferno/papers/dis.html
96[2] http://inferno-os.org
97[3] http://inferno-os.org/inferno/papers/limbo.html
Tests/Limbo/count.b+17−0
@@ -0,0 +1,17 @@
1implement count;
2
3include "sys.m";
4include "draw.m";
5
6count: module
7{
8 init: fn(ctxt: ref Draw->Context, args: list of string);
9};
10
11init(ctxt: ref Draw->Context, args: list of string)
12{
13 sys := load Sys Sys->PATH;
14 sys->print("Counting...\n");
15 for (i := 0; i < 20; i++)
16 sys->print("%d\n", i);
17}
Tests/Limbo/countmin.b+16−0
@@ -0,0 +1,16 @@
1implement count;
2
3include "sys.m";
4include "draw.m";
5
6count: module
7{
8 init: fn(ctxt: ref Draw->Context, args: list of string);
9};
10
11init(ctxt: ref Draw->Context, args: list of string)
12{
13 sys := load Sys Sys->PATH;
14 for (i := 0; i < 123; i++)
15 ;
16}