The recently removed "file.h" was #included by mmap.c, but mmap.c just
needed a few standard header files.
Similarly, remove <sys/mman.h> from file.c.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Move filename_set_extension() into path.c, so it has access to the
filesystem-specific character constants. This prevents something like:
nasm-code.d/foobar
... from getting truncated to ...
nasm-code.bin
... instead of producing ...
nasm-code.d/foobar.bin
Make the extension character (normally '.') configurable; this MIGHT
be usable on RISCOS at some point, although it is not entirely clear
that trying to make sense of RISCOS paths actually is meaningful,
because RISCOS compiler chains seem to do all kinds of path
translation magic trying to behave like other operating systems... it
might simply be more trouble than it is worth, especially for a
non-x86 platform.
As a side bonus, this removes the only use of strrchrnul(), so that
function can be dropped.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
file.h was only included from file.c; combine the two and declare
functions not used anywhere else as static.
Split out the checking I/O routines into a separate routine fileio.c
as they are (mostly) not host operating system specific, whereas
file.c is mostly host operating system generalization code.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
In the Windows-specific filename translation code, use
MultiByteToWideChar() instead of mbsrtowcs(). As this is
Windows-specific code it makes more sense to use the Windows-specific
API, and it might be more widely supported?
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
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>
Matching of branch instructions with prefixes and sizes is, to say the
least, tricky. Work through it, and add a new macro to help.
Fixes: https://github.com/netwide-assembler/nasm/issues/144
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>
The test for "absolute address can not be RIP-relative" is too strict
and causes false positive failures.
Fixes: https://github.com/netwide-assembler/nasm/issues/145
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>