Jump to content
Tuts 4 You

Problem trying to replicate the assembly code


Recommended Posts

movzx ecx,byte ptr [ebp+8]
mov eax,055555556h
imul ecx

I can understand what those instructions are doing. For instance if ecx takes the letter 'x', the registers would contain the following:

EAX: 0x50

ECX: 0x78

EDX: 0x28

Because 55555556 x 78 = 28000050, the high part goes to EAX and the low part goes to EDX.

What I cant understand is how do I replicate this using C or C++, I tried to make a function that multiplies some hex number with 55555556 and keep the high/low byte on another variable. But RE that program doesn't produces the same results as those assembly instructions.

Can anyone explain me how to translate those instructions into some HLL?

Thank in advance for your help :cc_chinese:

Edited by teerryn
Link to comment

Division by multiplication: http://research.swtch.com/divmult

Just as an aside, the disassembly is using hexadecimal but in your post you referred to multiplying by what appears to be a decimal number, this will produce incorrect results also if you are translating assembler to code directly:

55555556 != 0x55555556

55555556 * 10 = 0x211D1AE8 or 555555560

0x55555556 * 10 = 0x35555555C or 14316557660



Edited by ghandi
  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...