aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-04-05 22:32:25 -0500
committerJesse Luehrs <doy@tozt.net>2012-04-05 22:32:25 -0500
commit3394c2ace3a2c555cce22095f66cfc258873d8c0 (patch)
tree14dfe8b54f81419ae1234caa4963ca66339d96a2
parent8afefbfb5d3978deeddb40b03b4a5a9d1ad240f0 (diff)
downloadgames-emulation-dcpu16-3394c2ace3a2c555cce22095f66cfc258873d8c0.tar.gz
games-emulation-dcpu16-3394c2ace3a2c555cce22095f66cfc258873d8c0.zip
example asm file from the spec
-rw-r--r--examples/spec.asm28
1 files changed, 28 insertions, 0 deletions
diff --git a/examples/spec.asm b/examples/spec.asm
new file mode 100644
index 0000000..3000d44
--- /dev/null
+++ b/examples/spec.asm
@@ -0,0 +1,28 @@
+; Try some basic stuff
+ SET A, 0x30 ; 7c01 0030
+ SET [0x1000], 0x20 ; 7de1 1000 0020
+ SUB A, [0x1000] ; 7803 1000
+ IFN A, 0x10 ; c00d
+ SET PC, crash ; 7dc1 001a [*]
+
+; Do a loopy thing
+ SET I, 10 ; a861
+ SET A, 0x2000 ; 7c01 2000
+:loop SET [0x2000+I], [A] ; 2161 2000
+ SUB I, 1 ; 8463
+ IFN I, 0 ; 806d
+ SET PC, loop ; 7dc1 000d [*]
+
+; Call a subroutine
+ SET X, 0x4 ; 9031
+ JSR testsub ; 7c10 0018 [*]
+ SET PC, crash ; 7dc1 001a [*]
+
+:testsub SHL X, 4 ; 9037
+ SET PC, POP ; 61c1
+
+; Hang forever. X should now be 0x40 if everything went right.
+:crash SET PC, crash ; 7dc1 001a [*]
+
+; [*]: Note that these can be one word shorter and one cycle faster by using the short form (0x00-0x1f) of literals,
+; but my assembler doesn't support short form labels yet.