preproc: add %i... variants, evaluated macro parameters, cleanups
All directives which create single-line macros now have %i... variants
to define case-insensitive versions. Case insensitive rather sucks,
but at least this way it is consistent.
Single-line macro parameters can now be evaluated as a number, as done
by %assign. To do so, declare a parameter starting with =, for
example:
%define foo(x,=y) mov [x],macro_array_y
... would evaluate y as a number but leave x as a string.
NOTE: it would arguably be better to have this as a per-instance
basis, but it is easily handled by having a secondary macro called
with the same argument twice.
Finally, add a more consistent method for defining "magic" macros,
which need to be evaluated at runtime. For now, it is only used by the
special macros __FILE__, __LINE__, __BITS__, __PTR__, and __PASS__.
__PTR__ is a new macro which evaluates to word, dword or qword
matching the value of __BITS__.
The magic macro framework, however, provides a natural hook for a
future plug-in infrastructure to hook into a scripting language.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-02-27 06:00:54 +08:00
|
|
|
%define tonum(=x) x
|
|
|
|
|
|
|
|
dd tonum(1+3)
|
|
|
|
dd tonum(5*7)
|
2019-08-09 23:06:39 +08:00
|
|
|
|
2023-10-16 13:40:07 +08:00
|
|
|
%define mixed(a,=b,c) (a + b)
|
|
|
|
%define mixed2(a,=b,) (a + b)
|
|
|
|
%define mixed3(=a/u,=b/x,=c/ux) (a + b + c)
|
2019-08-09 23:06:39 +08:00
|
|
|
%define ALPHA (1 + 2)
|
|
|
|
%define BETA (3 + 4)
|
|
|
|
%define GAMMA (5 + 6)
|
|
|
|
|
|
|
|
dd mixed(ALPHA, BETA, GAMMA)
|
|
|
|
dd mixed2(ALPHA, BETA, GAMMA)
|
2023-10-16 13:40:07 +08:00
|
|
|
dd mixed3(-ALPHA, -BETA, -GAMMA)
|