Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question


Avatar of Fallacy911
Fallacy911 asked on
12 Comments1 Solution7717 ViewsLast Modified:
I know a lot of people have a very similar situation, but I cant wrap my mind around what the movsbl and "and" situation is doing with my input.

Like I understand that my string becomes a HEX value. (actually im not too sure how that works, like, how does a string of 6 letters become an 8 byte hex?)

And I see that it takes the Least Significant Byte of this string->Hex Value and sign extends it,
Then ANDS it with the 1111 Mask, then looks that offset value up in the EBX Array and increments eax (which starts out at 0) by this value.  And it requires EAX to be 49 at the end...

(It iteratively goes through to the second least significant byte, then the third least significant, then the fourth, I get that.
When it hits the end it goes back and sign extends the 1st LSByte +1???... I'm not sure how that works.  Maybe I'm not understanding the syntax of a movsbl with three arguments.
I get that the first is my string, and the second and third are just integers.  I suppose the second*third is which LBbyte to evaluate next?)

I understand that, but like... The Array has the following values in order:
2   a   6   1   c    16   9   3   4   7  e    5    b     8    f      d

I need some of those to add up to be 49, and I need a string->hex value that gives me the right ones to add up.
I am just so stumped there.  I could use hints on how to start... Please

Thank you very much

0x08048c 6d <phase_5+5>: mov    0x8(%ebp),%esi                       Moves inputted sring to ESI
0x08048c 70 <phase_5+8>: sub    $0xc,%esp                                
0x08048c 73 <phase_5+11>:        push   %esi

0x08048c 74 <phase_5+12>:        call   0x8048f19 <string_length>
0x08048c79 <phase_5+17>:        add    $0x10,%esp                               Set New Stack Frame
0x08048c7c <phase_5+20>:        cmp    $0x6,%eax                              Compare EAX to 6
0x08048c7f <phase_5+23>:        je     0x8048c86 <phase_5+30>     If theyre Equal, Move past Exploding
0x08048c81 <phase_5+25>:        call   0x8049400 <explode_bomb>
0x08048c86 <phase_5+30>:        mov    $0x0,%ecx                            ECX GETS ZERO
0x08048c8b <phase_5+35>:        mov    $0x0,%edx                            EDX gets ZERO
0x08048c90 <phase_5+40>:        mov    $0x804a5a0,%ebx                 EBX GETS TWO
0x08048c95 <phase_5+45>:        movsbl (%esi,%edx,1),%eax            
0x08048c99 <phase_5+49>:        and    $0xf,%eax         ANDS EAX's LOWER 4  Bits With 1111
0x08048c9c <phase_5+52>:        add    (%ebx,%eax,4),%ecx   ADD ebx + (eax*4), store in ecx

0x08048c9f <phase_5+55>:        inc    %edx                                 EDX is incremented
0x08048ca0 <phase_5+56>:        cmp    $0x5,%edx                       Compare EDX With 5
0x08048ca3 <phase_5+59>:        jle    0x8048c95 <phase_5+45>      Jump if less than or equal to, back to movsbl!, ELSE FINISHED
0x08048ca5 <phase_5+61>:        cmp    $0x31,%ecx
0x08048ca8 <phase_5+64>:        je     0x8048caf <phase_5+71>
0x08048caa <phase_5+66>:        call   0x8049400 <explode_bomb>
0x08048caf <phase_5+71>:        lea    -0x8(%ebp),%esp
0x08048cb2 <phase_5+74>:        pop    %ebx
0x08048cb3 <phase_5+75>:        pop    %esi
0x08048cb4 <phase_5+76>:        leave
0x08048cb5 <phase_5+77>:        ret
Avatar of Infinity08
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answers