Commit graph

79 commits

Author SHA1 Message Date
Peter Johnson
9d9618eeba Add offset parameter to output_expr functions (needed for relocation support).
svn path=/trunk/yasm/; revision=767
2002-10-20 20:39:29 +00:00
Peter Johnson
c5bfd97db6 Make bytecode and effaddr "data" extensions more portable by including the
base structure as the first element in each data structure.  Concept taken from
the JPEG library.

svn path=/trunk/yasm/; revision=761
2002-10-12 07:41:39 +00:00
Peter Johnson
494ed1738d Make output endian-tolerant by making intnum and floatnum output functions for
arch.  This will also simplify other objfmt expr output functions.  Change
file functions to use bits instead of byte/short/long, and create both little
and big endian versions.  This name change caused changes in several other
files.

svn path=/trunk/yasm/; revision=747
2002-10-06 19:43:51 +00:00
Peter Johnson
e4411d414d Make bcs_last() a fully visible function rather than a bc-int macro.
svn path=/trunk/yasm/; revision=729
2002-10-03 09:23:37 +00:00
Peter Johnson
3466293ed7 bc_tobytes(): Check for multiple of 0 and return with bufsize of 0.
svn path=/trunk/yasm/; revision=727
2002-10-03 08:19:21 +00:00
Peter Johnson
a3a9fd2aa0 Completely revamp how label resolution is done (part of Bug#6). Now calculates
/distances/ between bytecodes in a section using bc_calc_dist() functions (a
"typical" one is provided for most occasions).  expr_expand_labelequ() is gone,
as its functionality is integrated into expr_simplify().  Currently these
changes break most bin objfmt output, as it doesn't know how to resolve
absolute labels yet.  Also, very preliminary expr support for :, SEG, and WRT
operators has been added (part of Bug#2).  Several other minor bug fixes.

svn path=/trunk/yasm/; revision=718
2002-10-01 18:56:28 +00:00
Peter Johnson
090a25b8d4 Rename intnum_new_int to intnum_new_uint, and add new signed version of
intnum_new_int.  Currently only just calls intnum_new_uint with a cast, but
eventually there may be a better way of handling signed numbers.

svn path=/trunk/yasm/; revision=708
2002-09-24 18:35:51 +00:00
Peter Johnson
c5ef1bf2dc Eliminate duplicate code for callbacks from expr_expand_labelequ() by moving
code and adding a resolve_precall function parameter (which caused cascading
changes in bytecode-related sources).

svn path=/trunk/yasm/; revision=701
2002-08-18 03:48:17 +00:00
Peter Johnson
3320945f95 Massive restructuring of lexing and parsing (NASM-compatible parser).
Bugzilla Bug#3.  Not all instructions are parsed yet, so this is actually a
minor feature regression from the user side, but this commit lays the framework
for much easier additions of new assembler syntaxes and architectures.  The
re2c tool is now used to generate the lexers, as it's much more flexibly
function-oriented than lex.
 - nasm-bison.y is a repocopy+modify of nasm/bison.y.in.
 - x86arch.h now includes all of x86-int.h

svn path=/trunk/yasm/; revision=670
2002-08-09 05:43:03 +00:00
Peter Johnson
f8f1c204f7 Bytecode and objfmt changes:
- Add two new bytecode types:
   BC_ALIGN (not yet implemented) for performing nice alignment magic.
   BC_OBJFMT_DATA for storing objfmt-generated data in more advanced objfmts.
 - objfmt structure changes:
   Add handling functions for BC_OBJFMT_DATA data.
   Allow a number of functions to be NULL.

svn path=/trunk/yasm/; revision=631
2002-05-23 07:24:41 +00:00
Peter Johnson
ac2743de63 Prevent spurious "Circular reference detected" errors by refining the return
value for bc_resolve() to enum-defined flags.

svn path=/trunk/yasm/; revision=623
2002-05-20 01:08:42 +00:00
Peter Johnson
4407d49d66 During the first pass of basic optimization, continue reporting errors, don't
stop at the first error.
To help prevent spurios errors, make bytecodes with errors 0 length in
bc_resolve().

svn path=/trunk/yasm/; revision=621
2002-05-11 01:50:11 +00:00
Peter Johnson
58cc15c1d6 Change handling of res* (no longer require that the entire containing buffer
be allocated and filled with 0's to write it out).
Other fixes:
 Specifically look for floating point values in res* and multiple exprs.
 One-byte PC-relative displacement *is* legal (short jumps).

svn path=/trunk/yasm/; revision=620
2002-05-05 18:18:07 +00:00
Peter Johnson
a6d468b938 Splint cleanups.
svn path=/trunk/yasm/; revision=595
2002-04-22 01:51:24 +00:00
Peter Johnson
9398eb518e Add some splint-suggested cleanups.
svn path=/trunk/yasm/; revision=551
2002-04-05 03:17:44 +00:00
Peter Johnson
fe8c2a009f Restructure bc_calc_len() family into bc_resolve() family. Many many many
bugfixes to the bc_tobytes() family and other functions.  Binary object output
is now close to complete: just a few more bugs to kill!

svn path=/trunk/yasm/; revision=528
2002-03-18 07:16:52 +00:00
Peter Johnson
d85e7014a8 Binary object format output! Lots of structural changes needed, particularly
with regards to resolve_label().
MAJOR FIXME: The tobytes() pass acts like a final optimization pass.  This
causes internal errors because of length mismatches (optimized to shorter len).

svn path=/trunk/yasm/; revision=521
2002-03-17 21:58:36 +00:00
Peter Johnson
62750a30d3 Enhance bc_resolve() implementation a bit, but comment out, as this function
will probably disappear in the near future (its functionality will be handled
directly by the object format module without the need for another pass).

svn path=/trunk/yasm/; revision=481
2002-03-07 07:40:40 +00:00
Peter Johnson
8a515e968a Reverse how traverse functions do early termination (now, they terminate on
a non-zero func return and return the value func returned).  Document the
changes in the header files.

svn path=/trunk/yasm/; revision=468
2002-02-20 07:38:41 +00:00
Peter Johnson
66bf6be085 Implement rest of bc_calc_len for general bytecodes.
svn path=/trunk/yasm/; revision=457
2002-01-11 02:59:33 +00:00
Peter Johnson
5b2166d50a Don't store "determined" immediate len and neg. Both will be determined from
the expr when that's actually possible.

svn path=/trunk/yasm/; revision=456
2002-01-10 05:39:25 +00:00
Peter Johnson
ee74365f05 Add new bc_resolve() family, and rewrite calc_len to /just/ calculate the
length, not modify anything else (particularly expressions w/temp. resolved
labels).

svn path=/trunk/yasm/; revision=452
2002-01-10 05:01:36 +00:00
Peter Johnson
cc635cc237 Change return type of calc_len() family back to int from unsigned long.
svn path=/trunk/yasm/; revision=448
2002-01-09 09:10:36 +00:00
Peter Johnson
e23d88b957 Make resolve_label() take a symrec * instead of a section * and bytecode *.
Extend expr_expand_equ() into expr_expand_labelequ() and call resolve_label()
here.

svn path=/trunk/yasm/; revision=440
2002-01-09 07:23:00 +00:00
Peter Johnson
e2f2ede90c bc_calc_len() family should return unsigned long, not int.
svn path=/trunk/yasm/; revision=436
2002-01-09 05:05:21 +00:00
Peter Johnson
3f2186c1bf Change from current file/line dual storage to a monotonically-increasing line
"index".  This fixes some problems with assumptions made by various parts of
the code that are invalidated when the line number doesn't always increase (eg.
when the NASM %line directive is used).
Speed fixes are needed to the implementation of the line_* functions in
globals.c before this is finished.

svn path=/trunk/yasm/; revision=424
2002-01-07 07:42:27 +00:00
Peter Johnson
2727869bd8 Start work on optimizer module. Moved all "post-parser-finalization" code
into the optimizer stage, where it belongs.  Naming has changed, but most
implementations have not been brought up to date to do what they say they
do.

svn path=/trunk/yasm/; revision=388
2001-12-07 03:32:05 +00:00
Peter Johnson
0f852333df LCLint-related comment fixes.
svn path=/trunk/yasm/; revision=387
2001-12-03 07:37:33 +00:00
Peter Johnson
ae85d1edb1 Add support for incbin pseudo-instruction.
svn path=/trunk/yasm/; revision=386
2001-12-03 07:33:48 +00:00
Peter Johnson
e8d7d5cad9 Add opt_flags (space for use by the optimizer).
svn path=/trunk/yasm/; revision=384
2001-12-03 02:52:44 +00:00
Peter Johnson
825eaa5823 Massive cleanup of debugging output (via _print() functions). All now take
FILE *'s to print to somewhere other than stdout, and the formatting is
improved through the use of a global indent_level.

Changes to main() include the ability to specify an output file.

svn path=/trunk/yasm/; revision=357
2001-11-21 08:25:09 +00:00
Peter Johnson
7a3761ac0c Plug memory leak in dvs_delete().
svn path=/trunk/yasm/; revision=352
2001-11-19 07:43:26 +00:00
Peter Johnson
8178f883a5 Modify so that almost everything passes LCLint with the options in lclint.sh.
This is actually worthwhile; I found and fixed a few bugs/edge cases while
doing this.
For more information on LCLint, see <http://lclint.cs.virginia.edu/>.

svn path=/trunk/yasm/; revision=335
2001-11-17 08:33:23 +00:00
Peter Johnson
f58d7cb093 Split x86-specific stuff away from bytecode.
svn path=/trunk/yasm/; revision=316
2001-11-05 05:49:19 +00:00
Peter Johnson
a7ac50c918 Add coretype.h, make util.h do a lot more, use util.h to simplify include
sections of C files.  Also remove IdPath from top comment in files where
RCSID() is used.  Move RCSID() to immediately after util.h include.

svn path=/trunk/yasm/; revision=313
2001-11-03 05:17:51 +00:00
Peter Johnson
405df52913 bytecode_print(): Change how NULL values are output for imm and multiple.
bytecode_parser_finalize_insn(): Add some preliminary imm handling.  Handle
shift_op special-casing (,1 hack).

svn path=/trunk/yasm/; revision=312
2001-11-03 04:13:42 +00:00
Peter Johnson
4d95de5161 Plug memory leaks, and enhance finding later ones with *_delete functions.
Fix a *major* bug in expr_level_op().

svn path=/trunk/yasm/; revision=301
2001-10-29 04:52:44 +00:00
Peter Johnson
dc1c3c70f5 Get rid of all the extra filename strdup()'s. (Bug #14).
svn path=/trunk/yasm/; revision=300
2001-10-29 01:10:20 +00:00
Peter Johnson
7a6eaf8c03 Make InternalError() a bit easier to call. Also, reverse its file and line
parameters to match the *At() functions.

svn path=/trunk/yasm/; revision=299
2001-10-29 00:21:00 +00:00
Peter Johnson
6f708e3034 Add xfree() to replace calls to free().
This also fixes the build breakage caused by removing stdlib includes.

svn path=/trunk/yasm/; revision=298
2001-10-29 00:11:14 +00:00
Peter Johnson
adf5a95e89 Add option for malloc debugging using dmalloc library (http://dmalloc.com/).
Remove unnecessary stdlib includes (because we use xmalloc instead of malloc).

svn path=/trunk/yasm/; revision=297
2001-10-29 00:01:31 +00:00
Peter Johnson
e7bab50cf2 Parse NOSPLIT.
Move some work to subfunctions in expr so they can be used for both 16-bit
and 32-bit checking.

svn path=/trunk/yasm/; revision=295
2001-10-28 23:39:14 +00:00
Peter Johnson
121f93b0a0 *COMPLETELY* rewrite most of expression handling.
Features:
- More complex memory expressions like [bx-(bx-di)] are now calculated through
  as valid.
- Much better simplification.
Internal changes:
- More flexible n-way tree (rather than old binary-only).
- Many new functions to simplify and deal with very complex expressions.

svn path=/trunk/yasm/; revision=294
2001-10-28 09:22:13 +00:00
Peter Johnson
e640f25da5 Update comment on disp.len to match changes in expr.c.
svn path=/trunk/yasm/; revision=288
2001-10-18 07:02:11 +00:00
Peter Johnson
6ac7d95579 Call expr_expand_equ() on effective address from bytecode_parser_finalize().
svn path=/trunk/yasm/; revision=285
2001-10-15 07:07:55 +00:00
Peter Johnson
0be7a0d444 Add first version of post-parsing bytecode finalization. Lots of work still
to be done at the bytecode and expression level.

svn path=/trunk/yasm/; revision=283
2001-10-15 04:42:47 +00:00
Peter Johnson
053329a368 Clarify and fix some usages of valid/need flags for modrm and sib bytes.
In bytecode_print(), check for NULL ea displacement and print out modrm and
sib bytes in octal (because it's easier to read the 2/3/3 format in octal).

svn path=/trunk/yasm/; revision=277
2001-10-12 02:29:31 +00:00
Peter Johnson
84de990744 Support TIMES prefix. Split expr parsing to have a no-float and no-string
version (for times and reserve space).

svn path=/trunk/yasm/; revision=275
2001-10-11 22:55:04 +00:00
Peter Johnson
193392dcb6 Fix LOTS of little nits. Primary changes:
- New intnum module to replace using just unsigned long (for >32 bit values).
   Read values using BitVector instead of strtoul().
 - Brought both floatnum and intnum into expr (still need to integrate calc for
   floatnum).
 - Add traversal function to ternary tree (for use by symrec_foreach).
 - Change floatnum output interface from single/double/extended to byte size.
 - Try to make floatnum/intnum interfaces very similar.  Still needs work.
 - Add/fix *_print functions, including interating ones for sections/bytecodes.
 - Fix handling of $ and $$.  Both now are properly parsed and bytecode'd.
 - Print out all sections and symbol table in main() in preparation for work
   on "cleanup" functionality between parser and optimizer stages (really part
   of the parser stage).

svn path=/trunk/yasm/; revision=270
2001-10-11 05:34:50 +00:00
Peter Johnson
217b33802c Make data.insn.imm within bytecode a pointer. This prevents leakage in calls to
bytecode_new_insn().

svn path=/trunk/yasm/; revision=266
2001-10-04 06:01:44 +00:00