Author Topic: Macros with masm 6.1  (Read 13719 times)

dedndave

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: Macros with masm 6.1
« Reply #15 on: September 18, 2013, 02:49:30 AM »
this seems to build ok
Code: [Select]
        .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

  • Member
  • *****
  • Posts: 1471
  • The base type of a type is the type itself
    • SmplMath macros
Re: Macros with masm 6.1
« Reply #16 on: September 18, 2013, 02:50:29 AM »
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

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: Macros with masm 6.1
« Reply #17 on: September 18, 2013, 02:54:15 AM »
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

  • Guest
Re: Macros with masm 6.1
« Reply #18 on: September 18, 2013, 05:14:03 AM »
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

  • Guest
Re: Macros with masm 6.1
« Reply #19 on: September 18, 2013, 05:17:16 AM »
Dave I change the name for the segment to "jklm", and I still get the same response from the assembler

japheth

  • Guest
Re: Macros with masm 6.1
« Reply #20 on: September 18, 2013, 05:23:58 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

  • Guest
Re: Macros with masm 6.1
« Reply #21 on: September 18, 2013, 05:31:15 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

  • Guest
Re: Macros with masm 6.1
« Reply #22 on: September 18, 2013, 05:43:08 AM »
I'm so used to mplab, where writing macros is easy. EDITED  :eusa_boohoo:

qWord

  • Member
  • *****
  • Posts: 1471
  • The base type of a type is the type itself
    • SmplMath macros
Re: Macros with masm 6.1
« Reply #23 on: September 18, 2013, 05:54:17 AM »
if 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

  • Guest
Re: Macros with masm 6.1
« Reply #24 on: September 18, 2013, 06:02:50 AM »
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

  • Member
  • *****
  • Posts: 1471
  • The base type of a type is the type itself
    • SmplMath macros
Re: Macros with masm 6.1
« Reply #25 on: September 18, 2013, 06:17:53 AM »
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.
Code: [Select]
   .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

  • Guest
Re: Macros with masm 6.1
« Reply #26 on: September 18, 2013, 06:28:23 AM »
simply looks like I can't write macros, that has happen to me in more than one program, the assembler is corrupted maybe.

georg

  • Guest
Re: Macros with masm 6.1
« Reply #27 on: September 18, 2013, 08:18:48 AM »
finally I get the problem, a little detail :icon_redface:, thank you all for your kind help.

georg

  • Guest
Re: Macros with masm 6.1
« Reply #28 on: September 18, 2013, 08:20:59 AM »
One must first declare the macro, then call the macro, not otherwise  :biggrin:

dedndave

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: Macros with masm 6.1
« Reply #29 on: September 18, 2013, 08:24:26 AM »
the code in reply #15 should work for you
and, yes - macros are typically defined very near the beginning of source