Heres an disas
of a function which takes input and stops a bomb from exploding.
0x00000000004011ca <+0>: sub $0x8,%rsp #reserve 8 bytes on stack
0x00000000004011ce <+4>: cmpb $0x37,0x1(%rdi) #compare 0x37 ('7') with second character of input
0x00000000004011d2 <+8>: jne 0x4011df <phase_1+21> #explode bomb if not equal
0x00000000004011d4 <+10>: cmpb $0x5d,0x2(%rdi) #compare 0x5d (']') with third character of input
0x00000000004011d8 <+14>: jne 0x4011df <phase_1+21> #explode bomb if not equal
0x00000000004011da <+16>: cmpb $0x5a,(%rdi) #compare 0x5a ('Z') with first character of input
0x00000000004011dd <+19>: je 0x4011ed <phase_1+35> #if all equal, skip bomb explosion
0x00000000004011df <+21>: callq 0x401c01 <bomb_ignition> #bomb explode
0x00000000004011e4 <+26>: mov $0xffffffffffffffff,%rax #rax = -1
0x00000000004011eb <+33>: jmp 0x401200 <phase_1+54> #end
0x00000000004011ed <+35>: movsbl 0xf(%rdi),%eax //need help here
0x00000000004011f1 <+39>: add $0x1b,%eax
0x00000000004011f4 <+42>: movsbl 0xe(%rdi),%edx
0x00000000004011f8 <+46>: cmp %edx,%eax
0x00000000004011fa <+48>: sete %al
0x00000000004011fd <+51>: movzbl %al,%eax
0x0000000000401200 <+54>: add $0x8,%rsp
0x0000000000401204 <+58>: retq
I have annotated what i think its doing with #
. Please tell me if im wrong anywhere. I need help in figuring out what its doing at and after the first movsbl
. From just reading, I think it extends %rdi
by 15, then puts it in %eax
. then adds 27. To what, I dont know. Then it extends %rdi
by 14 and put it in %edx
. It compares, and if equal, then sets flag %al
? Then moves %al
to %eax
. Then clears up stack space. Then returns.
Did I go wrong anywhere in my understanding of anything? Can someone clarify what movsbl
is doing in this? ANY HELP APPRECIATED. Thanks