Commit graph

94 commits

Author SHA1 Message Date
Peter Johnson
cfc6bf0ded Clean up and simplify libyasm.h options and symbol visibility:
- Move config.h and util.h from libyasm (and installed libyasm) to top level.
- Move yasm_* functions from util.h to coretype.h.
- Remove a number of autoconf-related YASM_*_INTERNAL options from libyasm.h.
- Rename YASM_INTERNAL to YASM_LIB_INTERNAL; it now actually means what the
  comment describes: enables definitions that violate the yasm_* namespace.

While we're at it, no longer define YASM_LIB_INTERNAL from yasm frontend, so
it's closer to what a real typical libyasm-using application would look like.

svn path=/trunk/yasm/; revision=944
2003-05-05 03:42:12 +00:00
Peter Johnson
8f91cd9d24 Change how bytecode and section lists are allocated. When YASM_INTERNAL is not
defined, the structures for the list heads are not defined, so the existing
yasm_bcs_initialize() and yasm_sections_initialize() were impossible to use.
Instead, rename these functions to yasm_bcs_new() and yasm_sections_new() and
make them allocate the space internally.  Update yasm_bcs_delete() and
yasm_sections_delete() to free the internally-allocated space.

svn path=/trunk/yasm/; revision=942
2003-05-04 22:15:09 +00:00
Peter Johnson
0ab3ae5153 Flatten arch interface, changing some parse function names in the process.
No functional changes.

svn path=/trunk/yasm/; revision=903
2003-03-31 05:36:30 +00:00
Peter Johnson
dd1d356936 De-constify yasm_bytecode parameter to yasm_output_expr_func.
svn path=/trunk/yasm/; revision=883
2003-03-24 06:46:22 +00:00
Peter Johnson
0caa11ff3b Enable more warnings and perform code cleanups to avoid them.
When -Werror is used, disable -Wconversion, because flex-generated code causes
warnings when calling fwrite() and fread().

svn path=/trunk/yasm/; revision=873
2003-03-17 00:03:02 +00:00
Peter Johnson
0786a76895 Make libyasm a "real" library, including installing header files.
Start separating modules and frontends from libyasm internals.

svn path=/trunk/yasm/; revision=849
2003-03-15 05:07:49 +00:00
Peter Johnson
84ee559be7 The Great Renaming (prefixing with yasm_), Part 2: allocation functions.
svn path=/trunk/yasm/; revision=843
2003-03-12 06:08:43 +00:00
Peter Johnson
d9f68d6d4b Unmodularize errwarn, while making key errwarn functions replaceable.
Also removes dependency of libyasm on libintl (gettext), so it can be linked
-no-undefined now!

svn path=/trunk/yasm/; revision=842
2003-03-10 08:55:41 +00:00
Peter Johnson
a2e07e1e10 The Great Renaming (prefixing with yasm_), Part 1.
svn path=/trunk/yasm/; revision=838
2003-03-08 19:15:40 +00:00
Peter Johnson
d54377029e bc_new_objfmt_data() was creating a bytecode with the incorrect type.
svn path=/trunk/yasm/; revision=837
2003-03-08 07:33:06 +00:00
Peter Johnson
b1faf6329c Relicense under 2-clause BSD license.
svn path=/trunk/yasm/; revision=835
2003-02-21 03:50:29 +00:00
Peter Johnson
9f6cb6783f Modularize errwarn. gettext()-ize in errwarn, not in every module, eliminating
libintl dependency in modules.
Also standardize initialize() and cleanup() functions.
Move replace_extension() from file.c to main.c.
Clean up some extern variable declarations in various places (particularly
nasm-compatible parser).

svn path=/trunk/yasm/; revision=792
2002-11-01 10:05:03 +00:00
Peter Johnson
2f19ce4ecd Delete last of global variables by making a line manager and passing around
the line index.  Fixes some minor line number/error message nits due to
incorrect usage of line_index in old global variable method.

svn path=/trunk/yasm/; revision=787
2002-10-27 09:21:39 +00:00
Peter Johnson
caf89035f8 Remove indent_level global by passing it as a parameter.
svn path=/trunk/yasm/; revision=786
2002-10-26 19:50:08 +00:00
Peter Johnson
d6f22c3fce Dynamically load all modules (preloading some of the default ones).
Start reducing global variables for cleaner module separation.
Add rudimentary debug format module interface and "null" debug format.

svn path=/trunk/yasm/; revision=784
2002-10-26 08:25:39 +00:00
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