3

sorry I would have a probelam. In practice The MASM Assembler does not recognize my macro labels, or rather, even if I define them as local, the following returns to me:

ERROR A2005 Multidefined Symbol

....

This for more and more time

I'll post the macro code here:

input_int MACRO register

    LOCAL input, stop_input

    push    ax
    push    cx

    xor     register, register

    mov     cx, 5

    input:  mov   ah, 01h
            int   21h
            xor   ah, ah

            cmp   al, 13
            je   stop_input

            cmp   al, 48
            jb    stop
    
            cmp   al, 57
            ja    stop

            sub   al, 48
            mov   store_in, ax
            mov   ax, 10
            mul   register
            add   store_in, ax
            mov   register, store_in

            loop  input
            pop   cx
            pop   ax
    
    stop_input: mov  ah, 02h
                mov  dl, 13
                int  21h
                mov  dl, 10
                int  21h
       ENDM

And here the expansion of there

code SEGMENT PARA PUBLIC        

    ASSUME ss: stack, ds: data, cs: code

_start:
    ;load the DS
    mov     ax, data
    mov     ds, ax

    ;ouput msg1
    mov     ah, 09h
    mov     dx, OFFSET msg1
    int     21h

    ;input1
    input_int bx

    ;output msg2
    mov   ah, 09h
    mov   dx, OFFSET msg2
    int   21h 
    
    ;input msg2
    input_int dx

    stop: mov   ah, 04ch
          mov   al, 1
          int   21h

 code ENDS       
    END _start

I have no errors, but there are. In my opinion the assembler has gone mad, you recommend another version of MASM to generate 16bit executables that does not have this bug. I am currently using MASM 5.0.

EDIT: I wrote a new program calling the same macro twice here is the result:

Image

The same mistakes. The code:

abMacro MACRO

    LOCAL jump, doNothing

    mov     cx, 5

    jump: add   ax,10

           cmp   ax, 30
           je    doNothing

           loop  jump

     doNothing: nop

ENDM

stack SEGMENT PARA STACK

    db      ?

stack ENDS


data SEGMENT PARA PUBLIC

     db      ?

data ENDS

code SEGMENT PARA PUBLIC

     ASSUME ss: stack, ds: data, cs: code

_start:

     mov     ax, data
     mov     ds, ax

     abMacro

     abMacro

     mov     ah, 04ch
     mov     al, 1
     int     21h

code ENDS
     END _start

In my opinion the assembler has gone mad. For me It was given me a badly written Assembler, or I touched some files, which is unlikely since I don't even know where the sources are.

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
mattstack
  • 103
  • 6
  • 3
    Does it say what symbols? Maybe the assembler is trying to tell you this should be a function not a macro :D Joke aside, if the problem is with the `LOCAL` then reduce it to a minimal example and post full code along with the command you use to assemble. – Jester Apr 02 '21 at 17:58
  • maybe share the whole program as currently there's stuff missing in your example – Paweł Łukasik Apr 02 '21 at 18:34
  • Ok now i edit the post – mattstack Apr 02 '21 at 18:43
  • 1
    MASM 6.11 can still generate segmented code for DOS. MASM 6.11 could still run in DOS (and was last version to do so). You can use MASM 6.15 to make DOS programs but the assembler runs in Windows, and you need a 16-bit linker. MASM32 SDK (google it) comes with one called `link16.exe`. MASM 6.15 was the last version to support generation of DOS programs. – Michael Petch Apr 02 '21 at 21:22
  • 1
    I believe what is going on here is that early versions of MASM before 5.1 were limited when using LABEL inside macros. What you can do is use anonymous labels (@@) and then use the @B to go back to the previous @@ (anonymous label) or go forward to the next one with @F. This code likely would assemble in 5.10 https://pastebin.com/raw/VwMJ1s0F . A restriction was you could only go back or forward to the nearest anonymous label. You couldn't skip forward back 2 or more. – Michael Petch Apr 02 '21 at 21:27

1 Answers1

4

It's super weird but it started to work after removing the empty line between macro definition and LOCALs.

So if your macro declaration is

abMacro MACRO

    LOCAL jump, doNothing

It will return bunch of redefinition errors as in your post enter image description here

but if you remove that empty line, so it is like this

abMacro MACRO
    LOCAL jump, doNothing

enter image description here

Paweł Łukasik
  • 3,893
  • 1
  • 24
  • 36