Tidy up a *lot* of code by moving error functions into separate source
files. This required breaking out some of the assembler-only files
into a separate library, as it conflicts with stubs in the
disassembler.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Currently speculative size calculations is only done during
jmp_match(), but it might be used for other things in the
future. Either way, it is cleaner to have it factored out into a
separate function.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The convention of passing 0 to inflateInit2() to autodetect the window
size is not supported in really old versions of zlib. The only
downside with simply passing in the maximum value (15) is potential
additional memory buffer allocations, but it is a drop in the bucket
for NASM.
Fixes: https://github.com/netwide-assembler/nasm/issues/165
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
NASM would throw a warning on some valid prefixed RET instructions,
e.g. "o32 ret" instead of "retd" in 16-bit mode. Correct that.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Instruction mismatch errors have been held until the last assembly
pass in case changed %if statements cause a code path to be elided in
subsequent passes. However, it is confusing to the user if error
messages aren't shown if another error terminates assembly.
Use the already existing mechanism for warnings to hold the messages
unless another error terminates assembly.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The ret.asm test was broken because the assembly expected -DERROR=1
whereas the run script provided -DERROR, masking all the actual
errors...
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The ret.asm test was broken because the assembly expected -DERROR=1
whereas the run script provided -DERROR, masking all the actual
errors...
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Always generate a list file and point output at a given filename, even
if failure is expected.
Remove ad hoc -o output names that generally don't point into safe
locations.
The result is that the preprocessing options (-E) no longer output to
stdout, so change the tests accordingly.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Re-introduce ERR_HOLD, which means that an error is treated like a
warning except for the last pass, but unlike ERR_PASS2 the error
message *will* be issued if another error happens on the same pass, just
like warnings.
This will be used to improve error messages on instruction mismatch.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The $(DIRS) dependency didn't include $(PROGOBJ), which could cause
Make to try to build asm/nasm.o or disasm/ndisasm.o before the
corresponding object subdirectory had been created.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
If printing a pass report is enabled, then do so even if the assembly
session failed -- except for a critical or panic failure (e.g. if
running out of memory, which could cause recursive failures.)
This can help discovering e.g. why certain error messages don't appear
when one would expect them (because they have not been detected in the
current pass.)
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Rename the "headers" directory to "templates", and rename the files
within as template.* with the appropriate file types so that editors
will pick up the correct type. Add a .h file template.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Duplicated code is asking for trouble. Make the Watcom brain damage
workarounds at least patternized.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
C23 defines unreachable() as a macro in <stddef.h>. For earlier
versions of gcc, __builtin_unreachable() is possible.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The test needs to test for neither nor; as it was it tested "(not C++)
or C23" which was not at all what was intended...
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Apparently NASM has been doing this in violation of the spec since
JMPE was first added. Hopefully fixing it won't cause new problems...
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The C++-style cast-to-bool hack was broken in concept that it doesn't help the
fundamental problem -- implicit conversions are broken for the
backwards compatibility enum definition -- as well as in
implementation, as it misspelled __STDC_VERSION__ as __STDC_VERSION.
The #ifdef bool test *should* have prevented this problem, but
apparently several compilers do define "bool" in <stdbool.h> even when
it is a keyword, in violation of the C23 spec.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Improve the byte code reference documentation to make a few opcodes
more clear and add some general properties about the byte codes,
including the files that need to be changed when the byte code
changes.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The operand size prefix byte code (o#) was missing in the CMPXCHG
pattern.
Reported-by: Yongjie Sheng <sheng.yongjie@intel.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Don't stop travis after a single test failure. It is better to run all
the tests and get a comprehensive list of failing tests.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Quoted strings should be valid inside directives, including ones that
contain a ] character. Also check for garbage on the line after the
directive.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
If the assembly stops after the first pass, only active_list_options
will be seen; this is also the value that applies for local changes in
the list options. Thus, both variables need to be tweaked.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The o64, a64 and a16 prefixes are only possible in specific
modes. It is a lot easier to debug with a more sensible error message.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The prefix/suffix directive documentation were missing some brackets,
lost in the course of editing.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
`a || b` only evaluates b if a is false. `a | b` always evaluates
both a and b. If a and b are of type bool, || is usually what you
want, so clang now warns on `|` where both arguments are of type bool.
This warning fires once in nasm. It looks like `|` is an (inconsequential)
typo of `||`, so use that instead.
No intended behavior change.
Not all registers are valid as memory references, and thus
using RM_ZERO is incorrect. Use RN_ZERO instead, which is simply the
zero-register bit.
Fixes: https://github.com/netwide-assembler/nasm/issues/140
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
[ hpa: added comment that "rm" really is a WMAKE internal command. ]
Signed-off-by: KO Myung-Hun <komh78@gmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Open Watcom does not support 64-bit constants at 'case'.
[ hpa: I'm pulling this, but I'm really, *really* questioning its
supportability long term. The OpenWatcom people need to fix this, or
we are just going to have to say "OW is not supported."
At some point we *are* going to move to a "C99 is baseline" policy for
code; there are simply too many features in C99 that are actively
painful to be without.
That is, unless we decide to go to C++, which is under consideration
but is a much bigger job. In that case, the target will probably be
either C++11 or C++14 as those C++ versions contain some pretty
essential features. ]
Signed-off-by: KO Myung-Hun <komh78@gmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
For the benefit of those platforms which have to rely on VPATH, avoid
having the same filename in multiple subdirectories.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>