mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-09-22 10:43:39 -04:00
NASM 0.98.12
This commit is contained in:
13
assemble.c
13
assemble.c
@@ -59,7 +59,8 @@
|
||||
* as a literal byte in order to aid the disassembler.
|
||||
* \340 - reserve <operand 0> bytes of uninitialised storage.
|
||||
* Operand 0 had better be a segmentless constant.
|
||||
* \370,\371,\372 - match only if operand 0, 1, 2 meets byte jump criteria.
|
||||
* \370,\371,\372 - match only if operand 0 meets byte jump criteria.
|
||||
* 370 is used for Jcc, 371 is used for JMP.
|
||||
* \373 - assemble 0x03 if bits==16, 0x05 if bits==32;
|
||||
* used for conditional jump over longer jump
|
||||
*/
|
||||
@@ -151,9 +152,11 @@ static int jmp_match (long segment, long offset, int bits,
|
||||
unsigned char c = code[0];
|
||||
|
||||
|
||||
if (c != 0370) return 0;
|
||||
if (ins->oprs[0].opflags & OPFLAG_FORWARD) return (!pass0); /* match a forward reference */
|
||||
|
||||
if (c != 0370 && c != 0371) return 0;
|
||||
if (ins->oprs[0].opflags & OPFLAG_FORWARD) {
|
||||
if (optimizing<0 && c==0370) return 1;
|
||||
else return (pass0==0); /* match a forward reference */
|
||||
}
|
||||
isize = calcsize (segment, offset, bits, ins, code);
|
||||
if (ins->oprs[0].segment != segment) return 0;
|
||||
isize = ins->oprs[0].offset - offset - isize; /* isize is now the delta */
|
||||
@@ -546,7 +549,7 @@ static int is_sbyte (insn *ins, int op, int size)
|
||||
int ret;
|
||||
|
||||
ret = !(ins->forw_ref && ins->oprs[op].opflags ) && /* dead in the water on forward reference or External */
|
||||
(optimizing || !(ins->oprs[op].type & (BITS16|BITS32))) &&
|
||||
(optimizing>0 || !(ins->oprs[op].type & (BITS16|BITS32))) &&
|
||||
ins->oprs[op].wrt==NO_SEG && ins->oprs[op].segment==NO_SEG;
|
||||
|
||||
v = ins->oprs[op].offset;
|
||||
|
@@ -479,7 +479,7 @@ IRETW void \320\1\xCF 8086
|
||||
JCXZ imm \310\1\xE3\50 8086
|
||||
JECXZ imm \311\1\xE3\50 386
|
||||
JMP imm|short \1\xEB\50 8086
|
||||
JMP imm \370\1\xEB\50 8086,ND
|
||||
JMP imm \371\1\xEB\50 8086,ND
|
||||
JMP imm \322\1\xE9\64 8086
|
||||
JMP imm|near \322\1\xE9\64 8086,ND
|
||||
JMP imm|far \322\1\xEA\34\37 8086,ND
|
||||
|
16
macros.c
16
macros.c
@@ -1,12 +1,6 @@
|
||||
/* This file auto-generated from standard.mac by macros.pl - don't edit it */
|
||||
|
||||
static char *stdmac[] = {
|
||||
"%idefine IDEAL",
|
||||
"%idefine JUMPS",
|
||||
"%idefine P386",
|
||||
"%idefine P486",
|
||||
"%idefine P586",
|
||||
"%idefine END",
|
||||
"%define __NASM_MAJOR__ 0",
|
||||
"%define __NASM_MINOR__ 98",
|
||||
"%define __FILE__",
|
||||
@@ -63,12 +57,6 @@ static char *stdmac[] = {
|
||||
"%imacro bits 1+.nolist",
|
||||
"[bits %1]",
|
||||
"%endmacro",
|
||||
"%imacro use16 0.nolist",
|
||||
"[bits 16]",
|
||||
"%endmacro",
|
||||
"%imacro use32 0.nolist",
|
||||
"[bits 32]",
|
||||
"%endmacro",
|
||||
"%imacro global 1-*.nolist",
|
||||
"%rep %0",
|
||||
"[global %1]",
|
||||
@@ -81,9 +69,5 @@ static char *stdmac[] = {
|
||||
"%rotate 1",
|
||||
"%endrep",
|
||||
"%endmacro",
|
||||
"%imacro cpu 1+.nolist",
|
||||
"[cpu %1]",
|
||||
"%endmacro",
|
||||
NULL
|
||||
};
|
||||
#define TASM_MACRO_COUNT 6
|
||||
|
@@ -7,7 +7,7 @@
|
||||
# redistributable under the licence given in the file "Licence"
|
||||
# distributed in the NASM archive.
|
||||
|
||||
# use strict; # if your PERL's got it
|
||||
# use strict;
|
||||
|
||||
my $fname;
|
||||
my $line = 0;
|
||||
|
BIN
misc/exasm.zip
BIN
misc/exasm.zip
Binary file not shown.
27
nasm.c
27
nasm.c
@@ -51,7 +51,7 @@ static struct ofmt *ofmt = NULL;
|
||||
static FILE *error_file; /* Where to write error messages */
|
||||
|
||||
static FILE *ofile = NULL;
|
||||
int optimizing = 0; /* number of optimization passes to take */
|
||||
int optimizing = -1; /* number of optimization passes to take */
|
||||
static int sb, cmd_sb = 16; /* by default */
|
||||
static unsigned long cmd_cpu = IF_PLEVEL; /* highest level by default */
|
||||
static unsigned long cpu = IF_PLEVEL; /* passed to insn_size & assemble.c */
|
||||
@@ -386,11 +386,14 @@ static int process_arg (char *p, char *q)
|
||||
else
|
||||
ofmt->current_dfmt = ofmt->debug_formats[0];
|
||||
} else if (p[1]=='O') { /* Optimization level */
|
||||
int opt;
|
||||
if (!isdigit(*param)) report_error(ERR_FATAL,
|
||||
"command line optimization level must be 0..3 or <nn>");
|
||||
optimizing = atoi(param);
|
||||
if (optimizing <= 0) optimizing = 0;
|
||||
else if (optimizing <= 3) optimizing *= 5; /* 5 passes for each level */
|
||||
opt = atoi(param);
|
||||
if (opt<=0) optimizing = -1; /* 0.98 behaviour */
|
||||
else if (opt==1) optimizing = 0; /* Two passes, 0.98.09 behavior */
|
||||
else if (opt<=3) optimizing = opt*5; /* Multiple passes */
|
||||
else optimizing = opt; /* Multiple passes */
|
||||
} else if (p[1]=='P' || p[1]=='p') { /* pre-include */
|
||||
pp_pre_include (param);
|
||||
} else if (p[1]=='D' || p[1]=='d') { /* pre-define */
|
||||
@@ -754,8 +757,8 @@ static void assemble_file (char *fname)
|
||||
report_error(ERR_FATAL, "command line: "
|
||||
"32-bit segment size requires a higher cpu");
|
||||
|
||||
pass_max = optimizing + 2; /* passes 1, optimizing, then 2 */
|
||||
pass0 = !optimizing; /* start at 1 if not optimizing */
|
||||
pass_max = (optimizing>0 ? optimizing : 0) + 2; /* passes 1, optimizing, then 2 */
|
||||
pass0 = !(optimizing>0); /* start at 1 if not optimizing */
|
||||
for (pass = 1; pass <= pass_max && pass0 <= 2; pass++) {
|
||||
int pass1, pass2;
|
||||
ldfunc def_label;
|
||||
@@ -1027,11 +1030,11 @@ static void assemble_file (char *fname)
|
||||
report_error, evaluate,
|
||||
def_label);
|
||||
|
||||
if (!optimizing && pass == 2) {
|
||||
if (!(optimizing>0) && pass == 2) {
|
||||
if (forwref != NULL && globallineno == forwref->lineno) {
|
||||
output_ins.forw_ref = TRUE;
|
||||
do {
|
||||
output_ins.oprs[forwref->operand].opflags|= OPFLAG_FORWARD;
|
||||
output_ins.oprs[forwref->operand].opflags |= OPFLAG_FORWARD;
|
||||
forwref = saa_rstruct (forwrefs);
|
||||
} while (forwref != NULL && forwref->lineno == globallineno);
|
||||
} else
|
||||
@@ -1039,7 +1042,7 @@ static void assemble_file (char *fname)
|
||||
}
|
||||
|
||||
|
||||
if (!optimizing && output_ins.forw_ref)
|
||||
if (!(optimizing>0) && output_ins.forw_ref)
|
||||
{
|
||||
if (pass == 1) {
|
||||
for(i = 0; i < output_ins.operands; i++)
|
||||
@@ -1251,13 +1254,13 @@ static void assemble_file (char *fname)
|
||||
if (pass>1 && !global_offset_changed) {
|
||||
pass0++;
|
||||
if (pass0==2) pass = pass_max - 1;
|
||||
} else if (!optimizing) pass0++;
|
||||
} else if (!(optimizing>0)) pass0++;
|
||||
|
||||
} /* for (pass=1; pass<=2; pass++) */
|
||||
|
||||
nasmlist.cleanup();
|
||||
#if 1
|
||||
if (optimizing && using_debug_info) /* -On and -g switches */
|
||||
if (optimizing>0 && using_debug_info) /* -On and -g switches */
|
||||
fprintf(error_file,
|
||||
"info:: assembly required 1+%d+1 passes\n", pass_cnt-2);
|
||||
#endif
|
||||
@@ -1511,6 +1514,8 @@ static unsigned long get_cpu (char *value)
|
||||
!nasm_stricmp(value, "p2") ) return IF_P6;
|
||||
if (!nasm_stricmp(value, "p3") ||
|
||||
!nasm_stricmp(value, "katmai") ) return IF_KATMAI;
|
||||
if (!nasm_stricmp(value, "p4") || /* is this right? -- jrc */
|
||||
!nasm_stricmp(value, "willamette") ) return IF_WILLAMETTE;
|
||||
|
||||
report_error (pass0<2 ? ERR_NONFATAL : ERR_FATAL, "unknown 'cpu' type");
|
||||
|
||||
|
2
nasm.h
2
nasm.h
@@ -13,7 +13,7 @@
|
||||
|
||||
#define NASM_MAJOR_VER 0
|
||||
#define NASM_MINOR_VER 98
|
||||
#define NASM_VER "0.98.11"
|
||||
#define NASM_VER "0.98.12"
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
|
2
parser.c
2
parser.c
@@ -686,7 +686,7 @@ insn *parse_line (int pass, char *buffer, insn *result,
|
||||
if (is_simple(value)) {
|
||||
if (reloc_value(value)==1)
|
||||
result->oprs[operand].type |= UNITY;
|
||||
if (optimizing) {
|
||||
if (optimizing>0) {
|
||||
if (reloc_value(value) >= -128 &&
|
||||
reloc_value(value) <= 127)
|
||||
result->oprs[operand].type |= SBYTE;
|
||||
|
@@ -917,7 +917,8 @@ delete_Token(Token * t)
|
||||
{
|
||||
Token *next = t->next;
|
||||
nasm_free(t->text);
|
||||
t->next = freeTokens ? freeTokens->next : NULL;
|
||||
/* t->next = freeTokens ? freeTokens->next : NULL; */
|
||||
t->next = freeTokens;
|
||||
freeTokens = t;
|
||||
return next;
|
||||
}
|
||||
|
@@ -1,86 +1,84 @@
|
||||
***************
|
||||
*** 1,4 ****
|
||||
- # $Id$
|
||||
#
|
||||
# Auto-configuring Makefile for RDOFF object file utils; part of the
|
||||
# Netwide Assembler
|
||||
--- 1,4 ----
|
||||
+ # $Id$
|
||||
#
|
||||
# Auto-configuring Makefile for RDOFF object file utils; part of the
|
||||
# Netwide Assembler
|
||||
***************
|
||||
*** 31,37 ****
|
||||
.c.o:
|
||||
# $Id$
|
||||
#
|
||||
# Auto-configuring Makefile for RDOFF object file utils; part of the
|
||||
# Netwide Assembler
|
||||
#
|
||||
# The Netwide Assembler is copyright (C) 1996 Simon Tatham and
|
||||
# Julian Hall. All rights reserved. The software is
|
||||
# redistributable under the licence given in the file "Licence"
|
||||
# distributed in the NASM archive.
|
||||
|
||||
top_srcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
bindir = @bindir@
|
||||
mandir = @mandir@
|
||||
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@ @GCCFLAGS@ -I$(srcdir) -I$(top_srcdir)
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
LN_S = @LN_S@
|
||||
|
||||
LDRDFLIBS = rdoff.o nasmlib.o symtab.o collectn.o rdlib.o segtab.o hash.o
|
||||
RDXLIBS = rdoff.o rdfload.o symtab.o collectn.o hash.o
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
|
||||
- all: rdfdump ldrdf rdx rdflib rdf2bin rdf2com
|
||||
all: rdfdump ldrdf rdx rdflib rdf2bin rdf2com rdf2ihx
|
||||
|
||||
rdfdump: rdfdump.o
|
||||
rdfdump: rdfdump.o
|
||||
$(CC) $(LDFLAGS) -o rdfdump rdfdump.o
|
||||
--- 31,37 ----
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
|
||||
+ all: rdfdump ldrdf rdx rdflib rdf2bin rdf2com rdf2ihx
|
||||
|
||||
rdfdump: rdfdump.o
|
||||
$(CC) $(LDFLAGS) -o rdfdump rdfdump.o
|
||||
***************
|
||||
*** 45,51 ****
|
||||
ldrdf: ldrdf.o $(LDRDFLIBS)
|
||||
$(CC) $(LDFLAGS) -o ldrdf ldrdf.o $(LDRDFLIBS)
|
||||
rdx: rdx.o $(RDXLIBS)
|
||||
$(CC) $(LDFLAGS) -o rdx rdx.o $(RDXLIBS)
|
||||
rdflib: rdflib.o
|
||||
$(CC) $(LDFLAGS) -o rdflib rdflib.o
|
||||
rdf2bin: rdf2bin.o $(RDXLIBS) nasmlib.o
|
||||
$(CC) $(LDFLAGS) -o rdf2bin rdf2bin.o $(RDXLIBS) nasmlib.o
|
||||
rdf2com:
|
||||
rdf2com:
|
||||
rm -f rdf2com && $(LN_S) rdf2bin rdf2com
|
||||
rdf2ihx: rdf2ihx.o $(RDXLIBS) nasmlib.o
|
||||
$(CC) $(LDFLAGS) -o rdf2ihx rdf2ihx.o $(RDXLIBS) nasmlib.o
|
||||
|
||||
rdf2bin.o: rdf2bin.c
|
||||
rdfdump.o: rdfdump.c
|
||||
rdoff.o: rdoff.c rdoff.h
|
||||
--- 45,54 ----
|
||||
$(CC) $(LDFLAGS) -o rdf2bin rdf2bin.o $(RDXLIBS) nasmlib.o
|
||||
rdf2com:
|
||||
rm -f rdf2com && $(LN_S) rdf2bin rdf2com
|
||||
+ rdf2ihx: rdf2ihx.o $(RDXLIBS) nasmlib.o
|
||||
+ $(CC) $(LDFLAGS) -o rdf2ihx rdf2ihx.o $(RDXLIBS) nasmlib.o
|
||||
rdf2ihx.o: rdf2ihx.c
|
||||
rdf2bin.o: rdf2bin.c
|
||||
rdfdump.o: rdfdump.c
|
||||
rdoff.o: rdoff.c rdoff.h
|
||||
ldrdf.o: ldrdf.c rdoff.h $(top_srcdir)/nasmlib.h symtab.h collectn.h rdlib.h
|
||||
symtab.o: symtab.c symtab.h
|
||||
collectn.o: collectn.c collectn.h
|
||||
rdx.o: rdx.c rdoff.h rdfload.h symtab.h
|
||||
rdfload.o: rdfload.c rdfload.h rdoff.h collectn.h symtab.h
|
||||
rdlib.o: rdlib.c rdlib.h
|
||||
rdflib.o: rdflib.c
|
||||
segtab.o: segtab.c
|
||||
|
||||
+ rdf2ihx.o: rdf2ihx.c
|
||||
rdf2bin.o: rdf2bin.c
|
||||
rdfdump.o: rdfdump.c
|
||||
rdoff.o: rdoff.c rdoff.h
|
||||
***************
|
||||
*** 62,78 ****
|
||||
$(CC) -c $(CFLAGS) $(top_srcdir)/nasmlib.c
|
||||
nasmlib.o: $(top_srcdir)/nasmlib.c
|
||||
## $(CC) -c $(CFLAGS) $(top_srcdir)/nasmlib.c
|
||||
cd $(top_srcdir);make nasmlib.o
|
||||
cp $(top_srcdir)/nasmlib.o $(srcdir)
|
||||
|
||||
clean:
|
||||
- rm -f *.o rdfdump ldrdf rdx rdflib rdf2bin rdf2com
|
||||
clean:
|
||||
rm -f *.o rdfdump ldrdf rdx rdflib rdf2bin rdf2com rdf2ihx
|
||||
|
||||
spotless: clean
|
||||
spotless: clean
|
||||
rm -f Makefile
|
||||
|
||||
distclean: spotless
|
||||
distclean: spotless
|
||||
|
||||
- install: rdfdump ldrdf rdx rdflib rdf2bin rdf2com
|
||||
install: rdfdump ldrdf rdx rdflib rdf2bin rdf2com rdf2ihx
|
||||
$(INSTALL_PROGRAM) rdfdump $(INSTALLROOT)$(bindir)/rdfdump
|
||||
$(INSTALL_PROGRAM) ldrdf $(INSTALLROOT)$(bindir)/ldrdf
|
||||
$(INSTALL_PROGRAM) rdx $(INSTALLROOT)$(bindir)/rdx
|
||||
$(INSTALL_PROGRAM) rdflib $(INSTALLROOT)$(bindir)/rdflib
|
||||
$(INSTALL_PROGRAM) rdf2bin $(INSTALLROOT)$(bindir)/rdf2bin
|
||||
cd $(INSTALLROOT)$(bindir) && rm -f rdf2com && $(LN_S) rdf2bin rdf2com
|
||||
--- 65,82 ----
|
||||
$(CC) -c $(CFLAGS) $(top_srcdir)/nasmlib.c
|
||||
|
||||
clean:
|
||||
+ rm -f *.o rdfdump ldrdf rdx rdflib rdf2bin rdf2com rdf2ihx
|
||||
|
||||
spotless: clean
|
||||
rm -f Makefile
|
||||
|
||||
distclean: spotless
|
||||
|
||||
+ install: rdfdump ldrdf rdx rdflib rdf2bin rdf2com rdf2ihx
|
||||
$(INSTALL_PROGRAM) rdfdump $(INSTALLROOT)$(bindir)/rdfdump
|
||||
$(INSTALL_PROGRAM) ldrdf $(INSTALLROOT)$(bindir)/ldrdf
|
||||
$(INSTALL_PROGRAM) rdx $(INSTALLROOT)$(bindir)/rdx
|
||||
$(INSTALL_PROGRAM) rdflib $(INSTALLROOT)$(bindir)/rdflib
|
||||
$(INSTALL_PROGRAM) rdf2bin $(INSTALLROOT)$(bindir)/rdf2bin
|
||||
+ $(INSTALL_PROGRAM) rdf2ihx $(INSTALLROOT)$(bindir)/rdf2ihx
|
||||
$(INSTALL_PROGRAM) rdf2ihx $(INSTALLROOT)$(bindir)/rdf2ihx
|
||||
cd $(INSTALLROOT)$(bindir) && rm -f rdf2com && $(LN_S) rdf2bin rdf2com
|
||||
|
1366
rdoff/ldrdf.c
1366
rdoff/ldrdf.c
File diff suppressed because it is too large
Load Diff
@@ -1,34 +1,56 @@
|
||||
***************
|
||||
*** 26,32 ****
|
||||
; test source file for assembling to binary files
|
||||
; build with:
|
||||
; nasm -f bin -o bintest.com bintest.asm
|
||||
|
||||
; When run (as a DOS .COM file), this program should print
|
||||
; hello, world
|
||||
; on two successive lines, then exit cleanly.
|
||||
|
||||
; This file should test the following:
|
||||
; [1] Define a text-section symbol
|
||||
; [2] Define a data-section symbol
|
||||
; [3] Define a BSS-section symbol
|
||||
; [4] Define a NASM local label
|
||||
; [5] Reference a NASM local label
|
||||
; [6] Reference a text-section symbol in the text section
|
||||
; [7] Reference a data-section symbol in the text section
|
||||
; [8] Reference a BSS-section symbol in the text section
|
||||
; [9] Reference a text-section symbol in the data section
|
||||
; [10] Reference a data-section symbol in the data section
|
||||
; [11] Reference a BSS-section symbol in the data section
|
||||
|
||||
BITS 16
|
||||
ORG 0x100
|
||||
|
||||
SECTION .text
|
||||
|
||||
jmp start ; [6]
|
||||
|
||||
- end mov ax,0x4c00 ; [1]
|
||||
endX mov ax,0x4c00 ; [1]
|
||||
int 0x21
|
||||
|
||||
start mov byte [bss_sym],',' ; [1] [8]
|
||||
--- 26,32 ----
|
||||
|
||||
jmp start ; [6]
|
||||
|
||||
+ endX mov ax,0x4c00 ; [1]
|
||||
start mov byte [bss_sym],',' ; [1] [8]
|
||||
mov bx,[bssptr] ; [7]
|
||||
mov al,[bx]
|
||||
mov bx,[dataptr] ; [7]
|
||||
mov [bx],al
|
||||
mov cx,2
|
||||
.loop mov dx,datasym ; [1] [4] [7]
|
||||
mov ah,9
|
||||
push cx
|
||||
int 0x21
|
||||
pop cx
|
||||
loop .loop ; [5] [6]
|
||||
mov bx,[textptr] ; [7]
|
||||
jmp bx
|
||||
|
||||
start mov byte [bss_sym],',' ; [1] [8]
|
||||
***************
|
||||
*** 49,55 ****
|
||||
datasym db 'hello world', 13, 10, '$' ; [2]
|
||||
bssptr dw bss_sym ; [2] [11]
|
||||
dataptr dw datasym+5 ; [2] [10]
|
||||
- textptr dw end ; [2] [9]
|
||||
|
||||
SECTION .bss
|
||||
|
||||
--- 49,55 ----
|
||||
datasym db 'hello world', 13, 10, '$' ; [2]
|
||||
bssptr dw bss_sym ; [2] [11]
|
||||
dataptr dw datasym+5 ; [2] [10]
|
||||
+ textptr dw endX ; [2] [9]
|
||||
SECTION .data
|
||||
|
||||
datasym db 'hello world', 13, 10, '$' ; [2]
|
||||
bssptr dw bss_sym ; [2] [11]
|
||||
dataptr dw datasym+5 ; [2] [10]
|
||||
textptr dw endX ; [2] [9]
|
||||
|
||||
SECTION .bss
|
||||
|
||||
bss_sym resb 1 ; [3]
|
||||
|
Reference in New Issue
Block a user