Author Topic: NASM macro parser suxx  (Read 7829 times)

nobody

  • Guest
NASM macro parser suxx
« on: March 10, 2008, 11:15:20 AM »
OK, here's my problem: I've a macro and I always get "error: invalid combination of opcode and operands". What the f* is wrong in nasm?!? (My code couldn't be wrong, because nasm compiles it without a fass if it's not in a macro). And, how can I make nasm to print more specific error messages?!? I only got the line number of the macrocall, how can I get the line inside a multiline macro?!?

Here's my code (does not work):

%assign      exceptionmask      (event | event.hwexception << 2)
%macro      exceptionhandler   2
kernel_ex%1:
%if %2
      pop         ebx
%else
      mov         ebx, 0
%endif
      pushad
      movzx         eax, %1
      shl         eax, 4
      add         eax, exceptionmask
      jmp         kernel_syscall
%endmacro

exceptionhandler   00h, 0
      exceptionhandler   01h, 0
      exceptionhandler   02h, 0
      [...]

Another code (that's working):

kernel_ex00h:
      mov         ebx, 0
      pushad
      movzx         eax, %1
      shl         eax, 4
      add         eax, exceptionmask
      jmp         kernel_syscall

Any suggestion would be greatful. And PLEASE, if an error occurs in a multiline macro, print that line number...
Cheers,
Turdus

nobody

  • Guest
Re: NASM macro parser suxx
« Reply #1 on: March 10, 2008, 11:53:28 AM »
I've found the problem:

%macro movez 1
movzx %1
%endmacro

movzx 01h ;this will work
movez 01h ;but this won't

nasm version: NASM version 0.98.40 (Apple Computer, Inc. build 11) compiled on Sep 23 2007

Cheers,
Turdus

nobody

  • Guest
Re: NASM macro parser suxx
« Reply #2 on: March 10, 2008, 12:02:49 PM »
I'd expect movzx to require a size specifier - byte or word (unless second operand is a reg). Try that. The "-e" switch should provide preprocessed output, try assembling that with "-a" and see where the error is(?). Or comment out lines one at a time.

Best,
Frank

Debbie Wiles

  • Guest
Re: NASM macro parser suxx
« Reply #3 on: March 10, 2008, 12:28:20 PM »
movzx requires two parameters. It takes the form:

movzx reg,reg/mem

As Frank said, the second parameter must be sized, so if it is a memory reference you need an operand size specifier.

"movzx 01h" should NOT work, because you are only giving it one operand. The error is right :)