I'd like to have a macro that tells me the content of the previous byte in the code section, like this:
include \masm32\include\masm32rt.inc
mytest MACRO
if [$-1] eq 90 ; error A2094: operand must be relocatable
echo NOP
else
echo not a nop
endif
ENDM
.code
start:
db 90 ; nop
mytest ; tell me if the previous instruction is a nop
exit
end start
That should be possible for the assembler, but what I tried just throws errors. Any ideas?
Thanks, jj
Quote from: jj2007 on July 22, 2013, 06:48:49 AMThat should be possible for the assembler
I'm afraid this is not possible with MASM.
That's what I suspected. Bad luck :(
Thanks, qWord.
if [$-1] eq 90 ; error A2094: operand must be relocatable
it's an assembly-time conditional, as i'm sure you know
they have to be resolved on the first pass (i.e., before the value of the byte is known)
you can do it with a run-time conditional, but that's probably not what you want
Quote from: dedndave on July 22, 2013, 08:12:08 AMthey have to be resolved on the first pass (i.e., before the value of the byte is known)
Right. Would be difficult indeed...
Quote from: qWord on July 22, 2013, 07:55:51 AM
I'm afraid this is not possible with MASM.
True. However, FASM can do it - it has LOAD and STORE directives. STORE is needed because FASM's ORG directive works fairly differently than MASM's.
Hi Jochen!
I didn't try to write such a macro but next lines worked for me ( I checked it in Olly)
.code
start:
db 90 ; nop
mov eax,$-1
fn MessageBox,0,uhex$([eax]),"AL=90?",MB_OK
exit
end start
Nitpickers corner: 90 isn't NOP :biggrin:
ATTENTION! : Execute it in debugger
I used Olly. All worked well.
mytest MACRO
mov eax,$-1
mov eax,[eax]
EXITM <eax>
ENDM
.code
start:
db 0cch ; hardcoded BreakPoint
db 90h ; not NOP ;)
fn MessageBox,0,uhex$(mytest()),"AL=90?",MB_OK
exit
sinsi:
did you mean that opcode 90h performs some operation inside the register ?
Quote from: vertograd on July 23, 2013, 12:21:45 AM
sinsi:
did you mean that opcode 90h performs some operation inside the register ?
No, he's just teasing me. I had used 90d, it should be 90h :P
In the meantime, I've solved the problem with runtime instructions; see last attachment (http://masm32.com/board/index.php?topic=2137.msg22252#new), search inside the *.asm file for
22.7.13Thanks to everybody :icon14: