NASM - The Netwide Assembler

Related Projects => NASMX => Topic started by: pprocacci on June 04, 2019, 01:55:02 AM

Title: Subtle Bug (I think)
Post by: pprocacci on June 04, 2019, 01:55:02 AM
While reading through nasmx.inc trying to learn nasm's preprocessor since it's godly, I was trying to invoke the %else in the below snippet:


Code: [Select]
nasmx.inc: line 1248-1255


%iftoken %{2}_size
%assign %%__argsize %{2}_size
%if (%%__argsize < 1)
%fatal invalid size for %{$__nx_name}.%{1}: %{2}
%endif
%else
%fatal unknown size for %{$__nx_name}.%{1}: %{2}
%endif


I couldn't.  Everything I was throwing at this test was always returning true.

A sample of what I was trying:

Code: [Select]
%include 'nasmx.inc'

NASMX_STRUC POINT
 NASMX_RESERVE x, yadda, 1
 NASMX_RESERVE y, uint32_t, 1
NASMX_ENDSTRUC

Now, it's possible that I'm simply doing it wrong, and quite frankly if it works, why should I care right?
It just bothers me that ${2}_size evaluates to a true value even when it isn't defined as a token as yadda_size for instance isn't defined.

Am I missing something?