Commit Graph

18 Commits

Author SHA1 Message Date
H. Peter Anvin
33ef63669c doc: improve some formatting, mostly of the warning list
Fix some formatting markups, especially with regards to warnings.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2024-04-04 12:58:32 -07:00
H. Peter Anvin
73676357de BR 3392906: error out on bad syntax "db 1 2"
NASM would try to "eat the comma token" in db expressions, even for
cases where the token was not a comma. Fix that and error out
properly.

To give better error messages, track where in the input string a token
starts or ends. This information is only valid as long as the input
string is kept, but that is just fine for error messages during
parsing.

Reported-by: Peter Cordes <pcordes@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2023-10-11 12:06:58 -07:00
H. Peter Anvin (Intel)
de8817ddbc doc: clean up warnings formatting
When a warning documentation message contains more than one paragraph,
we have to indent the subsequent paragraphs using \> unless they are a
code paragraph (\c).

Improve a few warnings doc messages.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-27 22:30:50 -07:00
H. Peter Anvin (Intel)
84b852bff0 Implement an enhanced version of MASM's dup() and "db ?" syntax.
Add support for complex data (Dx) statement expressions involving both
initialized and uninitialized data. In addition, we have support for
overriding the size of each element on an individual item and/or list
basis.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2019-10-16 14:29:16 -07:00
H. Peter Anvin
8571f06061 preprocessor: major cleanups; inline text into Token
Major cleanups of the preprocessor. In particular, the
block-allocation of Token is pretty ridiculous since nearly every
token requires a text allocation anyway. Change the definition of
Token so that only very long tokens (48+ characters on 64-bit systems)
need to be stored out of line.

If malloc() preserves alignment (XXX: glibc doesn't) then this means
that each Token will fit in a cache line.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-09-23 16:40:03 -07:00
H. Peter Anvin
8960e1bc83 Remove #includes already provided by "compiler.h"
"compiler.h" already includes a bunch of common include files. There
is absolutely no reason to duplicate them in individual files, and in
fact it robs us of central control of how these files are used.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-27 12:45:44 -08:00
H. Peter Anvin
c2f3f26015 Replace <ctype.h> includes with "nctype.h"
For almost everything we should use "nctype.h". Right now we don't
have a nasm_toupper() to use <ctype.h> for things that need toupper().

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-27 12:37:25 -08:00
H. Peter Anvin
2e53f27e9d Move <string.h> inclusion to compiler.h
There is absolutely no reason not to include <string.h> globally, and
with the inline function for mempcpy() we need it there anyway.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-26 06:32:37 -08:00
H. Peter Anvin (Intel)
5df6ca712d With buffered warnings, change the handling of error passes
With buffered warnings, most warnings *must* be issued on every pass,
so ERR_PASS1 is simply wrong in most cases.

ERR_PASS1 now means "force this warning to be output even in
pass_first(). This is to be used for the case where the warning is
only executed in pass_first() code; this is highly discouraged as it
means the warnings will not appear in the list file and subsequent
passes may make the warning suddenly vanish.

ERR_PASS2 just as before suppresses an error or warning unless we are
in pass_final().

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-18 12:25:11 -08:00
H. Peter Anvin (Intel)
80c4f23c52 nasm_warnf() -> nasm_warn()
We want to strongly encourage writers of warnings to create warning
categories, so remove the flagless nasm_warn() and change nasm_warnf()
to nasm_warn().

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-14 13:33:24 -08:00
H. Peter Anvin (Intel)
723ab481a6 warnings: define warning classes at point of use
It is extremely desirable to allow the user fine-grained control of
warnings, but this has been complicated by the fact that a warning
class has had to be defined in no less than three places (error.h,
error.c, nasmdoc.src) before it can be used in source code. Instead,
use a script to define these via magic comments at the point of use.

This hopefully will encourage creating new classes as needed.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 21:53:31 -08:00
H. Peter Anvin (Intel)
df4d342599 warnings: rename ERR_WARN_* to WARN_*
The prefix ERR_WARN_ is unnecessarily long and may be a disincentive
to create new warning categories. Change it to WARN_*, it is still
plenty distinctive.

This is equivalent to nasm-2.14.xx checkin 77f53ba6d4.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-12 17:48:38 -08:00
Cyrill Gorcunov
b449ce49d9 stdscan: Use nasm_error helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-12-01 21:02:51 +03:00
H. Peter Anvin
1350620bf1 ctype: create our own ctype table
Create our own ctype table where we can do the tests we want to do
cheaply, instead of calling ctype functions and then adding additional
tests all over the code.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-11-28 14:55:58 -08:00
H. Peter Anvin
94adf7d765 eval: add support for signed shift operators <<< and >>>
Add support for signed shifts.  The operators are <<< and >>>,
although the former is (inherently) idntical to <<.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-06-15 18:37:32 -07:00
H. Peter Anvin
b20bc733c9 asm/*: Move directive processing to its own file, refactor error handling
Move directive processing to its own file, and move nasmlib/error.c to
asm/error.c (it was not used by the disassembler); remove some extern
declarations from .c files, and do some general code cleanups.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 19:31:04 -08:00
Martin Lindhe
9b5aa2e6d0 Drop redundant test with isnumchar
fix pvs-studio error 'V501 There are identical sub-expressions '(c) == '_'' to
the left and to the right of the '||' operator.'. isnumchar() is a macro
defined as (nasm_isalnum(c) || (c) == '_')

Signed-off-by: Martin Lindhe <martin-commit@ubique.se>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-01-05 22:38:41 +03:00
H. Peter Anvin
e1f985c167 Reorganize the source code into subdirectories
Make the source code easier to understand and keep track of by
organizing it into subdirectories depending on the function.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-05-25 12:06:29 -07:00