First, i define a macro?
dstri macro
'10-1'
endm
and then, this macro:dstri is called in my data segment?
ser db dstri
but the assemler issure the followed message?error A2148: invalid symbol type in expression : dstri
i can't find the root cause.
dstri macro
'10-1'
endm
and then, this macro:dstri is called in my data segment?
ser db dstri
but the assemler issure the followed message?error A2148: invalid symbol type in expression : dstri
i can't find the root cause.
then lines inside a macro need to make sense.
the interpreter needs to recognize them as lines of sourcecode.
so put the db in there too.
the interpreter needs to recognize them as lines of sourcecode.
so put the db in there too.
First, i define a macro?
dstri macro
'10-1'
endm
and then, this macro:dstri is called in my data segment?
ser db dstri
but the assemler issure the followed message?error A2148: invalid symbol type in expression : dstri
i can't find the root cause.
if I redefine the macro as:
----------------------------
dstri macro
db '10-1'
endm
--------------------------
and call it in data segment as:
-------------------------------
ser dstri
------------------------------
there is also error.
Let's also allow the macro the declare the label :)
dstri macro Where:REQ, Whut
Where db Whut
endm
Now use as:
dstri ser, '10-1'
According to the macro, this should produce:
ser db '10-1'
THAT should work.
dstri macro Where:REQ, Whut
Where db Whut
endm
Now use as:
dstri ser, '10-1'
According to the macro, this should produce:
ser db '10-1'
THAT should work.
Let's also allow the macro the declare the label :)
dstri macro Where:REQ, Whut
Where db Whut
endm
Now use as:
dstri ser, '10-1'
According to the macro, this should produce:
ser db '10-1'
THAT should work.
Thanks for your help!
As you have shown above , I can redefine the macro and still use it in this style: dstri ser, '10-1'.
Your idea enlightens me, so I think whether is the macro calling statement in my code wrong.
if I redefine the macro as:
----------------------------
dstri macro
db '10-1'
endm
--------------------------
and call it in data segment as:
-------------------------------
ser dstri ;whether this macro calling syntax is wrong?
------------------------------
------------------------------------
dstri ;if directly used as this style, MASM works smoothly:
-----------------------------------
Could you give me some hint to let me confirm my idea?
TO use it in .data you can try
Is that what you mean?
ser label byte
dstri
Is that what you mean?
dstri macro
exitm <'10-1'>
endm
ser db dstri()
Ultrano, doesn't that depend on the version of masm?
I don't know. I don't cross-check with different versions, I stick with the tried-and-true 6.14.8444.
P.S. and it's not like I used a hack in the code above. It's a documented thing.
P.S. and it's not like I used a hack in the code above. It's a documented thing.
I don't know. I don't cross-check with different versions, I stick with the tried-and-true 6.14.8444.
P.S. and it's not like I used a hack in the code above. It's a documented thing.
Yeah, I think version 6+ does it, but not 5.
I know it's not a hack, plenty of macros in masm32 use it - hell I use it...
if I redefine the macro as:
and call it in my data segment:
Ultrano, do you mean the macro dstri called in this case will NOT be expanded into ser db '10-1' as I imagined?
dstri macro
db '10-1'
endm
and call it in my data segment:
dseg segment
ser dstri
dseg ends
Ultrano, do you mean the macro dstri called in this case will NOT be expanded into ser db '10-1' as I imagined?
Macros, that do not use "exitm" expect that they are the first statement on this line, or that a label is given before them.
There's a cmdline argument of ml.exe to output the pure asm code, with macros being expanded, try to study from that ;)
dseg segment
ser dstri ; won't assemble, if the assembler doesn't treat ser as label (mine doesn't)
ser2: dstri ; will assemble, ser2 is a label. The assembler doesn't treat ser2 as a label to an array of bytes.
ser3 db '10-1' ; will assemble, ser3 is a label. ser3 is treated as a label to an array of bytes
dseg ends
...
.code
mov ser2[0],7 ; error. ser2 is of unknown size (is it a byte, word, dword ? the assembler doesn't know)
mov byte ptr ser2[0],7 ; correct
mov byte ptr ,7 ; correct
mov ser3[0],7 ; correct
There's a cmdline argument of ml.exe to output the pure asm code, with macros being expanded, try to study from that ;)
Thanks! got it.