zongors-reality-engine/test/add.asm

18 lines
369 B
NASM

main:
lodi $0 1 ;load 1 into r0
pshi $0 ;push onto stack
lodi $0 1 ;1
pshi $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
pshi $2
retn ; actually do the return