Commit graph

122 commits

Author SHA1 Message Date
H. Peter Anvin
e5a352516c BR 2672117: handle long lines for db/dw/etc.
Handle long arrays on a single line in db/dw/etc.
2009-03-07 21:54:31 -08:00
H. Peter Anvin
3213a57740 nasm.c: another readability cleanup
Yet another change for readability
2009-02-26 14:36:19 -08:00
H. Peter Anvin
7219198d72 nasm.c: readability cleanup for seg:off parsing
The code to pick apart seg:off in nasm.c was virtually unreadable due
to mechanized line breaking.
2009-02-26 14:34:48 -08:00
H. Peter Anvin
2186415f01 BR 2593349: Move version message back to stdout
Checkin 4b9358928b changed the version
message from stdout to stderr, but:

a) doesn't motivate the change in the commit log;
b) bundles that with other changes;
c) is inconsistent with other programs;
d) was done by me and I can't remember any reason for it.

Hence conclude it was unintentional and therefore a bug.  Since this
commit was done after 2.05.01 no stable release has been affected.
2009-02-13 09:36:47 -08:00
H. Peter Anvin
f1e46600d2 Fix the [warning] directive
Fix multiple bugs in the [warning] directive:

- Only parsed on pass 1
- "-" was interpreted as "+"
2009-01-05 09:08:06 -08:00
Victor van den Elzen
f568613c2a Fix BR #916647
nasm.c should respect the default debug format of the output format,
instead of replacing it with the first format in the list.
This is cleaner and allows the list to be sorted normally.

This commit rewrites commit 116994111b which was very fragile.
2008-11-05 14:19:15 +01:00
Charles Crayne
e2dea103db Prevent erroneous extra "final" pass
Specifically check for end of final pass.
2008-11-03 18:21:24 -08:00
H. Peter Anvin
4b9358928b Move all version strings to a single compilation unit (ver.c)
Move all the version strings to a single compilation unit, ver.c; this
does not include the version macros, which are fed into macros.c.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-31 16:53:49 -07:00
H. Peter Anvin
9a65f71d64 Better description of the number-overflow warning
Better grammar and fix incorrect description of the number-overflow
warning (it is not just limited to 64-bit arithmetic overflow, it also
triggers when trying to squeeze in a value which is too large into an
immediate.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-26 08:59:04 -07:00
H. Peter Anvin
6f4e92b760 BR: 2196966: make the -w/-W options work again
The code to parse the -w/-W options was updating warning_on[], not
warning_on_global[], but warning_on[] is reset at the beginning of
each pass (to let the warning directive work); as a result the -w/-W
options don't actually do anything at all.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-26 08:57:13 -07:00
H. Peter Anvin
e9d7f1a074 Better warnings for out-of-range values
Issue better warnings for out-of-range values.  This is not yet
complete.

In particular, note we may have out-of-range for values that end up
being subject to optimization.  That is because the optimization takes
place on the *truncated* value, not the pre-truncated value.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-06 18:47:29 -07:00
H. Peter Anvin
972079f6a8 Put the static information about warnings in a structure
Put the static information about warnings in a structure, so one can
see what goes with what.  Also, change the sense so "true" means
enabled.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-09-30 17:01:23 -07:00
H. Peter Anvin
2f16043879 Allow %warning output to be suppressed
Allow the user to suppress user-specified warnings.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-09-30 16:39:17 -07:00
H. Peter Anvin
61f130f4e9 Set __PASS__ to 3 for preprocess only
When running the preprocessor only, set __PASS__ to 3.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-09-25 15:45:06 -07:00
Charles Crayne
c1905c2169 Halt assembly if addresses are not converging.
Change global_offset_changed from bool to int so that
progress of convergence can be monitored. If change count
does not decrease from previous pass, increment stall counter.
If stall count reaches threshold, terminate assembly
with error message.
2008-09-11 18:54:06 -07:00
Victor van den Elzen
4252823e95 Limit number of passes to 1000
Now NASM won't take unreasonable an amount of time to generate
wrong code when it encounters equ's that don't converge, ex:

FOO equ FOO + 1
2008-09-11 15:07:05 +02:00
Victor van den Elzen
28f4634634 Remove obsolete ROL-EQU hack
Now that there is proper forward reference resolution,
we can get rid of this junk. Wiping the flags also
removed the SBYTEnn flags, causing

cmp eax, a-b
a: nop
b:

to assemble with -Ox like

cmp eax, strict dword -1

This is now fixed.
2008-09-11 13:14:23 +02:00
Charles Crayne
2581c869b1 Decouple forward references from optimization
Users who wish to control the level of optimization can
continue to specify -O0, -O1, or -Ox,
where x can be the letter itself, or any number > 1.

However, even with optimization turned off,
NASM will always make enough passes to resolve
forward references. As a result, INCBIN is now the only
item left in the critical expressions list, although TIMES
still has its own constant value check.
2008-09-10 19:21:52 -07:00
Victor van den Elzen
22343c2c72 Add macro-defaults warning class and documentation. 2008-08-06 14:48:55 +02:00
Victor van den Elzen
819703afce Fix multipass inline warning (dis/en)abling
Also add a new form: resetting warnings to their original value.
2008-07-16 15:20:56 +02:00
Victor van den Elzen
c82c372495 Fix fclose bug on error.
Contrary to the comments, the fclose is needed.
Failure to close the file caused remove to fail on Windows.
2008-07-16 12:20:23 +02:00
H. Peter Anvin
bda7a6e371 ctype.h: wrapper ctype functions with a cast to (unsigned char)
ctype functions take an *int*, which the user is expected to have
taken the input character from getc() and friends, or taken a
character and cast it to (unsigned char).

We don't care about EOF (-1), so use macros that cast to (unsigned
char) for us.
2008-06-21 10:23:17 -07:00
H. Peter Anvin
ca5ec7a225 Make -F imply -g (BR 1991213)
When the user specifies -F, imply the -g option.  Too many users seem
to make this mistake.
2008-06-11 18:07:40 -07:00
H. Peter Anvin
ac8f8fcb27 Use an explicit table for tolower() to avoid a function call
On some platforms, tolower() is implemented as a function call, in
order to handle locale support.  We never change locales, so can the
result of tolower() into a table, so we don't have to sit through the
function call every time.

~1.3% overall performance improvement on a macro-heavy benchmark under
Linux x86-64.
2008-06-11 15:49:41 -07:00
H. Peter Anvin
7df0417e58 Add %warning, saner unquoting of %error
- Add %warning directive
- Only unquote an %error or %warning string if it is the only thing on
  the directive line.
- Don't expand macros inside a quoted string, even for %error.
2008-06-10 18:27:38 -07:00
H. Peter Anvin
fcb8909749 Move all the RAA code out of nasmlib
The RAA code doesn't have to be in nasmlib; it is only used by nasm
itself, and is better handled in a separate module.
2008-06-09 17:40:16 -07:00
H. Peter Anvin
1803dedae8 Move all the SAA code out of nasmlib
Move all the SAA code out of nasmlib; it's not used by anything than
nasm itself.  Cleaning out the kitchen sink known as nasmlib is a good
thing, too.
2008-06-09 17:32:43 -07:00
H. Peter Anvin
9e1f528c36 Add the -MP option to emit phony targets
Add the -MP option to emit phony targets.  Since this means each
header file has to be visited more than once, change the
implementation to use an internal list of all the dependencies, and
centralize the emission of the dependency files.
2008-05-29 21:38:00 -07:00
H. Peter Anvin
07b7b9e15e Implement -MD, -MF, -MT, -MQ
Implement the dependency options:

-MF: set the file to which dependencies are written.
-MD: generate dependencies in parallel with compilation.
-MT: set the name of the dependency target.
-MQ: same as -MT, but *attempt* to quote it for Makefile safety.
2008-05-29 19:09:11 -07:00
H. Peter Anvin
dfb918047b Add DY, YWORD, and the SY instruction flag
Add the DY instruction, YWORD keyword, and an SY marker for
instruction sizes.  Add a few more AVX sample instructions.
2008-05-20 11:43:53 -07:00
H. Peter Anvin
d85d250fa2 First cut at AVX machinery.
First cut at AVX machinery support.  The only instruction implemented
is VPERMIL2PS, and it's probably buggy.  I'm checking this in with the
hope that other people can start helping out with (a) testing this,
and (b) adding instructions.

NDISASM support is not there yet.
2008-05-04 17:53:31 -07:00
H. Peter Anvin
6b18bcce46 BR 774131: date and time macros
This checkin creates the following date and time macros:

__DATE__, __TIME__, __UTC_DATE__, __UTC_TIME__: strings

__DATE_NUM__, __TIME_NUM__, __UTC_DATE_NUM__, __UTC_TIME_NUM__:
civil dates in digit-string formats

__POSIX_TIME__: time in POSIX time_t format
2008-02-16 14:54:10 -08:00
H. Peter Anvin
2b046cf67f Ignore ERR_PASS1 except for actual warnings
is_suppressed_warning() should never return true unless we're actually
dealing with a warning.  There is a handful of cases where we pass
ERR_PASS1 down together with errors, but that's mostly because it fits
into an overall pattern.  Thus, ignore it.
2008-01-22 14:08:36 -08:00
H. Peter Anvin
be2678cd31 nasm.c: clean up the handing of response files
Avoid using malloc/free (not nasm_malloc/nasm_free even) in the
processing of response files; move to separate function.
2008-01-21 16:23:59 -08:00
H. Peter Anvin
a2c486cd6b Remove debugging printf
Remove debugging printf which shouldn't ever have been checked in ;)
2008-01-13 11:46:04 -08:00
H. Peter Anvin
00835fec0e Sanitize the pass logic, and only issue PASS1 warnings on pass0 == 1
For PASS1 warnings, only do them when pass0 == 1.  The prior passes
are to be considered training passes.  This is a bit awkward if we
then hit an error, but it's better than n repeated warnings.
2008-01-08 23:03:57 -08:00
H. Peter Anvin
34ec300643 Remove magic "five pass minimum" - I'm pretty sure optimizer is fixed.
The five-pass-minimum was a hack for a bug which I think is identified
now.  Doesn't really change the fact that if you want the optimizer,
you probably want -Ox.
2008-01-08 22:31:20 -08:00
H. Peter Anvin
62cf415f49 Optimizer: force progression through final passes when hitting limit
We have a number of bug reports about things not working properly when
the optimizer is running out of passes.  I suspect the reason is
simply that we don't properly execute the final passes (pass0 = 1, 2)
when hitting the limit.  Make sure we advance pass0 the last few
times.
2008-01-08 22:29:21 -08:00
Beroset
095e6a2973 regularized spelling of license to match name of LICENSE file 2007-12-29 09:44:23 -05:00
H. Peter Anvin
70c0bf22a2 BR 1834731: Remove redundant error messages for no input file
Avoid redundant error messages:

./nasm
nasm: error: no input file specified
nasm: fatal: file `' is both input and output file
type `nasm -h' for help

... which is more than a wee bit confusing to the user.
2007-11-19 11:45:40 -08:00
H. Peter Anvin
dc24271fae BR 1091926: Bounds checking for command line parsing
Avoid failure if the command line has doctored arguments.
2007-11-18 11:55:10 -08:00
H. Peter Anvin
423e381dd7 Clean up the command-line parsing; make -w/-W match others
Clean up the command-line parsing and make -w/-W match the behaviour
of all the other options with regards to arguments.
2007-11-15 17:12:29 -08:00
H. Peter Anvin
c68ec01277 Enable a few warnings by default; clean up warning descriptions 2007-11-13 11:34:34 -08:00
H. Peter Anvin
b030c92fee Add gcc-style -W/-Wno- warning selections; -Wall; -Werror
Add gcc-style -Wxxx -Wno-xxx warning selection as an alternative to
-w+xxx/-w-xxx.

Add "all" as an alias for all (actual) warnings.

Add "error" to treat warnings as errors.
2007-11-13 11:31:15 -08:00
H. Peter Anvin
d1fb15c154 Address data is int64_t; simplify writing an address object
Address data is always int64_t even if the size itself is smaller;
this was broken on bigendian hosts (still need testing!)

Create simple "write sized object" macros.
2007-11-13 09:37:59 -08:00
Charles Crayne
5fbbc8c2e7 Upgrade RAA functions to hold 64-bit data. 2007-11-07 19:03:46 -08:00
H. Peter Anvin
7065309739 Formatting: kill off "stealth whitespace"
"Stealth whitespace" makes it harder to read diffs, and just generally
cause unwanted weirdness.  Do a source-wide pass to get rid of it.
2007-10-19 14:42:29 -07:00
Charles Crayne
192d5b5e9c Suppress a few signedness warnings 2007-10-18 19:02:42 -07:00
H. Peter Anvin
f6c9e65d4f Implement floating-point option control directive
New directive [FLOAT] with associated standard macros; allows the
setting to be saved and restored.
2007-10-16 14:40:27 -07:00
H. Peter Anvin
fab3a6c9de Floating-point warning fixes; fix round-to-overflow
Actually generate the appropriate floating-point warnings, and only
one per assembly, pretty please.

Correct the round-to-overflow condition; as written all numbers with a
positive exponent were considered overflows!
2007-10-16 11:48:07 -07:00