Commit Graph

1829 Commits

Author SHA1 Message Date
H. Peter Anvin
23595f5946 assemble: move the instruction-matching loop into a common function
Move the instruction-matching loop into a common function.  This gives
us a single point to adjust the instruction-selection algorithm.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-25 17:44:25 -07:00
H. Peter Anvin
65289e84ed assemble: replace random integers with an enum for match results
Match results were reported with random integers.  Replace with an
enum.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-25 17:25:11 -07:00
Cyrill Gorcunov
2ec4ad8556 sync.c - introduce swap_sync helper
Just to remove code duplication

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-07-20 17:59:00 +04:00
Cyrill Gorcunov
10b4a18d7f preproc.c - remove redundant assignment
There is no need for tline assignment right
before it'll be assigned again in for() cycle.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-07-20 17:59:00 +04:00
Cyrill Gorcunov
2a75829452 nasmlib.h - introduce list iterator helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-07-20 17:59:00 +04:00
H. Peter Anvin
594c9646ae Merge branch 'new-preproc' 2009-07-19 22:36:44 -07:00
H. Peter Anvin
54dd03bfe5 NASM 2.07 2009-07-19 22:16:52 -07:00
H. Peter Anvin
dbb640b846 Drop efunc and evalfunc as input to the preprocessor
We only ever invoked the preprocessor with fixed values for efunc and
evalfunc, so call nasm_error() and evaluate() directly.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-18 18:57:16 -07:00
H. Peter Anvin
00444ae04e Drop efunc and evaluate argument to parse_line()
We never invoked the parser with anything but the default definitions
for evaluate and efunc.  Unlike the backend, though, we sometimes
invoke parse_line() with redefine_label() instead of define_label().

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-18 18:49:55 -07:00
H. Peter Anvin
605f5155ee Drop the ofmt and errfunc arguments to label definition functions
We never set ofmt and errfunc to anything but the global values.
Dropping them from the label definition function command line
simplifies the code.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-18 18:43:58 -07:00
H. Peter Anvin
ab6443969a Run make alldeps 2009-07-18 18:43:28 -07:00
H. Peter Anvin
9bd1506d59 Remove function pointers in output, simplify error handling
Remove a bunch of function pointers in the output stage; they are
never changed and don't add any value.  Also make "ofile" a global
variable and let the backend use it directly.

All we ever did with these variables were stashing it in locals and
using them as-is anyway for no benefit.

Also change the global error function, nasm_error() into a true
function which invokes a function pointer internally.  That lets us
use direct calls to it.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-18 18:43:12 -07:00
H. Peter Anvin
159178f2aa Merge commit 'nasm-2.07rc7' into new-preproc 2009-07-17 00:55:17 -04:00
H. Peter Anvin
b2aae9441e NASM 2.07rc7 2009-07-17 00:35:58 -04:00
H. Peter Anvin
a5fd1ca895 outcoff: fix invalid reference to ofmt
ofmt is a static in nasm.c (why?), not a global...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-16 22:46:34 -04:00
H. Peter Anvin
892bafc9b1 test/Makefile: add more output rules
Add more output rules to be able to try things quickly.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-16 22:44:43 -04:00
H. Peter Anvin
d1904c6cbb outcoff: this is COFF, not binary
Fix error message in outcoff to say COFF, not binary format...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-16 22:44:19 -04:00
H. Peter Anvin
8a962b3efd BR 2822263: don't re-invoke ofmt->symdef() in pass2 unless "special"
Before checkin aeb0e0e9f1 we would only
invoke ofmt->symdef() for a common variable during pass 2 if that
variable had "special" in the declaration.  That checkin
unintentionally changed that behavior.

That doesn't mean that the pre-existing behavior is right, but this
should at least fix the resulting regressions.  This really warrants
more investigation.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-16 22:35:25 -04:00
Keith Kanios
e5b9d2dac0 outform.h: update comments regarding macho32/macho64 2009-07-16 21:13:10 -05:00
H. Peter Anvin
fc81021fcf xcrcgen: tool to create a "generalized CRC" hash table
A so-called "generalized CRC" is a form of hash function based on a
table similar to the conventional bytewise software implementation of
CRC.  For each byte in each data set, it contains a random
byte permutation table.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-16 10:43:38 -04:00
H. Peter Anvin
02d66b182c crcgen: clean up whitespace
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-16 10:23:26 -04:00
H. Peter Anvin
395d381114 crcgen: utility program to generate CRC tables
Small utility program to generate CRC tables in both C and Perl
formats.  Note: we don't actually need a true CRC, which is what this
generates.  We may want to consider going to a "generalized CRC",
meaning a randomly generated set of 8 bytewise permutations.  These
have the advantage of not being linear, while having the same software
implementation as a true CRC.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-16 10:20:14 -04:00
H. Peter Anvin
80d0fd371f Merge branch 'master' into new-preproc 2009-07-16 10:18:43 -04:00
H. Peter Anvin
a99c98470e changes: it's not just invalid UTF-8 sequences that are affected...
It isn't just invalid UTF-8 sequences that are affected; it is in fact
any high-bit bytes (we don't ever try to construct UTF-8 characters,
just deconstruct them.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 17:43:32 -04:00
H. Peter Anvin
a329a85cdf NASM 2.07rc6 2009-07-15 16:33:25 -04:00
H. Peter Anvin
67d520c7fa Merge branch 'master' into new-preproc 2009-07-15 16:32:49 -04:00
H. Peter Anvin
cc6ee1acf2 changes: document fixed crash on invalid UTF-8 sequences
Document nasm_quote() fixes.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 16:31:55 -04:00
H. Peter Anvin
252c2db7d9 quote: use nasm_assert() instead of plain assert()
We have nasm_assert() now, so use it...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 16:30:30 -04:00
H. Peter Anvin
4d5029dd76 quote: we must do unsigned comparison to get length of octal escape
When computing the length of an octal escape, we need to do an
unsigned compare, otherwise we only allocate space for one character
for bytes in the \200..\377 range, which is obviously incorrect.

Reported-by: Ed Beroset <beroset@mindspring.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 16:30:22 -04:00
H. Peter Anvin
b93c1881f6 quote: don't use sprintf()
There is no point in using sprintf(), and it adds the possibility of
either bugs due to the output not matching what the byte count loop is
expecting, or just cause people to freak out due to the notion that
"sprinf is unsafe".

Reported-by: Ed Beroset <beroset@mindspring.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 16:30:15 -04:00
H. Peter Anvin
d46ac3c87d quote: use nasm_assert() instead of plain assert()
We have nasm_assert() now, so use it...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 16:28:43 -04:00
H. Peter Anvin
13028a5a19 quote: we must do unsigned comparison to get length of octal escape
When computing the length of an octal escape, we need to do an
unsigned compare, otherwise we only allocate space for one character
for bytes in the \200..\377 range, which is obviously incorrect.

Reported-by: Ed Beroset <beroset@mindspring.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 16:22:47 -04:00
H. Peter Anvin
62f2863860 doc: use consistent title case
Section titles are in title case and don't end with a period.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 09:27:10 -04:00
H. Peter Anvin
9bd5e12f53 doc: fix formatting of the bin multisection header
"Multisection" is not a keyword...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 09:21:01 -04:00
H. Peter Anvin
89cee57ad0 preproc: style cleanups
Fix indentation, space between if and (, and prefer (foo) and (!foo)
to (foo != NULL) and (foo == NULL).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 09:16:54 -04:00
H. Peter Anvin
a758c48c61 NASM 2.07rc5 2009-07-15 09:08:28 -04:00
H. Peter Anvin
db8f96e0e6 preproc: formatting cleanups
Fix inconsistent indentation, and legacy use of partial directives
instead of simply pp_directives[i].

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-15 09:07:29 -04:00
Keith Kanios
d37a38c359 pptok: change %rimacro to %irmacro
preproc: change PP_RIMACRO to PP_IRMACRO
nasmdoc: add entries for %[i]deftok and %[i]rmacro
2009-07-14 21:00:40 -05:00
H. Peter Anvin
cd0943e277 preproc: don't pass an enum to %s
Need to use pp_directives[directive], not the plain directive, which
is an enum.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-14 15:17:11 -04:00
H. Peter Anvin
f9c9a6717c preproc: generic solution for error on NUL characters in string
Strings returned by nasm_unquote() can contain NUL characters, which
will not be legal if then used as a C string.  Create a general
function which looks for NUL characters in the string and issues an
error if they are found.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-14 15:14:05 -04:00
H. Peter Anvin
2f55bdaaca preproc: reject NUL characters in %deftok directives
We could either error out or convert them to whitespace; this
implements the error option.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-14 15:04:04 -04:00
H. Peter Anvin
466ba97d68 quote: don't use sprintf()
There is no point in using sprintf(), and it adds the possibility of
either bugs due to the output not matching what the byte count loop is
expecting, or just cause people to freak out due to the notion that
"sprinf is unsafe".

Reported-by: Ed Beroset <beroset@mindspring.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-14 14:48:26 -04:00
H. Peter Anvin
bf0247af7a Don't try to fclose() the output if ofile is NULL
ofile == NULL means no output file is open, so don't try to close the
output file if that is true.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-14 14:47:41 -04:00
H. Peter Anvin
68bec0872f outobj: don't fclose() the output
Missed fclose() in outobj when converting system to global fclose().

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-14 14:47:04 -04:00
Keith Kanios
b83fd0b947 preproc: add %[i]deftok support
pptok: add %deftok and %ideftok preprocessor directives
2009-07-14 01:04:12 -05:00
H. Peter Anvin
340ee009d6 Merge branch 'master' into new-preproc
Conflicts:
	.gitignore
2009-07-13 21:41:33 -04:00
H. Peter Anvin
44a0d177f0 gitignore: add test results, *.dbg
Add test result directories and *.dbg to gitignore.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-13 21:27:21 -04:00
H. Peter Anvin
2a3154c4d3 ELF: add debug support for TY_YWORD
Add debug support for TY_YWORD (256 bits/32 bytes).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-13 21:25:36 -04:00
Cyrill Gorcunov
e3042cb103 elf32: debug32_typevalue - fix TY_OWORD size
TY_OWORD is 8 * TY_WORD = 16 bytes length

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-13 17:19:21 -04:00
H. Peter Anvin
ad01495da8 .gitignore: add testresults, a few more version.* versions, *.dbg
Update .gitignore.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-13 14:57:58 -04:00