News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Error A2026: constant expected

Started by Hyzau, November 25, 2012, 06:57:27 AM

Previous topic - Next topic

Hyzau

Hi,

Once again, sorry for disturbing you
I'm having the following syntax which I want to translate in MASM

movzx eax , word [(ebx-1)*2+eax]


I've tried many things but I can't figure out what syntax should I use in masm



mov eax, 2
mov dwSave, ebx
sub dwSave, 1
mul dwSave ; I can't alter ebx, i need it later so I put it in "dwSave dd 0"

[Doing some change on eax]

add eax, dwSave ;  so eax = (ebx - 1) * 2 + eax

movzx eax, [eax] ; error A2070: invalid instruction operands
movzx eax, word [eax] ; error A2009: syntax error in expression // Yeah I know that it was wrong but tried it anyway ><
movzx eax, word ptr [eax] ; seems to doesn't give the right  value


By the way, the original code is NASM.
Thanks in advance for your help.

Best regards,

Hyzau

Okay,

movzx eax, word ptr [eax]


May be the right solution ^^. However, it doesn't work for me because I'm loosing EDX during the MUL...
If you have a working syntax which don't force me to use MUL it could be great.


jj2007

Use movzx eax, word ptr [2*ebx+eax-2]

Welcome to the Forum :icon14:

nidud

#3
deleted

Hyzau

Quote from: jj2007 on November 25, 2012, 07:33:23 AM
Use movzx eax, word ptr [2*ebx+eax-2]

Welcome to the Forum :icon14:

Well thanks a lot  :biggrin:
It's kinda simpler than my all my stuff.

I've was searching a solution for hours now and I didn't thought about brackets ><



jj2007

The push/pop works but is kind of slow, at least on my CPU:

Intel(R) Celeron(R) M CPU        420  @ 1.60GHz (SSE3)
loop overhead is approx. 189/100 cycles

124     cycles for 100 * movzx JJ
226     cycles for 100 * push nidud

12      bytes for movzx JJ
17      bytes for push nidud

29811   = eax movzx JJ
29811   = eax push nidud