News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Jump Tables Effectiveness

Started by zemtex, January 14, 2011, 01:53:06 PM

Previous topic - Next topic

zemtex

A much more delicate way to do it is to use (OFFSET JmpTable-4) so that the calculation is done at assembly time. When you use [-4] in brackets, the calculation is done at execution time and will waste cycles.

This will calculate at runtime: call switches[4*ebx-4]

This (The subtraction part) will calculate at assembly time: lea ecx, [4*ecx+(OFFSET JmpTable-4)]

It is a much more delicate way to do it.

EDIT: I tried it in olly, it seems like your solution calculated at assembly time after all. Then it would be the same.

FF149D FC3FEC00   CALL DWORD PTR DS:[EBX*4+0EC3FFC]

and here is mine:

8D0C8D FC3FEC00   LEA ECX,[ECX*4+0EC3FFC]

Can never be too careful  :P
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

jj2007

Quote from: zemtex on January 17, 2011, 11:51:35 AM
EDIT: I tried it in olly, it seems like your solution calculated at assembly time after all. Then it would be the same.

Yes indeed :bg