assembly - Caller save registers in recursion -
in recursion, need save both caller save , callee save registers? following recursion save calle-save register ebx:
int rfact(int x) { int result; if (x <= 1) result = 1; else result = n* rfact(x-1); return result; }
assembly:
rfact: pushl %ebp  .l3: movl %esp, %ebp pushl %ebx subl $4, %esp movl 8(%ebp), %ebx movl $1, %eax cmpl $1, %ebx jle .l3 leal -1(%ebx), %eax movl %eax, (%esp) call rfact imull %ebx, %eax addl $4, %esp popl %ebx popl %ebp ret
is there example of recursion save caller-save register?
Comments
Post a Comment