I think this is actually a pretty simple problem. I need to rebuild this assembly code to c-code. I will also provide what I think will continue so that you can, hopefully, indicate where I did wrong, and now I can learn from my mistakes.
.LFBO pushq %rbp movq %rsp,%rbp movl %edi,-4(%rbp) movl %esi,-8(%rbp) movl -4(%rbp),%eax compl -8(%rbp),%eax jg .L2 movl -8(%rbp),%eax jmp .L3 .L2: movl -4(%rbp),%eax .L3: popq %rbp ret
So here is what I think of it: the first two lines after .LFBO:
pushq %rbp movq %rsp,%rbp
just set the stack for execution, which should follow.
movl %edi,-4(%rbp)
captures the first variable, name it x
movl %esi,-8(%rbp)
captures the second variable calling it y
movl -4(%rbp),%eax
captures x for comparison in the next line
compl -8(%rbp),%eax
compares x and y variables, computing xy
jg .L2
says jump to .L2 if x> y
if x <= y, then calculate the following lines without going to .L2
movl -8(%rbp),%eax
copy x = y
jmp .L3
go to .L3
if x> y on the jg line, then you go to .L2: and end this line
movl -4(%rbp),%eax
that's where I realized that I was really embarrassed. It seems to me that you are copying x to x then .L3 is complete and I think x is returning
c assembly x86-64 reverse-engineering conditional-statements
scottybobby
source share