Author Topic: Passing parameters in a macro  (Read 2696 times)

Offline afk

  • Jr. Member
  • *
  • Posts: 11
Passing parameters in a macro
« on: August 24, 2011, 08:38:35 PM »
In the outline code below I'm trying to pass a value directly to a macro but without success.
The goal is to compare FirstString with SecondString for a length of 10 chars.

_StrComp    FirstString, SecondString, 10

. . . .
%macro _StrComp 3
    mov ecx, %3
. . . .
%endmacro

NASM reports an invalid combination of opcode and operands.
I know I can pass the value in a 32 bit register or a variable but I'd like to pass the value directly if I can.
Is this possible ?
Thanks in advance.
afk

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2364
  • Country: us
Re: Passing parameters in a macro
« Reply #1 on: August 24, 2011, 09:47:09 PM »
Hi afk,

Should be possible. (tries it) Yeah, it seems to work for me. I didn't cut-and-paste your exact code, just typed in a "quick test", but I think I got it pretty much the same. Check your code carefully for typos, etc. If the problem persists, let us know what OS, what version of Nasm, what command line... anything else you think might help track it down. I don't think this is a "bug report", but I could be wrong. It's "supposed to work"!

Best,
Frank


Offline afk

  • Jr. Member
  • *
  • Posts: 11
Re: Passing parameters in a macro
« Reply #2 on: August 25, 2011, 12:08:56 AM »
Hi Frank,
Wow ! Don't you ever sleep ?? ;-)
Thanks for the quick response. I should have done what you did - make a quick test. I would have found out right away that the error had nothing to do with the parameter passing. But . . .

I found that the sticking point is my attempt to
            cmp %2, 0
 INSIDE the macro. 

If I do this:
            mov eax,%2
            cmp eax,0
then I'm all set.

Thanks again for the quick turnaround.
afk