0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-10-10 00:25:06 -04:00
Commit Graph

5488 Commits

Author SHA1 Message Date
Iouri Kharon
89439aa58d Remove unneeded (illegal) evex-encoding of VCVTPS2PH
According to the June edition of SDM evex-form of the VCVTPS2PH command only exists with mmmmm equal to 0f38, and map5 only exists for the VCVTPS2PHX command
2025-10-07 10:16:36 -07:00
H. Peter Anvin (Intel)
41d35bb483 Merge multiple fixes from "InstLatx64" 2025-10-07 10:13:12 -07:00
H. Peter Anvin
e72a54174c insns.dat: correct the [LD][GI]DT patterns
It is somewhat counterintuitive, but the correct flag for the memory
operand is "OSIZE". The "nw" flag takes care of promoting the default
operand size on 64 bits to 64.

Fixes: https://github.com/netwide-assembler/nasm/issues/130
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 09:58:54 -07:00
H. Peter Anvin
f047ceeae3 test/Makefile: add .bin{16,32,64} targets
Quick and easy way to run the same test for 16-, 32- and 64-bit output
without mixing them together in one binary output file.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 09:57:19 -07:00
H. Peter Anvin
fa43d8e01d asm: new --bits option to set the processor mode on the command line
This is really just a shorthand for the --before option, but it is
really convenient for quickly writing multimode tests.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 09:56:20 -07:00
H. Peter Anvin
2c63ab038c asm/preproc.c: generalize pp_pre_command()
Generalize pp_pre_command() so that the first argument doesn't have to
be a preprocessor token. Instead, the two arguments are now both
turned into token streams, separated by a whitespace token.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 09:53:15 -07:00
H. Peter Anvin
f1b6d3188c preproc: add a %selbits() function
Although one can implement this "manually" in terms of %sel(), this
function is *really* useful for making multi-mode tests and allows for
better error checking.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 09:17:59 -07:00
H. Peter Anvin
e4044cfc48 assemble.c: avoid a panic after invalid instruction error
If an instruction triggers an error (nasm_nonfatal) it is legitimate
for calcsize() to return 0; in that case no further processing is
needed.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 09:16:06 -07:00
H. Peter Anvin
6df250aee3 parser: add the actual name of a label to the label-orphan warning
The label-orphan warning is *way* more useful if it includes the
actual label name; this way the programmer can usually spot
immediately if it is a label or misspelled instruction.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 08:30:02 -07:00
Yongjie Sheng
d66187c1de reconstruct ffmpegtest to be generic to support more different projects 2025-10-07 08:11:33 -07:00
InstLatx64
2a2acca7c0 AVX512_VP2INTERSECT test files
AVX512_VP2INTERSECT 32b/64b test files
Checked with XED version: [v2025.06.08]
2025-10-07 12:07:55 +02:00
InstLatx64
f4b1a206e0 Remove duplicates
Remove duplicates:
- V{MAX,MIN}{P,S}H
- VEXTRACT{F,I}{32x4,64x2}
- VF{,C}MULCPH
- VF{,N}M{ADD,SUB}{132,213,231}SH
Removed AVX10_1 label from VADDPH/VCMPPH due to consistency
2025-10-07 11:35:15 +02:00
InstLatx64
fb43244978 KUNPCK* fix
KUNPCK* fix, it compiles k_test.asm without errors
2025-10-07 11:07:33 +02:00
InstLatx64
172c4b2342 Missing AVX-VNNI_INT{,8,16} instructions
-- AVX-VNNI_INT{,8,16} instructions: VPDP{B,W}{SS,SU,US,UU}{D,DS}
- AVX-VNNI_INT{,8,16}  test files
Checked with XED version: [v2025.06.08]
2025-10-07 09:52:13 +02:00
Yongjie Sheng
9cb23294a4 fix a displacement offset calculation error for movddup 2025-10-07 14:35:45 +08:00
Alexey Vishnyakov
891c63e64f output: fix null pointer dereferences in output/outaout.c
The bugs were found by Svace static analysis tool:

1. sym can be null in when exact is false, and sym is later dereferenced
   by sym->symnum
2. asym can be null, no return from function is performed, and asym is
   dereferenced by asym->symnum
2025-10-06 14:58:40 -07:00
Ivan Sorokin
bd7185bad1 fix undefined behavior in count_mmac_params
When compiled -fsanitize=undefined nasm produced this error message:

asm/preproc.c:2523:25: runtime error: member access within null pointer of type 'struct Token'

The problem is reproducible on tests avx512f, avx512cd, avx512pf
and avx512er in the test suite.

The problematic line was:

    /* Advance to the next comma */
    maybe_comma = &t->next;                            <<< HERE
    while (tok_isnt(t, ',')) {
        if (!tok_white(t))
            comma = NULL; /* Non-empty parameter */
        maybe_comma = &t->next;
        t = t->next;
    }

When t is NULL this line doesn't cause memory access, but it is still an
undefined behavior according to C standard.

I believe that the underlying problem is that this loop doesn't have a sound
invariant about maybe_comma:

* On first iteration: *maybe_comma == t->next
* On the following iterations: *maybe_comma == t

I don't know what the intended loop invariant is and I decided to just
mechanically fix the deferencing of NULL pointer, completely preserving
the existing behavior.

Signed-off-by: Ivan Sorokin <vanyacpp@gmail.com>
2025-10-06 14:56:45 -07:00
Ivan Sorokin
ad297258c1 fix memory leak in eval_strfunc
When running with -fsanitize=leak enabled nasm prints this error:

==19965==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 360 byte(s) in 90 object(s) allocated from:
    #0 0x7faee9396867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x5645d39a401c in nasm_malloc nasmlib/alloc.c:55
    #2 0x5645d3a41f9d in string_transform asm/strfunc.c:356
    #3 0x5645d3a37d40 in eval_strfunc asm/eval.c:761
    #4 0x5645d3a37d40 in expr6 asm/eval.c:906
    #5 0x5645d3a3968d in expr5 asm/eval.c:627
    #6 0x5645d3a39aca in expr4 asm/eval.c:602
    #7 0x5645d3a39b72 in expr3 asm/eval.c:563
    #8 0x5645d3a39db8 in expr2 asm/eval.c:537
    #9 0x5645d3a39f38 in expr1 asm/eval.c:511
    #10 0x5645d3a3a0b8 in expr0 asm/eval.c:485
    #11 0x5645d3a3a242 in rexp3 asm/eval.c:422
    #12 0x5645d3a3a508 in rexp2 asm/eval.c:396
    #13 0x5645d3a3a6a8 in rexp1 asm/eval.c:369
    #14 0x5645d3a3a838 in rexp0 asm/eval.c:342
    #15 0x5645d3a3a838 in cexpr asm/eval.c:305
    #16 0x5645d3a3ad08 in bexpr asm/eval.c:298
    #17 0x5645d3a3ad08 in evaluate asm/eval.c:1032
    #18 0x5645d39e4f20 in parse_line asm/parser.c:959
    #19 0x5645d399e243 in assemble_file asm/nasm.c:1735
    #20 0x5645d3998801 in main asm/nasm.c:719
    #21 0x7faee8aaed8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #22 0x7faee8aaee3f in __libc_start_main_impl ../csu/libc-start.c:392
    #23 0x5645d399acd4 in _start (/home/ivan/d/nasm/nasm+0x2e5cd4)

SUMMARY: AddressSanitizer: 360 byte(s) leaked in 90 allocation(s).

This problem is reproducible on test utf.asm.

The problem was caused by the fact that eval_strfunc doesn't free the string
allocated by string_transform.

Signed-off-by: Ivan Sorokin <vanyacpp@gmail.com>
2025-10-06 14:50:40 -07:00
Elyes Haouas
fc720e7040 Remove useless parentheses in return statements
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 14:28:54 -07:00
H. Peter Anvin
f6a17a29c0 nasmlib.h: protect list_last() macro against misuse
The list_last() macro is a statement macro; wrap it in a
do { ... } while(0) block to prevent accidental misuse.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 14:27:30 -07:00
Elyes Haouas
f744ec431f Remove trailing semicolon in macros
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
[ hpa: only one of the defined issues was valid, removed the rest. ]
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2025-10-06 14:26:42 -07:00
Elyes Haouas
d9494d5240 output/outmacho.c: Add missing space at break quoted strings
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
2025-10-06 14:22:59 -07:00
Elyes Haouas
346a1b3344 SubmittingPatches: Update git link
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
2025-10-06 14:22:50 -07:00
H. Peter Anvin
81dd083291 outelf.c: remove stray semicolon
Harmless, but undesirable.

Fixes: https://github.com/netwide-assembler/nasm/pull/57
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 14:19:15 -07:00
H. Peter Anvin
0c3a964caf doc: remove stray "are"
"are generate" -> "generate"

Fixes: https://github.com/netwide-assembler/nasm/pull/87
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 14:14:09 -07:00
H. Peter Anvin
5b9099c058 asm/parser: print the actual token in an error, not its value
Printing an internal token value is not very user-friendly :) Print
the contents of the actual token in question.

Fixes: https://github.com/netwide-assembler/nasm/pull/90
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 14:07:33 -07:00
Yongjie Sheng
8d4710d014 ffmpegtest: fix variable rev change in a subshell does not impact parent
Error status would get lost.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 13:58:27 -07:00
KO Myung-Hun
57bf1b7b06 doc: document that the obj output format GROUP directive is cumulative
The GROUP directive can now be specified more than once for a group,
and the result is cumulative (the union of all specified groups.)

Signed-off-by: KO Myung-Hun <komh78@gmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 13:26:35 -07:00
KO Myung-Hun
c7e17f5dde outobj: make a group cumulative
On any other OMF assemblers such as MASM, TASM and ALP, a group is
cumulative.

Signed-off-by: KO Myung-Hun <komh78@gmail.com>
2025-10-06 13:24:09 -07:00
H. Peter Anvin
755593b128 NASM 3.01rc3 nasm-3.01rc3 2025-10-06 13:11:59 -07:00
H. Peter Anvin
0bc42dd1e0 changes.src: document TEST reg,mem fix
Add TEST reg,mem to release notes.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 13:11:09 -07:00
H. Peter Anvin
b3358fe63e insns.dat: reinstate TEST reg,mem alias
Officially the syntax for TEST is "rm,reg"; however TEST is
commutative in every aspect, and as such "reg,mem" is an equivalent
form that NASM has also supported in the past.

Reinstate it properly.

Fixes: https://bugzilla.nasm.us/show_bug.cgi?id=3392962
Reported-by: E. C. Masloch <pushbx@ulukai.org>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 13:07:09 -07:00
H. Peter Anvin
2bb275d651 NASM 3.01rc2 nasm-3.01rc2 2025-10-06 12:10:18 -07:00
H. Peter Anvin
11c512850e warnings.pl: tidy up the formatting of the warning output
Clean up the formatting of the generated warning files.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 12:07:23 -07:00
H. Peter Anvin
d5705c96bb changes.src: use \c{...} formatting for instructions
Instructions are literals, mark them with \c{...}.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 11:57:37 -07:00
Maciej Wieczor-Retman
cb03c02553 doc: Summarize PR changes
Merge PRs 127, 126, 125, 124 and 91. Document some of the most relevant
changes.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-10-06 19:29:38 +02:00
InstLatx64
2488b6cfb3 AVX512_FP16 mnemonic fix
-- VGETMAXPH -> VMAXPH
-- VGETMINPH -> VMINPH
-- VFCMULCPCH -> VFCMULCPH
-- VFMULCPCH -> VFMULCPH
-- VPMADD{132,213,231}SH -> VFMADD{132,213,231}SH
-- VPMSUB{132,213,231}SH -> VFMSUB{132,213,231}SH
2025-10-06 19:29:33 +02:00
InstLatx64
70ed10d2e2 AVX512BF16 fix
AVX512BF16 fix:
-- VCVTNEPS2BF16 operand count
-- VDPBF16PS operand size
AVX512BF16 test files
Checked with XED version: [v2025.06.08]
2025-10-06 19:17:51 +02:00
Maciej Wieczor-Retman
0fb33913d6 x86: tools: Remove unused perl code variables
Merged version of a PR by mknos:
https://github.com/netwide-assembler/nasm/pull/91

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-10-06 19:17:51 +02:00
InstLatx64
62f5f6990f AMX-COMPLEX support
-- TCMMIMFP16PS, TCMMRLFP16PS instructions
-- AMX.asm fix: Similar to GATHER instructions, 3-operand AMX instructions cannot have the same operand more than once
Checked with XED version: [v2025.06.08]
2025-10-06 19:17:43 +02:00
Iouri Kharon
8f47ba7cc7 fix TCVTROWPS2PHL (typo?):
see Intel® Architecture Instruction Set Extensions and Future Features Programming Reference, March 2025 319433-057
else (without this correction) it conflict with VPERMI2PS
2025-10-06 18:56:51 +02:00
H. Peter Anvin
f7702bed4d NASM 3.01rc1 nasm-3.01rc1 2025-10-06 09:47:56 -07:00
H. Peter Anvin
13379eb48a changes.src: document %exitrep/%exitmacro %if fix
Add the fix for %exitrep/%exitmacro to the release notes.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 09:43:26 -07:00
H. Peter Anvin
d9958f428a test/exitrep: test for proper %if and %rep evaluation suppression
If a line is suppressed, the %if or %rep condition must never be
evaluated. Test for it, and add the exitrep test to travis.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 09:38:55 -07:00
H. Peter Anvin
2255ebb549 preproc: don't evaluate an %if condition if suppressed
When a line is suppressed there is no guarantee that it is
syntactically valid, so treat it exactly like a dead %if branch.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 09:20:30 -07:00
H. Peter Anvin
6b1636ab0e changes.src: drop 3.00.01; plan 3.01 as a bug fix release
Looks like there are enough critical changes to justify a release
without a bunch of new development. Let's just call the new
release 3.01 and avoid a bunch of excess dottage.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 08:33:16 -07:00
H. Peter Anvin
3bb875f3e5 Merge remote-tracking branch 'origin/nasm-3.00.xx' 2025-10-04 18:31:52 -07:00
H. Peter Anvin
312ea7d2d3 nasmdoc.css: make columns wider, smaller text in Appendix F
The column width really wasn't quite enough.

Make the text size in Appendix F which can be rather wide
smaller. There is also no real reason to put that in a background box.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-04 16:25:21 -07:00
H. Peter Anvin
1ec9d7dc22 changes.src: add obj2 output format to the release notes
Need to be added to the release notes...

Cc: KO Myung-Hun <komh78@gmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-04 15:59:13 -07:00
KO Myung-Hun
38fd561a0b outfmt.src: Add explanation for obj2 output format
Signed-off-by: KO Myung-Hun <komh78@gmail.com>
2025-10-04 15:57:30 -07:00