Reputation: 23
I'm trying to implement couple of macros for x86 project.
I just moved from MARS mips assembly so dont judge my incompetence.
I think I'm doing everything as in this guide https://www.tutorialspoint.com/assembly_programming/assembly_macros.htm
%macro assign a,b
mov ax, [b]
mov [a], ax
%endmacro
This is the error i get:
fun.asm:21: error: `%macro' expects a parameter count
I've also tried doing this with "%" before values (a and b) but it only produced syntax errors
Could anybody point out what exactly am i doing wrong?
Upvotes: 2
Views: 4882
Reputation: 30450
I don't think you can directly give names to the arguments like that. Instead you supply the number of arguments you expect and refer to the with %1
, %2
, etc. So your macro would look like this:
%macro assign 2
mov ax, [%2]
mov [%1], ax
%endmacro
There's more details in the NASM manual.
Upvotes: 8