Reputation: 115
This function is not iterating properly. The result of it just squares the base regardless of the exponent. I have commented my thoughts on what I think is happening.
As an aside, is there an easy way I can debug assembly with breakpoints and stepping through? Potentially an IDE you recommend? Teach a man to fish they say...
Thank you for the help!
my_pow:
movl $0, %eax
movl %edi, %eax #result = base
movl $2, %r9d #i = 2
Loop:
cmpl %r9d, %esi #if i <= exp
mul %edi #multiply result*=base
inc %r9d #i++
jle Loop #if it was less than, do it again
ret #if it was greater don't go to the label and return what is in %eax
Upvotes: 0
Views: 30