I was just playing around with MASM, trying to see what I could stick a dword ptr too..... And looking at my opcode book...

There is an indirect version of jmp :eek:

Hmmm, there is an indirect version of call, so I probably should have known that :o

I noticed then, that the MASM generated jump table uses the indirect form of jmp:

jmp dword ptr (some API call)

Then I tried doing crazy stuff:

jmp dword ptr [eax+ebx*2+36]

Yes that works, and it is only 4 bytes of code.


jmp dword ptr foobar

db 00,00,00,00

Yes that sets EIP to address 0.

My mind is currently trying to take in what this all means.... Jump Tables...

Anything else? Anyone have a clever, useful application for indirect jmp?


I also tried crazy stuff like call word ptr foobar, but call to a word ptr is completly useless in win32asm, as you cannot access memory that far down.
Posted on 2002-09-06 12:59:08 by ThoughtCriminal
Jump tables are one very usefull application anyway, MASM & FASM
Posted on 2002-09-06 13:11:06 by Eóin
Thanks Eoin for those two link. I know nothing of using macros however, i write everything longhand.

I guess it is pretty hard for people to say how they use a particular instruction. Depends on context.

So I found out I can do some pretty wacky things with jmp. Now to find some more wacky things with other instructions.
Posted on 2002-09-07 04:53:52 by ThoughtCriminal

See NaN's and Thomas's OOP package, you'll find that all methods are referred via pointers. All Call's to methods are indirect calls.

Anything where control needs to be sent to one of N routines, and WHICH routine that needs to be called/jmped to can be determined at one time, can take advantage of pointers. Say at init you find that you have processor X, you have several routines optimized for processor X,Y,Z, you just change one pointer and voila! you have one pointer for the routine pointing to the routine optimized for processor X.
Posted on 2002-09-07 05:58:31 by AmkG
Where do I find these OOP packages? Just do a search on this site?
Posted on 2002-09-07 10:17:53 by drhowarddrfine

MASM can handle both the default jump table at the end for API calls or direct calls. There is a utility in MASM32 that creates include files that use an EXTERNDEF format that assemble as direct calls. All you need to do is construct a set of includes with it from the libraries you are using.


Posted on 2002-09-07 23:56:58 by hutch--
There's a OOP framework in the \Masm32\Oop folder.
Posted on 2002-09-08 00:52:51 by Qweerdy