diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2014-07-11 22:28:51 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2014-07-11 22:28:51 -0700 |
commit | d17e8291efb5fb7c6f793ef925c6c262ce855581 (patch) | |
tree | c671e45336cae97d65a543c2cc8e3cc129d31327 | |
parent | 368e76cdf685e589f807755bdd39a31e8ccd2c83 (diff) | |
download | mu-d17e8291efb5fb7c6f793ef925c6c262ce855581.tar.gz |
20 - relative addressing for jumps
-rw-r--r-- | mu.arc | 4 | ||||
-rw-r--r-- | mu.arc.t | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/mu.arc b/mu.arc index 765ccf4b..d0f83099 100644 --- a/mu.arc +++ b/mu.arc @@ -69,13 +69,13 @@ (= (memory* oarg.0.1) (type* (otypes arg.0))) jmp - (do (= pc (- arg.0.1 1)) ; because continue still increments (bug) + (do (= pc (+ pc arg.0.1)) ; relies on continue still incrementing (bug) ;? (prn "jumping to " pc) (continue)) jifz (when (is 0 (memory* arg.0.1)) ;? (prn "jumping to " arg.1.1) - (= pc (- arg.1.1 1)) ; because continue still increments (bug) + (= pc (+ pc arg.1.1)) ; relies on continue still incrementing (bug) (continue)) reply (do (= result arg) diff --git a/mu.arc.t b/mu.arc.t index d35bddf0..8150f4a1 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -166,7 +166,7 @@ (add-fns '((main ((integer 1) <- loadi 8) - (jmp (location 3)) + (jmp (offset 1)) ((integer 2) <- loadi 3) (reply)))) (run function*!main) @@ -178,7 +178,7 @@ (add-fns '((main ((integer 1) <- loadi 8) - (jmp (location 3)) + (jmp (offset 1)) ((integer 2) <- loadi 3) (reply) ((integer 3) <- loadi 34)))) @@ -191,7 +191,7 @@ (add-fns '((main ((integer 1) <- loadi 0) - (jifz (integer 1) (location 3)) + (jifz (integer 1) (offset 1)) ((integer 2) <- loadi 3) (reply) ((integer 3) <- loadi 34)))) @@ -204,7 +204,7 @@ (add-fns '((main ((integer 1) <- loadi 1) - (jifz (integer 1) (location 3)) + (jifz (integer 1) (offset 1)) ((integer 2) <- loadi 3) (reply) ((integer 3) <- loadi 34)))) @@ -219,7 +219,7 @@ ((integer 4) <- otype 0) ((integer 5) <- loadi 0) ; type index corresponding to 'integer' ((integer 6) <- sub (integer 4) (integer 5)) - (jifz (integer 6) (location 5)) + (jifz (integer 6) (offset 1)) (reply) ((integer 7) <- arg) ((integer 8) <- arg) |