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.
Posted on 2008-10-04 01:10:48 by qlmi
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.
Posted on 2008-10-04 04:48:49 by Homer

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.

Posted on 2008-10-04 08:22:27 by qlmi
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.
Posted on 2008-10-04 21:19:59 by Homer

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? 
Posted on 2008-10-04 22:55:01 by qlmi
TO use it in .data you can try
  ser label byte
  dstri

Is that what you mean?
Posted on 2008-10-04 23:17:58 by sinsi


dstri macro
  exitm <'10-1'>
endm

ser    db  dstri()
Posted on 2008-10-05 00:42:30 by Ultrano
Ultrano, doesn't that depend on the version of masm?
Posted on 2008-10-05 00:48:38 by sinsi
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.
Posted on 2008-10-05 01:44:36 by Ultrano

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...
Posted on 2008-10-05 02:14:43 by sinsi
if I redefine the macro as:

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?
     
Posted on 2008-10-05 02:29:44 by qlmi
Macros, that do not use "exitm" expect that they are the first statement on this line, or that a label is given before them.


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 ;)
Posted on 2008-10-05 09:47:18 by Ultrano
Thanks! got it.
Posted on 2008-10-07 05:46:06 by qlmi