yeah

i see

but

how do i navigate through them with hex values ?

i mean, is that possible?

like timon said :

2) use the result from point 1 as your index in a jump table.

how i do that

i see

but

how do i navigate through them with hex values ?

i mean, is that possible?

like timon said :

2) use the result from point 1 as your index in a jump table.

how i do that

32-bit addressing, you take the result, multiply it times 4 (shl eax,2), add the base of the jump table to it, and then you have your offset. Excuse my NASM once again...

It is pretty crude, but I think you get the idea. The key is that the result is multiplied times 4 and added to the jump_table base address, creating an instant offset for function address lookup.

;Data

jump_table:

DD function_address1 ;Takes up 4 bytes trying to define the address of the function

DD function_address2 ;Takes up 4 bytes trying to define the address of the function

;... 4000 or so more functions addresses ...

DD function_addressN ;Takes up 4 bytes trying to define the address of the function

;Code (assumes result is in EAX already)

mov ebx, jump_table ;Load the actual base address of the jump table

shl eax,2 ;Multiply the result by 4 to compensate for 32-bit address data storage

add ebx,eax ;Add the offset

mov eax,DWORD ;Load the function address at the specified jump table offset

jmp eax ;Jump to function address

;Functions

proc function_address1

;do whatever here...

endproc

proc function_address2

;do whatever here...

endproc

;... 4000 or so more functions ...

proc function_addressN

;do whatever here...

endproc

It is pretty crude, but I think you get the idea. The key is that the result is multiplied times 4 and added to the jump_table base address, creating an instant offset for function address lookup.

thats totally a greaaaat example

the nasm can be convert to masm np

so the values need to be consecutive : 0001,0002,0003,0004

so the (shl eax,2) works right?

if its that

my problem is tottaly solved !

thanks guys!

:D

the nasm can be convert to masm np

so the values need to be consecutive : 0001,0002,0003,0004

so the (shl eax,2) works right?

if its that

my problem is tottaly solved !

thanks guys!

:D

so the values need to be consecutive : 0001,0002,0003,0004

Yes, that is the automatic math that makes the jump table work so efficiently, with respect to the need to store a 32-bit function address. This is the basis behind the GDT/LDT/IDT in the OS Dev world.

The trade-off for this speed increase, is space/memory. So you can take how ever many functions you have, multiply it times 4, and that is how much memory the jump table *should* consume.

You stated the number of functions to be in the thousands, so you can easily look at 4KB for the jump table per one thousand functions, an excellent trade-off between speed/space, if you ask me :)