Peter Johnson [Thu, 19 Oct 2006 03:21:18 +0000 (03:21 -0000)]
Fix #84: I broke the idiom of concating a decimal number to a register
in the preproc (e.g mm%$x -> mm0) when I implemented a minor optimization
(outputing values in hex to avoid the 2x decimal conversion overhead) in
[1488]. Revert that optimization.
I believe the right way to do this is to add the GAS (and MASM) syntax
sugar of mm(0) etc. to NASM syntax, then any number (not just decimal)
can be used as the new idiom for doing this. But that wouldn't unbreak
programs that already exist, so we're left with this state of affairs.
Sigh.
Peter Johnson [Wed, 18 Oct 2006 04:21:21 +0000 (04:21 -0000)]
Fix handling of CPU flags; the old code would simply take the last CPU
setting in the file and use it against the entire file (oops).
(first half of #83)
Also make the error message a lot nicer, at least for ones we detect early
(shl ax, 2 in 8086 mode still gives the old message).
Peter Johnson [Sat, 7 Oct 2006 17:27:56 +0000 (17:27 -0000)]
Fix error/warnings in the NASM preprocessor to reference the correct line
number, rather than the last parsed line number. Also improve
"cannot reference symbol" error a bit, to include the symbol name.
Peter Johnson [Thu, 5 Oct 2006 06:22:25 +0000 (06:22 -0000)]
Change genmodule to parse through the Makefile (or Makefile.am) looking for YASM_MODULES,
rather than simply taking a list of modules on the command line. This allows significant
improvement of the behavior when used with Visual Studio, as the "old" way of doing this
with Visual Studio build files was to scan through the .c files; this brought up things
that were actually disabled in the build.
Also incorporate a patch by Charles Bailey to make the VC8 build less noisy, and allow use
of Win32 Bison if it's installed. Instructions updated as well.
Peter Johnson [Wed, 4 Oct 2006 04:38:43 +0000 (04:38 -0000)]
Follow-up to #80 and #81: "xchg ax, ax" can use the short 0x90 form as
16-bit operations don't clear the high bits of the 64-bit register, so
this is effectively a NOP as well.
While I'm still looking at this, make "xchg rax, rax" not output a REX
prefix.
I thought about being extra-clever and have "xchg ax, ax" not output an
operand-size prefix, but thought better of it: if the user says "ax"
they're probably going to expect the prefix to be there. Left in as
a comment for future readers of the code.
Peter Johnson [Sat, 30 Sep 2006 05:13:41 +0000 (05:13 -0000)]
Fix #77 by performing symrec-symrec -> subst placeholder transformation
recursively in yasm_expr__bc_dist_subst(); before this we would only do
one level, which fails on simple structures like the old NASM align approach
of "($$-$) & value" (as the $$-$ is one level down in the expression).
Peter Johnson [Fri, 29 Sep 2006 07:18:45 +0000 (07:18 -0000)]
- Fix much brokenness in absolute value handling, particularly in regards to
PC-relative relocations (jumps and calls).
- Allow SEG:OFF to be used as just an offset portion (like NASM does).
- Labels in absolute sections that are declared global are given the correct
absolute value in the symbol table.
One difference from NASM:
label equ 0040h:001eh
jmp label
in NASM means the same as:
jmp 001eh (a near jump)
but yasm will treat this the same as:
jmp 0040h:001eh (a far jump)
I'm still not completely happy with this implementation, but it's workable
and fixes all the bugs I've found so far in absolute handling.
Peter Johnson [Tue, 19 Sep 2006 04:02:38 +0000 (04:02 -0000)]
Remove ancient doc directory.
Also remove float (gdtoa and softfloat) directory, as no one is asking for
floating point calculation, we've never integrated any of this code, and
it's just taking up space (note it's still available on a branch).
Peter Johnson [Sat, 16 Sep 2006 05:43:41 +0000 (05:43 -0000)]
Make out_test.sh smart about 0-byte errwarn output and don't require a
golden errwarn file in this case. This allows us to remove around 150
0-byte .errwarn test files.
Peter Johnson [Sat, 16 Sep 2006 01:36:58 +0000 (01:36 -0000)]
* section.c (yasm_object_optimize): Set active flag to indicate it's already
on QB. We use this flag other places, but forgot to set it here. This
could cause an infinite loop in (rare) situations.
Reported by: Brian Gladman <brg@gladman.plus.com>
(also committed the code he sent that hits this bug as a testcase)
Peter Johnson [Sat, 12 Aug 2006 18:27:04 +0000 (18:27 -0000)]
Fix #58 and a more basic form of this bug (all EAs that needed non-zero
displacement length and required optimization would end up with 0
displacement length, causing an internal error).
Peter Johnson [Tue, 20 Jun 2006 06:23:07 +0000 (06:23 -0000)]
In preparation for further work on optimizing multiple, break multiple apart
from bytecode.len into bytecode.mult_int. Add new function
yasm_bc_next_offset() to handle the most common use case of bytecode.len,
figuring out the following bytecode's offset.
Peter Johnson [Wed, 14 Jun 2006 07:23:49 +0000 (07:23 -0000)]
Implement first cut at optimizer step 2. Limitations:
- Does not detect cycles, so will infinite loop.
- Does not yet handle secondary expansion of bc offset bytecodes.
However, dwarf64_leb128 now generates essentially identical code to GAS
(except GAS generates relocs for in-file function refs, whereas yasm does not)
x86id tests also now work, but have not been checked yet (so no checkin of
new golden results yet).
Peter Johnson [Tue, 13 Jun 2006 06:37:37 +0000 (06:37 -0000)]
Build up interval tree. Change how SPECIAL_BC_OFFSET is handled for better
code commonality. Change optd.spans to a doubly-linked list and delete
directly from it rather than deactivating.
Peter Johnson [Mon, 12 Jun 2006 07:53:49 +0000 (07:53 -0000)]
Move towards building interval tree by splitting dependent value into
sym-sym terms. Starting to get some code duplication that should get
refactored somehow, but the first priority is getting it working.
Peter Johnson [Sun, 11 Jun 2006 20:30:46 +0000 (20:30 -0000)]
x86_bc_insn_expand(): Don't require ea/imm to be abs to expand, and check
span ID.
dwarf32_testhd.hex: New optimizer downsizes .text by 4 bytes, update.
Peter Johnson [Sat, 10 Jun 2006 18:35:36 +0000 (18:35 -0000)]
x86_bc_insn_tobytes(): Fix the case where we get here with imm8 post-op
still enabled; we need to fix up the immlen to 8 (as it's maintained with
the wordsize version up to this point).
Peter Johnson [Sat, 10 Jun 2006 16:54:45 +0000 (16:54 -0000)]
yasm_object_optimize(): Fix error/warning handling by using the new method.
effaddr.asm: Disable now-unsupported construct of [reg*(label2-label)].
x86_bc_insn_calc_len(): Don't destroy NULL intnum.
Peter Johnson [Sat, 10 Jun 2006 08:00:14 +0000 (08:00 -0000)]
Fix all tests with miscomparing object files. Dramatically clean up some
x86 code (mainly x86_checkea_calc_displen(), and parts of
x86_bc_insn_calc_len()) to use new yasm_value_get_intnum().
Allow NULL to be passed as bc to yasm_value_get_intnum() to prevent
calculation of PC-relative values (returning NULL instead).
Peter Johnson [Thu, 8 Jun 2006 04:10:04 +0000 (04:10 -0000)]
Fix cross-reference filename/line number. We were reporting (wrongly) the
virtual line number rather than the physical filename/line number. This
was broken when the errwarn code was changed and not caught because I didn't
check the errwarn results closely enough for this case.
* nasm-token.re, gas-token.re: Propagate warnings from arch early.
This is a case where we probably want the double-error/warning on a single
line.
* errwarn.h: Add xref filename to yasm_print_error_func, and document all
parameters.
* errwarn.c: Get the physical file/line for xref virtual line.
* yasm.c: Update to match new yasm_print_error_func definition.
Peter Johnson [Wed, 7 Jun 2006 04:01:33 +0000 (04:01 -0000)]
Get rid of calc_bc_dist_func, the only times this was used was when
yasm_common_calc_bc_dist was used. Rename yasm_common_calc_bc_dist to
yasm_calc_bc_dist, call it directly from the expr functions, and change
higher-level callers to boolean flags of whether to calculate bc distance
or not.
Peter Johnson [Thu, 1 Jun 2006 06:40:12 +0000 (06:40 -0000)]
Fix use of arithmetic with single-character constants in data declarations.
Multi-character constants are still not valid, as they are somewhat
difficult to handle without adding some sort of string handling into
yasm_expr. This fix may break big-endian targets (we don't have any yet).
* nasm-bison.y: Add new token ONECHARSTR. Add string rule that takes
STRING and ONECHARSTR; use this instead of STRING everywhere but dataval.
In dvexpr, take ONECHARSTR as character constant.
* nasm-token.re: Generate ONECHARSTR for one-character string contants.
Reported by: Robert Riebisch <rr@bttr-software.de>
Peter Johnson [Wed, 31 May 2006 06:13:01 +0000 (06:13 -0000)]
Merge [1333]-[1543] (inclusive) into new-optimizer branch. This results in
a temporary regression of functionality but will yield some benefits later
on (chief among them is easier eventual merging back to the mainline!).
Peter Johnson [Mon, 22 May 2006 06:19:04 +0000 (06:19 -0000)]
* x86parse.gap: Update pushf generation to match popf for legalization and
prefix regarding pushfq vs 64-bit mode.
* pushf.asm, pushf-err.asm: New tests for pushf and popf in all modes.
Peter Johnson [Fri, 12 May 2006 02:12:19 +0000 (02:12 -0000)]
* x86id.c: Add support for 64-bit far jmp/call. These are not listed in the
AMD64 ISA reference but are in the Intel EM64T reference.
* x86arch.h: Add CPU_EM64T flag.
* x86parse.gap: Add CPU_EM64T as feature and enable it as part of "prescott".
* far64.asm: Test for 64-bit far jmp/call.
Peter Johnson [Thu, 11 May 2006 07:00:33 +0000 (07:00 -0000)]
Fix major bug related to multiple handling. Unfortunately this slows down
bytecode multiple output significantly, but this way handles generating
relocations correctly (otherwise extern foo; times 5 dd foo doesn't work!).
* bytecode.h (yasm_bc_tobytes): Remove multiple output parameter.
(yasm_bc_get_multiple): New.
* bytecode.c (yasm_bc_tobytes): Update to iterate through multiple here.
(yasm_bc_get_multiple): New.
* xdf-objfmt.c, elf-objfmt.c, bin-objfmt.c, coff-objfmt.c: Don't iterate
through multiple here.
* nasm-listfmt.c: Use yasm_bc_get_multiple() to get multiple instead of
yasm_bc_tobytes().
* bytecode.pxi: Update.
* tests/win32-relocovfl.asm: Tests both this and [1534] but generates too
huge of a file (3MB) to be put into the automated tests.