News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Macros with masm 6.1

Started by georg, September 18, 2013, 01:52:43 AM

Previous topic - Next topic

dedndave

this seems to build ok
        .MODEL  Small
        .STACK  2048
        .DOSSEG
        .386
        OPTION  CaseMap:None

;####################################################################################

fmacro  macro mbit,mstatus,mdata
        mov     bBit,mbit
        mov     bStatus,mstatus
        mov     wDir,offset mdata
    endm

;####################################################################################

;        .DATA

;************************************************************************************

        .DATA?

bStatus db ?
bBit    db ?
bFlag   db ?
wDir    dw ?

;####################################################################################

        .CODE

;************************************************************************************

_main   PROC    FAR

        fmacro  1,2,bFlag

        mov     ax,4C00h
        int     21h

_main   ENDP

;####################################################################################

        END     _main


so, it would appear it didn't like one or more of the names, "status", "bit", "flag", "dir"
also - the name "DTA" stands for "Data Transfer Area"
probably not a public symbol - just wanted you to know   :P

qWord

the macro from the OP look OK - the problem must be caused by the call or it's arguments.
Macro arguments can have any name, because they are local (but of course not MASM's reserved words).
You might post the source, or a reduce form of it. The corresponding output from the build console might also be helpful.

BTW: the error message come from the assembler and not the linker!
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

qWord,
in his data segment, he has labels, "status", "bit", "flag", "dir"
it was probably choking on one of those - "bit" is most likely
but, none of them are good names   :biggrin:

georg

I'm going to try to change the name of the arguments, maybe is the cause of the problem, (the assembler should point at the wrong code though not try the macro like a black box) the masm 6.1 have a command line option to enable macros?, or disable I think not, but just in case. this is the message:

error A2008: syntax error fmacro

georg

Dave I change the name for the segment to "jklm", and I still get the same response from the assembler

japheth

Quote from: georg on September 18, 2013, 05:14:03 AM
error A2008: syntax error fmacro

This is a very strong indication that the assembler doesn't know "fmacro".

Perhaps you didn't show us the full source code? What's between the definition of fmacro and the macro "invokation"?


georg

Quote from: japheth on September 18, 2013, 05:23:58 AM
Quote from: georg on September 18, 2013, 05:14:03 AM
error A2008: syntax error fmacro

This is a very strong indication that the assembler doesn't know "fmacro".



hi: japheth
that's exactly what I mean, and is the only error, if I copy paste the macro code, I don't get the error.

georg

I'm so used to mplab, where writing macros is easy. EDITED  :eusa_boohoo:

qWord

Quote from: georg on September 18, 2013, 05:31:15 AMif I copy paste the macro code, I don't get the error.
How should we interpret that?
MREAL macros - when you need floating point arithmetic while assembling!

georg

Hi: qWord

jklm segment public 'data'
cbit    byte  ?
cstatus byte ?
cflag byte ?
cdir word ?
jklm ends

fmacro  macro fbit,fstatus,fflag
              mov cbit,fbit
              mov cstatus,fstatus
              mov cdir, offset fflag
            endm
inst segment readonly public 'code'
            assume cs:inst, ds:jklm
main   proc
          fmacro 1h,2h,cflag
          mov  ax,4c00h
          int    21h
main   endp
inst ends
          end

I simply copy the macro code:


jklm segment public 'data'
cbit    byte  ?
cstatus byte ?
cflag byte ?
cdir word ?
jklm ends

inst segment readonly public 'code'
            assume cs:inst, ds:jklm
main   proc
;         fmacro 1h,2h,cflag
          mov cbit,1h
          mov cstatus,2h
          mov cdir, offset cflag
          mov  ax,4c00h
          int    21h
main   endp
inst ends
          end

I could have made a mistake, but is only an example.

EDITED

qWord

please stop editing your post!
I was able to assemble the code you did supply - there was only a spelling error: dFlag instead of bFlag.

   .MODEL  Small
        .STACK  2048
        .DOSSEG
        .386
        OPTION  CaseMap:None

;####################################################################################

fmacro  macro mbit,mstatus,mdata
        mov     bBit,mbit
        mov     bStatus,mstatus
        mov     wDir,offset mdata
    endm

;####################################################################################

;        .DATA

;************************************************************************************

        .DATA?

bStatus db ?
bBit    db ?
bFlag   db ?
wDir    dw ?

;####################################################################################

        .CODE

;************************************************************************************

_main   PROC    FAR
       fmacro 1h,2h,bFlag

;////////////////////////////////////////
        mov     ax,4C00h
        int     21h

_main   ENDP
            END _main
MREAL macros - when you need floating point arithmetic while assembling!

georg

simply looks like I can't write macros, that has happen to me in more than one program, the assembler is corrupted maybe.

georg

finally I get the problem, a little detail :icon_redface:, thank you all for your kind help.

georg

One must first declare the macro, then call the macro, not otherwise  :biggrin:

dedndave

the code in reply #15 should work for you
and, yes - macros are typically defined very near the beginning of source