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
Yongjie2017
6f3147b4ec add avx 10.2 instructions 2025-09-04 16:33:43 +08:00
Yongjie2017
e56130aeb5 add few missing avx10_1 instructions 2025-09-04 16:32:17 +08:00
Maciej Wieczor-Retman
1ebd820dfc insns: travis: apx: IDIV instruction
Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 08:40:28 +02:00
Maciej Wieczor-Retman
d79e4bb93a insns: travis: apx: ENQCMD[S] instructions
Add enqcmd and enqcmds to the database.

Add relevant tests.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 08:40:28 +02:00
Maciej Wieczor-Retman
13b4160ec8 insns: travis: apx: DIV instruction
Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 08:40:28 +02:00
Maciej Wieczor-Retman
e91a81d780 x86: preinsns: Fix missing vex.w bits
Looks like the wwflag variable was set for both ww and w1 which caused
some VEX.W bits to not get set. Don't set the wwflag for w0 or w1 cases
in the script.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 08:40:28 +02:00
Maciej Wieczor-Retman
74867b7750 insns: travis: apx: DEC instruction
Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 08:40:28 +02:00
Maciej Wieczor-Retman
ca1228e0dd insns: travis: apx: CRC32 APX, cleanup and tests
Clean up CRC32 with $dq macro and add the APX variants.

Also add tests for legacy and APX variants.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 08:40:28 +02:00
Maciej Wieczor-Retman
bfb82694b7 insns: travis: apx: CMPccXADD instruction
Add CMPccXADD variant to the database with some basic testcases.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 08:40:28 +02:00
Maciej Wieczor-Retman
429f54a391 insns: travis: apx: CMOVcc instruction
Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 08:40:28 +02:00
Maciej Wieczor-Retman
276b9d82b8 insns: travis: apx: Add APX extended bitmask instructions
Add APX variants of BLSI, BEXTR, BLSMSK, BLSR, BZHI.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 08:40:28 +02:00
Maciej Wieczor-Retman
75b5a4e1aa insns: travis: apx: ANDN instruction
Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 08:40:28 +02:00
Maciej Wieczor-Retman
980238ae27 travis: apx: Tests for already implemted A* APX instructions
The ADD, ADC, ADCX, ADOX, AND instruction testcases.

Part of ADCX tests is commented out because addressing with R16-R31 is
currently bugged without some other mechanism indicating using the APX.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 08:40:28 +02:00
Maciej Wieczor-Retman
dc172d3f82 insns: travis: apx: APX support fo atomic instructions
Add the AOR instruction and use $bwdq macros on the other new atomic
instructions: AADD, AAND and AXOR.

Add tests.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 08:40:28 +02:00
Maciej Wieczor-Retman
89dfdc164c travis: apx: Setup test cases for apx
This json allows assembling the first column in the testcase macro when
updating the apx.bin.t file, and assembling the second column when
running the test.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 08:40:28 +02:00
Maciej Wieczor-Retman
1b9c2f873d x86: Immediate operand longer than byte not possible
Due to ib in the apx arithmetic instruction preprocessed implementation
only byte size immediate operands were possible. Changing ib to i# fixes
the issue.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-04 08:40:28 +02:00
H. Peter Anvin
e0d5333a47 doc: add 2.17 release notes and document [dollarhex]
Add the beginnings (at least) of release notes for 2.17, and document
the [dollarhex] directive.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-03 12:31:03 -07:00
H. Peter Anvin
d1ab9e0ae7 test/dollar.asm: check a few more cases, including %assign
Check a few more corner cases, including $ and $$, as well as parsing
in the assembler (dd) and the preprocessor (%assign).

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-03 11:48:02 -07:00
H. Peter Anvin
e80bc631a2 preproc: identify $$ as TOKEN_BASE when tokenizing
$$ is TOKEN_BASE, not a symbol. If this is done incorrectly, ppscan
chokes on $$ as it ends up being an invalid symbol.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-03 11:33:08 -07:00
H. Peter Anvin
60594fde66 Fix generation of segment references with offsets
Segment references can come from two places: either an explicit SEG
operator or from a far expression. In the former case, the segment can
have a programmer-provided offset, but in the latter case, it
cannot.

The fix for bug 3392949 fixed the latter case, but broke the
former. This patch hopefully makes both work.

Rename out_segment() to out_farseg() and add a comment to explain the
logic behind the difference.

Reported-by: E. C. Masloch <pushbx@ulukai.org>
Fixes: https://bugzilla.nasm.us/show_bug.cgi?id=3392950
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-03 11:06:16 -07:00
H. Peter Anvin
7e8f1d571e preproc: fix generation of macro invocation debug data
It is possible for m->mstk.mmac to point back to itself. In that case,
don't terminate the macro debug invocation just yet.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-03 10:34:28 -07:00
H. Peter Anvin
ece92ba533 output/legacy.c: remove stale file
output/legacy.c is no longer used, remove it.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-03 10:33:59 -07:00
H. Peter Anvin
6c105cea3b Improve misc/omfdump, add misc/Makefile, use -std=c23 if possible
- Add improvements to omfdump from Bernd Böckmann.

- Add misc/Makefile with option to install omfdump and auxiliary NASM
  data files.

- Use compiler.h and friends in the misc directory.

- Use -std=c23 if the C compiler supports it.

Cc: Bernd Boeckmann <bernd-github@boeckmann.io>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2025-09-03 10:05:21 -07:00
H. Peter Anvin
78abbf26df asm/floats.c: micro-optimize set_bit()
Micro-optimize the set_bit() function. Using size_t (in particular,
using an unsigned type) produces better code.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-03 01:27:30 -07:00
H. Peter Anvin
38631c577a doc: there is no %fullpath() function, only %realpath()
Remove a reference to a non-existent %fullpath() function; the
function is called %realpath().

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-03 01:10:29 -07:00
H. Peter Anvin
a84925df12 $ numeric syntax: require a digit to follow
The documentation actually states that $ as a hex prefix is only valid
when followed by a digit, which at least makes the syntax conflict
less complicated. Actually match the documentation.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-03 01:05:41 -07:00
H. Peter Anvin
b3c99f9c19 doc: bump copyright year
It is 2025...

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-03 00:59:04 -07:00
H. Peter Anvin
7e46f6f7ab doc: fix a couple of syntax errors
Fix syntax errors that prevented the documentation from being
buildable.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-03 00:57:43 -07:00
H. Peter Anvin
ebfdbfc355 readnum: improve help text about deprecated $hex
State that the right thing to do is $hex -> 0xhex.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-03 00:53:16 -07:00
H. Peter Anvin
54efdde7b1 preproc: warn for leading $ when a number is consumed in preprocessor
To avoid repeated warnings, there is no warning issued for when
tokenizing a number starting with $ in the preprocessor, but issue a
warning if such a number is *consumed* (used in arithmetic) in the
preprocessor.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-03 00:46:23 -07:00
H. Peter Anvin
178a1b7443 Add directive to disable dollar-hex constants
The use of $ prefixes for hexadecimal numbers conflicts with
the use of $ to escape symbols.  Add a directive to disable
$ for hexadecimal numbers so that those escapes work OK.

As a result, allow escaped symbols to start with a digit.

Add a warning that this syntax is deprecated.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-03 00:35:41 -07:00
H. Peter Anvin
3ec5f486c6 disasm: fix VEX3 parsing, ignore immediate sizes
Immediate size annotations are irrelevant for disassembly matching.

VEX3 parsing corrected.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-02 22:22:35 -07:00
H. Peter Anvin
6698897d4f disasm: correct the offset of IP-relative displacement
IP-relative values, both jump addresses and RIP-relative memory
addressing, are relative to the end of the instruction.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-02 22:05:53 -07:00
H. Peter Anvin
b6d3474a00 disasm: strip sizes from unsized registers; fix VEX map parsing
- Correct the parsing of VEX map numbers
- Strip the size bits from register names that don't have
  intrinsic size

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-02 22:01:33 -07:00
H. Peter Anvin
f2b6dd6f66 More KMOV pattern fixes
Work even more on KMOV size encodings.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2025-09-02 21:09:20 -07:00
H. Peter Anvin
5a9a15ad18 insns.dat: fix KMOV patterns with GPRs
KMOV with GPR size encodings are "special"; the encoding matches neither
the K register size encodings nor the APX ones.  In the end it seems
that the most straightforward is simply to hand-code the B and W
patterns.

The disassembler still breaks horribly on these patterns....

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-02 20:32:33 -07:00
H. Peter Anvin
0852ca5694 disasm: handle NOP disassembly, remove debug message
NOP disassembly is a little "special" because it sits as part of the
XCHG instructions. Add a flag to bail out of the disassembler search
early, and ignore the 0330 bytecode.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-02 20:01:36 -07:00
H. Peter Anvin
6f42a3aaf6 (Hopefully) fix kmov and kunpck instructions, disallow "test" for "ktest"
Fix the handling of instruction patterns for KMOV and KUNPCK.
Don't allow K-less versions of KTEST and KORTEST because of
fundmentally different semantics.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-02 18:54:27 -07:00
H. Peter Anvin
c6bb32e9d1 preinsns.pl: don't allow KTEST to be just TEST
The semantics for KTEST are so very different from TEST that it would
be a bad idea to allow the TEST spelling.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-02 18:18:07 -07:00
H. Peter Anvin
9c3d6ff000 stdscan: handle $-escaped symbols starting with $
For a symbol to start with $, it needs to be escaped with a second
dollar sign: $$. This was not handled correctly, instead $$ was seen
as TOKEN_BASE.

Fix this.

Reported-by: E. C. Masloch <pushbx@ulukai.org>
Fixes: https://bugzilla.nasm.us/show_bug.cgi?id=3392922
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-02 17:55:22 -07:00
H. Peter Anvin
5201aab90f Update the canned Mkfiles for librarized ndisasm
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-02 17:11:45 -07:00
H. Peter Anvin
4b1d54e1d9 disasm: add option for wide output
An x86 instruction can be up to 15 bytes long + WAIT
pseudo-prefix. Add an option to make the hex dump wide enough to
accommodate all 16 possible bytes.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-02 16:44:38 -07:00
H. Peter Anvin
80225b4722 Add support for the {pt} and {pn} branch hint prefixes
Add support for the {pt} and {pn} branch hint prefixes, now when they
are no longer orphanned...

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-02 16:29:46 -07:00
H. Peter Anvin
56567a0c4c disasm: fix the disassembler for many APX cases
With these changes, the disassembler correctly decodes the ccmp.asm
and apx.asm tests.

Fix rebuilding the main tools from test/Makefile.in.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-02 15:40:32 -07:00
H. Peter Anvin
acd01496d7 asm: distinguish between VEX.V as an immediate and a prefix; fix WW
If VEX.V is an immediate, it should not be subject to register range
checks.

If the WW flag is set, REX_W needs to be OR'd in, not XOR'd, because
the map might have the W bit set for matching purposes.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-02 15:38:49 -07:00
H. Peter Anvin
6068546dbb test/Makefile.in: add explicit nasm and ndisasm targets
With ndisasm now built separately, make it easier to explicitly make
nasm and ndisasm from the test directory.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-02 10:47:36 -07:00
H. Peter Anvin
e05867ce3d ndisasm: make the assembler (hopefully) work again
- Significantly overhauled the disassembler internals to make
  better use of the information already in the instruction template
  and to reduce the implementation differences with the assembler
- Add APX support to the disassembler
- Fix problem with disassembler truncating addresses of jumps
- Fix generation of invalid EAs in 16-bit mode
- Fix array overrun for types in a few modules
- Fix invalid ND flag on near JMP

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-08-30 16:16:43 -07:00
H. Peter Anvin
3efdd3cf9a assemble: rex2.w; hinted Jcc in 64-bit mode; UDB
- rex2.w is used as a opcode extension (JMPABS), not rex2.x1 as an
  earlier version of the spec had.
- Segment prefixes used as Jcc hints are valid in 64-bit mode.
- Avoid duplicate warning messages for ignored/invalid prefixes.
  * emit_prefixes() is called twice during code generation.
- Add the UDB #UD opcode in 64-bit mode; SALC is 16/32-bit only.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-08-29 13:55:30 -07:00
H. Peter Anvin
050c275c39 Makefile: factor out the disassembler
Factor the objects ONLY needed for the disassembler into a
separate library. This allows building the assembler even while
the disassembler is not yet buildable; this makes working on
the disassembler easier.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-08-29 13:26:44 -07:00
H. Peter Anvin
9f86275c74 Merge remote-tracking branch 'origin/master' into apx.wip
Resolved Conflicts:
	disasm/disasm.c

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-08-29 01:51:27 -07:00