Files
rasp/tests/test_call.asm
Alek Ratzloff 551bd2c3f4 Add initial register states to meta section; remove entry directive
It makes sense to allow users to set the initial register values. This
allows someone to e.g. enable interrupts once the VM has started, or set
the initial stack pointer value.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-03-10 12:18:31 -04:00

37 lines
529 B
NASM

.section data $0x1000 {
factorial:
cmplt %r0, $2
jnz factorial_one
push %r0
sub %r0, $1
call factorial
pop %r0
mul %status, %r0
jmp factorial_end
factorial_one:
mov %status, $1
factorial_end:
ret
main:
mov %r0, $6
call factorial
cmpeq %status, $720
jz fail
mov %status, $0
jmp end
fail:
mov %status, $1
end:
halt
.export main
}
.meta {
ip: main
}