Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .global _inAsm
- .extern printShit
- _inAsm:
- pushl %ebp
- movl %esp, %ebp
- pushl %ebx
- pushl %edi
- pushl %esi
- xorl %edx, %edx
- movl 8(%ebp), %ebx # GET n
- movl $2, %esi # int i=2;
- movl $1, %edi # last=1;
- # initial test for while loop
- cmpl $1, %ebx # compare n : 1
- jle after_loop
- loop:
- #loop body
- movl %ebx, %eax # get Dividend n
- xorl %edx, %edx
- idivl %esi # n%i
- # if test
- cmpl $0, %edx # compare n%i : 0
- jne after_if
- # if body
- movl %esi, %edi # last=i;
- movl %ebx, %eax # get value of n
- xorl %edx, %edx
- idivl %esi # n/i;
- movl %eax, %ebx # store quotient back to the register which must hold n
- after_if:
- incl %esi # i++;
- cmpl $1, %ebx # compare n : 1
- jg loop
- after_loop:
- movl %edi, %eax
- pushl %eax
- call _printShit
- popl %eax
- end:
- popl %esi
- popl %edi
- popl %ebx
- movl %ebp, %esp
- popl %ebp
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement