Commit graph

263 commits

Author SHA1 Message Date
H. Peter Anvin (Intel)
8317d7ae2f Mkfiles/msvc.mak: make the docs: target actually work under real nmake
The docs: target fed doc/Makefile.in directly to nmake, but that file
relies on several GNU make-only constructs nmake cannot parse at all:
the $^ automatic variable (not valid nmake macro syntax -- fatal
parse error), $< used outside of an inference rule (silently
unsupported, since nmake only defines $< within .SUFFIXES-style
rules), and the GNU-only "-include *.dep" optional wildcard include
directive (nmake only understands the unrelated "!include"
directive). Add tools/mkmsvcdocmak.pl, which rewrites just those
constructs to their explicit nmake-safe equivalents in a generated
copy (doc/Makefile.msvc), leaving doc/Makefile.in itself untouched for
the Unix/GNU make build. Verified by rewriting doc/Makefile.in this
way and building nasmdoc.pdf through it with GNU make standing in for
nmake.

Also, doc/Makefile.in expects doc/warnings.src, doc/perlbreq.src and
doc/pptok.src to have already been generated -- the Unix "doc" target
does this via the top-level Makefile.in before recursing into doc/,
but msvc.mak's docs: target had no equivalent step. warnings.src and
pptok.src already had msvc.mak rules (just not wired up as
prerequisites of docs:); perlbreq.src had no rule at all, since the
top-level Makefile.in generates it with a POSIX find/sed pipeline that
doesn't translate to Windows. Add tools/genperlbreq.pl, a portable
pure-Perl equivalent (using File::Find), and a doc\perlbreq.src rule
in msvc.mak that uses it; verified it produces output byte-identical
to the existing POSIX pipeline.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-07 15:26:53 -07:00
H. Peter Anvin (Intel)
5d727e1253 Mkfiles/msvc.mak: document docs rule's tool requirements
Note that building the documentation via the "docs" nmake target
requires Ghostscript and the Roboto/Roboto Mono fonts, per
doc/source.src. This target previously also had to work around
doc/Makefile.in containing a bare, unexpanded "@SET_MAKE@" line
(fixed in the preceding commit), which made it a hard nmake parse
error; that workaround is no longer needed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-07 15:26:53 -07:00
H. Peter Anvin (Intel)
c0b64a692b Mkfiles/: sync with Makefile.in
Sync the standalone Makefiles with Makefile.in (adding
x86/insns-cc.ph.)

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2026-07-06 13:54:38 -07:00
H. Peter Anvin (Intel)
720a32672c Refactor the handling of primary input/output files
Replace the direct setting of variables for input and output variables
with accessors. This allows for properly tracking the lifetimes of the
data and allows for things like checking of the overwrite of the
primary input file to be centralized.

It isn't possible *in the general case* to check for overwrite of
*any* of the input files, although in the particularly important case
of the assembler proper it ought to be possible to do a bit better:

it should be able to guard for overwrites of non-primary input files
except for the error file or the list file if and only if -Lp is used.

That is, however, a latter project.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2026-06-29 18:22:26 -07:00
H. Peter Anvin (Intel)
08a369628e Rename emacstok.pl back to nasmtok.pl
This script can output more than just Emacs format these days; it is
already used to produce both Emacs and JSON output, and it seems
unlikely that we would want to create another script to output any
additional file formats.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2026-06-21 14:34:09 -07:00
Jiri Malak
8d1f35b78f open-watcom: fix Open Watcom build make file
Resolves Conflicts:
	Mkfiles/openwcom.mak
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2026-06-11 14:05:52 -07:00
H. Peter Anvin (Intel)
f216d5b65d editors: rename nasmtok.pl to emacstok.pl
Rename this script to reflect its function within the NASM tree. The
output file is still called nasmtok.el, however, as it reflects its
function within an Emacs environment.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2026-06-07 20:04:50 -07:00
H. Peter Anvin (Intel)
f7a4d8fd1b openwcom.mak: add zlib to the VPATH
It isn't clear if this is actually mandatory, but it is consistent
with the rest of the directories.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2026-02-26 15:44:17 -08:00
H. Peter Anvin (Intel)
ff7a315acb nasmlib: move filename_set_extension() into path.c
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>
2025-12-15 09:58:42 -08:00
H. Peter Anvin (Intel)
795daf3d2d nasmlib: split file.c into file.c and fileio.c; remove file.h
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>
2025-12-14 17:47:47 -08:00
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)
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
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
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
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
H. Peter Anvin (Intel)
ae9335a0b9 labels: make the prefix/suffix options and pragmas consistent
Make the spellings for the label-mangling options and pragmas
consistent, and implement the directive forms which were documented
but never implemented.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 18:46:39 -07:00
H. Peter Anvin
cd5dfb8c5f warnings: always regenerate outputs; tidy up unnecessary rules
With warnings disaggregated, there is no reason to play games with not
updating the output timestamp. Always write the files as usual.

Remove unnecessary Makefile rules.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
1# Please enter the commit message for your changes. Lines starting
2025-10-04 14:04:31 -07:00
H. Peter Anvin
d45ad2e7ed openwcom.mak: use %null instead of @rem for $(SIDE)
%null appears to be the recommended way to do $(SIDE) on WMAKE.

Suggested-by: KO Mying-Hun <komh78@gmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-03 10:23:11 -07:00
Yongjie2017
f0037ab726
additional note for running nmake building 2025-10-03 08:59:41 +08:00
H. Peter Anvin
7415a1e5f8 Build: update various build installation directories
Modernize and improve the handling of build directories.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-02 16:08:04 -07:00
H. Peter Anvin
959644a017 msvc.mak: make sure perl is only run if it exists
Only try to run a Perl interpreter if the system actually has one
available. Because timestamps on Windows are apparently not preserved
on archive extraction, otherwise it might happen that nmake will try
to rebuild files even through they already exist.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-01 19:36:22 -07:00
H. Peter Anvin
dfacf9a3d7 Makefiles: remove warnings generation from auxiliary Makefiles
The .time trick doesn't seem to work in general, and auxiliary
Makefiles aren't guaranteed to build modified sources anyway.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-01 13:55:33 -07:00
H. Peter Anvin
205512f3c0 Makefile: a few more portability improvements
Define macros for generating an empty file and for a dummy (side
effect) target.

Tweak MSVC compiler options.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-01 13:55:07 -07:00
H. Peter Anvin
a54a902f4e Makefile: unbreak msvc.mak
With these changes msvc.mak works on Visual Studio 2022.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-01 13:54:04 -07:00
H. Peter Anvin
4acc3dbccc Fix more license headers 2025-10-01 12:05:34 -07:00
H. Peter Anvin
ca0ceeb546 doc: switch from Adobe Source to Google Roboto
The NASM webpage is already using Roboto, and looks more legible in
the end.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-29 18:52:01 -07:00
H. Peter Anvin
945d4327b5 build: even more fixes for building in a separate directory
Move the directories dependency to a variable to break secondary make
versions.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-25 13:28:08 -07:00
H. Peter Anvin
1f095bea4a Makefile.in: fix rules for separate-directory build
1. POSIX does not allow $< in a non-pattern rule.
2. insns.xda is a build-time generated file.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-25 12:18:02 -07:00
H. Peter Anvin
ac1a64c4d2 Makefile: move syncfiles into a separate target
It isn't actually required to have $(PERLREQ) to run syncfiles,
so factor it out into a separate target.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-25 09:26:01 -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
83534f1f37 Merge remote-tracking branch 'origin/master' into apx.wip
Resolved Conflicts:
	Makefile.in
	Mkfiles/msvc.mak
	Mkfiles/openwcom.mak
	asm/assemble.c
	asm/nasm.c
	asm/parser.c
	doc/Makefile.in
	include/nasm.h
	include/tables.h
	output/legacy.c
	travis/test/br3392531.stderr
	travis/test/br3392716.stderr
	travis/test/org.stderr
	x86/insns.dat

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-08-25 21:09:15 -07:00
H. Peter Anvin
df4555d68b preproc: compress standard macros with zlib
The very simple compression scheme used for the builtin macro sets no
longer works adequately, and in fact it generates incorrect output
now.

Drop the whole idea of an ad hoc compression scheme and just use
zlib. For the case where there is no system zlib available, include a
(subset of) the zlib distribution. The configure script can be set to
force this included zlib if desired (e.g. for testing.)

Unfortunately this turned out to be a pretty painful can of worms in
terms of complexity. On the other hand having zlib available might be
useful at some point in the future.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-08-15 16:51:39 -07:00
H. Peter Anvin
2726aefb06 output: remove the legacy output entry point
Remove the legacy output entry point. It has proven impossible to find
the time to completely port the backends all at once.

Instead, always generate the legacy output data, but put them into the
out_data structure. Then add a macro to explode these arguments into
separate variables, equivalent to the old function arguments. This
also centralizes the type definitions for these variables.

Most importantly, it means that the entire struct out_data is now
always available, which means that backends that need the additional
information available in that structure, such as the specific
instruction template, can access that information without needing to
revamp the entire backend code all at once.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-08-13 13:51:25 -07:00
H. Peter Anvin
1286a2da4e Tidy up handling of modr/m and compressed immediates
Merge a bunch of common code in the handling of modr/m
generation. Make the handing of compressed disp8 simpler and more
transparent by exporting a the shift factor for the compressed
immediate in ea_data. For the case of no compression, the shift factor
is simply 0; there is no need to distinguish "compressed" from
"uncompressed".

The tidied up version of the disp8 code is simple enough that it makes
more sense to inline it.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2024-08-03 16:24:49 -07:00
H. Peter Anvin
e699956758 Mkfiles/README: recommend MSYS2 on Windows
Even Microsoft seems to recommend MSYS2 for autoconf compatibility
now.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2024-04-17 09:41:47 -07:00
H. Peter Anvin
99fec7e7d0 Makefile: more cleanup/dist fixes
Even more fixes to the various clean and dist targets, sigh.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2024-04-12 14:35:56 -07:00
H. Peter Anvin
caaf81c22e deps: don't break if run in a build directory; don't delete unconfig.h
Don't break Makefile.dep generation if run from a separate build
directory.

config/unconfig.h is a bit special; it is kept in the repository for
the benefit of non-configure users. Therefore, don't have "make
spotless" delete it.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2024-04-12 13:17:40 -07:00
H. Peter Anvin
66276870f2 Makefiles: defined $(WARNSRCS), but need to actually use it...
The $(WARNSRCS) definition doesn't help much unless it is actually
used somewhere...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2024-01-29 19:07:54 -08:00
H. Peter Anvin
4bf01032e5 Makefiles: try to fix compiling with MSVC/nmake
Try to address Makefile portability bugs affecting MSVC/nmake.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2024-01-29 19:00:15 -08:00
H. Peter Anvin
1e965e30ff windows host: add embedded manifest file
Without a manifest, Windows applications force a fixed PATH_MAX limit
to any pathname; this is unnecessary.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2024-01-29 17:19:32 -08:00
H. Peter Anvin
7e80d6b834 Make: handle warning files while building in a directory
The dependency on the warning files breaks when we are building in a
directory *and* the files already exist from being shipped with the
distribution tarballs. The make VPATH simply isn't sophisticated
enough to deal with it, so let the C compiler handle it by #including
the generated file from a dummy C file.

Reported-by: Rudi Heitbaum <rudi@heitbaum.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2023-01-17 13:05:55 -08:00
H. Peter Anvin
2d5cf17130 misc/emacstbl.pl: add NASM version to output, add to Makefile
Include the version number in the output (misc/nasmtok.el) and add a
rule for generating it to the Makefiles.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-17 12:52:52 -08:00
H. Peter Anvin
a2eabbe1d7 insns: drop special handling of conditional instructions
Instead of handling conditional instructions ad hoc, generate
individual instruction patterns as normal. This simplifies the code
and makes CMPccXADD support simpler (otherwise it would be necessary
to hack in the handling of a condition code in the middle of an
instruction.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-12 12:37:37 -08:00
H. Peter Anvin
93548c2de2 rdoff: kill it off
RDOFF has been deprecated as it has unfixable problems, and has been
announced that it will be killed off in NASM 2.16.

This deletes it once and for all.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-07 16:49:13 -08:00
Igor Glucksmann
ed2c609976 output/coff: Support for COMDAT sections
Signed-off-by: "Glücksmann, Igor" <igor.glucksmann@avast.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2021-12-17 23:45:25 +03:00
H. Peter Anvin (Intel)
ed63993519 Merge remote-tracking branch 'github/nasm-2.15.xx'
No conflicts.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-09-11 18:27:06 -07:00
H. Peter Anvin (Intel)
d85890aac7 Makefile.in: fix warning dependencies
Fix circular dependency on asm/warnings.c by factoring out
warnings.$(O) from the dependencies, and use a separate <file>.time
which "generate" the main source file as a "side effect", giving us a
null target.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-09-11 18:11:51 -07:00
H. Peter Anvin (Intel)
cc843efa38 Merge tag 'nasm-2.15.04'
NASM 2.15.04

Conflicts:
	asm/listing.h
	asm/pptok.pl
	asm/preproc.c
	version

This doesn't pass travis test 3392711, which is using an extremely odd
construct of %?? in the middle of an argument sequence for an smacro
while not being in a macro itself, and expecting it to expand to the
macro name. This seems to *really* confuse the master branch.

Resolve this later...
2020-08-25 16:16:09 -07:00
H. Peter Anvin
f3a3f9925c Auto-make the warning files
The warning files are generated by a script, but the scripts is fast
enough run every time a C file is updated. To prevent having to
rebuild every file, however, make the generation script only actually
modify the file if it has changed.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-08-18 15:07:51 -07:00
H. Peter Anvin (Intel)
32322a9a93 preproc: get rid of the prepreprocessor and the nop preprocessor
Fold the prepreprocessor and the nop preprocessor into the main
preprocessor. This means handling # cpp-like lines and TASM
compatibility tokens in the preprocessor proper, but that is really
not very hard to do.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 23:34:52 -07:00