Make debug messages more dynamic by making it easy to conditionalize
the messages.
Change ERR_NOTE to ERR_INFO which reflects the usage better. Other
compilers use note: for additional information.
Don't unwind the macro stack with ERR_HERE; it is only going to give
confusing results as it will unwind the wrong macro stack.
Add ERR_LISTMSG level which is *always* suppressed, but will still
appear in the list file.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
ERR_NOTE just confuses things, especially in the case of a suppressed
warning.
The preprocessor doesn't use it for unwinding macros, either.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This allows the K instructions to be specified without a size suffix
as long as the operands are sized; this matches the way most other x86
instructions work. As this is not the syntax specified in the SDM,
don't use it for disassembly.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The flags massaging in insns.pl could end up with things like double
commas in some pathological cases, which would make insns_flag_index()
very unhappy due to the appearance of an empty argument. Fix this by
processing the flags as a list already in insns.pl.
Be more explicit and consistent in error messages.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The single-line macro argument parsing was completely broken as a
comma would not be recognized as an argument separator.
In the process of fixing this, make a fair bit of code cleanups.
Note: reverse tokens for smacro->expansion doesn't actually make any
sense anymore, might reconsider that.
This checkin also removes the distinction between "magic" and plain
smacros; the only difference is which specific expand method is being
invoked.
Finally, extend the allocating-string functions such that *all* the
allocating string functions support querying the length of the string
a posteori.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Allow overriding the autotools install location via environment
variables.
Handle missing aclocal or automake, which aren't mandatory as we cache
the files we get from them.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
We have to call expand_one_smacro() recursively, otherwise we will not
expand smacros which point to other smacros. We cannot simply do this
by looping after token pasting, because we need to make sure we don't
recursively expand the same smacro.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Add comments to iflag.c so a human user can have any hope of
figuring out what a particular bitmask actually means.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
For constructs like TIMES xx RESB yy merge the TIMES and RESB and feed
a single reservation to the backend; this can (obviously) be
dramatically faster.
Add byte count in listings for <incbin> and repeat count to <rept>; to
make them more reasonable in length shorten to <bin ...> and <rep ...>
respectively, and don't require leading zeroes in bin/rep/res count.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Add file missing from commit 418138c8f2:
iflags: move definitions to a separate file; auto-generate more
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Print a warning if one tries to assemble an obsolete instruction,
unless there is an exact match for the CPU directive.
For example:
CPU 386
POP CS ; Warning - obsolete instruction
CPU 8086
POP CS ; No warning
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Fix the definition of IF_CPU_LEVEL_MASK (which was missing the top
bit, IFM_ANY itself).
Add CPU definitions that we actually have into directiv.c.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Additional simplifications, including using the new IFM_ masks,
and make IF_GENBIT() automatically mask the field number.
When bit 31 in a field is set, iflag_cmp() could return the wrong
ordering value. Fix.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Move the definitions to a separate file, in order to separate code
from data better.
We can auto-generate more information about the instruction flags, so
let's do so.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Have warnings.pl give a warning(!) message if a warning definition is
found to be duplicated, including the location of both
definitions. Much better than silently creating bogus output.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Seems like Ghostscript has managed to break fontconfig support again,
at least in Fedora 30. Help Ghostscript along by giving it an explicit
font path.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
If an UTF-8 value exceeds 0x7fffffff, there is no legitimate encoding
for it. However, using FE or FF as leading bytes provide at least some
kind of encoding. This is assembly, and the programmer is (almost?)
always right. It might be worthwhile to add a suppressible warning for
invalid UTF-8 strings in general, though, including any character >
0x10ffff, surrogates, or a string that is constructed by hand.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Returning NULL makes more sense than returning the initial pointer
(the only other sensible alternative would be to return a pointer the
final null character.)
This currently can't happen, as all callers to nasm_skip_string()
currently explicitly tests for an initial quote.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
The merging of adjacent ' or " strings really does nothing but
introduce gratuitous incompatiblities; drop it.
Allow *some* control characters (BEL BS TAB ESC) in
nasm_unquote_cstr().
The ` state machine can be greatly simplified by treating \0 as just
another character and let it terminate the string in appropriate
contexts, just like `. The only difference with ` is when it occurs
in state st_backslash: you can't escape the null character.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Unfortunately, there is an assumption that the section name is bounded to '65'
characters and dashes have been appended so far. A simple fix for this report:
https://bugzilla.nasm.us/show_bug.cgi?id=3392564
We may need to cleanup further for those hardcoded numbers in decorating the
section info.
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
TOKEN_ID is from enum pp_token_type, but struct Type has enum
token_type. TOK_ID seems to be a matched one.s
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Windows supports pathnames up to 32767 UTF-16 characters, but using
the standard interfaces only up to 260 characters. Wrap the functions
that take filenames on Windows.
Clean up the compatiblity layers some more for reduced #ifdefs.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Split the code for getting a line of tokens from the code that sets
verror and detokenizes the resulting string.
While we are at it, merge the handling of EOF and ^Z into the general
loop in read_line().
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The smacro expansion code was virtually impossible to understand, and
was leading to very strange failures. Clean it up, and do much better
handling of magic macros. This should also allow for recursive
macros, but recursive macros are extremely tricky in that it is very
hard to keep them from recursing forever, unless there is at least one
argument which is never expanded. They are not currently implemented.
Even so, I believe token pasting makes it possible to create infinite
loops; e.g.:
%define foo foo %+
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
In nasm_unquote_cstr(), disallow any control character, not just
NUL. This will matter when allowing quoting symbols.
Merge nasm_unquote() and nasm_unquote_cstr().
Strings can now be concatenated, C style: adjacent quoted strings
(including whitespace-separated) are merged into a single string.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>