Add function call test
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
36
tests/call.asm
Normal file
36
tests/call.asm
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
.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 {
|
||||||
|
entry: main
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user