Author Topic: Problem with macro parameter  (Read 2025 times)

nobody

  • Guest
Problem with macro parameter
« 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

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2381
  • Country: us
Re: Problem with macro parameter
« Reply #1 on: October 04, 2007, 07:49:31 PM »
...
cmp byte [%1 + si], '$'
...
mov al, [%1 + si]
...

Best,
Frank

nobody

  • Guest
Re: Problem with macro parameter
« Reply #2 on: October 05, 2007, 09:14:04 AM »
Great thanks. It works!