aboutsummaryrefslogtreecommitdiff
path: root/examples/hello.asm
diff options
context:
space:
mode:
Diffstat (limited to 'examples/hello.asm')
-rw-r--r--examples/hello.asm18
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/hello.asm b/examples/hello.asm
new file mode 100644
index 0000000..1b3897a
--- /dev/null
+++ b/examples/hello.asm
@@ -0,0 +1,18 @@
+; Assembler test for DCPU
+; by Markus Persson
+
+ set a, 0xbeef ; Assign 0xbeef to register a
+ set [0x1000], a ; Assign memory at 0x1000 to value of register a
+ ifn a, [0x1000] ; Compare value of register a to memory at 0x1000 ..
+ set PC, end ; .. and jump to end if they don't match
+
+ set i, 0 ; Init loop counter, for clarity
+:nextchar ife [data+i], 0 ; If the character is 0 ..
+ set PC, end ; .. jump to the end
+ set [0x8000+i], [data+i] ; Video ram starts at 0x8000, copy char there
+ add i, 1 ; Increase loop counter
+ set PC, nextchar ; Loop
+
+:data dat "Hello world!", 0 ; Zero terminated string
+
+:end sub PC, 1 ; Freeze the CPU forever \ No newline at end of file