Is it possible to to use the outer macro parameter is used by inner macro?

84 Views Asked by At
data segment
    str db "hello$" 
    str2 db "world$" 
data ends  
 
adds macro a,b
    lea si,a
    lea di,b
endm
    
subs macro x,y
    adds x,y
endm  

code segment
assume cs:code,ds:data
start:  mov ax,data
        mov ds,ax
        
        subs str,str2
        
        mov ah,4ch
        int 21h
        
        end start
        code ends

The above is just an example, in case of integers works fine but in this case of strings why it doesn't replace x,y with str,str2??? plz help out me fast I need to work on it for the project. The error generated by it is:

enter image description here

1

There are 1 best solutions below

3
On BEST ANSWER

The lack of nested macros is a limitation with EMU8086 and I don't think it is possible. If you used MASM/TASM/JWASM it should handle it properly.

On newer versions of MASM str is an instruction on the 386 and it is a good idea to rename str to something else to avoid MASM giving an error.

The last 2 lines of your code are reversed and should be:

code ends
end start

You have to end the current segment with ends before ending the program with end.