oK hutch made a macro



jabs MACRO address
push address
retn
ENDM


that has the unfortunate side effect of messing up call/ret pairing :(

alternatively you could use


jabs MACRO address
mov eax,address
jmp eax
ENDM

but what if you cant spare any registers?

now im not interested in useing the direct jump oppcode I just want a macro so that I can type jabs address and it will work all the time..

So I made this one


jabs MACRO address
push address
add esp,4
jmp DWORD PTR [esp-4]
ENDM


and i have used it successfully, I know that the stack is ESP+ and so I was hopeing that ESP- was unused,
anyway thats my question, will doing this work always? or are there some sitiation where esp- is used?
Posted on 2003-02-17 17:58:24 by dionysus
I would call it creative thinking... looks good to me. The only thing i can say about it is this will make it very easy to write spagetti code and end up with very unpredictable errors (and error tracking), since its very easy to lose sight of what you dont see when your write code: the stack.

Those who use this macro better have an solid understanding of how functions are called, processed for params, and returned from.

:NaN:
Posted on 2003-02-17 22:36:29 by NaN
jl32 MACRO address:REQ

LOCAL jta
jta = address - $ - 5
db 0E9h
dd jta
ENDM

ja32 MACRO address:REQ
db 0E9h
dd address
ENDM

jl8 MACRO address:REQ
LOCAL jta
jta = address - $ - 2
db 0EBh
db jta
ENDM

ja8 MACRO address:REQ
db 0EBh
db address
ENDM
this always works for me ^_^

use the macros postfixed with 32 for full displacement jumps and the 8 for 8 bit displacements. Use the 8 bit displacements if the jump if the range is -128 to +127 bytes, this will make your code smaller.

jl8 and jl32 (prefix: jl) - for labels E.G. jl8 label or jl32 label ... (but why would you want to use these macros when you can just simply use :: jmp label) ^_^

ja8 and ja32 (prefix: ja) - for absolute jumps E.G. ja32 31Fh or ja8 0Ch ... Don't forget to calculate the number of bytes to jump. MASM gives me an error if I start calculating for an absolute jump ( jta = address - $ - 2 ... ) - the same thing I did with labels.


:grin:


Posted on 2003-02-18 00:41:04 by arkane