2009-06-29 07:58:10 +08:00
|
|
|
## --------------------------------------------------------------------------
|
|
|
|
##
|
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
|
|
|
## Copyright 1996-2019 The NASM Authors - All Rights Reserved
|
2009-06-29 07:58:10 +08:00
|
|
|
## See the file AUTHORS included with the NASM distribution for
|
|
|
|
## the specific copyright holders.
|
|
|
|
##
|
|
|
|
## Redistribution and use in source and binary forms, with or without
|
|
|
|
## modification, are permitted provided that the following
|
|
|
|
## conditions are met:
|
|
|
|
##
|
|
|
|
## * Redistributions of source code must retain the above copyright
|
|
|
|
## notice, this list of conditions and the following disclaimer.
|
|
|
|
## * Redistributions in binary form must reproduce the above
|
|
|
|
## copyright notice, this list of conditions and the following
|
|
|
|
## disclaimer in the documentation and/or other materials provided
|
|
|
|
## with the distribution.
|
|
|
|
##
|
|
|
|
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
|
|
## CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
|
|
## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
## DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
|
|
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
|
|
## EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
##
|
|
|
|
## --------------------------------------------------------------------------
|
|
|
|
|
2007-09-12 09:29:43 +08:00
|
|
|
#
|
|
|
|
# A * at the end indicates a condition; the list of conditions are
|
|
|
|
# on lines starting with *; the negatives are auto-generated
|
|
|
|
#
|
2019-08-15 16:14:23 +08:00
|
|
|
|
|
|
|
# Condition stems. %if MUST BE FIRST in this list.
|
|
|
|
%if*
|
|
|
|
%elif*
|
|
|
|
|
|
|
|
# Condition tests
|
2007-09-12 09:29:43 +08:00
|
|
|
*
|
|
|
|
*ctx
|
|
|
|
*def
|
2008-02-17 09:01:40 +08:00
|
|
|
*empty
|
2010-07-14 03:00:58 +08:00
|
|
|
*env
|
2007-09-12 09:29:43 +08:00
|
|
|
*id
|
|
|
|
*idn
|
|
|
|
*idni
|
|
|
|
*macro
|
|
|
|
*num
|
|
|
|
*str
|
2008-02-17 09:01:40 +08:00
|
|
|
*token
|
2019-08-15 16:14:23 +08:00
|
|
|
|
|
|
|
# Directives with -i- versions for case insensitive
|
|
|
|
%!assign
|
|
|
|
%!defalias
|
|
|
|
%!define
|
|
|
|
%!defstr
|
|
|
|
%!deftok
|
|
|
|
%!macro
|
|
|
|
%!pathsearch
|
|
|
|
%!rmacro
|
|
|
|
%!strcat
|
|
|
|
%!strlen
|
|
|
|
%!substr
|
|
|
|
%!xdefine
|
|
|
|
%un!macro
|
|
|
|
|
|
|
|
# Other directives
|
2007-09-12 09:29:43 +08:00
|
|
|
%arg
|
|
|
|
%clear
|
2008-05-31 01:42:30 +08:00
|
|
|
%depend
|
2007-09-12 09:29:43 +08:00
|
|
|
%else
|
|
|
|
%endif
|
|
|
|
%endm
|
|
|
|
%endmacro
|
|
|
|
%endrep
|
|
|
|
%error
|
2009-07-12 03:26:34 +08:00
|
|
|
%exitmacro
|
2007-09-12 09:29:43 +08:00
|
|
|
%exitrep
|
2008-09-24 15:21:58 +08:00
|
|
|
%fatal
|
2007-09-12 09:29:43 +08:00
|
|
|
%include
|
|
|
|
%line
|
|
|
|
%local
|
|
|
|
%pop
|
2016-10-05 05:07:19 +08:00
|
|
|
%pragma
|
2007-09-12 09:29:43 +08:00
|
|
|
%push
|
|
|
|
%rep
|
|
|
|
%repl
|
|
|
|
%rotate
|
|
|
|
%stacksize
|
|
|
|
%undef
|
2019-08-15 14:45:57 +08:00
|
|
|
%undefalias
|
2008-06-20 06:04:18 +08:00
|
|
|
%use
|
2008-06-11 09:27:38 +08:00
|
|
|
%warning
|