39 lines
433 B
NASM
39 lines
433 B
NASM
format ms64 coff
|
|
|
|
section '.text' code readable executable
|
|
|
|
use64
|
|
|
|
public _loop
|
|
_loop:
|
|
xor eax, eax
|
|
inc eax
|
|
mov rbx, rdx ; RDX is overwritten by mul
|
|
@again:
|
|
cmp rbx, 0
|
|
je @loop_end
|
|
mul rcx
|
|
dec rbx
|
|
jmp @again
|
|
@loop_end:
|
|
ret
|
|
|
|
public _tail_recursion
|
|
_tail_recursion:
|
|
test ecx, ecx
|
|
je @is_0
|
|
mov eax, ecx
|
|
dec ecx
|
|
@loop:
|
|
test ecx, ecx
|
|
jz @tr_end
|
|
|
|
mul ecx
|
|
dec ecx
|
|
|
|
jnz @loop
|
|
jmp @tr_end
|
|
@is_0:
|
|
mov eax, 1
|
|
@tr_end:
|
|
ret |