Permalink
Browse files

meta: A handful of simple words.

So close! Just gotta implement interpret, and then we can start the debugging
process.
  • Loading branch information...
1 parent 6c9edd4 commit 19ceb3019cc244d088483d304d97bdbea632e612 @MostAwesomeDude committed Apr 12, 2012
Showing with 21 additions and 0 deletions.
  1. +21 −0 cauliflower/meta.py
View
@@ -291,13 +291,32 @@ def thread(self, name, words, flags=None):
ucode += assemble(ADD, J, 0x1)
ma.asm("0branch", ucode)
+# Goddammit DCPU!
+ucode = assemble(SUB, J, [J])
+ma.asm("nbranch", ucode)
+
+ucode = assemble(IFN, Z, 0x0)
+ucode += assemble(SUB, J, [J])
+ucode += assemble(IFE, Z, 0x0)
+ucode += assemble(ADD, J, 0x1)
+ma.asm("0nbranch", ucode)
+
# Main stack manipulation.
ucode = assemble(SET, PUSH, Z)
ma.asm("dup", ucode)
# Return stack manipulation.
+ucode = _push(0xd000)
+ma.asm("r0", ucode)
+
+ucode = _push(Y)
+ma.asm("rsp@", ucode)
+
+ucode = _pop(Y)
+ma.asm("rsp!", ucode)
+
ucode = _push([Y])
ucode += assemble(ADD, Y, 0x1)
ma.asm("r>", ucode)
@@ -444,4 +463,6 @@ def thread(self, name, words, flags=None):
"[",
], flags=IMMEDIATE)
+# ma.thread("quit", ["r0", "rsp!", "interpret", "nbranch", 0x8])
+
ma.finalize()

0 comments on commit 19ceb30

Please sign in to comment.