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
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
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
Thank you, Tola (yeah, it's a stupid mistake). ;)