zongors-reality-engine/test/add.asm

19 lines
445 B
NASM

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:
popu $0 ; pop unsigned int
popi $1 ; int a
popi $2 ; int b
addi $3 $2 $1 ; a + b
pushi $3 ; push a + b onto stack for return
return $0 ; actually do the return