Hey, I need to diffuse a binary bomb, I'm not an assembly language expert... so I'd appreciate any help =)
080519e5 <phase_2>:
80519e5: 55 push %ebp
80519e6: 89 e5 mov %esp,%ebp
80519e8: 53 push %ebx
80519e9: 83 ec 2c sub $0x2c,%esp
80519ec: 8d 45 d8 lea 0xffffffd8(%ebp),%eax
80519ef: 50 push %eax
80519f0: ff 75 08 pushl 0x8(%ebp)
80519f3: e8 5f 03 00 00 call 8051d57 <read_six_numbers>
80519f8: bb 01 00 00 00 mov $0x1,%ebx
80519fd: 83 c4 10 add $0x10,%esp
8051a00: 8b 44 9d d4 mov 0xffffffd4(%ebp,%ebx,4),%e
ax
8051a04: 83 c0 05 add $0x5,%eax
8051a07: 39 44 9d d8 cmp %eax,0xffffffd8(%ebp,%ebx,
4)
8051a0b: 74 05 je 8051a12 <phase_2+0x2d>
8051a0d: e8 9a 07 00 00 call 80521ac <explode_bomb>
8051a12: 43 inc %ebx
8051a13: 83 fb 05 cmp $0x5,%ebx
8051a16: 7e e8 jle 8051a00 <phase_2+0x1b>
8051a18: 8b 5d fc mov 0xfffffffc(%ebp),%ebx
8051a1b: c9 leave
8051a1c: c3 ret
08051d57 <read_six_numbers>:
8051d57: 55 push %ebp
8051d58: 89 e5 mov %esp,%ebp
8051d5a: 83 ec 08 sub $0x8,%esp
8051d5d: 8b 55 0c mov 0xc(%ebp),%edx
8051d60: 8d 42 14 lea 0x14(%edx),%eax
8051d63: 50 push %eax
8051d64: 8d 42 10 lea 0x10(%edx),%eax
8051d67: 50 push %eax
8051d68: 8d 42 0c lea 0xc(%edx),%eax
8051d6b: 50 push %eax
8051d6c: 8d 42 08 lea 0x8(%edx),%eax
8051d6f: 50 push %eax
8051d70: 8d 42 04 lea 0x4(%edx),%eax
8051d73: 50 push %eax
8051d74: 52 push %edx
8051d75: 68 72 23 05 08 push $0x8052372
8051d7a: ff 75 08 pushl 0x8(%ebp)
8051d7d: e8 d6 f7 ff ff call 8051558 <_PROCEDURE_LINKAGE_TABLE_
+0xb0>
8051d82: 83 c4 20 add $0x20,%esp
8051d85: 83 f8 05 cmp $0x5,%eax
8051d88: 7f 05 jg 8051d8f <read_six_numbers+0x38>
8051d8a: e8 1d 04 00 00 call 80521ac <explode_bomb>
8051d8f: c9 leave
8051d90: c3 ret
This is what I know about phase 2
080519e5 <phase_2>:
80519e5: 55 push %ebp <------------------------P
ushes ebp onto the stack
80519e6: 89 e5 mov %esp,%ebp <-------------------ebp = esp
80519e8: 53 push %ebx <------------------------P
ushes ebx onto the stack
80519e9: 83 ec 2c sub $0x2c,%esp <------------------esp = esp-44
80519ec: 8d 45 d8 lea 0xffffffd8(%ebp),%eax <-------load effective address eax = 0xffffffd8(%ebp)?
80519ef: 50 push %eax <------------------------P
ushes eax onto the stack
80519f0: ff 75 08 pushl 0x8(%ebp) <-------------------Push ebp onto the stack offset by 8
80519f3: e8 5f 03 00 00 call 8051d57 <read_six_numbers> <--Call the function with the parameters already there
80519f8: bb 01 00 00 00 mov $0x1,%ebx <-------------------ebx = 1
80519fd: 83 c4 10 add $0x10,%esp <------------------esp = esp + 10
8051a00: 8b 44 9d d4 mov 0xffffffd4(%ebp,%ebx,4),%e
ax<-eax = 0xffffffd4(%ebp,%ebx,4)
8051a04: 83 c0 05 add $0x5,%eax <-------------------eax = eax + 5
8051a07: 39 44 9d d8 cmp %eax,0xffffffd8(%ebp,%ebx,
4)<-compar
es eax with that huge offset thing
8051a0b: 74 05 je 8051a12 <phase_2+0x2d> <------jumps if the compare works out right
8051a0d: e8 9a 07 00 00 call 80521ac <explode_bomb> <------explodes bomb, have to avoid this
8051a12: 43 inc %ebx <------------------------i
ncrement ebx by 1?
8051a13: 83 fb 05 cmp $0x5,%ebx <-------------------compar
e ebx to 5
8051a16: 7e e8 jle 8051a00 <phase_2+0x1b> <------jump less than phase 2 + the offset 8051A00
8051a18: 8b 5d fc mov 0xfffffffc(%ebp),%ebx <-------ebx = the huge offset of ebp
8051a1b: c9 leave <-------------------------
----breaks
down the current stack frame
8051a1c: c3 ret <-------------------------
----It goes back to the calling code
And this is what I think the C code should look like, not 100% sure its right:
void phase_2(char *input)
{
int ii;
int numbers[6];
read_six_numbers(input, numbers);
for (ii = 1; ii < 6; ii++) {
if (numbers[ii] != numbers[ii-1] + 5)
explode_bomb();
}
}
I've gotta diffuse 4 more phases after this so I'd appreciate any hints to get this done. Thanks in advance!!