summaryrefslogtreecommitdiff
path: root/nasm.c
diff options
context:
space:
mode:
authorVictor van den Elzen <victor.vde@gmail.com>2009-03-31 04:59:44 +0200
committerVictor van den Elzen <victor.vde@gmail.com>2010-07-24 22:00:12 +0200
commitac732cb6a599836bf4c988e59ac6de4498758c72 (patch)
tree9983e099a978cd40786f9529eb687a6d5a14d265 /nasm.c
parent088d151130b427367766057feadd8351e03ee19b (diff)
downloadnasm-ac732cb6a599836bf4c988e59ac6de4498758c72.tar.gz
Improve process_ea and introduce -OL
Two fixes: 1. Optimization of [bx+0xFFFF] etc 0xFFFF is an sbyte under 16-bit semantics, so make sure to check it right. 2. Don't optimize displacements in -O0 Displacements that fit into an sbyte or can be removed should *not* be optimized in -O0. Implicit zero displacements are still optimized, e.g.: [eax] -> 0 bit displacement, [ebp] -> 8 bit displacement. However explicit displacements are not optimized: [eax+0] -> 32 bit displacement, [ebp+0] -> 32 bit displacement. Because #2 breaks compatibility with 0.98, I introduced a new optimization level: -OL, legacy.
Diffstat (limited to 'nasm.c')
-rw-r--r--nasm.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/nasm.c b/nasm.c
index 7a63afb8..f6a710a4 100644
--- a/nasm.c
+++ b/nasm.c
@@ -674,14 +674,22 @@ static bool process_arg(char *p, char *q)
case '5': case '6': case '7': case '8': case '9':
opt = strtoul(param, &param, 10);
- /* -O0 -> optimizing == -1, 0.98 behaviour */
- /* -O1 -> optimizing == 0, 0.98.09 behaviour */
- if (opt < 2)
- optimizing = opt - 1;
+ if (opt == 0)
+ /* no optimization */
+ optimizing = -2;
+ else if (opt == 1)
+ /* 0.98.09 behaviour */
+ optimizing = 0;
else
optimizing = opt;
break;
+ case 'L':
+ /* 0.98 behaviour */
+ param++;
+ optimizing = -1;
+ break;
+
case 'v':
case '+':
param++;
@@ -783,10 +791,11 @@ static bool process_arg(char *p, char *q)
" -F format select a debugging format\n\n"
" -I<path> adds a pathname to the include file path\n");
printf
- (" -O<digit> optimize branch offsets\n"
- " -O0: No optimization (default)\n"
+ (" -O<digit> optimize code size\n"
+ " -O0: No optimization\n"
+ " -OL: Legacy optimization\n"
" -O1: Minimal optimization\n"
- " -Ox: Multipass optimization (recommended)\n\n"
+ " -Ox: Full optimization (default)\n\n"
" -P<file> pre-includes a file\n"
" -D<macro>[=<value>] pre-defines a macro\n"
" -U<macro> undefines a macro\n"