mov eax, [eax*2 + ebx]
mov eax, [ebx + eax*2]
mov eax, [ (eax*2) + ebx]


all the above code will result in: mov eax, [ebx + eax*2]


can someone here explain me why? what order does masm follow??
Posted on 2001-07-19 12:39:10 by nop
Multiplication first, then addition/subtraction.
Posted on 2001-07-19 13:56:17 by comrade
It's a matter of instruction encoding and the architecture. The "index" register is the only register that can be scaled (EAX*2). The "base" register can't be scaled. So MASM always makes a scaled register the index, no matter "where" it's coded. :)
Posted on 2001-07-20 00:17:09 by S/390
Nop, find a style you like. I personally always have the immediate
offset part first, followed by the scaled portion (and have it in
paranthesis), and finally the base register. Looks neatest that
way :).
Posted on 2001-07-20 00:55:12 by f0dder
f0dder, you think you can give me an example?

thank for the reply guys!
Posted on 2001-07-20 07:22:13 by nop
sure, I write it like..



mov eax, [variable1 + (ebx*2) + esi]
Posted on 2001-07-20 07:54:27 by f0dder
thank alot f0dder! i found that to be readable too.
Posted on 2001-07-20 08:24:39 by nop
beauty is in the eye of the beholder
Posted on 2006-04-19 23:27:44 by comrade
Yup.
Posted on 2006-04-20 05:03:06 by f0dder