about summary refs log tree commit diff stats
path: root/mu.arc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-07-11 21:29:43 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-07-11 21:29:43 -0700
commitb83c85c8a41dd0e6042e2e3a07e8550cd2eca59b (patch)
tree5bb55779e5c24e1d704fbf80ed6e03035ae6b974 /mu.arc
parent77f8e6cd2534fb7c63b0021b7adcd1a2b8348402 (diff)
downloadmu-b83c85c8a41dd0e6042e2e3a07e8550cd2eca59b.tar.gz
16 - conditional and unconditional jumps
Diffstat (limited to 'mu.arc')
-rw-r--r--mu.arc11
1 files changed, 11 insertions, 0 deletions
diff --git a/mu.arc b/mu.arc
index 78d2f654..a4bf4e2d 100644
--- a/mu.arc
+++ b/mu.arc
@@ -3,6 +3,7 @@
 (def clear ()
   (= types* (obj
               integer (obj size 1)
+              location (obj size 1)
               address (obj size 1)))
   (= memory* (table))
   (= function* (table)))
@@ -19,7 +20,9 @@
 
 (def run (instrs (o fn-args))
   (ret result nil
+;?     (prn instrs)
     (for pc 0 (< pc len.instrs) (++ pc)
+;?       (prn pc)
       (let instr instrs.pc
 ;?         (prn instr)
 ;?         (prn memory*)
@@ -53,6 +56,14 @@
                 (= (memory* oarg.0.1)
                    ; hardcoded channel for now
                    (memory* pop.fn-args.1))
+              jmp
+                (do (= pc arg.0.1)
+;?                     (prn "jumping to " pc)
+                    (continue))
+              jifz
+                (when (is 0 (memory* arg.0.1))
+                  (= pc arg.1.1)
+                  (continue))
               reply
                 (do (= result arg)
                     (break))