arg:24 op:8
arith: add,
sub, mul, div, mod
logic: band,
bor, bxor, shl, shr, not,
eq, ne, lt, le, gt, ge
data:
ld, st, ldx, stx, lit, get, put
control: call, ret, case, fun, jt, jf, jmp
other: inc,
dec, callt, sys
36 instructions
a = b + c
get.2
get.3
add
put.1
global var a,b,c
a = b + c
ld.b
ld.c
add
st.a
local var a,b,c
if( a == b ) c = 1 else c = 2
get.1
get.2
eq
jf xx
lit.1
put.3
jmp yy
:xx
lit.2
put.3
:yy
mysum(a,b){ return a + b; }
fun.x
get.1
get.2
add
ret.y
main(){ mysum(3,4); }
fun.x
lit.3
lit.4
call.mysum
ret.y
Source
sum(n, m){
if( n == m ) return
m;
else return n + sum(
n+1, m);
}
main(){
print(sum(1,10));
}
(fun main
(print (call sum 1 10 )))
(fun sum
(if-else
(== #1 #2 )
(return #2 )
(return (+ #1 (call sum
(+ #1 1 )#2 )))))
:main
fun.1
lit.1
lit.10
call.sum
sys.1
ret.1
:sum
fun.1
get.2
get.1
eq
jf.L18
get.1
ret.3
jmp.L26
:L18
get.2
get.2
lit.1
add
get.1
call.sum
add
ret.3
:L26
ret.3
last update 16 August 2012