20 - relative addressing for jumps
This commit is contained in:
parent
368e76cdf6
commit
d17e8291ef
4
mu.arc
4
mu.arc
|
@ -69,13 +69,13 @@
|
||||||
(= (memory* oarg.0.1)
|
(= (memory* oarg.0.1)
|
||||||
(type* (otypes arg.0)))
|
(type* (otypes arg.0)))
|
||||||
jmp
|
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)
|
;? (prn "jumping to " pc)
|
||||||
(continue))
|
(continue))
|
||||||
jifz
|
jifz
|
||||||
(when (is 0 (memory* arg.0.1))
|
(when (is 0 (memory* arg.0.1))
|
||||||
;? (prn "jumping to " arg.1.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))
|
(continue))
|
||||||
reply
|
reply
|
||||||
(do (= result arg)
|
(do (= result arg)
|
||||||
|
|
10
mu.arc.t
10
mu.arc.t
|
@ -166,7 +166,7 @@
|
||||||
(add-fns
|
(add-fns
|
||||||
'((main
|
'((main
|
||||||
((integer 1) <- loadi 8)
|
((integer 1) <- loadi 8)
|
||||||
(jmp (location 3))
|
(jmp (offset 1))
|
||||||
((integer 2) <- loadi 3)
|
((integer 2) <- loadi 3)
|
||||||
(reply))))
|
(reply))))
|
||||||
(run function*!main)
|
(run function*!main)
|
||||||
|
@ -178,7 +178,7 @@
|
||||||
(add-fns
|
(add-fns
|
||||||
'((main
|
'((main
|
||||||
((integer 1) <- loadi 8)
|
((integer 1) <- loadi 8)
|
||||||
(jmp (location 3))
|
(jmp (offset 1))
|
||||||
((integer 2) <- loadi 3)
|
((integer 2) <- loadi 3)
|
||||||
(reply)
|
(reply)
|
||||||
((integer 3) <- loadi 34))))
|
((integer 3) <- loadi 34))))
|
||||||
|
@ -191,7 +191,7 @@
|
||||||
(add-fns
|
(add-fns
|
||||||
'((main
|
'((main
|
||||||
((integer 1) <- loadi 0)
|
((integer 1) <- loadi 0)
|
||||||
(jifz (integer 1) (location 3))
|
(jifz (integer 1) (offset 1))
|
||||||
((integer 2) <- loadi 3)
|
((integer 2) <- loadi 3)
|
||||||
(reply)
|
(reply)
|
||||||
((integer 3) <- loadi 34))))
|
((integer 3) <- loadi 34))))
|
||||||
|
@ -204,7 +204,7 @@
|
||||||
(add-fns
|
(add-fns
|
||||||
'((main
|
'((main
|
||||||
((integer 1) <- loadi 1)
|
((integer 1) <- loadi 1)
|
||||||
(jifz (integer 1) (location 3))
|
(jifz (integer 1) (offset 1))
|
||||||
((integer 2) <- loadi 3)
|
((integer 2) <- loadi 3)
|
||||||
(reply)
|
(reply)
|
||||||
((integer 3) <- loadi 34))))
|
((integer 3) <- loadi 34))))
|
||||||
|
@ -219,7 +219,7 @@
|
||||||
((integer 4) <- otype 0)
|
((integer 4) <- otype 0)
|
||||||
((integer 5) <- loadi 0) ; type index corresponding to 'integer'
|
((integer 5) <- loadi 0) ; type index corresponding to 'integer'
|
||||||
((integer 6) <- sub (integer 4) (integer 5))
|
((integer 6) <- sub (integer 4) (integer 5))
|
||||||
(jifz (integer 6) (location 5))
|
(jifz (integer 6) (offset 1))
|
||||||
(reply)
|
(reply)
|
||||||
((integer 7) <- arg)
|
((integer 7) <- arg)
|
||||||
((integer 8) <- arg)
|
((integer 8) <- arg)
|
||||||
|
|
Loading…
Reference in New Issue