While NASM doesn't allow this, GAS does.
While we're here, greatly clean up GAS data bytecode creation by no longer
building intermediate valparam list.
* bytecode.h (yasm_dv_create_string): Add length parameter.
(yasm_bc_create_data): Add append_zero parameter for new ability to append
a single ero byte after each data value. This is used by the GAS .asciz
directive.
* bytecode.c (bytecode_data, ...): Implement the above.
* gas-bison.y (gas_define_strings, gas_define_data)
(gas_define_leb128): Remove; replace in usage with direct calls to bytecode
functions. Add str, dataval, and datavalhead to parser union. Add new
dirvals, which has valparams type, and change strvals and datavals to
datavals type.
* gas-token.re: Use new str type where STRING token is generated.
* nasm-bison.y: Add str type to union, and use for STRING token.
* nasm-token.re: Use new str type where STRING token is generated.
* coff-objfmt.c (win32_objfmt_directive): Adjust for updates to
bytecode_data.
* strzero.asm: Simple test for NUL in GAS string.
svn path=/trunk/yasm/; revision=1293
parse_check_segreg, parse_check_insn, parse_check_prefix, and
parse_check_targetmod. This will allow for future improvements to
identifier handling in the various parsers.
svn path=/trunk/yasm/; revision=1249
bytes and offsets, but relocations are not yet indicated. Also, this
outputs post-preprocessed source, so no comments, etc, are visible in the
list file.
* listfmt.h: New header file describing listfmt module interface.
* coretype.h: Declare new yasm_listfmt typedef.
* libyasm.h: Include listfmt.h.
* libyasm/Makefile.inc (modinclude_HEADERS): Add listfmt.h.
* yasm-module.h (module_type): Add MODULE_LISTFMT for listfmts.
(load_listfmt_module, list_listfmts): New macros for listfmts.
* yasm-module.c (module_type_str): Add listfmt string for MODULE_LISTFMT.
(list_module_load): Add support for MODULE_LISTFMT.
* bytecode.h (yasm_bc_tobytes): Comment clarification on effect of calling
yasm_bc_tobytes twice on the same bytecode.
* linemgr.h: Replace support for associated data with support for bytecode
and source line information.
(yasm_linemap_get_data): Remove.
(yasm_linemap_get_source): Add.
(yasm_linemap_add_data): Remove.
(yasm_linemap_add_source): Add.
* linemgr.c (yasm_linemap, yasm_linemap_create, yasm_linemap_destroy)
(yasm_linemap_add_data, yasm_linemap_add_source, yasm_linemap_get_data)
(yasm_linemap_get_source): Likewise.
* nasm-token.re (fill): Save previous 2 lines instead of previous 1 line.
(destroy_line, print_line, line_assoc_data): Remove.
(save_line): Save line in structure instead of calling yasm_linemap_add_data.
* nasm-bison.y (input rule): Call yasm_linemap_add_source here.
* nasm-parser.h (yasm_parser_nasm): Add second line of storage and save_last
variable to toggle between the two lines.
* nasm-parser.c (nasm_parser_do_parse): Initialize save_last.
* modules/Makefile.inc: Include new modules/listfmts/Makefile.inc.
* modules/listfmts/Makefile.inc: New;
includes modules/listfmts/nasm/Makefile.inc.
* modules/listfmts/nasm/Makefile.inc: New build file for NASM-like listfmt.
* nasm-listfmt.c: New NASM-like listfmt.
* yasm.c: Enable use of listfmts, and default to NASM listfmt.
(list_filename, cur_listfmt, cur_listfmt_module): New listfmt variables.
(opt_listfmt_handler, opt_listfile_handler): New listfmt functions.
(options): Add --lformat (-L) and --list (-l) options.
(main): Load "nasm" listfmt as default if none selected.
Enable saving of input lines if list output file enabled.
Open and write to the list file.
(open_obj): Rename to open_file and make more generic.
(cleanup): Destroy listfmt and list filename if created.
svn path=/trunk/yasm/; revision=1152
(Hopefully) finish cleanups begun in phase 1 (see phase 1 commit message),
making dbgfmt, objfmt, optimizer, and preproc module interfaces follow the
same thread-safe interface style as the phase 1 changes.
Also put in a large number of doxygen documentation cleanups.
svn path=/trunk/yasm/; revision=1097
"functions" that call down to the module level. Doesn't really change the
internal complexities, just makes it easier to read and write code that
uses it.
svn path=/trunk/yasm/; revision=1080
As yasm has evolved, various minor additions have been made to libyasm to
support the new features. These minor additions have accumulated, and
some contain significant redundancies. In addition, the core focus of
yasm has begun to move away from the front-end commandline program "yasm"
to focusing on libyasm, a collection of reusable routines for use in all
sorts of programs dealing with code at the assembly level, and the modules
that provide specific features for parsing such code.
This libyasm/module update focuses on cleaning up much of the cruft that
has accumulated in libyasm, standardizing function names, eliminating
redundancies, making many of the core objects more reusable for future
extensions, and starting to make libyasm and the modules thread-safe by
eliminating static variables.
Specific changes include:
- Making a symbol table data structure (no longer global). It follows a
factory model for creating symrecs.
- Label symbols now refer only to bytecodes; bytecodes have a pointer to
their containing section.
- Standardizing on *_create() and *_destroy() for allocation/deallocation.
- Adding a standardized callback mechanism for all data structures that
allow associated data. Allowed the removal of objfmt and
dbgfmt-specific data callbacks in their interfaces.
- Unmodularizing linemgr, but allowing multiple linemap instances (linemgr
is now renamed linemap).
- Remove references to lindex; all virtual lines (from linemap) are now
just "line"s.
- Eliminating the bytecode "type" enum, instead adding a standardized
callback mechanism for custom (and standard internal) bytecode types.
This will make it much easier to add new bytecodes, and eliminate the
possibility of type collisions. This also allowed the removal of the
of_data and df_data bytecodes, as objfmts and dbgfmts can now easily
implement their own bytecodes, and the cleanup of arch's bytecode usage.
- Remove the bytecodehead and sectionhead pseudo-containers, instead
making true containers: section now implements all the functions of
bytecodehead, and the new object data structure implements all the
functions of sectionhead.
- Add object data structure: it's a container that contains sections, a
symbol table, and a line mapping for a single object. Every former use
of sectionhead now takes an object.
- Make arch interface and all standard architectures thread-safe:
yasm_arch_module is the module interface; it contains a create()
function that returns a yasm_arch * to store local yasm_arch data; all
yasm_arch_module functions take the yasm_arch *.
- Make nasm parser thread-safe.
To be done in phase 2: making other module interfaces thread-safe. Note
that while the module interface may be thread-safe, not all modules may be
written in such a fashion (hopefully all the "standard" ones will be, but
this is yet to be determined).
svn path=/trunk/yasm/; revision=1058
- 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
key headers in certain situations (config.h when compiling with Visual C++ for
one), and is also more correct in general.
svn path=/trunk/yasm/; revision=887
When -Werror is used, disable -Wconversion, because flex-generated code causes
warnings when calling fwrite() and fread().
svn path=/trunk/yasm/; revision=873
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
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
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