summaryrefslogtreecommitdiff
path: root/nasmlib.c
AgeCommit message (Collapse)AuthorFilesLines
2009-06-27Move backend-specific code to output/; break out null debug stuffH. Peter Anvin1-54/+0
Move backend-specific code into the output/ directory, and make the null debugging backend a separate file (it certainly isn't needed for ndisasm...) Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-02-21BR 2592476: Treat WAIT as a prefix even though it's really an instructionH. Peter Anvin1-2/+2
WAIT is technically an instruction, but from an assembler standpoint it behaves as if it had been a prefix. In particular, it has to be ordered *before* any real hardware prefixes.
2009-02-21nasmlib: make nasm_strcat() take const argumentsH. Peter Anvin1-1/+1
None of the strings passed to nasm_strcat() are modified, to make them const.
2009-02-21Unify all-zero buffers; add fwritezero()H. Peter Anvin1-0/+23
We have a number of all-zero buffers in the code. Put a single all-zero buffer in nasmlib.c. Additionally, add fwritezero() which can be used to write an arbitrary number of all-zero bytes; this prevents the situation where the all-zero buffer is simply too small.
2008-06-28nasmlib: fix nasm_str[n]icmp()H. Peter Anvin1-4/+4
Fix nasm_str[n]icmp() on platforms which don't have this function natively. XXX: Given the new nasm_tolower() implementation, we should consider if this might actually be a faster function than the platform-native one.
2008-06-21ctype.h: wrapper ctype functions with a cast to (unsigned char)H. Peter Anvin1-2/+2
ctype functions take an *int*, which the user is expected to have taken the input character from getc() and friends, or taken a character and cast it to (unsigned char). We don't care about EOF (-1), so use macros that cast to (unsigned char) for us.
2008-06-11Use an explicit table for tolower() to avoid a function callH. Peter Anvin1-2/+17
On some platforms, tolower() is implemented as a function call, in order to handle locale support. We never change locales, so can the result of tolower() into a table, so we don't have to sit through the function call every time. ~1.3% overall performance improvement on a macro-heavy benchmark under Linux x86-64.
2008-06-10nasmlib.c: fwriteint*() only need WORDS_LITTLEENDIANH. Peter Anvin1-2/+2
fwriteint*() don't require unaligned references, so they can be optimized for WORDS_LITTLEENDIAN rather than X86_MEMORY...
2008-06-09Move all the RAA code out of nasmlibH. Peter Anvin1-93/+0
The RAA code doesn't have to be in nasmlib; it is only used by nasm itself, and is better handled in a separate module.
2008-06-09Move all the SAA code out of nasmlibH. Peter Anvin1-305/+0
Move all the SAA code out of nasmlib; it's not used by anything than nasm itself. Cleaning out the kitchen sink known as nasmlib is a good thing, too.
2008-06-01qstring: backquoted strings seem to work now...H. Peter Anvin1-18/+45
Hopefully backquoted strings should work correctly now.
2008-06-01qstring: first cut at full quoted string support in the preprocessorH. Peter Anvin1-225/+0
First attempt at properly handle quoted strings in the preprocessor. This also adds range support in %substr. No support in the assembler yet.
2008-06-01qstring: add nasm_unquote() supporting `...`H. Peter Anvin1-0/+205
Add a nasm_unquote() function supporting the intended `...` syntax.
2008-05-30Introduce %depend and %pathsearch, and make incbin a macroH. Peter Anvin1-0/+2
Introduce new preprocessor directives %depend and %pathsearch, and make incbin a standard macro using these filenames. This lets us remove the code that makes incbin search the path.
2008-05-04First cut at AVX machinery.H. Peter Anvin1-3/+3
First cut at AVX machinery support. The only instruction implemented is VPERMIL2PS, and it's probably buggy. I'm checking this in with the hope that other people can start helping out with (a) testing this, and (b) adding instructions. NDISASM support is not there yet.
2008-02-24Dwarf3 support for ELF32Charles Crayne1-0/+55
1. Port dwarf3 support from ELF64 to ELF32 2. Move common SAA extentions to nasmlib
2008-01-21RAA subsystem: use shift instead of divideH. Peter Anvin1-16/+12
Make the RAA size always a power of two, so we can use shifts instead of multiple, expensive divides.
2008-01-21nasmlib.c: log nasm_free() before calling free()H. Peter Anvin1-1/+1
If we're logging nasm_free(), then log it before we actually call free(); that way we can find out what the last thing was if free() crashes.
2008-01-08BR 1864243: better warnings for out-of-range constantsH. Peter Anvin1-1/+1
In particular, we'd miss issuing warnings for out-of-range dword values, and the message for constants too large (we can't deal with > 64 bits) said 32 bits, not 64.
2007-12-29regularized spelling of license to match name of LICENSE fileBeroset1-1/+1
2007-11-19BR 877583: Fix RAA memory leakH. Peter Anvin1-3/+2
raa_free() didn't actually do the proper job; it would only free leaf nodes, not internal nodes.
2007-11-17Check in Keith's FixesCharles Crayne1-8/+5
1. Don't warn on 32-bit overflow 2. Change EM64T to Intel 64 in Defining CPU Dependencies section of documentation.
2007-11-13Clean up the fwrite*() function definitions somewhatH. Peter Anvin1-16/+12
Slight cleanup of the fwrite*() functions. This actually helps gcc generate better code on i386, for no apparent reason.
2007-11-13x86-host-specific performance improvementH. Peter Anvin1-0/+30
If we're on an x86 host, we can do unaligned littleendian memory references directly. Just do'em.
2007-11-13Address data is int64_t; simplify writing an address objectH. Peter Anvin1-14/+16
Address data is always int64_t even if the size itself is smaller; this was broken on bigendian hosts (still need testing!) Create simple "write sized object" macros.
2007-11-08nasmlib.c: prefix_name(): use the elements() macroH. Peter Anvin1-1/+1
Use the elements() macro to count the elements in a static array.
2007-11-08constipate the "str" argument to bsi() and bsii()H. Peter Anvin1-2/+2
The string argument to bsi() and bsii() should be const.
2007-11-07Upgrade RAA functions to hold 64-bit data.Charles Crayne1-2/+2
2007-11-05Upgrade label functions to 64-bitCharles Crayne1-1/+1
2007-10-26readnum(): handle prefix-suffix collision like "0h"H. Peter Anvin1-15/+11
Suffixed versions of zero will look like both a prefix and a suffix. Reject the prefixed version as being too short to decode.
2007-10-23Slightly simplify the radix-detection codeH. Peter Anvin1-2/+4
(pradix && pradix > sradix) etc. is unnecessary since pradix and sradix cannot be negative, so zero is always the smallest value. Put in a comment explaining why making the default radix == 10 doesn't need any additional error checking.
2007-10-22Unbreak particularly tricky hex constantsH. Peter Anvin1-7/+20
Unbreak hex constants which contain 'b' or 'd' in potentially tricky places.
2007-10-22More consistent handling of radix lettersH. Peter Anvin1-15/+31
Allow any radix letter from the set [bydtoqhx] to be used either "Intel-style" (0...x) or "C-style" (0x...). In Intel style, the leading 0 remains optional as long as the first digit is in the range 0-9. As a consequence, allow the prefix "0h" for hexadecimal floating point.
2007-10-19Formatting: kill off "stealth whitespace"H. Peter Anvin1-6/+6
"Stealth whitespace" makes it harder to read diffs, and just generally cause unwanted weirdness. Do a source-wide pass to get rid of it.
2007-10-19Allow underscores in numbers; better detection of FPH. Peter Anvin1-11/+14
- Allow underscores as group separators in numbers, for example: 0x1234_5678 is now a legal number. The underscore is just ignored, it adds no meaning. - Recognize dotless floating-point numbers, such as "1e30". This entails distinguishing hexadecimal numbers in the scanner, since e.g. 0x1e30 is a perfectly legitimate hex constant.
2007-10-15Recognize 'd', 't' and 'y' as radix suffixesH. Peter Anvin1-1/+3
'd', 't' and 'y' now recognized as radix suffixes.
2007-10-11Additional uses of bool and enumH. Peter Anvin1-3/+3
Proper use of bool and enum makes code easier to debug. Do more of it. In particular, we really should stomp out any residual uses of magic constants that aren't enums or, in some cases, even #defines.
2007-10-10saa_fread/fwrite: when seeking, must set [rw]ptr as wellH. Peter Anvin1-0/+2
[rw]ptr represent the global position and need to be kept in sync with [rw]pos:[rw]blk at all times. Failed to do that while seeking, with obviously bad results.
2007-10-10Use the compiler-provided booleans if available, otherwise emulateH. Peter Anvin1-8/+8
Both C and C++ have "bool", "true" and "false" in lower case; C requires <stdbool.h> for this, in C++ it is an inherent type built into the compiler. Use those instead of the old macros; emulate with a simple typedef enum if unavailable.
2007-10-08saa_rstruct: fix overrun checkH. Peter Anvin1-1/+1
The direction of the overrun test in saa_rstruct was backwards.
2007-10-07saa_fpwrite: initializing "len" should be part of the loopH. Peter Anvin1-2/+1
"len" should properly be initialized on every turn of the loop. It can be initialized to any value >= blk_len that fits in a size_t. (size_t)~0 would work except for any possible noncompliant C compilers that have a signed size_t (illegal per C99 7.17.2).
2007-10-07Fix infinite loop in function saa_fpwriteCharles Crayne1-0/+1
2007-10-04Rewrite the handling of SAA's to allow random accessH. Peter Anvin1-134/+163
SAA's were never intended to allow random access, but several backends do random or semirandom access via saa_fread() and saa_fwrite() anyway. Rewrite the SAA system to allow for efficient random access. On "label.pl 10000000" this improves performance by a factor of 12.
2007-10-02Portability fixesH. Peter Anvin1-3/+5
Concentrate compiler dependencies to compiler.h; make sure compiler.h is included first in every .c file (since some prototypes may depend on the presence of feature request macros.) Actually use the conditional inclusion of various functions (totally broken in previous releases.)
2007-09-28Add substitutes for snprintf() and vsnprintf()H. Peter Anvin1-1/+1
To deal with fools^Wpeople trying to keep really old systems alive, create a proper framework for substitution functions, and make it possible to deal with the lack of snprintf/vsnprintf in particular.
2007-09-25Add nasm_zalloc() to nasmlib.cH. Peter Anvin1-8/+23
Add nasm_zalloc(), a wrapper around calloc(), to allocate zero-initialized memory. For large allocations, this is often far more efficient than allocating and zeroing, since the operating system tends to keep a pool of zero pages around.
2007-09-19Make nasm_malloc() et al available from inside ndisasmH. Peter Anvin1-146/+0
Clean up nasmlib to remove functions irrelevant for ndisasm; make nasm_malloc() etc usable inside ndisasm.
2007-08-31Minor cleanup; remove duplication of names.cH. Peter Anvin1-7/+1
2007-08-30Finishing touches on perfect hash tokenizer; actually turn the thing onH. Peter Anvin1-216/+1
Finish the perfect hash tokenizer, and actually enable it. Move stdscan() et al to a separate file, since it's not needed in any of the clients of nasmlib other than nasm itself. Run make alldeps.
2007-08-29nasmlib: add bsii() case-insensitive version of bsi()H. Peter Anvin1-0/+16