0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-11-08 23:27:15 -05:00

5561 Commits

Author SHA1 Message Date
H. Peter Anvin (Intel)
f4f7d18c06 error: factor out error functions into separate files
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>
2025-11-07 14:42:33 -08:00
H. Peter Anvin (Intel)
c0e4def0fe assemble: factor out calcsize_speculative()
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>
2025-11-07 11:51:01 -08:00
redzimski
94c6ecda5b fix [warning push] causing "unknown warning name"
[warning push] emitted a "unknown warning name" warning when
-w+unknown-warning is set.
2025-11-04 10:23:54 -08:00
Petr Sumbera
ca178f80d8 Fix for big endian platforms.
https://bugzilla.nasm.us/show_bug.cgi?id=3392745
2025-11-04 10:14:49 -08:00
H. Peter Anvin (Intel)
acfeb7df6c zlib: pass 15 not 0 to inflateInit2()
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>
2025-11-04 00:38:17 -08:00
H. Peter Anvin (Intel)
94923e1382 travis: improve the RET instruction test
Split the RET instruction test by mode for ease of disassembly, and
test more subcases.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-15 22:51:34 -07:00
H. Peter Anvin (Intel)
e19c989bd5 insns.dat: correct the handling of RET instructions with prefixes
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>
2025-10-15 22:44:23 -07:00
H. Peter Anvin (Intel)
4709cfe493 Show instruction mismatch errors if another error terminates assembly
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>
2025-10-15 22:32:36 -07:00
H. Peter Anvin
ca67f50341 travis: unbreak the ret.asm test
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>
2025-10-15 22:32:32 -07:00
H. Peter Anvin
bf16907c9d travis: unbreak the ret.asm test
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>
2025-10-15 22:29:01 -07:00
H. Peter Anvin
1a907c27a5 travis: always generate a list file; show subtest number
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>
2025-10-15 22:11:09 -07:00
H. Peter Anvin (Intel)
94dd4d30a7 test: improve ret.asm
Add more valid and invalid combinations of return instructions.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-15 21:12:58 -07:00
H. Peter Anvin (Intel)
1b939ecf3d errors: add the ability to hold errors, not just warnings
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>
2025-10-15 21:09:05 -07:00
H. Peter Anvin (Intel)
9503778d6e ndisasm: handle byte code 0300..0303 (HINT_NOP)
Avoid ndisasm printing error messages due to an unknown byte code.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-15 21:05:46 -07:00
H. Peter Anvin (Intel)
fc56538bce Makefile: include $(PROGOBJ) in $(DIRS) dependency
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>
2025-10-15 20:00:36 -07:00
H. Peter Anvin (Intel)
efe066ef40 nasm.c: if enabled, print a pass report even on failure
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>
2025-10-15 17:34:42 -07:00
H. Peter Anvin (Intel)
ab8787a1fa Rename "headers" directory to "templates", add .h template
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>
2025-10-15 17:34:29 -07:00
H. Peter Anvin (Intel)
f520436a7a Make Watcom workarounds a little less obnoxious
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>
2025-10-15 17:34:10 -07:00
KO Myung-Hun
e86773d70b openwcom.mak: clean up internal zlib directory
Signed-off-by: KO Myung-Hun <komh78@gmail.com>
2025-10-15 17:31:44 -07:00
H. Peter Anvin (Intel)
44ec97993a compiler: add and use unreachable() macro
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>
2025-10-13 17:53:42 -07:00
H. Peter Anvin (Intel)
9ba21c1e50 .gitignore: add .bin16, .bin32, .bin64
New test format suffixes. These are output files and should be ignored
by git.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-12 13:43:00 -07:00
H. Peter Anvin (Intel)
746e7c9efa compiler.h: the test for "neither C++ nor C23" still wrong
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>
2025-10-12 13:05:55 -07:00
H. Peter Anvin (Intel)
dfb3b0013e version: now working on 3.02... 2025-10-12 12:59:14 -07:00
H. Peter Anvin (Intel)
0bc4333150 Change JMPE encoding from being relative to being absolute
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>
2025-10-12 12:58:04 -07:00
H. Peter Anvin (Intel)
44e89ba9b6 compiler.h: drop the stupid C++-style cast-to-bool hack
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>
2025-10-12 12:48:32 -07:00
H. Peter Anvin (Intel)
587ed5e36d x86/bytecode.txt: improve byte code documentation
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>
2025-10-12 11:23:28 -07:00
H. Peter Anvin (Intel)
e9fac2faa6 NASM 3.01 nasm-3.01 2025-10-10 23:42:56 -07:00
Yongjie Sheng
3e925ee75c add project test for intel-ipsec-mb isa-l_crypto isa-l 2025-10-11 09:49:07 +08:00
H. Peter Anvin (Intel)
5d655306f9 NASM 3.01rc9 nasm-3.01rc9 2025-10-10 17:23:52 -07:00
H. Peter Anvin (Intel)
e20b3087cc changes.src: update release notes
A few more changes.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-10 16:37:04 -07:00
H. Peter Anvin (Intel)
8f1cd30fcb insns.dat: fix CMPXCHG operand size
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>
2025-10-10 16:24:22 -07:00
H. Peter Anvin (Intel)
a7457e66cf Fix matching of branch instructions with prefixes and sizes
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>
2025-10-10 13:07:46 -07:00
H. Peter Anvin (Intel)
2c71e67762 travis: don't stop on failure
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>
2025-10-10 10:55:11 -07:00
H. Peter Anvin (Intel)
c0aec6969b directives: correctly handle quoted strings in directives
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>
2025-10-10 10:41:09 -07:00
H. Peter Anvin (Intel)
5a6b276b89 travis: make travis output list files for debugging
It is so much easier to debug problems with a list file in hand.
Generate them, always.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-09 22:28:34 -07:00
H. Peter Anvin (Intel)
4cdb62ffb6 listing: modify active_list_options, not just list_options
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>
2025-10-09 20:09:33 -07:00
H. Peter Anvin (Intel)
7e82d9d1e3 Add a default-error warning for impossible o64, a64, or a16 prefixes
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>
2025-10-09 19:24:07 -07:00
H. Peter Anvin (Intel)
a16571a705 doc/directiv.src: fix missing ] in prefix/suffix documentation
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>
2025-10-09 17:29:00 -07:00
H. Peter Anvin (Intel)
b8e256a475 changes.src: add missing \>
Add missing \> marker (bulleted list continuation.)

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-09 17:25:54 -07:00
H. Peter Anvin (Intel)
f87fb5c957 nasm.spec.in: change http:// to https://
Change URLs to https://.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-09 17:19:54 -07:00
H. Peter Anvin (Intel)
b453f9e8ea nasm.spec.in: be extra obnoxious about build requirements
It is better to put in too many BuildRequires than too few.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-09 17:19:09 -07:00
Igor Glücksmann
35ef2e2d1a Fixed PDF doc line overflow
Resolved Conflicts:
	doc/nasmdoc.src

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-09 17:08:35 -07:00
H. Peter Anvin (Intel)
69c25535ae NASM 3.01rc8 nasm-3.01rc8 2025-10-09 16:15:52 -07:00
H. Peter Anvin (Intel)
ddf85b55ed changes.src: update release notes
Add recent changes to the release notes.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-09 16:14:58 -07:00
H. Peter Anvin (Intel)
3d96ea651a assemble: weaken the test for "absolute address can not be RIP-relative"
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>
2025-10-09 16:10:35 -07:00
Nico Weber
a8a1dc2b0c Fix Wbitwise-instead-of-logical warning
`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.
2025-10-09 15:48:18 -07:00
H. Peter Anvin (Intel)
9b101e9316 insns.pl: register 0 should add RN_ZERO, not RM_ZERO
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>
2025-10-09 15:42:29 -07:00
KO Myung-Hun
0c8379825e openwcom.mak: use internal commands if possible
[ 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>
2025-10-09 15:05:29 -07:00
KO Myung-Hun
29a5aabd7a Fix compilation with Open Watcom
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>
2025-10-09 14:52:29 -07:00
H. Peter Anvin (Intel)
013db3d446 nasmlib: rename crc32.c to crc32b.c to avoid conflict with zlib/crc32.c
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>
2025-10-09 14:49:22 -07:00