Question: optimising offset calculation

I've got a simple question to the mov-opcode.
SubMenuNr should be a DWORD-variable and
SubMenuSpace is a buffer

is this the faster way of calculating the offset:
mov ecx, SubMenuNr
shl ecx, 2
add ecx, OFFSET SubMenuSpace
mov , eax

or this:
mov ecx, SubMenuNr
shl ecx, 2
mov , eax

or this example:
mov ecx, SubMenuNr
mov [(ecx*2) + OFFSET SubMenuSpace], eax

I would think the last one, because there are not so much instructions like in the others, but appearances are deceiving!
Maybe one of you know something closer?

Thanks for your effort, Marwin
Posted on 2002-07-17 13:15:41 by Marwin
yep, the last one should be the fastest. i spotted a small mistake, though. you need to change it to
mov [(ecx*[COLOR=red]4[/COLOR]) + OFFSET SubMenuSpace], eax

Posted on 2002-07-17 18:04:57 by Tola
Thank you, Tola (yeah, it's a stupid mistake). ;)
Posted on 2002-07-18 16:21:43 by Marwin