I am working on the binary bomb project. I am working on this code and I am trying to understand parts of the assembly code. So I get through phase1 easily, and for phase 2 I need to input 4 characters.
For example: phase-2: x y z d
In the example below I used the input: a b c d as my four characters
When I run this in the gdp and inspect the assembly code I get the following:
Dump of assembler code for function phase2:
0x080487d6 <+0>: push %ebp
0x080487d7 <+1>: mov %esp,%ebp
0x080487d9 <+3>: sub $0xc,%esp
=> 0x080487dc <+6>: mov 0x8(%ebp),%ecx
0x080487df <+9>: mov 0xc(%ebp),%edx
0x080487e2 <+12>: mov 0x10(%ebp),%eax
0x080487e5 <+15>: mov %cl,-0x4(%ebp)
0x080487e8 <+18>: mov %dl,-0x8(%ebp)
0x080487eb <+21>: mov %al,-0xc(%ebp)
0x080487ee <+24>: cmpb $0x77,-0x4(%ebp)
0x080487f2 <+28>: jne 0x8048807 <phase2+49>
0x080487f4 <+30>: cmpb $0x62,-0x8(%ebp)
0x080487f8 <+34>: jne 0x8048807 <phase2+49>
0x080487fa <+36>: cmpb $0x79,-0xc(%ebp)
0x080487fe <+40>: jne 0x8048807 <phase2+49>
0x08048800 <+42>: mov $0x1,%eax
0x08048805 <+47>: jmp 0x804880c <phase2+54>
0x08048807 <+49>: mov $0x0,%eax
0x0804880c <+54>: leave
0x0804880d <+55>: ret
End of assembler dump.
What I really what to understand is
0x080487ee <+24>: cmpb $0x77,-0x4(%ebp)
What is going on here? I think that it is comparing the value $0x77 to the value in ebp. Does that make sense? When how do I know what is stored in ebp?
I run the code up until the above line, and ebp and I get the following:
ebp 0xbffff6e8 0xbffff6e8
So to sum it up, I want to know what that compare line is really doing, just so I can understand the code a little better. And how I can find out what that value in ebp is without going to the leave state.