0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-09-22 10:43:39 -04:00
Commit Graph

5245 Commits

Author SHA1 Message Date
H. Peter Anvin
68ea20e5f9 NASM 3.00rc2 nasm-3.00rc2 2025-09-05 18:38:12 -07:00
H. Peter Anvin
276cbf9682 autoconf/Makefile.in: add include for local zlib
When using the internal zlib, need to make sure to add the appropriate
-I option for the header...

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 18:36:28 -07:00
H. Peter Anvin
6fc4a7e668 NASM 3.0rc1 nasm-3.0rc1 2025-09-05 18:08:52 -07:00
H. Peter Anvin
7e4e937f97 Merge remote-tracking branch 'origin/master' 2025-09-05 18:03:44 -07:00
H. Peter Anvin
fb54b25f66 insns.dat: fix MOVRS pattern
MOVRS is a pretty basic instruction; it uses the normal operand size
handling.

Fix apx.bin.t accordingly.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 18:02:52 -07:00
H. Peter Anvin
419f369b42 doc: a few more index tweaks
Very minor cleanpus to the index.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 17:53:48 -07:00
H. Peter Anvin
7cc5291ece doc: tweaks to the index
Make the index at least a little bit more legible.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 17:51:38 -07:00
H. Peter Anvin
1d63ae2a3b doc: update the documentation, and auto-generate some indexes
There are currently six variations of each conditionals, and there may
be more in the future (e.g. %while). Stop trying to enumerate them all
everywhere.

Add support for index copying in the document processor.

Have pptok.pl auto-generate index metadata for conditional
preprocessor directives.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 17:12:06 -07:00
H. Peter Anvin
4cf4333ba2 standard.mac: define __?NASM_HAS_IFDIRECTIVE?__
Define a __?NASM_HAS_IFDIRECTIVE?__ to know when it is safe to use
%ifdirective and other dynamic probing features.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 17:12:06 -07:00
Maciej Wieczor-Retman
30eb8e2e2a insns: travis: apx: MOVRS instruction
Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-05 23:25:42 +02:00
Maciej Wieczor-Retman
beaeb77bce insns: travis: apx: MOVDIR instructions
Add MOVDIR64B and MOVDIRI to the database. Add relevant testcases

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-05 23:25:20 +02:00
H. Peter Anvin
f39677d527 test: add -DSRC as a standard option; bin32 and bin64 targets
Make it a little easier to run bench tests which include multiple bit
sizes, and add the SRC define to make SRC/BIN tests easier to run on
the bench.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 12:56:46 -07:00
H. Peter Anvin
ac93d75da3 Sanitize the handling of messsages; improve info and debug
Make the handling of messages saner. In particular, regularize the
handling of info and debug messages, so that nasm_info() and
nasm_debug() actually become useful.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 12:53:20 -07:00
Maciej Wieczor-Retman
05a07b7ccf insns: travis: apx: MOVBE instruction
Add the database entry and test cases.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-05 21:44:57 +02:00
Maciej Wieczor-Retman
712095fffe insns: travis: apx: LZCNT instruction
Doesn't yet work with EGPRs.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-05 17:23:29 +02:00
Maciej Wieczor-Retman
ca85c1c3b5 insns: travis: apx: LDTILECFG instruction
Add database entry and test cases.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-05 16:02:58 +02:00
Maciej Wieczor-Retman
3b3a115754 travis: apx: Finish the KMOV test cases
Add remaining APX versions of the KMOV tests (kmovw - kmovq)

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-05 15:19:36 +02:00
Maciej Wieczor-Retman
1054b5aefc x86: Fix handling of the ko# specifier
KMOV opcodes of 0x90 and 0x91 have similar bits set in all size
implementations. .66 and .W1 for 32bit, and .NP and .W1 for 64 bits.

Correct my previous mistake where I swapped the VEX/EVEX.pp values by
accident.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-05 15:17:05 +02:00
H. Peter Anvin
dfe7d54901 insns.dat: fix ADCX/ADOX patterns for proper disassembly
The 66 prefix on these instructions are an opcode extension prefix,
not an operand prefix, so use w# to set the size rather than o#.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 03:37:24 -07:00
H. Peter Anvin
a92616af5c disasm: fix the masking of the V4/X4 bit
This bit needs to be masked *except* when:
- There is no V operand
- The modr/m has mod == 3 OR there is an scc

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 03:32:28 -07:00
H. Peter Anvin
3ff46c587a assemble: trivially optimize emissions of REX+map prefixes
Emit rex+map prefixes as a single chunk of data.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 03:04:51 -07:00
H. Peter Anvin
29bc7c4811 ndisasm: REX2 *can* take REP or OSZ prefixes
Only VEX and EVEX may not take REP or OSZ prefixes.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 02:56:27 -07:00
H. Peter Anvin
52c5ee24cf ndisasm: fix legacy map handling, 8-bit GPRs
Fix the handling of legacy map prefixes (0F, 0F 38, 0F 3A).

Fix 8-bit GPRs decoding (REX vs no-REX versions.)

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 02:41:59 -07:00
Maciej Wieczor-Retman
fca408f86a travis: apx: Remove a TODO comment
The problems got fixed at 3.0rc0.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-05 11:10:38 +02:00
H. Peter Anvin
3a5cbc7a09 ndisasm: don't generate REX2 patterns for NOAPX instructions
The wrong flags field was examined for the NOAPX or NOREX flags.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 02:07:35 -07:00
Maciej Wieczor-Retman
e30047b2ff x86: travis: apx: Fix IMUL 0x6B not being able to use EVEX.ZU
64bit and 32bit variant of the IMUL 0x6B instruction can't make use of
the zero-upper bit. It gets assembled normally. With equal operand size
this makes sense since 64 and 32 bit legacy behavior was the same as the
APX ZU one. But the 0x6B IMUL variant uses 8 bit immediate values as the
second operand, hence it should be able to make use of ZU for 32 and 64
bit registers too.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-05 11:05:57 +02:00
H. Peter Anvin
62cc95297c insns.dat: fix encoding for JMPABS
JMPABS does not need .w1 and in fact is documented to NOT have or
require it.

Add jump-over emulation for the !APX case, similar to the jump-over
for long conditional branches in < 386.

Move JMP ABS patterns ahead of regular jumps; otherwise JMP ABS syntax
doesn't work.

Prefer JMPABS in the disassembler, since that is the documented form.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 02:00:39 -07:00
H. Peter Anvin
0da8e15640 insns.dat: fix JMPABS encoding
JMPABS is defined as REX2 + A1; there are no extra encoding bits.
MOVABS is only supported without REX2; since there are no register
numbers used for that instruction that is good enough.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 01:51:34 -07:00
H. Peter Anvin
78c98dac0f version: bump version number to 3.0rc0
It seems to make sense to call this upcoming release NASM 3.0.

Suggested by: Yongjie Sheng <sheng.yongjie@intel.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 01:12:27 -07:00
H. Peter Anvin
5158467d55 Add missing header file asm/asmutil.h
This file was missing from a previous checkin.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 01:08:25 -07:00
H. Peter Anvin
33262b072a Merge remote-tracking branch 'yongjie/apx.wip' into apx.wip 2025-09-05 01:02:52 -07:00
H. Peter Anvin
9a55314a23 travis: update tests for new or fixed errors/warnings
Some new warnings, some duplicate warnings removed.

The selfref test was broken because of mishandling of $ escaped
symbols; the new set of error messages are far more correct.

With all of this, travis now passes again.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 00:59:23 -07:00
H. Peter Anvin
c5faa4a452 assemble.c: don't warn about segment prefixes in 16/32-bit mode
The warning about ignored segment prefixes were incorrectly issued in
16/32-bit mode as well.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 00:49:49 -07:00
H. Peter Anvin
084714737a travis: confirm that crc32 test now produces the correct output
The crc32 test now does produce the correct output one would expect
for running with optimized assembly.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 00:45:32 -07:00
H. Peter Anvin
a2b1c752a4 insns.dat: add non-optimizing patterns for CRC32 byte
The CRC32 byte patterns are documented to be able to take a
(pointless) REX.W to "extend" the pattern to a 64-bit
destination... but that never changes the result.

However, be excrutiatingly correct and add those patterns when not
using optimization.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 00:41:18 -07:00
H. Peter Anvin
08969b4d38 insns.dat: fix the crc32 instructions
The crc32 instructions are kind of odd; the operand size really only
applies to the right (source) operand.

The APX forms are also kind of messy.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-05 00:19:14 -07:00
H. Peter Anvin
5ddccd6d04 travis: update apx.bin.t
Update the apx.bin.t file, since it now produces the same output as it
does with -DSRC and -DBIN.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-04 23:58:35 -07:00
H. Peter Anvin
cb20ce6f01 apx: handle RN_L16 on EAs, automatically generate EVEX forms
Memory references should have RN_L16 set if and only if they are
compatible with instruction patterns requiring register numbers below
16.

Add a "vex+" encoding pattern for VEX-encoded instructions that should
be promoted to EVEX when AVX-encoded.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-04 23:49:10 -07:00
H. Peter Anvin
e9d357ba19 Merge remote-tracking branch 'maciej/apx.wip.travis' into apx.wip 2025-09-04 20:12:16 -07:00
H. Peter Anvin
bb253780ab changes.src: update release log
Add updates to the release documentation.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-04 20:08:15 -07:00
H. Peter Anvin
6a270222be outobj: fix crash when no labels are defined in the default segment
If there are no labels in the default segment, then NASM would crash
if anything was emitted in it, as the label would be defined on the
final pass only.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-04 20:06:06 -07:00
H. Peter Anvin
31a160759d Add %ifdirective preprocessor directive
Along with C and other languages, the current trend is to be able to
probe for features rather than relying on version numbers. This is
motivated in part by the intent of bumping the major version number to
3.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-04 19:41:12 -07:00
H. Peter Anvin
ec48f1a3f8 preproc: unbreak %cond()
The previous patch accidentally broke the %cond() function.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-04 18:23:55 -07:00
H. Peter Anvin
d5bd136ced preproc: add message-generating and %null() functions
Add the %null(), %note(), %warning(), %error(), and %fatal()
functions. They behave like the corresponding directives, then expands
to nothing.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-04 17:10:42 -07:00
H. Peter Anvin
61b525fbc1 nasmlib.h: add convenience macros for iterating over fixed arrays
Iterating over fixed arrays is a common operation; add macros to
simplify the task.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-04 17:09:57 -07:00
Maciej Wieczor-Retman
5d1deaffc3 WIP apx: KMOV instructions
Add KMOV APX variants to the database. Add relevant tests.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 23:35:14 +02:00
Maciej Wieczor-Retman
312b89d71f x86: Fix wrong encondig of 32 bit KMOV variants
VEX.pp should be 0 for 32 bit variant of KMOV.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 23:35:14 +02:00
Maciej Wieczor-Retman
3387f868fd insns: travis: apx: INV instruction
Add INVPCI, INVEPT, INVVPID APX instruction variants to the database and
relevant tests.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 23:29:21 +02:00
Maciej Wieczor-Retman
cb453cba39 insns: travis: apx: INC instruction
Add INC test cases and the database entry.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 13:33:06 +02:00
Maciej Wieczor-Retman
6b137d5212 insns: travis: apx: IMUL instruction test cases and bug fix
Add the test cases for the IMUL instruction.

Fix the 0x6B database bug that used the same bit width of the immediate
operand as the other operands. Make it 8 bit wide, just like in the
legacy instruction.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 13:13:12 +02:00