[BITS 32]
[CPU 486]
%macro definem 2+
mac %1, %2
%endmacro
%macro mac 2-*
%push
EXTERN %1
%assign %$ac (%0 -1)
%macro %[%1] %$ac
%rep %0
%rotate -1
push %1
%endrep
call %?
add esp, (%0 * 4)
%endmacro
%pop
%endmacro
definem printf, format, message
definem exit, errcode
SECTION .text
GLOBAL main
main:
printf dword strFormat, dword strMessage
sub eax, eax
exit eax
SECTION .data
strFormat DB "[+] %s", 10
strMessage DB "Hello, World!", 0
This code was tested and ran under NetBSD using:
b0x$ nasm -v
NASM version 2.10rc2 compiled on Nov 28 2010
b0x$ nasm -f elf -o klod.o klod.asm
b0x$ cc klod.o -o klod
b0x$ ./klod
[+] Hello, World!
b0x$