NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: Borneq on December 12, 2012, 11:18:14 PM

Title: Problem with arguments and preprocesing only
Post by: Borneq on December 12, 2012, 11:18:14 PM
In standard nasmx example demo1 for win32 is
;// the start of our program as defined with the ENTRY macro
proc   demo1, ptrdiff_t argcount, ptrdiff_t cmdline
locals none
    invoke    my_p, szContentTwo, szTitleTwo
    invoke    MessageBox, NULL, szContent, szTitle, MB_OK
    invoke    ExitProcess, NULL
endproc
If I try use argcount: mov eax,argcount is error: symbol `argcount' undefined
If I try preproces only -E is errors:
..\..\..\inc\nasmx.inc:358: error: symbol references not supported in preprocess-only mode
..\..\..\inc\nasmx.inc:358: error: non-constant value given to `%assign'
..\..\..\inc\nasmx.inc:360: fatal: unknown size0_t: 0
Title: Re: Problem with arguments and preprocesing only
Post by: Mathi on December 13, 2012, 02:01:34 AM
The syntax for referring to the function parameters is  (Only when using NASMX macro)

argv(.paramname)

Try,
mov    eax, uint32_t [argv(.argcount)]
or
mov     eax,  [argv(.argcount)]


Yeah, for a workaround for -E switch issue, you can add

%define __BITS__ 32

in your source file.

Thanks,
Mathi.
Title: Re: Problem with arguments and preprocesing only
Post by: Borneq on December 13, 2012, 08:19:21 AM
Thanks, all works!
In Nasm starting procedure:
proc   demo1, ptrdiff_t argcount, ptrdiff_t cmdline
gets argcount and cmdline like C programs ? cmdline is string table or one string?
Title: Re: Problem with arguments and preprocesing only
Post by: Mathi on December 13, 2012, 08:53:22 AM
Checkout the linux example in NASMX package. I guess it should work for win32 too.
demos\linux\DEMO3\demo3.asm

Regards,
Mathi.