You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-12Lines changed: 10 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,7 @@ In addition to the virtual machine itself you'll also find:
16
16
* Several[example programs](examples/).
17
17
* An example of[embedding](embedded.c) the virtual machine in a C host program.
18
18
* Along with the definition of a custom-opcode handler.
19
+
* A golang-interpreter for our bytecode.
19
20
20
21
This particular virtual machine is intentionally simple, but despite that it is hopefully implemented in a readable fashion. ("Simplicity" here means that we support only a small number of instructions, and the registers the virtual CPU possesses can store strings and integers, but not floating-point values.)
21
22
This particular virtual machine is register-based, having ten registers which can be used to store strings or integer values.
@@ -180,12 +181,14 @@ There are more examples stored beneath the `examples/` subdirectory in this repo
180
181
Golang Port
181
182
-----------
182
183
183
-
The virtual-machine which executes the bytecode is written in C,so for fun
184
+
The virtual-machine which executes the bytecode is written in C,but for fun
184
185
I thought it would be interesting to port it to golang.
185
186
186
-
The result is`main.go` which executes some of the programs, it will terminate
187
-
when it reaches an instruction which hasn't been implemented. For the moment
188
-
it runs a few of the examples:
187
+
The result is`main.go` which executes most of the sample programs, for those
188
+
that it cannot execute it will cleanly terminate when it reaches a bytecode
189
+
instruction which hasn't been implemented.
190
+
191
+
Sample usage:
189
192
190
193
$ ./compiler examples/jump.in
191
194
$ go run main.go examples/jump.raw
@@ -202,20 +205,15 @@ Similarly you can run the looping example:
202
205
Counting from ten to zero
203
206
10
204
207
9
205
-
8
206
-
7
207
-
6
208
-
5
209
-
4
210
-
3
211
-
2
212
-
1
208
+
..
209
+
..
213
210
0
214
211
Done
215
212
216
213
If you wish to submit a pull request implementing the missing opcodes I'd