NASM - The Netwide Assembler

NASM Forum => Using NASM => Topic started by: nobody on October 04, 2007, 06:48:40 PM

Title: Problem with macro parameter
Post by: nobody on October 04, 2007, 06:48:40 PM
I have macro that works with tasm but now I want compile it with nasm. Macro prints string terminated with '$'. When I write CMP byte ptr %1[si],'$' I get error message - looks like parameters work as registers.

PutString MACRO String
LOCAL skip
LOCAL next
   PUSHF
   PUSH bp
   PUSH AX
   PUSH BX
   PUSH SI

xor si,si

next:
   CMP byte ptr String[si],'$'
   JE skip

MOV ah,0Eh
   MOV al,byte ptr String[si]
   INT 10h

INC SI

JMP next

skip:
   POP SI
   POP BX
   POP AX
   POP bp
   popf
ENDM

and after convertion:

%macro PutString 1
   PUSHF
   PUSH bp
   PUSH AX
   PUSH BX
   PUSH SI

xor si,si

%%next:
   CMP byte ptr %1[si],'$' ; ooops!
   JE skip

MOV ah,0Eh
   MOV al,byte ptr %1[si] ; ooops!
   INT 10h

INC SI

JMP next

%%skip:
   POP SI
   POP BX
   POP AX
   POP bp
   popf
%endmacro
Title: Re: Problem with macro parameter
Post by: Frank Kotler on October 04, 2007, 07:49:31 PM
...
cmp byte [%1 + si], '$'
...
mov al, [%1 + si]
...

Best,
Frank
Title: Re: Problem with macro parameter
Post by: nobody on October 05, 2007, 09:14:04 AM
Great thanks. It works!