zongors-reality-engine/test/add.s

18 lines
376 B
ArmAsm

main:
loadi $0 1 ;load 1 into r0
pushi $0 ;push onto stack
loadi $0 1 ;1
pushi $0
call &add ; call memory location for tag "add"
popi $0 ;get value from function call "add"
itos $1 $0 ;convert int to string
puts $1 ;print string to stdout
halt
add:
popi $0 ; int a
popi $1 ; int b
addi $2 $1 $0 ; a + b
pushi $2
return ; actually do the return