From 4d083eb86c1055c201f3f82e80b0ff4a7e49cb66 Mon Sep 17 00:00:00 2001 From: MaartenBrock Date: Sun, 29 Oct 2006 16:29:34 +0000 Subject: [PATCH] * as/asx8051.dsp: corrected output directories * as/link/hc08: new directory for hc08 linker * as/hc08/aslink.h, as/link/aslink.h, * as/hc08/aslink.mak, as/link/hc08/aslink.mak, * as/hc08/clean.mk, as/link/hc08/clean.mk, * as/hc08/link_hc08.dsp, as/link/hc08/link_hc08.dsp, * as/hc08/lkaomf51.c, as/link/hc08/lkaomf51.c, * as/hc08/lkarea.c, as/link/hc08/lkarea.c, * as/hc08/lkdata.c, as/link/hc08/lkdata.c, * as/hc08/lkelf.c, as/link/hc08/lkelf.c, * as/hc08/lkihx.c, as/link/hc08/lkihx.c, * as/hc08/lklibr.c, as/link/hc08/lklibr.c, * as/hc08/lkmain.c, as/link/hc08/lkmain.c, * as/hc08/lkmem.c, as/link/hc08/lkmem.c, * as/hc08/lkrloc.c, as/link/hc08/lkrloc.c, * as/hc08/lks19.c, as/link/hc08/lks19.c, * as/hc08/Makefile.aslink, as/link/hc08/Makefile.aslink, * as/hc08/Makefile.bcc, as/link/hc08/Makefile.bcc, * as/hc08/Makefile.in, as/link/hc08/Makefile.in, * as/link/hc08/conf.mk, * configure, * configure.in, * Makefile.in, * sdcc.dsw: moved hc08 linker to as/link/hc08 * as/hc08/lkeval.c, as/link/mcs51/lkeval.c, as/link/lkeval.c, * as/hc08/lkhead.c, as/link/mcs51/lkhead.c, as/link/lkhead.c, * as/hc08/lklex.c, as/link/mcs51/lklex.c, as/link/lklex.c, * as/hc08/lklist.c, as/link/mcs51/lklist.c, as/link/lklist.c, * as/hc08/lknoice.c, as/link/mcs51/lknoice.c, as/link/lknoice.c, * as/hc08/lksym.c, as/link/mcs51/lksym.c, as/link/lksym.c, * as/link/mcs51/aslink.dsp, * as/link/mcs51/Makefile.in: factored out the common files * as/hc08/lkstore.c: deleted, use the one already in as/link/ * as/clean.mk: extra cleaning common files * as/link/mcs51/strcmpi.c, as/strcmpi.c: moved * as/link/mcs51/strcmpi.h: deleted, moved protoype to aslink.h * as/mcs51/asm.h: include sdccconf.h or sdcc_vc.h git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4442 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 44 +- Makefile.in | 2 +- as/asx8051.dsp | 16 +- as/clean.mk | 4 + as/hc08/Makefile.bcc | 11 +- as/hc08/Makefile.in | 16 +- as/hc08/aslink.h | 783 -------------------- as/hc08/clean.mk | 2 +- as/hc08/lkhead.c | 153 ---- as/hc08/lklex.c | 640 ---------------- as/hc08/lknoice.c | 246 ------- as/hc08/lkstore.c | 50 -- as/hc08/lksym.c | 488 ------------ as/link/aslink.h | 4 +- as/{ => link}/hc08/Makefile.aslink | 0 as/link/hc08/Makefile.bcc | 20 + as/link/hc08/Makefile.in | 114 +++ as/{ => link}/hc08/aslink.mak | 0 as/link/hc08/clean.mk | 25 + as/link/hc08/conf.mk | 10 + as/{ => link}/hc08/link_hc08.dsp | 229 +----- as/{ => link}/hc08/lkaomf51.c | 0 as/{ => link}/hc08/lkarea.c | 49 +- as/{ => link}/hc08/lkdata.c | 2 +- as/{ => link}/hc08/lkelf.c | 0 as/{ => link}/hc08/lkihx.c | 0 as/{ => link}/hc08/lklibr.c | 7 +- as/{ => link}/hc08/lkmain.c | 25 +- as/{ => link}/hc08/lkmem.c | 3 +- as/{ => link}/hc08/lkrloc.c | 84 +-- as/{ => link}/hc08/lks19.c | 0 as/{hc08 => link}/lkeval.c | 0 as/link/{mcs51 => }/lkhead.c | 1 + as/link/{mcs51 => }/lklex.c | 0 as/{hc08 => link}/lklist.c | 0 as/link/{mcs51 => }/lknoice.c | 0 as/link/{mcs51 => }/lksym.c | 0 as/link/mcs51/Makefile.in | 13 +- as/link/mcs51/aslink.dsp | 42 +- as/link/mcs51/lkeval.c | 396 ---------- as/link/mcs51/lklist.c | 1099 ---------------------------- as/link/mcs51/strcmpi.h | 3 - as/mcs51/asm.h | 14 + as/{link/mcs51 => }/strcmpi.c | 1 - configure | 3 +- configure.in | 3 +- sdcc.dsw | 2 +- 47 files changed, 364 insertions(+), 4240 deletions(-) delete mode 100644 as/hc08/aslink.h delete mode 100644 as/hc08/lkhead.c delete mode 100644 as/hc08/lklex.c delete mode 100644 as/hc08/lknoice.c delete mode 100644 as/hc08/lkstore.c delete mode 100644 as/hc08/lksym.c rename as/{ => link}/hc08/Makefile.aslink (100%) create mode 100644 as/link/hc08/Makefile.bcc create mode 100644 as/link/hc08/Makefile.in rename as/{ => link}/hc08/aslink.mak (100%) create mode 100644 as/link/hc08/clean.mk create mode 100644 as/link/hc08/conf.mk rename as/{ => link}/hc08/link_hc08.dsp (52%) rename as/{ => link}/hc08/lkaomf51.c (100%) rename as/{ => link}/hc08/lkarea.c (94%) rename as/{ => link}/hc08/lkdata.c (99%) rename as/{ => link}/hc08/lkelf.c (100%) rename as/{ => link}/hc08/lkihx.c (100%) rename as/{ => link}/hc08/lklibr.c (98%) rename as/{ => link}/hc08/lkmain.c (98%) rename as/{ => link}/hc08/lkmem.c (99%) rename as/{ => link}/hc08/lkrloc.c (97%) rename as/{ => link}/hc08/lks19.c (100%) rename as/{hc08 => link}/lkeval.c (100%) rename as/link/{mcs51 => }/lkhead.c (99%) rename as/link/{mcs51 => }/lklex.c (100%) rename as/{hc08 => link}/lklist.c (100%) rename as/link/{mcs51 => }/lknoice.c (100%) rename as/link/{mcs51 => }/lksym.c (100%) delete mode 100644 as/link/mcs51/lkeval.c delete mode 100644 as/link/mcs51/lklist.c delete mode 100644 as/link/mcs51/strcmpi.h rename as/{link/mcs51 => }/strcmpi.c (96%) diff --git a/ChangeLog b/ChangeLog index bafc801c..121a959b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,43 @@ +2006-10-29 Maarten Brock + + * as/asx8051.dsp: corrected output directories + * as/link/hc08: new directory for hc08 linker + * as/hc08/aslink.h, as/link/aslink.h, + * as/hc08/aslink.mak, as/link/hc08/aslink.mak, + * as/hc08/clean.mk, as/link/hc08/clean.mk, + * as/hc08/link_hc08.dsp, as/link/hc08/link_hc08.dsp, + * as/hc08/lkaomf51.c, as/link/hc08/lkaomf51.c, + * as/hc08/lkarea.c, as/link/hc08/lkarea.c, + * as/hc08/lkdata.c, as/link/hc08/lkdata.c, + * as/hc08/lkelf.c, as/link/hc08/lkelf.c, + * as/hc08/lkihx.c, as/link/hc08/lkihx.c, + * as/hc08/lklibr.c, as/link/hc08/lklibr.c, + * as/hc08/lkmain.c, as/link/hc08/lkmain.c, + * as/hc08/lkmem.c, as/link/hc08/lkmem.c, + * as/hc08/lkrloc.c, as/link/hc08/lkrloc.c, + * as/hc08/lks19.c, as/link/hc08/lks19.c, + * as/hc08/Makefile.aslink, as/link/hc08/Makefile.aslink, + * as/hc08/Makefile.bcc, as/link/hc08/Makefile.bcc, + * as/hc08/Makefile.in, as/link/hc08/Makefile.in, + * as/link/hc08/conf.mk, + * configure, + * configure.in, + * Makefile.in, + * sdcc.dsw: moved hc08 linker to as/link/hc08 + * as/hc08/lkeval.c, as/link/mcs51/lkeval.c, as/link/lkeval.c, + * as/hc08/lkhead.c, as/link/mcs51/lkhead.c, as/link/lkhead.c, + * as/hc08/lklex.c, as/link/mcs51/lklex.c, as/link/lklex.c, + * as/hc08/lklist.c, as/link/mcs51/lklist.c, as/link/lklist.c, + * as/hc08/lknoice.c, as/link/mcs51/lknoice.c, as/link/lknoice.c, + * as/hc08/lksym.c, as/link/mcs51/lksym.c, as/link/lksym.c, + * as/link/mcs51/aslink.dsp, + * as/link/mcs51/Makefile.in: factored out the common files + * as/hc08/lkstore.c: deleted, use the one already in as/link/ + * as/clean.mk: extra cleaning common files + * as/link/mcs51/strcmpi.c, as/strcmpi.c: moved + * as/link/mcs51/strcmpi.h: deleted, moved protoype to aslink.h + * as/mcs51/asm.h: include sdccconf.h or sdcc_vc.h + 2006-10-29 Raphael Neider * src/pic/ralloc.c (newReg): create aliases for registers with @@ -19,12 +59,12 @@ * device/lib/_putchar.c, device/lib/_getchar.c, device/lib/inituart.c: Removed. - + 2006-10-26 Jesus Calvino-Fraga * device/lib/_putchar.c, device/lib/_getchar.c, device/lib/inituart.c: Initialize uart only if SM0 and SM1 are zero. Also, use flag to turn - on/off CR to CRLF conversion. + on/off CR to CRLF conversion. 2006-10-25 Frieder Ferlemann diff --git a/Makefile.in b/Makefile.in index 54f76486..43da4eac 100644 --- a/Makefile.in +++ b/Makefile.in @@ -21,7 +21,7 @@ SDCC_PACKIHX = support/packihx SDCC_LIBRARIAN = support/librarian ifeq ($(OPT_DISABLE_HC08), 0) -SDCC_ASLINK += as/hc08 +SDCC_ASLINK += as/hc08 as/link/hc08 endif ifeq ($(OPT_DISABLE_MCS51), 0) diff --git a/as/asx8051.dsp b/as/asx8051.dsp index c6683405..f59aa2f4 100644 --- a/as/asx8051.dsp +++ b/as/asx8051.dsp @@ -32,13 +32,13 @@ RSC=rc.exe # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "xa51\Debug" -# PROP BASE Intermediate_Dir "xa51\Debug" +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 -# PROP Output_Dir "xa51\Debug" -# PROP Intermediate_Dir "xa51\Debug" +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FR /FD /GZ /c @@ -56,14 +56,14 @@ LINK32=link.exe # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "xa51\Release" -# PROP BASE Intermediate_Dir "xa51\Release" +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" # PROP BASE Ignore_Export_Lib 0 # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 -# PROP Output_Dir "xa51\Release" -# PROP Intermediate_Dir "xa51\Release" +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FD /c diff --git a/as/clean.mk b/as/clean.mk index ee9489db..5d9b58fe 100644 --- a/as/clean.mk +++ b/as/clean.mk @@ -1,5 +1,9 @@ clean: $(MAKE) -C z80 clean BUILDDIR=$(BUILDDIR) + rm -f *core *[%~] *.[oa] + rm -f .[a-z]*~ + rm -f *.dep + rm -rf obj distclean: $(MAKE) -C z80 distclean BUILDDIR=$(BUILDDIR) diff --git a/as/hc08/Makefile.bcc b/as/hc08/Makefile.bcc index b30978c4..a621c679 100644 --- a/as/hc08/Makefile.bcc +++ b/as/hc08/Makefile.bcc @@ -8,18 +8,9 @@ ASOBJECTS = asmain.obj aslex.obj assym.obj assubr.obj asnoice.obj \ asexpr.obj asdata.obj aslist.obj asout.obj asstore.obj \ h08ext.obj h08pst.obj h08mch.obj h08adr.obj strcmpi.obj -LKOBJECTS = lkmain.obj lkhead.obj lkarea.obj lkdata.obj \ - lkeval.obj lklex.obj lksym.obj lkrloc.obj \ - lklibr.obj lklist.obj lkihx.obj lks19.obj \ - lkstore.obj lknoice.obj lkmem.obj lkaomf51.obj strcmpi.obj - ASX8051 = $(PRJDIR)/bin/asx8051.exe -ASLINK = $(PRJDIR)/bin/aslink.exe -all: $(ASX8051) $(ASLINK) +all: $(ASX8051) $(ASX8051): $(ASOBJECTS) $(CC) $(CFLAGS) -e$@ $(ASOBJECTS) - -$(ASLINK): $(LKOBJECTS) - $(CC) $(CFLAGS) -e$@ $(LKOBJECTS) diff --git a/as/hc08/Makefile.in b/as/hc08/Makefile.in index 799da3d3..d5186282 100644 --- a/as/hc08/Makefile.in +++ b/as/hc08/Makefile.in @@ -42,14 +42,7 @@ ASOBJECTS = asmain.o aslex.o assym.o assubr.o asnoice.o \ m08ext.o m08pst.o m08mch.o m08adr.o strcmpi.o ASSOURCES = $(patsubst %.o,%.c,$(ASOBJECTS)) -LKOBJECTS = lkmain.o lkhead.o lkarea.o lkdata.o \ - lkeval.o lklex.o lksym.o lkrloc.o \ - lklibr.o lklist.o lkihx.o lks19.o lkelf.o \ - lkstore.o lknoice.o lkmem.o lkaomf51.o strcmpi.o -LKSOURCES = $(patsubst %.o,%.c,$(LKOBJECTS)) - ASHC08 = $(top_builddir)bin/as-hc08$(EXEEXT) -ASLINK = $(top_builddir)bin/link-hc08$(EXEEXT) transform = @program_transform_name@ @@ -60,21 +53,16 @@ all: checkconf $(ASHC08) $(ASLINK) $(ASHC08): $(ASOBJECTS) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(ASOBJECTS) -$(ASLINK): $(LKOBJECTS) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(LKOBJECTS) - # Compiling and installing everything and runing test # --------------------------------------------------- install: all installdirs $(INSTALL) $(ASHC08) `echo $(DESTDIR)$(bindir)/as-hc08$(EXEEXT)|sed '$(transform)'` $(STRIP) `echo $(DESTDIR)$(bindir)/as-hc08$(EXEEXT)|sed '$(transform)'` - $(INSTALL) $(ASLINK) `echo $(DESTDIR)$(bindir)/link-hc08$(EXEEXT)|sed '$(transform)'` - $(STRIP) `echo $(DESTDIR)$(bindir)/link-hc08$(EXEEXT)|sed '$(transform)'` # Deleting all the installed files # -------------------------------- uninstall: - rm -f $(DESTDIR)$(bindir)/as-hc08$(EXEEXT) $(DESTDIR)$(bindir)/link-hc08$(EXEEXT) + rm -f $(DESTDIR)$(bindir)/as-hc08$(EXEEXT) # Performing self-test @@ -97,7 +85,7 @@ installdirs: # --------------------- dep: Makefile.dep -Makefile.dep: $(ASSOURCES) $(LKSOURCES) $(srcdir)/*.h $(top_builddir)*.h $(top_srcdir)/*.h +Makefile.dep: $(ASSOURCES) $(srcdir)/*.h $(top_builddir)*.h $(top_srcdir)/*.h $(CPP) $(CPPFLAGS) $(M_OR_MM) $(filter %.c,$^) >Makefile.dep ifeq "$(findstring $(MAKECMDGOALS),uninstall check installcheck installdirs \ diff --git a/as/hc08/aslink.h b/as/hc08/aslink.h deleted file mode 100644 index a3c0ea79..00000000 --- a/as/hc08/aslink.h +++ /dev/null @@ -1,783 +0,0 @@ -/* aslink.h */ - -/* - * (C) Copyright 1989-1995 - * All Rights Reserved - * - * Alan R. Baldwin - * 721 Berkeley St. - * Kent, Ohio 44240 - * - * 28-Oct-97 JLH: - * - add proto for StoreString - * - change s_id from [NCPS] to pointer - * - change NCPS to 80 - * - case sensitive - * - add R_J11 for 8051 assembler - * 31-Oct-97 JLH: - * - add jflag and jfp for NoICE output - * 30-Jan-98 JLH: - * - add memory space flags to a_flag for 8051 - */ - -#define VERSION "V01.70 + NoICE + SDCC Feb 1999" - -/* - * Case Sensitivity Flag - */ -#define CASE_SENSITIVE 1 - -/*)Module asmlnk.h - * - * The module asmlnk.h contains the definitions for constants, - * structures, global variables, and LKxxxx functions - * contained in the LKxxxx.c files. - */ - -/*)BUILD - $(PROGRAM) = ASLINK - $(INCLUDE) = ASLINK.H - $(FILES) = { - LKMAIN.C - LKLEX.C - LKAREA.C - LKHEAD.C - LKSYM.C - LKEVAL.C - LKDATA.C - LKLIST.C - LKRLOC.C - LKLIBR.C - LKS19.C - LKIHX.C - } - $(STACK) = 2000 -*/ - -/* DECUS C void definition */ -/* File/extension seperator */ - -#ifdef decus -#define VOID char -#define FSEPX '.' -#endif - -/* PDOS C void definition */ -/* File/extension seperator */ - -#ifdef PDOS -#define VOID char -#define FSEPX ':' -#endif - -/* Default void definition */ -/* File/extension seperator */ - -#ifndef VOID -#define VOID void -#define FSEPX '.' -#define OTHERSYSTEM -#endif - -/* - * PATH_MAX - */ -#include -#ifndef PATH_MAX /* POSIX, but not required */ - #if defined(__BORLANDC__) || defined(_MSC_VER) - #include - #define PATH_MAX _MAX_PATH - #else - #define PATH_MAX 255 /* define a reasonable value */ - #endif -#endif - -/* - * This file defines the format of the - * relocatable binary file. - */ - -#define NCPS 80 /* characters per symbol (JLH: change from 8) */ -#define NDATA 16 /* actual data */ -#define NINPUT PATH_MAX /* Input buffer size */ -#define NHASH 64 /* Buckets in hash table */ -#define HMASK 077 /* Hash mask */ -#define NLPP 60 /* Lines per page */ -#define NTXT 16 /* T values */ - -/* - * The "R_" relocation constants define values used in - * generating the assembler relocation output data for - * areas, symbols, and code. - * - * - * Relocation types. - * - * 7 6 5 4 3 2 1 0 - * +-----+-----+-----+-----+-----+-----+-----+-----+ - * | MSB | PAGn| PAG0| USGN| BYT2| PCR | SYM | BYT | - * +-----+-----+-----+-----+-----+-----+-----+-----+ - */ - -#define R_WORD 0x00 /* 16 bit */ -#define R_BYTE 0x01 /* 8 bit */ - -#define R_AREA 0x00 /* Base type */ -#define R_SYM 0x02 - -#define R_NORM 0x00 /* PC adjust */ -#define R_PCR 0x04 - -#define R_BYT1 0x00 /* Byte count for R_BYTE = 1 */ -#define R_BYT2 0x08 /* Byte count for R_BYTE = 2 */ - -#define R_SGND 0x00 /* Signed Byte */ -#define R_USGN 0x10 /* Unsigned Byte */ - -#define R_NOPAG 0x00 /* Page Mode */ -#define R_PAG0 0x20 /* Page '0' */ -#define R_PAG 0x40 /* Page 'nnn' */ - -#define R_LSB 0x00 /* low byte */ -#define R_MSB 0x80 /* high byte */ - -#define R_BYT3 0x100 /* if R_BYTE is set, this is a - * 3 byte address, of which - * the linker must select one byte. - */ -#define R_HIB 0x200 /* If R_BYTE & R_BYT3 are set, linker - * will select byte 3 of the relocated - * 24 bit address. - */ - -#define R_J11 (R_WORD|R_BYT2) /* JLH: 11 bit JMP and CALL (8051) */ -#define R_J19 (R_WORD|R_BYT2|R_MSB) /* 19 bit JMP/CALL (DS80C390) */ -#define R_C24 (R_WORD|R_BYT1|R_MSB) /* 24 bit address (DS80C390) */ -#define R_J19_MASK (R_BYTE|R_BYT2|R_MSB) - -#define IS_R_J19(x) (((x) & R_J19_MASK) == R_J19) -#define IS_R_J11(x) (((x) & R_J19_MASK) == R_J11) -#define IS_C24(x) (((x) & R_J19_MASK) == R_C24) - -#define R_ESCAPE_MASK 0xf0 /* Used to escape relocation modes - * greater than 0xff in the .rel - * file. - */ - -/* - * Global symbol types. - */ -#define S_REF 1 /* referenced */ -#define S_DEF 2 /* defined */ - -/* - * Area type flags - */ -#define A_CON 0000 /* concatenate */ -#define A_OVR 0004 /* overlay */ -#define A_REL 0000 /* relocatable */ -#define A_ABS 0010 /* absolute */ -#define A_NOPAG 0000 /* non-paged */ -#define A_PAG 0020 /* paged */ - -/* Additional flags for 8051 address spaces */ -#define A_DATA 0000 /* data space (default)*/ -#define A_CODE 0040 /* code space */ -#define A_XDATA 0100 /* external data space */ -#define A_BIT 0200 /* bit addressable space */ - -#define A_NOLOAD 0400 /* nonloadable */ -#define A_LOAD 0000 /* loadable (default) */ - -/* - * File types - */ -#define F_STD 1 /* stdin */ -#define F_LNK 2 /* File.lnk */ -#define F_REL 3 /* File.rel */ - -/* - * General assembler address type - */ -typedef unsigned int Addr_T; - -/* - * The structures of head, area, areax, and sym are created - * as the REL files are read during the first pass of the - * linker. The struct head is created upon encountering a - * H directive in the REL file. The structure contains a - * link to a link file structure (struct lfile) which describes - * the file containing the H directive, the number of data/code - * areas contained in this header segment, the number of - * symbols referenced/defined in this header segment, a pointer - * to an array of pointers to areax structures (struct areax) - * created as each A directive is read, and a pointer to an - * array of pointers to symbol structures (struct sym) for - * all referenced/defined symbols. As H directives are read - * from the REL files a linked list of head structures is - * created by placing a link to the new head structure - * in the previous head structure. - */ -struct head -{ - struct head *h_hp; /* Header link */ - struct lfile *h_lfile;/* Associated file */ - int h_narea; /* # of areas */ - struct areax **a_list; /* Area list */ - int h_nglob; /* # of global symbols */ - struct sym **s_list; /* Globle symbol list */ - char m_id[NCPS]; /* Module name */ -}; - -/* - * A structure area is created for each 'unique' data/code - * area definition found as the REL files are read. The - * struct area contains the name of the area, a flag byte - * which contains the area attributes (REL/CON/OVR/ABS), - * an area subtype (not used in this assembler), and the - * area base address and total size which will be filled - * in at the end of the first pass through the REL files. - * As A directives are read from the REL files a linked - * list of unique area structures is created by placing a - * link to the new area structure in the previous area structure. - */ -struct area -{ - struct area *a_ap; /* Area link */ - struct areax *a_axp; /* Area extension link */ - Addr_T a_addr; /* Beginning address of area */ - Addr_T a_size; /* Total size of the area */ - char a_type; /* Area subtype */ - int a_flag; /* Flag byte */ - char a_id[NCPS]; /* Name */ - char *a_image; - char *a_used; -}; - -/* - * An areax structure is created for every A directive found - * while reading the REL files. The struct areax contains a - * link to the 'unique' area structure referenced by the A - * directive and to the head structure this area segment is - * a part of. The size of this area segment as read from the - * A directive is placed in the areax structure. The beginning - * address of this segment will be filled in at the end of the - * first pass through the REL files. As A directives are read - * from the REL files a linked list of areax structures is - * created for each unique area. The final areax linked - * list has at its head the 'unique' area structure linked - * to the linked areax structures (one areax structure for - * each A directive for this area). - */ -struct areax -{ - struct areax *a_axp; /* Area extension link */ - struct area *a_bap; /* Base area link */ - struct head *a_bhp; /* Base header link */ - Addr_T a_addr; /* Beginning address of section */ - Addr_T a_size; /* Size of the area in section */ -}; - -/* - * A sym structure is created for every unique symbol - * referenced/defined while reading the REL files. The - * struct sym contains the symbol's name, a flag value - * (not used in this linker), a symbol type denoting - * referenced/defined, and an address which is loaded - * with the relative address within the area in which - * the symbol was defined. The sym structure also - * contains a link to the area where the symbol was defined. - * The sym structures are linked into linked lists using - * the symbol link element. - */ -struct sym -{ - struct sym *s_sp; /* Symbol link */ - struct areax *s_axp; /* Symbol area link */ - char s_type; /* Symbol subtype */ - char s_flag; /* Flag byte */ - Addr_T s_addr; /* Address */ - char *s_id; /* Name: JLH change from [NCPS] */ -}; - -/* - * The structure lfile contains a pointer to a - * file specification string, the file type, and - * a link to the next lfile structure. - */ -struct lfile -{ - struct lfile *f_flp; /* lfile link */ - int f_type; /* File type */ - char *f_idp; /* Pointer to file spec */ -}; - -/* - * The struct base contains a pointer to a - * base definition string and a link to the next - * base structure. - */ -struct base -{ - struct base *b_base; /* Base link */ - char *b_strp; /* String pointer */ -}; - -/* - * The struct globl contains a pointer to a - * global definition string and a link to the next - * global structure. - */ -struct globl -{ - struct globl *g_globl; /* Global link */ - char *g_strp; /* String pointer */ -}; - -/* - * A structure sdp is created for each 'unique' paged - * area definition found as the REL files are read. - * As P directives are read from the REL files a linked - * list of unique sdp structures is created by placing a - * link to the new sdp structure in the previous area structure. - */ -struct sdp -{ - struct area *s_area; /* Paged Area link */ - struct areax *s_areax; /* Paged Area Extension Link */ - Addr_T s_addr; /* Page address offset */ -}; - -/* - * The structure rerr is loaded with the information - * required to report an error during the linking - * process. The structure contains an index value - * which selects the areax structure from the header - * areax structure list, a mode value which selects - * symbol or area relocation, the base address in the - * area section, an area/symbol list index value, and - * an area/symbol offset value. - */ -struct rerr -{ - int aindex; /* Linking area */ - int mode; /* Relocation mode */ - Addr_T rtbase; /* Base address in section */ - int rindex; /* Area/Symbol reloaction index */ - Addr_T rval; /* Area/Symbol offset value */ -}; - -/* - * The structure lbpath is created for each library - * path specification input by the -k option. The - * lbpath structures are linked into a list using - * the next link element. - */ -struct lbpath { - struct lbpath *next; - char *path; -}; - -/* - * The structure lbname is created for all combinations of the - * library path specifications (input by the -k option) and the - * library file specifications (input by the -l option) that - * lead to an existing file. The element path points to - * the path string, element libfil points to the library - * file string, and the element libspc is the concatenation - * of the valid path and libfil strings. - * - * The lbpath structures are linked into a list - * using the next link element. - * - * Each library file contains a list of object files - * that are contained in the particular library. e.g.: - * - * \iolib\termio - * \inilib\termio - * - * Only one specification per line is allowed. - */ -struct lbname { - struct lbname *next; - char *path; - char *libfil; - char *libspc; -}; - -/* - * The function fndsym() searches through all combinations of the - * library path specifications (input by the -k option) and the - * library file specifications (input by the -l option) that - * lead to an existing file for a symbol definition. - * - * The structure lbfile is created for the first library - * object file which contains the definition for the - * specified undefined symbol. - * - * The element libspc points to the library file path specification - * and element relfil points to the object file specification string. - * The element filspc is the complete path/file specification for - * the library file to be imported into the linker. The - * file specicifation may be formed in one of two ways: - * - * (1) If the library file contained an absolute - * path/file specification then this becomes filspc. - * (i.e. C:\...) - * - * (2) If the library file contains a relative path/file - * specification then the concatenation of the path - * and this file specification becomes filspc. - * (i.e. \...) - * - * The lbpath structures are linked into a list - * using the next link element. - */ -struct lbfile { - struct lbfile *next; - char *libspc; - char *relfil; - char *filspc; - long offset; /*>=0 if rel file is embedded in a lib file at this offset*/ -}; - -/* - * External Definitions for all Global Variables - */ - -extern char *_abs_; /* = { ". .ABS." }; - */ -extern int lkerr; /* ASLink error flag - */ -extern char *ip; /* pointer into the REL file - * text line in ib[] - */ -extern char ib[NINPUT]; /* REL file text line - */ -extern char *rp; /* pointer into the LST file - * text line in rb[] - */ -extern char rb[NINPUT]; /* LST file text line being - * address relocated - */ -extern unsigned char ctype[]; /* array of character types, one per - * ASCII character - */ - -extern char sdccopt[NINPUT]; -extern char sdccopt_module[NINPUT]; -extern char curr_module[NINPUT]; - -/* - * Character Type Definitions - */ -#define SPACE 0000 -#define ETC 0000 -#define LETTER 0001 -#define DIGIT 0002 -#define BINOP 0004 -#define RAD2 0010 -#define RAD8 0020 -#define RAD10 0040 -#define RAD16 0100 -#define ILL 0200 - -#define DGT2 DIGIT|RAD16|RAD10|RAD8|RAD2 -#define DGT8 DIGIT|RAD16|RAD10|RAD8 -#define DGT10 DIGIT|RAD16|RAD10 -#define LTR16 LETTER|RAD16 - -#if CASE_SENSITIVE -#else -extern char ccase[]; /* an array of characters which - * perform the case translation function - */ -#endif - -extern struct lfile *filep; /* The pointers (lfile *) filep, - * (lfile *) cfp, and (FILE *) sfp - * are used in conjunction with - * the routine as_getline() to read - * asmlnk commands from - * (1) the standard input or - * (2) or a command file - * and to read the REL files - * sequentially as defined by the - * asmlnk input commands. - * - * The pointer *filep points to the - * beginning of a linked list of - * lfile structures. - */ -extern struct lfile *cfp; /* The pointer *cfp points to the - * current lfile structure - */ -extern struct lfile *startp;/* asmlnk startup file structure - */ -extern struct lfile *linkp; /* pointer to first lfile structure - * containing an input REL file - * specification - */ -extern struct lfile *lfp; /* pointer to current lfile structure - * being processed by parse() - */ -extern struct head *headp; /* The pointer to the first - * head structure of a linked list - */ -extern struct head *hp; /* Pointer to the current - * head structure - */ -extern struct area *areap; /* The pointer to the first - * area structure of a linked list - */ -extern struct area *ap; /* Pointer to the current - * area structure - */ -extern struct areax *axp; /* Pointer to the current - * areax structure - */ -extern struct sym *symhash[NHASH]; /* array of pointers to NHASH - * linked symbol lists - */ -extern struct base *basep; /* The pointer to the first - * base structure - */ -extern struct base *bsp; /* Pointer to the current - * base structure - */ -extern struct globl *globlp;/* The pointer to the first - * globl structure - */ -extern struct globl *gsp; /* Pointer to the current - * globl structure - */ -extern struct sdp sdp; /* Base Paged structure - */ -extern struct rerr rerr; /* Structure containing the - * linker error information - */ -extern FILE *ofp; /* Linker Output file handle - */ -extern FILE *mfp; /* Map output file handle - */ -extern FILE *jfp; /* NoICE output file handle - */ -extern FILE *rfp; /* File handle for output - * address relocated ASxxxx - * listing file - */ -extern FILE *sfp; /* The file handle sfp points to the - * currently open file - */ -extern FILE *tfp; /* File handle for input - * ASxxxx listing file - */ -extern FILE *dfp; /* File handle for debug info output - */ -extern int dflag; /* Output debug information flag - */ -extern int oflag; /* Output file type flag - */ -extern int mflag; /* Map output flag - */ -extern int sflag; /* JCF: Memory usage output flag - */ -extern int jflag; /* NoICE output flag - */ -extern int xflag; /* Map file radix type flag - */ -extern int pflag; /* print linker command file flag - */ -extern int uflag; /* Listing relocation flag - */ -extern int rflag; /* Extended linear address record flag. - */ -extern int radix; /* current number conversion radix: - * 2 (binary), 8 (octal), 10 (decimal), - * 16 (hexadecimal) - */ -extern int line; /* current line number - */ -extern int page; /* current page number - */ -extern int lop; /* current line number on page - */ -extern int pass; /* linker pass number - */ -extern int rtcnt; /* count of elements in the - * rtval[] and rtflg[] arrays - */ -extern Addr_T rtval[]; /* data associated with relocation - */ -extern int rtflg[]; /* indicates if rtval[] value is - * to be sent to the output file. - * (always set in this linker) - */ -extern int hilo; /* REL file byte ordering - */ -extern int gline; /* LST file relocation active - * for current line - */ -extern int gcntr; /* LST file relocation active - * counter - */ -extern struct lbpath *lbphead; /* pointer to the first - * library path structure - */ -extern struct lbname *lbnhead; /* pointer to the first - * library name structure - */ -extern struct lbfile *lbfhead; /* pointer to the first - * library file structure - */ -extern Addr_T iram_size; /* internal ram size - */ -extern long xram_size; /* external ram size - */ -extern long code_size; /* code size - */ - - -/* C Library function definitions */ -/* for reference only -extern VOID exit(); -extern int fclose(); -extern char * fgets(); -extern FILE * fopen(); -extern int fprintf(); -extern VOID free(); -extern VOID * malloc(); -extern char putc(); -extern char * strcpy(); -extern int strlen(); -extern char * strncpy(); -*/ - -/* Program function definitions */ - -/* lkmain.c */ -extern FILE * afile(); -extern VOID bassav(); -extern VOID gblsav(); -extern VOID iramsav(); -extern VOID xramsav(); -extern VOID codesav(); -extern VOID iramcheck(); -extern VOID link_main(); -extern VOID lkexit(); -extern int main(); -extern VOID map(); -extern int parse(); -extern VOID setbas(); -extern VOID setgbl(); -extern VOID usage(); -extern VOID copyfile(); - -/* lklex.c */ -extern char endline(); -extern char get(); -extern VOID getfid(); -extern VOID getid(); -extern VOID getSid(); -extern int as_getline(); -extern int getmap(); -extern char getnb(); -extern int more(); -extern VOID skip(); -extern VOID unget(); -extern VOID chop_crlf(); - -/* lkarea.c */ -extern VOID lkparea(); -extern VOID lnkarea(); -extern Addr_T lnksect(struct area *tap); -extern VOID newarea(); - -/* lkhead.c */ -extern VOID module(); -extern VOID newhead(); - -/* lksym.c */ -extern int hash(); -extern struct sym * lkpsym(); -extern VOID * new(); -extern struct sym * newsym(); -extern VOID symdef(); -extern int symeq(); -extern VOID syminit(); -extern VOID symmod(); -extern Addr_T symval(); - -/* lkeval.c */ -extern int digit(); -extern Addr_T eval(); -extern Addr_T expr(); -extern int oprio(); -extern Addr_T term(); - -/* lklist.c */ -extern int dgt(); -extern VOID lkulist(); -extern VOID lkalist(); -extern VOID lkglist(); -extern VOID lstarea(); -extern VOID newpag(); -extern VOID slew(); - -/* lkrloc.c */ -extern Addr_T adb_b(); -extern Addr_T adb_hi(); -extern Addr_T adb_lo(); -extern Addr_T adb_24_hi(Addr_T v, int i); -extern Addr_T adb_24_mid(Addr_T v, int i); -extern Addr_T adb_24_lo(Addr_T v, int i); -extern Addr_T adw_w(); -extern Addr_T adw_24(Addr_T, int); -extern Addr_T adw_hi(); -extern Addr_T adw_lo(); -extern Addr_T evword(); -extern VOID rele(); -extern VOID reloc(); -extern VOID relt(); -extern VOID relr(); -extern VOID relp(); -extern VOID relerr(); -extern char * errmsg[]; -extern VOID errdmp(); -extern VOID relerp(); -extern VOID erpdmp(); -extern VOID prntval(); -extern int lastExtendedAddress; - -/* lklibr.c */ -extern int addfile(); -extern VOID addlib(); -extern VOID addpath(); -extern int fndsym(); -extern VOID library(); -extern VOID loadfile(); -extern VOID search(); - -/* lks19.c */ -extern VOID s19(); - -/* lkihx.c */ -extern VOID ihx(); -extern VOID ihxEntendedLinearAddress(Addr_T); -extern VOID newArea(); - -/* lkstore.c */ -extern char *StoreString( char *str ); - -/* lknoice.c */ -extern void DefineNoICE( char *name, Addr_T value, int page ); - -/* JCF: lkmem.c */ -extern int summary(struct area * xp); - -/* JCF: lkaomf51.c */ -extern void SaveLinkedFilePath(char * filepath); -extern void CreateAOMF51(void); - -/* EEP: lkelf.c */ -extern VOID elf(); diff --git a/as/hc08/clean.mk b/as/hc08/clean.mk index 6b47bf1c..44d3d52a 100644 --- a/as/hc08/clean.mk +++ b/as/hc08/clean.mk @@ -5,7 +5,7 @@ include $(top_builddir)Makefile.common clean: rm -f *core *[%~] *.[oa] rm -f .[a-z]*~ - rm -f $(top_builddir)bin/as-hc08$(EXEEXT) $(top_builddir)bin/link-hc08$(EXEEXT) as-hc08$(EXEEXT) link-hc08$(EXEEXT) + rm -f $(top_builddir)bin/as-hc08$(EXEEXT) as-hc08$(EXEEXT) # Deleting all files created by configuring or building the program diff --git a/as/hc08/lkhead.c b/as/hc08/lkhead.c deleted file mode 100644 index 41a5198c..00000000 --- a/as/hc08/lkhead.c +++ /dev/null @@ -1,153 +0,0 @@ -/* lkhead.c */ - -/* - * (C) Copyright 1989-1995 - * All Rights Reserved - * - * Alan R. Baldwin - * 721 Berkeley St. - * Kent, Ohio 44240 - */ - -#include -#include -#include "aslink.h" - -/*Module lkhead.c - * - * The module lkhead.c contains the function newhead() which - * creates a head structure and the function module() which - * loads the module name into the current head structure. - * - * lkhead.c contains the following functions: - * VOID newhead() - * VOID module() - * - * lkhead.c contains no local variables. - */ - -/*)Function VOID newhead() - * - * The function newhead() creates a head structure. All head - * structures are linked to form a linked list of head structures - * with the current head structure at the tail of the list. - * - * local variables: - * int i evaluation value - * head * thp temporary pointer - * to a header structure - * - * global variables: - * area *ap Pointer to the current - * area structure - * lfile *cfp The pointer *cfp points to the - * current lfile structure - * head *headp The pointer to the first - * head structure of a linked list - * head *hp Pointer to the current - * head structure - * - * functions called: - * Addr_T expr() lkeval.c - * VOID * new() lksym.c - * VOID lkparea() lkarea.c - * - * side effects: - * A new head structure is created and linked to any - * existing linked head structure. The head structure - * parameters of file handle, number of areas, and number - * of global symbols are loaded into the structure. - * The default area "_abs_" is created when the first - * head structure is created and an areax structure is - * created for every head structure called. - */ - -/* - * Create a new header entry. - * - * H n areas n global symbols - * | | - * | `---- hp->h_nglob - * `------------ hp->h_narea - * - */ -VOID -newhead() -{ - register int i; - struct head *thp; - - hp = (struct head *) new (sizeof(struct head)); - if (headp == NULL) { - headp = hp; - } else { - thp = headp; - while (thp->h_hp) - thp = thp->h_hp; - thp->h_hp = hp; - } - /* - * Set file pointer - */ - hp->h_lfile = cfp; - /* - * Evaluate and build Area pointer list - */ - i = hp->h_narea = eval(); - if (i) - hp->a_list = (struct areax **) new (i*sizeof(struct areax *)); - /* - * Evaluate and build Global symbol pointer list - */ - skip(-1); - i = hp->h_nglob = eval(); - if (i) - hp->s_list = (struct sym **) new (i*sizeof(struct sym *)); - /* - * Setup Absolute DEF linkage. - */ - lkparea(_abs_); - ap->a_flag = A_ABS; -} - -/*)Function VOID module() - * - * The function module() copies the module name into - * the current head structure. - * - * local variables: - * char id[] module id string - * - * global variables: - * head *headp The pointer to the first - * head structure of a linked list - * head *hp Pointer to the current - * head structure - * int lkerr error flag - * FILE * stderr c_library - * - * functions called: - * int fprintf() c_library - * VOID getid() lklex.c - * char * strncpy() c_library - * - * side effects: - * The module name is copied into the head structure. - */ - -/* - * Module Name - */ -VOID -module() -{ - char id[NCPS]; - - if (headp) { - getid(id, -1); - strncpy(hp->m_id, id, NCPS); - } else { - fprintf(stderr, "No header defined\n"); - lkerr++; - } -} diff --git a/as/hc08/lklex.c b/as/hc08/lklex.c deleted file mode 100644 index 7c481300..00000000 --- a/as/hc08/lklex.c +++ /dev/null @@ -1,640 +0,0 @@ -/* lklex.c */ - -/* - * (C) Copyright 1989-1995 - * All Rights Reserved - * - * Alan R. Baldwin - * 721 Berkeley St. - * Kent, Ohio 44240 - */ - -#include -#include -#include "aslink.h" - -/*)Module lklex.c - * - * The module lklex.c contains the general lexical analysis - * functions used to scan the text lines from the .rel files. - * - * lklex.c contains the fllowing functions: - * char endline() - * char get() - * VOID getfid() - * VOID getid() - * VOID getSid() - * int as_getline() - * int getmap() - * char getnb() - * int more() - * VOID skip() - * VOID unget() - * - * lklex.c contains no local variables. - */ - -/*)Function VOID getid(id,c) - * - * char * id a pointer to a string of - * maximum length NCPS - * int c mode flag - * >=0 this is first character to - * copy to the string buffer - * <0 skip white space - * - * The function getid() scans the current input text line - * from the current position copying the next LETTER | DIGIT string - * into the external string buffer (id). The string ends when a non - * LETTER or DIGIT character is found. The maximum number of - * characters copied is NCPS. If the input string is larger than - * NCPS characters then the string is truncated, if the input string - * is shorter than NCPS characters then the string is NULL filled. - * If the mode argument (c) is >=0 then (c) is the first character - * copied to the string buffer, if (c) is <0 then intervening white - * space (SPACES and TABS) are skipped. - * - * local variables: - * char * p pointer to external string buffer - * int c current character value - * - * global variables: - * char ctype[] a character array which defines the - * type of character being processed. - * This index is the character - * being processed. - * - * called functions: - * char get() lklex.c - * char getnb() lklex.c - * VOID unget() lklex.c - * - * side effects: - * use of getnb(), get(), and unget() updates the - * global pointer ip the position in the current - * input text line. - */ - -VOID -getid(id, c) -register int c; -char *id; -{ - register char *p; - - if (c < 0) { - c = getnb(); - } - p = id; - do { - if (p < &id[NCPS]) - *p++ = c; - } while (ctype[c=get()] & (LETTER|DIGIT)); - unget(c); - while (p < &id[NCPS]) - *p++ = 0; -} - -/*)Function VOID getSid (char *id) - * - * char * id a pointer to a string of - * maximum length NCPS - * - * getSid is derived from getid. It is called from newsym() - * in lksym.c, when an S-record has to be scanned. getSid accepts - * much more characters than getid, which is necessary for SDCC. - * - * The function getSid() scans the current input text line - * from the current position copying the next string - * into the external string buffer (id). The string ends when a space - * character (space, tab, \0) is found. The maximum number of - * characters copied is NCPS. If the input string is larger than - * NCPS characters then the string is truncated, if the input string - * is shorter than NCPS characters then the string is NULL filled. - * Intervening white space (SPACES and TABS) are skipped. - * - * local variables: - * char * p pointer to external string buffer - * int c current character value - * - * global variables: - * char ctype[] a character array which defines the - * type of character being processed. - * This index is the character - * being processed. - * - * called functions: - * char get() lklex.c - * char getnb() lklex.c - * VOID unget() lklex.c - * - * side effects: - * use of getnb(), get(), and unget() updates the - * global pointer ip the position in the current - * input text line. - */ - -VOID -getSid (id) -char *id; -{ - register int c; - register char *p; - - c = getnb(); - p = id; - do { - if (p < &id[NCPS]) - *p++ = c; - c = get(); - } while (c != '\0' && c != ' ' && c != '\t'); - unget(c); - while (p < &id[NCPS]) - *p++ = 0; -} - -/*)Function VOID getfid(fid,c) - * - * char * str a pointer to a string of - * maximum length PATH_MAX - * int c this is first character to - * copy to the string buffer - * - * The function getfid() scans the current input text line from - * the current position copying the next string into the external - * string buffer (str). The string ends when end of line is found. - * Trailing spacers are removed. The maximum number of characters - * copied is PATH_MAX. If the input string is larger than PATH_MAX - * characters then the string is truncated. The string is NULL - * terminated. - * - * local variables: - * char * p pointer to external string buffer - * int c current character value - * - * global variables: - * char ctype[] a character array which defines the - * type of character being processed. - * This index is the character - * being processed. - * - * called functions: - * char get() lklex.c - * - * side effects: - * use of get() updates the global pointer ip - * the position in the current input text line. - */ - -VOID -getfid(str, c) -register int c; -char *str; -{ - register char *p; - - p = str; - do - { - if (p < &str[PATH_MAX-1]) - *p++ = c; - c = get(); - if (c == ';') - while (c) - c = get(); - } while (c); - /* trim trailing spaces */ - --p; - while (p >= str && ctype[(int)*p] == SPACE) - --p; - /* terminate the string */ - *(++p) = '\0'; -} - -/*)Function char getnb() - * - * The function getnb() scans the current input text - * line returning the first character not a SPACE or TAB. - * - * local variables: - * int c current character from input - * - * global variables: - * none - * - * called functions: - * char get() lklex.c - * - * side effects: - * use of get() updates the global pointer ip, the position - * in the current input text line - */ - -char -getnb() -{ - register int c; - - while ((c=get())==' ' || c=='\t') - ; - return (c); -} - -/*)Function VOID skip() - * - * The function skip() scans the input text skipping all - * letters and digits. - * - * local variables: - * none - * - * global variables: - * char ctype[] array of character types, one per - * ASCII character - * - * functions called: - * char get() lklex.c - * char getnb() lklex.c - * VOID unget() lklex.c - * - * side effects: - * Input letters and digits are skipped. - */ - -VOID -skip(c) -register int c; -{ - if (c < 0) - c = getnb(); - while (ctype[c=get()] & (LETTER|DIGIT)) { ; } - unget(c); -} - -/*)Function char get() - * - * The function get() returns the next character in the - * input text line, at the end of the line a - * NULL character is returned. - * - * local variables: - * int c current character from - * input text line - * - * global variables: - * char * ip pointer into the current - * input text line - * - * called functions: - * none - * - * side effects: - * updates ip to the next character position in the - * input text line. If ip is at the end of the - * line, ip is not updated. - */ - -char -get() -{ - register int c; - - if ((c = *ip) != 0) - ++ip; - return (c); -} - -/*)Function VOID unget(c) - * - * int c value of last character - * read from input text line - * - * If (c) is not a NULL character then the global pointer ip - * is updated to point to the preceeding character in the - * input text line. - * - * NOTE: This function does not push the character (c) - * back into the input text line, only - * the pointer ip is changed. - * - * local variables: - * int c last character read - * from input text line - * - * global variables: - * char * ip position into the current - * input text line - * - * called functions: - * none - * - * side effects: - * ip decremented by 1 character position - */ - -VOID -unget(c) -{ - if (c != 0) - --ip; -} - -/*)Function int getmap(d) - * - * int d value to compare with the - * input text line character - * - * The function getmap() converts the 'C' style characters \b, \f, - * \n, \r, and \t to their equivalent ascii values and also - * converts 'C' style octal constants '\123' to their equivalent - * numeric values. If the first character is equivalent to (d) then - * a (-1) is returned, if the end of the line is detected then - * a 'q' error terminates the parse for this line, or if the first - * character is not a \ then the character value is returned. - * - * local variables: - * int c value of character - * from input text line - * int n looping counter - * int v current value of numeric conversion - * - * global variables: - * none - * - * called functions: - * char get() lklex.c - * VOID unget() lklex.c - * - * side effects: - * use of get() updates the global pointer ip the position - * in the current input text line - */ - -int -getmap(d) -{ - register int c, n, v; - - if ((c = get()) == '\0') - return (-1); - if (c == d) - return (-1); - if (c == '\\') { - c = get(); - switch (c) { - - case 'b': - c = '\b'; - break; - - case 'f': - c = '\f'; - break; - - case 'n': - c = '\n'; - break; - - case 'r': - c = '\r'; - break; - - case 't': - c = '\t'; - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - n = 0; - v = 0; - while (++n<=3 && c>='0' && c<='7') { - v = (v<<3) + c - '0'; - c = get(); - } - unget(c); - c = v; - break; - } - } - return (c); -} - -/*)Function int as_getline() - * - * The function as_getline() reads a line of input text from a - * .rel source text file, a .lnk command file or from stdin. - * Lines of text are processed from a single .lnk file or - * multiple .rel files until all files have been read. - * The input text line is copied into the global string ib[] - * and converted to a NULL terminated string. The function - * as_getline() returns a (1) after succesfully reading a line - * or a (0) if all files have been read. - * This function also opens each input .lst file and output - * .rst file as each .rel file is processed. - * - * local variables: - * int i string length - * int ftype file type - * char * fid file name - * - * global variables: - * lfile *cfp The pointer *cfp points to the - * current lfile structure - * lfile *filep The pointer *filep points to the - * beginning of a linked list of - * lfile structures. - * int gline get a line from the LST file - * to translate for the RST file - * char ib[NINPUT] REL file text line - * int pass linker pass number - * int pflag print linker command file flag - * FILE *rfp The file handle to the current - * output RST file - * FILE *sfp The file handle sfp points to the - * currently open file - * FILE * stdin c_library - * FILE * stdout c_library - * FILE *tfp The file handle to the current - * LST file being scanned - * int uflag update listing flag - * - * called functions: - * FILE * afile() lkmain.c - * int fclose() c_library - * char * fgets() c_library - * int fprintf() c_library - * VOID lkulist() lklist.c - * VOID lkexit() lkmain.c - * int strlen() c_library - * - * side effects: - * The input stream is scanned. The .rel files will be - * opened and closed sequentially scanning each in turn. - */ - -int -as_getline() -{ - register int ftype; - register char *fid; - -loop: if (pflag && cfp && cfp->f_type == F_STD) - fprintf(stdout, "ASlink >> "); - - if (sfp == NULL || fgets(ib, sizeof ib, sfp) == NULL) { - if (sfp) { - fclose(sfp); - sfp = NULL; - lkulist(0); - } - if (cfp == NULL) { - cfp = filep; - } else { - cfp = cfp->f_flp; - } - if (cfp) { - ftype = cfp->f_type; - fid = cfp->f_idp; - if (ftype == F_STD) { - sfp = stdin; - } else - if (ftype == F_LNK) { - sfp = afile(fid, "lnk", 0); - } else - if (ftype == F_REL) { - sfp = afile(fid, "rel", 0); - /* if a .cdb file exists then copy it over */ - if (dflag && sfp && dfp && pass == 0) { - FILE *xfp = afile(fid,"adb",0); //JCF: Nov 30, 2002 - if (xfp) { - copyfile(dfp,xfp); - fclose(xfp); - } - } - if (uflag && pass != 0) { - SaveLinkedFilePath(fid); //Save the linked path for aomf51 - if ((tfp = afile(fid, "lst", 0)) != NULL) { - if ((rfp = afile(fid, "rst", 1)) == NULL) { - fclose(tfp); - tfp = NULL; - } - } - } - gline = 1; - } else { - fprintf(stderr, "Invalid file type\n"); - lkexit(1); - } - if (sfp == NULL) { - lkexit(1); - } - goto loop; - } else { - filep = NULL; - return(0); - } - } - chop_crlf(ib); - return (1); -} - -/*)Function int more() - * - * The function more() scans the input text line - * skipping white space (SPACES and TABS) and returns a (0) - * if the end of the line or a comment delimeter (;) is found, - * or a (1) if their are additional characters in the line. - * - * local variables: - * int c next character from - * the input text line - * - * global variables: - * none - * - * called functions: - * char getnb() lklex.c - * VOID unget() lklex.c - * - * side effects: - * use of getnb() and unget() updates the global pointer ip - * the position in the current input text line - */ - -int -more() -{ - register int c; - - c = getnb(); - unget(c); - return( (c == '\0' || c == ';') ? 0 : 1 ); -} - -/*)Function char endline() - * - * The function endline() scans the input text line - * skipping white space (SPACES and TABS) and returns the next - * character or a (0) if the end of the line is found or a - * comment delimiter (;) is found. - * - * local variables: - * int c next character from - * the input text line - * - * global variables: - * none - * - * called functions: - * char getnb() lklex.c - * - * side effects: - * Use of getnb() updates the global pointer ip the - * position in the current input text line. - */ - -char -endline() -{ - register int c; - - c = getnb(); - return( (c == '\0' || c == ';') ? 0 : c ); -} - -/*)Function VOID chop_crlf(str) - * - * char *str string to chop - * - * The function chop_crlf() removes trailing LF or CR/LF from - * str, if present. - * - * local variables: - * int i string length - * - * global variables: - * none - * - * functions called: - * none - * - * side effects: - * none - */ - -VOID -chop_crlf(str) -char *str; -{ - register int i; - - i = strlen(str); - if (i >= 1 && str[i-1] == '\n') str[i-1] = 0; - if (i >= 2 && str[i-2] == '\r') str[i-2] = 0; -} diff --git a/as/hc08/lknoice.c b/as/hc08/lknoice.c deleted file mode 100644 index 2cd6a91c..00000000 --- a/as/hc08/lknoice.c +++ /dev/null @@ -1,246 +0,0 @@ -/* lknoice.c */ - -/* - * Extensions to CUG 292 linker ASLINK to produce NoICE debug files - * - * 31-Oct-1997 by John Hartman - * 30-Jan-98 JLH add page to DefineNoICE for 8051 - * 2-Feb-98 JLH Allow optional .nest on local vars - C scoping rules... - */ - -#include -#include -#include -#include "aslink.h" -#include "strcmpi.h" - -static void DefineGlobal( char *name, Addr_T value, int page ); -static void DefineScoped( char *name, Addr_T value, int page ); -static void DefineFile( char *name, Addr_T value, int page ); -static void DefineFunction( char *name, Addr_T value, int page ); -static void DefineStaticFunction( char *name, Addr_T value, int page ); -static void DefineEndFunction( Addr_T value, int page ); -static void DefineLine( char *lineString, Addr_T value, int page ); -static void PagedAddress( Addr_T value, int page ); - -/* - * Called from lstarea in lklist.c for each symbol. - * - * Generates appropriate NoICE commands into output file, if any is open - * - */ -void DefineNoICE( char *name, Addr_T value, int page ) -{ - char token1[NCPS]; /* parse for file.function.symbol */ - char token2[NCPS]; - char token3[NCPS]; - // char token4[NCPS]; - char sep1, sep2; - int j, level; - - /* no output if file is not open */ - if (jfp == NULL) return; - - j = sscanf( name, "%[^.]%c%[^.]%c%s", - token1, &sep1, token2, &sep2, token3 ); - switch (j) - { - /* file.function.symbol, or file.function..SPECIAL */ - case 5: - DefineFile( token1, 0, 0 ); - if (token3[0] == '.') - { - if (strcmp( token3, ".FN" ) == 0) - { - /* Global function */ - DefineFunction( token2, value, page ); - } - else if (strcmp( token3, ".SFN" ) == 0) - { - /* Static (file-scope) function */ - DefineStaticFunction( token2, value, page ); - } - else if (strcmp( token3, ".EFN" ) == 0) - { - /* End of function */ - DefineEndFunction( value, page ); - } - } - else - { - /* Function-scope var. */ - DefineFunction( token2, 0, 0 ); - - /* Look for optional level integer */ - j = sscanf( token3, "%[^.]%c%u", token1, &sep1, &level ); - if ((j == 3) && (level != 0)) - { - sprintf( &token1[ strlen(token1) ], "_%u", level ); - } - DefineScoped( token1, value, page ); - } - break; - - /* file.func. is illegal */ - case 4: - break; - - /* either file.symbol or file.line# */ - case 3: - DefineFile( token1, 0, 0 ); - if ((token2[0] >= '0') && (token2[0] <= '9')) - { - /* Line number */ - DefineLine( token2, value, page ); - } - else - { - /* File-scope symbol. (Kill any function) */ - DefineEndFunction( 0, 0 ); - DefineScoped( token2, value, page ); - } - break; - - /* symbol. is illegal */ - case 2: - break; - - /* just a symbol */ - case 1: - DefineGlobal( token1, value, page ); - break; - } -} - -static char currentFile[NCPS]; -static char currentFunction[NCPS]; - -/* - * static function: - * Define "name" as a global symbol - */ -void DefineGlobal( char *name, Addr_T value, int page ) -{ - fprintf( jfp, "DEF %s ", name ); - PagedAddress( value, page ); -} - -/* - * static function: - * Define "name" as a static (scoped) symbol - */ -void DefineScoped( char *name, Addr_T value, int page ) -{ - fprintf( jfp, "DEFS %s ", name ); - PagedAddress( value, page ); -} - -/* - * static function: - * Define "name" as the current file - */ -void DefineFile( char *name, Addr_T value, int page ) -{ - if (as_strcmpi( name, currentFile ) != 0) - { - strcpy( currentFile, name ); - if (value != 0) - { - fprintf( jfp, "FILE %s ", name ); - PagedAddress( value, page ); - } - else - { - fprintf( jfp, "FILE %s\n", name ); - } - } -} - -/* - * static function: - * Define "name" as the current function - */ -void DefineFunction( char *name, Addr_T value, int page ) -{ - if (as_strcmpi( name, currentFunction ) != 0) - { - strcpy( currentFunction, name ); - if (value != 0) - { - fprintf( jfp, "DEF %s ", name ); - PagedAddress( value, page ); - fprintf( jfp, "FUNC %s ", name ); - PagedAddress( value, page ); - } - else - { - fprintf( jfp, "FUNC %s\n", name ); - } - } -} - -/* - * static function: - * Define "name" as the current static (scoped) function - */ -void DefineStaticFunction( char *name, Addr_T value, int page ) -{ - if (as_strcmpi( name, currentFunction ) != 0) - { - strcpy( currentFunction, name ); - if (value != 0) - { - fprintf( jfp, "DEFS %s ", name ); - PagedAddress( value, page ); - fprintf( jfp, "SFUNC %s ", name ); - PagedAddress( value, page ); - } - else - { - fprintf( jfp, "SFUNC %s\n", name ); - } - } -} - -/* - * static function: - * Define the end of the current function - */ -void DefineEndFunction( Addr_T value, int page ) -{ - if (currentFunction[0] != 0) - { - if (value != 0) - { - fprintf( jfp, "ENDF " ); - PagedAddress( value, page ); - } - else - { - fprintf( jfp, "ENDF\n" ); - } - - currentFunction[0] = 0; - } -} - -/* - * static function: - * Define "lineNumber" as a line in the current file - */ -void DefineLine( char *lineString, Addr_T value, int page ) -{ - int indigit, lineNumber = 0; - - while( (indigit=digit( *lineString++, 10 )) >= 0) - { - lineNumber = 10*lineNumber + indigit; - } - fprintf( jfp, "LINE %u ", lineNumber ); - PagedAddress( value, page ); -} - -void PagedAddress( Addr_T value, int page ) -{ - fprintf( jfp, "%X:0x%X\n", page, value ); -} diff --git a/as/hc08/lkstore.c b/as/hc08/lkstore.c deleted file mode 100644 index 063e89c4..00000000 --- a/as/hc08/lkstore.c +++ /dev/null @@ -1,50 +0,0 @@ -/* lkstore.c */ - -/* - * Allocated string storage module. - * - * 31-Oct-1997 by John Hartman - */ - -#include -#include -#include -#include "aslink.h" - -/* - * Allocate space for "str", copy str into new space - * Return a pointer to the allocated name, or NULL if out of memory - */ -char *StoreString( char *str ) -{ - /* To avoid wasting memory headers on small allocations, we - / allocate a big chunk and parcel it out as required. - / These static variables remember our hunk - */ - #define STR_STORE_HUNK 2000 - static char *pNextFree = NULL; - static int bytesLeft = 0; - - int length; - char *pStoredString; - - length = strlen( str ) + 1; /* what we need, including null */ - - if (length > bytesLeft) - { - /* no space. Allocate a new hunk. We lose the pointer to any - / old hunk. We don't care, as the names are never deleted. - */ - pNextFree = (char*)new( STR_STORE_HUNK ); - bytesLeft = STR_STORE_HUNK; - } - - /* Copy the name and terminating null into the name store */ - pStoredString = pNextFree; - memcpy( pStoredString, str, length ); - - pNextFree += length; - bytesLeft -= length; - - return pStoredString; -} diff --git a/as/hc08/lksym.c b/as/hc08/lksym.c deleted file mode 100644 index 1ebc49cc..00000000 --- a/as/hc08/lksym.c +++ /dev/null @@ -1,488 +0,0 @@ -/* lksym.c */ - -/* - * (C) Copyright 1989-1995 - * All Rights Reserved - * - * Alan R. Baldwin - * 721 Berkeley St. - * Kent, Ohio 44240 - * - * 28-Oct-97 JLH: - * - lkpsym: Use StoreString for sym construction - * - change symeq() to do length-independent string compare - * - change hash() to do length-independent hash calculation - */ - -#include -#include -#if defined(_MSC_VER) -#include -#else -#include -#endif -#include "aslink.h" - -/*)Module lksym.c - * - * The module lksym.c contains the functions that operate - * on the symbol structures. - * - * lksym.c contains the following functions: - * int hash() - * sym * lkpsym() - * VOID * new() - * sym * newsym() - * VOID symdef() - * int symeq() - * VOID syminit() - * VOID symmod() - * Addr_T symval() - * - * lksym.c contains no local/static variables. - */ - -/*)Function VOID syminit() - * - * The function syminit() is called to clear the hashtable. - * - * local variables: - * int h computed hash value - * sym ** spp pointer to an array of - * sym structure pointers - * - * global variables: - * sym * symhash[] array of pointers to NHASH - * linked symbol lists - * - * functions called: - * none - * - * side effects: - * (1) The symbol hash tables are cleared - */ - -VOID -syminit() -{ - // register int h; - struct sym **spp; - - spp = &symhash[0]; - while (spp < &symhash[NHASH]) - *spp++ = NULL; -} - -/*)Function sym * newsym() - * - * The function newsym() is called to evaluate the symbol - * definition/reference directive from the .rel file(s). - * If the symbol is not found in the symbol table a new - * symbol structure is created. Evaluation of the - * directive determines if this is a reference or a definition. - * Multiple definitions of the same variable will be flagged - * as an error if the values are not identical. A symbol - * definition places the symbol value and area extension - * into the symbols data structure. And finally, a pointer - * to the symbol structure is placed into the head structure - * symbol list. Refer to the description of the header, symbol, - * area, and areax structures in lkdata.c for structure and - * linkage details. - * - * local variables: - * int c character from input text - * int i evaluation value - * char id[] symbol name - * int nglob number of symbols in this header - * sym * tsp pointer to symbol structure - * sym ** s list of pointers to symbol structures - * - * global variables: - * areax *axp Pointer to the current - * areax structure - * head *headp The pointer to the first - * head structure of a linked list - * int lkerr error flag - * - * functions called: - * Addr_T eval() lkeval.c - * VOID exit() c_library - * int fprintf() c_library - * char getSid() lklex.c - * char get() lklex.c - * char getnb() lklex.c - * sym * lkpsym() lksym.c - * - * side effects: - * A symbol structure is created and/or modified. - * If structure space allocation fails linker will abort. - * Several severe errors (these are internal errors - * indicating a corrupted .rel file or corrupted - * assembler or linker) will terminated the linker. - */ - -/* - * Find/Create a global symbol entry. - * - * S xxxxxx Defnnnn - * | | | - * | | `-- sp->s_addr - * | `----- sp->s_type - * `------------ sp->s_id - * - */ -struct sym * -newsym() -{ - register unsigned i ; - register unsigned nglob ; - register int c ; - struct sym *tsp; - struct sym **s; - char id[NCPS]; - - getSid(id); // old: getid(id, -1); - tsp = lkpsym(id, 1); - c = getnb();get();get(); - if (c == 'R') { - tsp->s_type |= S_REF; - if (eval()) { - fprintf(stderr, "Non zero S_REF\n"); - lkerr++; - } - } else - if (c == 'D') { - i = eval(); - if (tsp->s_type & S_DEF && tsp->s_addr != i) { - fprintf(stderr, "Multiple definition of %8s\n", id); - lkerr++; - } - tsp->s_type |= S_DEF; - /* - * Set value and area extension link. - */ - tsp->s_addr = i; - tsp->s_axp = axp; - } else { - fprintf(stderr, "Invalid symbol type %c for %8s\n", c, id); - lkexit(1); - } - /* - * Place pointer in header symbol list - */ - if (headp == NULL) { - fprintf(stderr, "No header defined\n"); - lkexit(1); - } - nglob = hp->h_nglob; - s = hp->s_list; - for (i=0; i < nglob ;++i) { - if (s[i] == NULL) { - s[i] = tsp; - return(tsp); - } - } - fprintf(stderr, "Header symbol list overflow\n"); - lkexit(1); - return(0); -} - -/*)Function sym * lkpsym(id,f) - * - * char * id symbol name string - * int f f == 0, lookup only - * f != 0, create if not found - * - * The function lookup() searches the symbol hash tables for - * a symbol name match returning a pointer to the sym structure. - * If the symbol is not found then a sym structure is created, - * initialized, and linked to the appropriate hash table if f != 0. - * A pointer to this new sym structure is returned or a NULL - * pointer is returned if f == 0. - * - * local variables: - * int h computed hash value - * sym * sp pointer to a sym structure - * - * global varaibles: - * sym * symhash[] array of pointers to NHASH - * linked symbol lists - * - * functions called: - * int hash() lksym.c - * VOID * new() lksym.c - * int symeq() lksym.c - * - * side effects: - * If the function new() fails to allocate space - * for the new sym structure the linker terminates. - */ - -struct sym * -lkpsym(id, f) -char *id; -{ - register struct sym *sp; - register int h; - - h = hash(id); - sp = symhash[h]; - while (sp != NULL) { - if (symeq(id, sp->s_id)) - return (sp); - sp = sp->s_sp; - } - if (f == 0) - return (NULL); - sp = (struct sym *) new (sizeof(struct sym)); - sp->s_sp = symhash[h]; - symhash[h] = sp; - sp->s_id = StoreString( id ); /* JLH */ - return (sp); -} - -/*)Function Addr_T symval(tsp) - * - * sym * tsp pointer to a symbol structure - * - * The function symval() returns the value of the - * relocated symbol by adding the variable definition - * value to the areax base address. - * - * local variables: - * Addr_T val relocated address value - * - * global variables: - * none - * - * functions called: - * none - * - * side effects: - * none - */ - -Addr_T -symval(tsp) -register struct sym *tsp; -{ - register Addr_T val; - - val = tsp->s_addr; - if (tsp->s_axp) { - val += tsp->s_axp->a_addr; - } - return(val); -} - -/*)Function VOID symdef(fp) - * - * FILE * fp file handle for output - * - * The function symdef() scans the hashed symbol table - * searching for variables referenced but not defined. - * Undefined variables are linked to the default - * area "_CODE" and reported as referenced by the - * appropriate module. - * - * local variables: - * int i hash table index loop variable - * sym * sp pointer to linked symbol structure - * - * global variables: - * area *areap The pointer to the first - * area structure of a linked list - * sym *symhash[NHASH] array of pointers to NHASH - * linked symbol lists - * - * functions called: - * symmod() lksym.c - * - * side effects: - * Undefined variables have their areas set to "_CODE". - */ - -VOID -symdef(fp) -FILE *fp; -{ - register struct sym *sp; - register int i; - - for (i=0; is_axp == NULL) - sp->s_axp = areap->a_axp; - if ((sp->s_type & S_DEF) == 0) - symmod(fp, sp); - sp = sp->s_sp; - } - } -} - -/*)Function VOID symmod(fp,tsp) - * - * FILE * fp output file handle - * sym * tsp pointer to a symbol structure - * - * The function symmod() scans the header structures - * searching for a reference to the symbol structure - * pointer to by tsp. The function then generates an error - * message whichs names the module having referenced the - * undefined variable. - * - * local variables: - * int i loop counter - * sym ** p pointer to a list of pointers - * to symbol structures - * - * global variables: - * head *headp The pointer to the first - * head structure of a linked list - * head *hp Pointer to the current - * head structure - * int lkerr error flag - * - * functions called: - * int fprintf() c_library - * - * side effects: - * Error output generated. - */ - -VOID -symmod(fp, tsp) -FILE *fp; -struct sym *tsp; -{ - register int i; - struct sym **p; - - if ((hp = headp) != NULL) { - while(hp) { - p = hp->s_list; - for (i=0; ih_nglob; ++i) { - if (p[i] == tsp) { - fprintf(fp, "\n?ASlink-Warning-Undefined Global '%s' ", tsp->s_id); - fprintf(fp, "referenced by module '%s'\n", hp->m_id); - lkerr++; - } - } - hp = hp->h_hp; - } - } -} - -/*)Function int symeq(p1, p2) - * - * char * p1 name string - * char * p2 name string - * - * The function symeq() compares the two name strings for a match. - * The return value is 1 for a match and 0 for no match. - * - * local variables: - * int h loop counter - * - * global variables: - * char ccase[] an array of characters which - * perform the case translation function - * - * functions called: - * none - * - * side effects: - * none - * - */ - -int -symeq(p1, p2) -register char *p1, *p2; -{ -#if CASE_SENSITIVE - return (strcmp( p1, p2 ) == 0); -#else - return (as_strcmpi( p1, p2 ) == 0); -#endif -} - -/*)Function int hash(p) - * - * char * p pointer to string to hash - * - * The function hash() computes a hash code using the sum - * of all characters mod table size algorithm. - * - * local variables: - * int h accumulated character sum - * int n loop counter - * - * global variables: - * char ccase[] an array of characters which - * perform the case translation function - * - * functions called: - * none - * - * side effects: - * none - * - */ - -int -hash(p) -register char *p; -{ - register int h; - - h = 0; - while (*p) { - -#if CASE_SENSITIVE - h += *p++; -#else - h += ccase[*p++]; -#endif - - }; - return (h&HMASK); -} - -/*)Function VOID * new(n) - * - * unsigned int n allocation size in bytes - * - * The function new() allocates n bytes of space and returns - * a pointer to this memory. If no space is available the - * linker is terminated. - * - * local variables: - * char * p a general pointer - * char * q a general pointer - * - * global variables: - * none - * - * functions called: - * int fprintf() c_library - * VOID * malloc() c_library - * - * side effects: - * Memory is allocated, if allocation fails - * the linker is terminated. - */ - -VOID * -new(n) -unsigned int n; -{ - register char *p; - - if ((p = (char *) calloc(n, 1)) == NULL) { - fprintf(stderr, "Out of space!\n"); - lkexit(1); - } - return (p); -} diff --git a/as/link/aslink.h b/as/link/aslink.h index b3d0adfa..23dd808e 100644 --- a/as/link/aslink.h +++ b/as/link/aslink.h @@ -278,8 +278,10 @@ struct area Addr_T a_size; /* Total size of the area */ Addr_T a_unaloc; /* Total number of unallocated bytes, for error reporting */ char a_type; /* Area subtype */ - char a_flag; /* Flag byte */ + int a_flag; /* Flag byte */ char a_id[NCPS]; /* Name */ + char *a_image; /* Something for hc08/lkelf */ + char *a_used; /* Something for hc08/lkelf */ }; /* diff --git a/as/hc08/Makefile.aslink b/as/link/hc08/Makefile.aslink similarity index 100% rename from as/hc08/Makefile.aslink rename to as/link/hc08/Makefile.aslink diff --git a/as/link/hc08/Makefile.bcc b/as/link/hc08/Makefile.bcc new file mode 100644 index 00000000..51c73f5d --- /dev/null +++ b/as/link/hc08/Makefile.bcc @@ -0,0 +1,20 @@ +# Makefile for Borland C++ + +PRJDIR = ../.. + +!include $(PRJDIR)/Bcc.inc + +LKOBJECTS = lkmain.obj lkarea.obj lkdata.obj \ + lkrloc.obj \ + lklibr.obj lkihx.obj lks19.obj \ + lkmem.obj lkaomf51.obj \ + ../lkeval.obj ../lkhead.obj ../lklex.obj ../lklist.obj \ + ../lknoice.obj ../lkstore.obj ../lksym.obj \ + ../../strcmpi.obj + +ASLINK = $(PRJDIR)/bin/aslink.exe + +all: $(ASLINK) + +$(ASLINK): $(LKOBJECTS) + $(CC) $(CFLAGS) -e$@ $(LKOBJECTS) diff --git a/as/link/hc08/Makefile.in b/as/link/hc08/Makefile.in new file mode 100644 index 00000000..508e1fb9 --- /dev/null +++ b/as/link/hc08/Makefile.in @@ -0,0 +1,114 @@ +# +# +# + +VERSION = @VERSION@ +VERSIONHI = @VERSIONHI@ +VERSIONLO = @VERSIONLO@ +VERSIONP = @VERSIONP@ + +SHELL = /bin/sh +CC = @CC@ +CPP = @CPP@ +INSTALL = @INSTALL@ +STRIP = @STRIP@ + +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ + +srcdir = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +libdir = @libdir@ +datadir = @datadir@ +includedir = @includedir@ +mandir = @mandir@ +man1dir = $(mandir)/man1 +man2dir = $(mandir)/man2 +infodir = @info@ + +EXEEXT = @EXEEXT@ + +VPATH = @srcdir@ + +CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/.. +CFLAGS = @CFLAGS@ -Wall +M_OR_MM = @M_OR_MM@ +LDFLAGS = @LDFLAGS@ + +LKOBJECTS = lkmain.o lkarea.o lkdata.o \ + lkrloc.o \ + lklibr.o lkihx.o lks19.o lkelf.o \ + lkmem.o lkaomf51.o \ + ../lkeval.o ../lkhead.o ../lklex.o ../lklist.o \ + ../lknoice.o ../lkstore.o ../lksym.o \ + ../../strcmpi.o +LKSOURCES = $(patsubst %.o,%.c,$(LKOBJECTS)) + +ASLINK = $(top_builddir)bin/link-hc08$(EXEEXT) + +transform = @program_transform_name@ + +# Compiling entire program or any subproject +# ------------------------------------------ +all: checkconf $(ASLINK) + +$(ASLINK): $(LKOBJECTS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(LKOBJECTS) + +# Compiling and installing everything and running test +# ---------------------------------------------------- +install: all installdirs + $(INSTALL) $(ASLINK) `echo $(DESTDIR)$(bindir)/link-hc08$(EXEEXT)|sed '$(transform)'` + $(STRIP) `echo $(DESTDIR)$(bindir)/link-hc08$(EXEEXT)|sed '$(transform)'` + +# Deleting all the installed files +# -------------------------------- +uninstall: + rm -f $(DESTDIR)$(bindir)/link-hc08$(EXEEXT) + + +# Performing self-test +# -------------------- +check: + + +# Performing installation test +# ---------------------------- +installcheck: + + +# Creating installation directories +# --------------------------------- +installdirs: + $(INSTALL) -d $(DESTDIR)$(bindir) + + +# Creating dependencies +# --------------------- +dep: Makefile.dep + +Makefile.dep: $(LKSOURCES) $(srcdir)/../*.h $(top_builddir)*.h $(top_srcdir)/*.h + $(CPP) $(CPPFLAGS) $(M_OR_MM) $(filter %.c,$^) >Makefile.dep + +ifeq "$(findstring $(MAKECMDGOALS),uninstall check installcheck installdirs \ + clean distclean mostlyclean realclean)" "" + include Makefile.dep +endif +include $(srcdir)/clean.mk + +# My rules +# -------- +.c.o: + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< + + +# Remaking configuration +# ---------------------- +checkconf: + @if [ -f $(top_builddir)devel ]; then\ + $(MAKE) -f conf.mk srcdir="$(srcdir)" top_builddir="$(top_builddir)" freshconf;\ + fi + +# End of Makefile diff --git a/as/hc08/aslink.mak b/as/link/hc08/aslink.mak similarity index 100% rename from as/hc08/aslink.mak rename to as/link/hc08/aslink.mak diff --git a/as/link/hc08/clean.mk b/as/link/hc08/clean.mk new file mode 100644 index 00000000..2ecd3c76 --- /dev/null +++ b/as/link/hc08/clean.mk @@ -0,0 +1,25 @@ +# Deleting all files created by building the program +# -------------------------------------------------- +include $(top_builddir)Makefile.common + +clean: + rm -f *core *[%~] *.[oa] + rm -f .[a-z]*~ + rm -f $(top_builddir)bin/link-hc08$(EXEEXT) link-hc08$(EXEEXT) + + +# Deleting all files created by configuring or building the program +# ----------------------------------------------------------------- +distclean: clean + rm -f Makefile *.dep + + +# Like clean but some files may still exist +# ----------------------------------------- +mostlyclean: clean + + +# Deleting everything that can reconstructed by this Makefile. It deletes +# everything deleted by distclean plus files created by bison, etc. +# ----------------------------------------------------------------------- +realclean: distclean diff --git a/as/link/hc08/conf.mk b/as/link/hc08/conf.mk new file mode 100644 index 00000000..ac65f24e --- /dev/null +++ b/as/link/hc08/conf.mk @@ -0,0 +1,10 @@ +# +# Makefile targets to remake configuration +# + +freshconf: Makefile + +Makefile: $(srcdir)/Makefile.in $(top_srcdir)/configure.in + cd $(top_builddir) && $(SHELL) ./config.status + +# End of conf.mk diff --git a/as/hc08/link_hc08.dsp b/as/link/hc08/link_hc08.dsp similarity index 52% rename from as/hc08/link_hc08.dsp rename to as/link/hc08/link_hc08.dsp index fe598cb2..ca05142d 100644 --- a/as/hc08/link_hc08.dsp +++ b/as/link/hc08/link_hc08.dsp @@ -32,8 +32,8 @@ RSC=rc.exe # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "link_hc08___Win32_Release" -# PROP BASE Intermediate_Dir "link_hc08___Win32_Release" +# PROP BASE Output_Dir "hc08\Release" +# PROP BASE Intermediate_Dir "hc08\Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /I "..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I ".." /I "..\..\.." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -50,14 +50,14 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"..\..\bin_vc\link-hc08.exe" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"..\..\..\bin_vc\link-hc08.exe" !ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "link_hc08___Win32_Debug" -# PROP BASE Intermediate_Dir "link_hc08___Win32_Debug" +# PROP BASE Output_Dir "hc08\Debug" +# PROP BASE Intermediate_Dir "hc08\Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 @@ -66,7 +66,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /I "..\..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe @@ -74,7 +74,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"..\..\bin_vc\link-hc08.exe" /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"..\..\..\bin_vc\link-hc08.exe" /pdbtype:sept !ENDIF @@ -88,47 +88,14 @@ LINK32=link.exe # Begin Source File SOURCE=.\lkaomf51.c - -!IF "$(CFG)" == "link_hc08 - Win32 Release" - -# PROP Intermediate_Dir "Release" - -!ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug" - -# PROP Intermediate_Dir "Debug" - -!ENDIF - # End Source File # Begin Source File SOURCE=.\lkarea.c - -!IF "$(CFG)" == "link_hc08 - Win32 Release" - -# PROP Intermediate_Dir "Release" - -!ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug" - -# PROP Intermediate_Dir "Debug" - -!ENDIF - # End Source File # Begin Source File SOURCE=.\lkdata.c - -!IF "$(CFG)" == "link_hc08 - Win32 Release" - -# PROP Intermediate_Dir "Release" - -!ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug" - -# PROP Intermediate_Dir "Debug" - -!ENDIF - # End Source File # Begin Source File @@ -136,222 +103,72 @@ SOURCE=.\lkelf.c # End Source File # Begin Source File -SOURCE=.\lkeval.c - -!IF "$(CFG)" == "link_hc08 - Win32 Release" - -# PROP Intermediate_Dir "Release" - -!ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug" - -# PROP Intermediate_Dir "Debug" - -!ENDIF - +SOURCE=..\lkeval.c # End Source File # Begin Source File -SOURCE=.\lkhead.c - -!IF "$(CFG)" == "link_hc08 - Win32 Release" - -# PROP Intermediate_Dir "Release" - -!ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug" - -# PROP Intermediate_Dir "Debug" - -!ENDIF - +SOURCE=..\lkhead.c # End Source File # Begin Source File SOURCE=.\lkihx.c - -!IF "$(CFG)" == "link_hc08 - Win32 Release" - -# PROP Intermediate_Dir "Release" - -!ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug" - -# PROP Intermediate_Dir "Debug" - -!ENDIF - # End Source File # Begin Source File -SOURCE=.\lklex.c - -!IF "$(CFG)" == "link_hc08 - Win32 Release" - -# PROP Intermediate_Dir "Release" - -!ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug" - -# PROP Intermediate_Dir "Debug" - -!ENDIF - +SOURCE=..\lklex.c # End Source File # Begin Source File SOURCE=.\lklibr.c - -!IF "$(CFG)" == "link_hc08 - Win32 Release" - -# PROP Intermediate_Dir "Release" - -!ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug" - -# PROP Intermediate_Dir "Debug" - -!ENDIF - # End Source File # Begin Source File -SOURCE=.\lklist.c - -!IF "$(CFG)" == "link_hc08 - Win32 Release" - -# PROP Intermediate_Dir "Release" - -!ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug" - -# PROP Intermediate_Dir "Debug" - -!ENDIF - +SOURCE=..\lklist.c # End Source File # Begin Source File SOURCE=.\lkmain.c - -!IF "$(CFG)" == "link_hc08 - Win32 Release" - -# PROP Intermediate_Dir "Release" - -!ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug" - -# PROP Intermediate_Dir "Debug" - -!ENDIF - # End Source File # Begin Source File SOURCE=.\lkmem.c - -!IF "$(CFG)" == "link_hc08 - Win32 Release" - -# PROP Intermediate_Dir "Release" - -!ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug" - -# PROP Intermediate_Dir "Debug" - -!ENDIF - # End Source File # Begin Source File -SOURCE=.\lknoice.c - -!IF "$(CFG)" == "link_hc08 - Win32 Release" - -# PROP Intermediate_Dir "Release" - -!ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug" - -# PROP Intermediate_Dir "Debug" - -!ENDIF - +SOURCE=..\lknoice.c # End Source File # Begin Source File SOURCE=.\lkrloc.c - -!IF "$(CFG)" == "link_hc08 - Win32 Release" - -# PROP Intermediate_Dir "Release" - -!ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug" - -# PROP Intermediate_Dir "Debug" - -!ENDIF - # End Source File # Begin Source File SOURCE=.\lks19.c - -!IF "$(CFG)" == "link_hc08 - Win32 Release" - -# PROP Intermediate_Dir "Release" - -!ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug" - -# PROP Intermediate_Dir "Debug" - -!ENDIF - # End Source File # Begin Source File -SOURCE=.\lkstore.c - -!IF "$(CFG)" == "link_hc08 - Win32 Release" - -# PROP Intermediate_Dir "Release" - -!ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug" - -# PROP Intermediate_Dir "Debug" - -!ENDIF - +SOURCE=..\lkstore.c # End Source File # Begin Source File -SOURCE=.\lksym.c - -!IF "$(CFG)" == "link_hc08 - Win32 Release" - -# PROP Intermediate_Dir "Release" - -!ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug" - -# PROP Intermediate_Dir "Debug" - -!ENDIF - +SOURCE=..\lksym.c # End Source File # Begin Source File -SOURCE=.\strcmpi.c - -!IF "$(CFG)" == "link_hc08 - Win32 Release" - -# PROP Intermediate_Dir "Release" - -!ELSEIF "$(CFG)" == "link_hc08 - Win32 Debug" - -# PROP Intermediate_Dir "Debug" - -!ENDIF - +SOURCE=..\..\strcmpi.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" -# End Group -# Begin Group "Resource Files" +# Begin Source File + +SOURCE=..\aslink.h +# End Source File +# Begin Source File -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +SOURCE=..\..\..\sdcc_vc.h +# End Source File # End Group # End Target # End Project diff --git a/as/hc08/lkaomf51.c b/as/link/hc08/lkaomf51.c similarity index 100% rename from as/hc08/lkaomf51.c rename to as/link/hc08/lkaomf51.c diff --git a/as/hc08/lkarea.c b/as/link/hc08/lkarea.c similarity index 94% rename from as/hc08/lkarea.c rename to as/link/hc08/lkarea.c index 86105da0..b103bc0a 100644 --- a/as/hc08/lkarea.c +++ b/as/link/hc08/lkarea.c @@ -37,7 +37,7 @@ * The function newarea() creates and/or modifies area * and areax structures for each A directive read from * the .rel file(s). The function lkparea() is called - * to find tha area structure associated with this name. + * to find the area structure associated with this name. * If the area does not yet exist then a new area * structure is created and linked to any existing * linked area structures. The area flags are copied @@ -203,6 +203,7 @@ lkparea(char *id) ap = areap; axp = (struct areax *) new (sizeof(struct areax)); + axp->a_addr = -1; /* default: no address yet */ while (ap) { if (symeq(id, ap->a_id)) { taxp = ap->a_axp; @@ -271,7 +272,7 @@ lkparea(char *id) * area address. The size of the area * is the sum of the section sizes. * - * NOTE: Relocatable (REL) areas ae always concatenated + * NOTE: Relocatable (REL) areas are always concatenated * with each other, thus relocatable area B * (defined after area A) will follow * relocatable area A independent of the @@ -304,9 +305,9 @@ lkparea(char *id) * functions called: * int fprintf() c_library * VOID lnksect() lkarea.c - * symbol *lkpsym() lksysm.c + * symbol *lkpsym() lksym.c * char * strncpy() c_library - * int symeq() lksysm.c + * int symeq() lksym.c * * side effects: * All area and areax addresses and sizes are @@ -315,6 +316,7 @@ lkparea(char *id) */ unsigned long codemap[2048]; +Addr_T lnksect(struct area *tap); /* * Resolve all area addresses. */ @@ -347,7 +349,10 @@ lnkarea() abs_ap->a_ap = areap; areap = abs_ap; } - ap = ap->a_ap; + else + { + ap = ap->a_ap; + } } /* next accumulate all GSINITx/GSFINAL area sizes @@ -410,6 +415,7 @@ lnkarea() } ap->a_type = 1; } + rloc[ locIndex ] = lnksect(ap); } @@ -419,7 +425,8 @@ lnkarea() * l_ the length of the area */ - if (! symeq(ap->a_id, _abs_)) { + if (! symeq(ap->a_id, _abs_)) + { strncpy(temp+2,ap->a_id,NCPS-2); *(temp+1) = '_'; @@ -464,7 +471,7 @@ lnkarea() } static -Addr_T find_empty_space(Addr_T start, Addr_T size) +Addr_T find_empty_space(Addr_T start, Addr_T size, unsigned long *map) { int i, j, k; unsigned long mask, b; @@ -478,12 +485,12 @@ Addr_T find_empty_space(Addr_T start, Addr_T size) while (i < j) { - if (codemap[i] & mask) + if (map[i] & mask) { k = 32; for (b=0x80000000; b!=0; b>>=1, k--) { - if (codemap[i] & b) + if (map[i] & b) break; } start = a + k; @@ -497,12 +504,12 @@ Addr_T find_empty_space(Addr_T start, Addr_T size) continue; mask &= (1 << ((start + size) & 0x1F)) - 1; - if (codemap[i] & mask) + if (map[i] & mask) { k = 32; for (b=0x80000000; b!=0; b>>=1, k--) { - if (codemap[i] & b) + if (map[i] & b) break; } start = (a & ~0x1F) + k; @@ -514,7 +521,7 @@ Addr_T find_empty_space(Addr_T start, Addr_T size) } static -Addr_T allocate_space(Addr_T start, Addr_T size, char* id) +Addr_T allocate_space(Addr_T start, Addr_T size, char* id, unsigned long *map) { int i, j; unsigned long mask; @@ -525,20 +532,20 @@ Addr_T allocate_space(Addr_T start, Addr_T size, char* id) while (i < j) { - if (codemap[i] & mask) + if (map[i] & mask) { fprintf(stderr, "memory overlap near 0x%X for %s\n", a, id); } - codemap[i++] |= mask; + map[i++] |= mask; mask = 0xFFFFFFFF; a += 32; } mask &= (1 << ((start + size) & 0x1F)) - 1; - if (codemap[i] & mask) + if (map[i] & mask) { fprintf(stderr, "memory overlap near 0x%X for %s\n", a, id); } - codemap[i] |= mask; + map[i] |= mask; return start; } @@ -576,7 +583,6 @@ Addr_T lnksect(struct area *tap) size = 0; addr = tap->a_addr; - /* MB: is this possible for hc08 ??? */ if ((tap->a_flag&A_PAG) && (addr & 0xFF)) { fprintf(stderr, "\n?ASlink-Warning-Paged Area %8s Boundary Error\n", tap->a_id); @@ -599,7 +605,7 @@ Addr_T lnksect(struct area *tap) * Absolute sections */ while (taxp) { - allocate_space(taxp->a_addr, taxp->a_size, tap->a_id); + allocate_space(taxp->a_addr, taxp->a_size, tap->a_id, codemap); taxp->a_addr = 0; /* reset to zero so relative addresses become absolute */ size += taxp->a_size; taxp = taxp->a_axp; @@ -609,14 +615,14 @@ Addr_T lnksect(struct area *tap) * Concatenated sections */ if (tap->a_size) { - addr = find_empty_space(addr, tap->a_size); + addr = find_empty_space(addr, tap->a_size, codemap); } while (taxp) { //find next unused address now if (taxp->a_size) { - addr = find_empty_space(addr, taxp->a_size); - allocate_space(addr, taxp->a_size, tap->a_id); + addr = find_empty_space(addr, taxp->a_size, codemap); + allocate_space(addr, taxp->a_size, tap->a_id, codemap); } taxp->a_addr = addr; addr += taxp->a_size; @@ -626,7 +632,6 @@ Addr_T lnksect(struct area *tap) } tap->a_size = size; - /* MB: is this possible for hc08 ??? */ if ((tap->a_flag&A_PAG) && (size > 256)) { fprintf(stderr, "\n?ASlink-Warning-Paged Area %8s Length Error\n", tap->a_id); diff --git a/as/hc08/lkdata.c b/as/link/hc08/lkdata.c similarity index 99% rename from as/hc08/lkdata.c rename to as/link/hc08/lkdata.c index 44e44233..022ad65c 100644 --- a/as/hc08/lkdata.c +++ b/as/link/hc08/lkdata.c @@ -118,7 +118,7 @@ long code_size=-1; /* code size struct lfile *filep; /* The pointers (lfile *) filep, * (lfile *) cfp, and (FILE *) sfp * are used in conjunction with - * the routine as_getline() to read + * the routine lk_getline() to read * asmlnk commands from * (1) the standard input or * (2) or a command file diff --git a/as/hc08/lkelf.c b/as/link/hc08/lkelf.c similarity index 100% rename from as/hc08/lkelf.c rename to as/link/hc08/lkelf.c diff --git a/as/hc08/lkihx.c b/as/link/hc08/lkihx.c similarity index 100% rename from as/hc08/lkihx.c rename to as/link/hc08/lkihx.c diff --git a/as/hc08/lklibr.c b/as/link/hc08/lklibr.c similarity index 98% rename from as/hc08/lklibr.c rename to as/link/hc08/lklibr.c index 9a36e262..f7614d28 100644 --- a/as/hc08/lklibr.c +++ b/as/link/hc08/lklibr.c @@ -133,7 +133,7 @@ addlib() } if(foundcount == 0) { - printf("?ASlink-Warning-Couldn't find library '%s'\n", ip); + fprintf(stderr, "?ASlink-Warning-Couldn't find library '%s'\n", ip); } } @@ -370,7 +370,8 @@ void LoadRel(FILE * libfp, char * ModName) if(EQ(str, ModName)) state=1; else { - printf("Bad offset in library file str=%s, Modname=%s\n", str, ModName); + fprintf(stderr, "?ASlink-Error-Bad offset in library file str=%s, Modname=%s\n", + str, ModName); lkexit(1); } } @@ -631,7 +632,7 @@ char *name; { if ((libfp = fopen(lbnh->libspc, "r")) == NULL) { - fprintf(stderr, "Cannot open library file %s\n", + fprintf(stderr, "ASlink-Error-Cannot open library file %s\n", lbnh->libspc); lkexit(1); } diff --git a/as/hc08/lkmain.c b/as/link/hc08/lkmain.c similarity index 98% rename from as/hc08/lkmain.c rename to as/link/hc08/lkmain.c index 4f6d0ff1..9b37da68 100644 --- a/as/hc08/lkmain.c +++ b/as/link/hc08/lkmain.c @@ -111,7 +111,7 @@ void Areas51 (void) * * The function main() evaluates the command line arguments to * determine if the linker parameters are to input through 'stdin' - * or read from a command file. The functions as_getline() and parse() + * or read from a command file. The functions lk_getline() and parse() * are to input and evaluate the linker parameters. The linking process * proceeds by making the first pass through each .rel file in the order * presented to the linker. At the end of the first pass the setbase(), @@ -165,7 +165,7 @@ void Areas51 (void) * FILE * afile() lkmain.c * int fclose() c_library * int fprintf() c_library - * int as_getline() lklex.c + * int lk_getline() lklex.c * VOID library() lklibr.c * VOID link_main() lkmain.c * VOID lkexit() lkmain.c @@ -188,8 +188,7 @@ void Areas51 (void) */ int -main(argc, argv) -char *argv[]; +main(int argc, char *argv[]) { register char *p; register int c, i; @@ -247,7 +246,7 @@ char *argv[]; filep = startp; while (1) { ip = ib; - if (as_getline() == 0) + if (lk_getline() == 0) break; if (pflag && sfp != stdin) fprintf(stdout, "%s\n", ip); @@ -282,7 +281,7 @@ char *argv[]; Areas51(); /*JCF: Create the default 8051 areas in the right order*/ - while (as_getline()) { + while (lk_getline()) { ip = ib; /* pass any "magic comments" to NoICE output */ @@ -406,8 +405,7 @@ char *argv[]; */ VOID -lkexit(i) -int i; +lkexit(int i) { if (mfp != NULL) fclose(mfp); if (jfp != NULL) fclose(jfp); @@ -461,7 +459,7 @@ int i; VOID link_main() { - register int c; + register char c; if ((c=endline()) == 0) { return; } switch (c) { @@ -945,7 +943,7 @@ bassav() /*)Function VOID setbas() * - * The function setbas() scans the base address lines in hte + * The function setbas() scans the base address lines in the * basep structure, evaluates the arguments, and sets beginning * address of the specified areas. * @@ -1056,7 +1054,7 @@ gblsav() /*)Function VOID setgbl() * - * The function setgbl() scans the global variable lines in hte + * The function setgbl() scans the global variable lines in the * globlp structure, evaluates the arguments, and sets a variable * to this value. * @@ -1158,9 +1156,7 @@ setgbl() */ FILE * -afile(fn, ft, wf) -char *fn; -char *ft; +afile(char *fn, char *ft, int wf) { FILE *fp; char fb[PATH_MAX]; @@ -1239,7 +1235,6 @@ iramsav() { unget(getnb()); if (ip && *ip) - //iram_size = atoi(ip); iram_size = expr(0); /* evaluate size expression */ else iram_size = 128; /* Default is 128 (0x80) bytes */ diff --git a/as/hc08/lkmem.c b/as/link/hc08/lkmem.c similarity index 99% rename from as/hc08/lkmem.c rename to as/link/hc08/lkmem.c index db9a2cd9..e250f95d 100644 --- a/as/hc08/lkmem.c +++ b/as/link/hc08/lkmem.c @@ -22,7 +22,6 @@ #include #include #include "aslink.h" -#include "strcmpi.h" int summary(struct area * areap) { @@ -257,7 +256,7 @@ int summary(struct area * areap) REPORT_ERROR(buff, 1); } #endif - /*Report the position of the begining of the stack*/ + /*Report the position of the beginning of the stack*/ fprintf(of, "\n%stack starts at: 0x%02lx (sp set to 0x%02lx)", rflag ? "16 bit mode initial s" : "S", Stack.Start, Stack.Start-1); diff --git a/as/hc08/lkrloc.c b/as/link/hc08/lkrloc.c similarity index 97% rename from as/hc08/lkrloc.c rename to as/link/hc08/lkrloc.c index 954b9c63..7aaf0c58 100644 --- a/as/hc08/lkrloc.c +++ b/as/link/hc08/lkrloc.c @@ -81,9 +81,7 @@ static int lastAreaIndex = -1; * */ -VOID -reloc(c) -char c; +VOID reloc(char c) { switch(c) { @@ -155,8 +153,7 @@ char c; * */ -VOID -relt() +VOID relt(VOID) { rtcnt = 0; while (more()) { @@ -256,8 +253,7 @@ relt() * */ -VOID -relr() +VOID relr(VOID) { register int mode; register Addr_T reli, relv; @@ -639,8 +635,7 @@ char *errmsg[] = { * */ -VOID -relp() +VOID relp(VOID) { register int aindex, rindex; int mode, rtp; @@ -740,8 +735,7 @@ relp() * */ -VOID -rele() +VOID rele(VOID) { if (uflag != 0) { lkulist(0); @@ -777,8 +771,7 @@ rele() * */ -Addr_T -evword() +Addr_T evword(VOID) { register Addr_T v; @@ -815,10 +808,7 @@ evword() * */ -Addr_T -adb_b(v, i) -register Addr_T v; -register int i; +Addr_T adb_b(register Addr_T v, register int i) { return(rtval[i] += v); } @@ -850,10 +840,7 @@ register int i; * */ -Addr_T -adb_lo(v, i) -Addr_T v; -int i; +Addr_T adb_lo(Addr_T v, int i) { register Addr_T j; @@ -896,10 +883,7 @@ int i; * */ -Addr_T -adb_hi(v, i) -Addr_T v; -int i; +Addr_T adb_hi(Addr_T v, int i) { register Addr_T j; @@ -942,8 +926,7 @@ int i; * */ -Addr_T -adb_24_hi(Addr_T v, int i) +Addr_T adb_24_hi(Addr_T v, int i) { register Addr_T j; @@ -990,8 +973,7 @@ adb_24_hi(Addr_T v, int i) * */ -Addr_T -adb_24_mid(Addr_T v, int i) +Addr_T adb_24_mid(Addr_T v, int i) { register Addr_T j; @@ -1031,8 +1013,7 @@ adb_24_mid(Addr_T v, int i) * */ -Addr_T -adb_24_lo(Addr_T v, int i) +Addr_T adb_24_lo(Addr_T v, int i) { register Addr_T j; @@ -1075,10 +1056,7 @@ adb_24_lo(Addr_T v, int i) * */ -Addr_T -adw_w(v, i) -register Addr_T v; -register int i; +Addr_T adw_w(register Addr_T v, register int i) { register Addr_T j; @@ -1116,8 +1094,7 @@ register int i; * The word value of rtval[] is changed. * */ -Addr_T -adw_24(Addr_T v, int i) +Addr_T adw_24(Addr_T v, int i) { register Addr_T j; @@ -1165,10 +1142,7 @@ adw_24(Addr_T v, int i) * */ -Addr_T -adw_lo(v, i) -Addr_T v; -int i; +Addr_T adw_lo(Addr_T v, int i) { register Addr_T j; @@ -1211,10 +1185,7 @@ int i; * */ -Addr_T -adw_hi(v, i) -Addr_T v; -int i; +Addr_T adw_hi(Addr_T v, int i) { register Addr_T j; @@ -1253,9 +1224,7 @@ int i; * */ -VOID -relerr(str) -char *str; +VOID relerr(char *str) { errdmp(stderr, str); if (mfp) @@ -1293,10 +1262,7 @@ char *str; * */ -VOID -errdmp(fptr, str) -FILE *fptr; -char *str; +VOID errdmp(FILE *fptr, char *str) { int mode, aindex, rindex; struct sym **s; @@ -1381,10 +1347,7 @@ char *str; * */ -VOID -prntval(fptr, v) -FILE *fptr; -Addr_T v; +VOID prntval(FILE *fptr, Addr_T v) { if (xflag == 0) { fprintf(fptr, "%04X\n", v); @@ -1418,9 +1381,7 @@ Addr_T v; * */ -VOID -relerp(str) -char *str; +VOID relerp(char *str) { erpdmp(stderr, str); if (mfp) @@ -1451,10 +1412,7 @@ char *str; * */ -VOID -erpdmp(fptr, str) -FILE *fptr; -char *str; +VOID erpdmp(FILE *fptr, char *str) { register struct head *thp; diff --git a/as/hc08/lks19.c b/as/link/hc08/lks19.c similarity index 100% rename from as/hc08/lks19.c rename to as/link/hc08/lks19.c diff --git a/as/hc08/lkeval.c b/as/link/lkeval.c similarity index 100% rename from as/hc08/lkeval.c rename to as/link/lkeval.c diff --git a/as/link/mcs51/lkhead.c b/as/link/lkhead.c similarity index 99% rename from as/link/mcs51/lkhead.c rename to as/link/lkhead.c index 41a5198c..b9c5541a 100644 --- a/as/link/mcs51/lkhead.c +++ b/as/link/lkhead.c @@ -108,6 +108,7 @@ newhead() */ lkparea(_abs_); ap->a_flag = A_ABS; + axp->a_addr = 0; } /*)Function VOID module() diff --git a/as/link/mcs51/lklex.c b/as/link/lklex.c similarity index 100% rename from as/link/mcs51/lklex.c rename to as/link/lklex.c diff --git a/as/hc08/lklist.c b/as/link/lklist.c similarity index 100% rename from as/hc08/lklist.c rename to as/link/lklist.c diff --git a/as/link/mcs51/lknoice.c b/as/link/lknoice.c similarity index 100% rename from as/link/mcs51/lknoice.c rename to as/link/lknoice.c diff --git a/as/link/mcs51/lksym.c b/as/link/lksym.c similarity index 100% rename from as/link/mcs51/lksym.c rename to as/link/lksym.c diff --git a/as/link/mcs51/Makefile.in b/as/link/mcs51/Makefile.in index 1d11f188..071cd958 100644 --- a/as/link/mcs51/Makefile.in +++ b/as/link/mcs51/Makefile.in @@ -37,12 +37,13 @@ CFLAGS = @CFLAGS@ -Wall -DINDEXLIB M_OR_MM = @M_OR_MM@ LDFLAGS = @LDFLAGS@ -LKOBJECTS = lkmain.o lkhead.o lkarea.o lkdata.o \ - lkeval.o lklex.o lksym.o lkrloc.o \ - lklibr.o lklist.o lkihx.o lks19.o \ - lknoice.o lkmem.o lkaomf51.o \ - ../lkstore.o \ - strcmpi.o +LKOBJECTS = lkmain.o lkarea.o lkdata.o \ + lkrloc.o \ + lklibr.o lkihx.o lks19.o \ + lkmem.o lkaomf51.o \ + ../lkeval.o ../lkhead.o ../lklex.o ../lklist.o \ + ../lknoice.o ../lkstore.o ../lksym.o \ + ../../strcmpi.o LKSOURCES = $(patsubst %.o,%.c,$(LKOBJECTS)) ASLINK = $(top_builddir)bin/aslink$(EXEEXT) diff --git a/as/link/mcs51/aslink.dsp b/as/link/mcs51/aslink.dsp index 9d49a88d..b1c68f33 100644 --- a/as/link/mcs51/aslink.dsp +++ b/as/link/mcs51/aslink.dsp @@ -7,19 +7,19 @@ CFG=aslink - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "aslink.mak". -!MESSAGE +!MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "aslink.mak" CFG="aslink - Win32 Release" -!MESSAGE +!MESSAGE !MESSAGE Possible choices for configuration are: -!MESSAGE +!MESSAGE !MESSAGE "aslink - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE "aslink - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE +!MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 @@ -55,19 +55,19 @@ LINK32=link.exe !ELSEIF "$(CFG)" == "aslink - Win32 Release" # PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "mcs51\Release" # PROP BASE Intermediate_Dir "mcs51\Release" # PROP BASE Ignore_Export_Lib 0 # PROP BASE Target_Dir "" # PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 +# PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FD /c -# ADD CPP /nologo /ML /W3 /GX /O2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FD /c +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -77,7 +77,7 @@ LINK32=link.exe # ADD BASE LINK32 /nologo /subsystem:console /machine:I386 /out:"..\..\..\bin_vc\aslink.exe" /pdbtype:sept # ADD LINK32 /nologo /subsystem:console /machine:I386 /out:"..\..\..\bin_vc\aslink.exe" /pdbtype:sept -!ENDIF +!ENDIF # Begin Target @@ -100,11 +100,11 @@ SOURCE=.\lkdata.c # End Source File # Begin Source File -SOURCE=.\lkeval.c +SOURCE=..\lkeval.c # End Source File # Begin Source File -SOURCE=.\lkhead.c +SOURCE=..\lkhead.c # End Source File # Begin Source File @@ -112,7 +112,7 @@ SOURCE=.\lkihx.c # End Source File # Begin Source File -SOURCE=.\lklex.c +SOURCE=..\lklex.c # End Source File # Begin Source File @@ -120,7 +120,7 @@ SOURCE=.\lklibr.c # End Source File # Begin Source File -SOURCE=.\lklist.c +SOURCE=..\lklist.c # End Source File # Begin Source File @@ -132,7 +132,7 @@ SOURCE=.\lkmem.c # End Source File # Begin Source File -SOURCE=.\lknoice.c +SOURCE=..\lknoice.c # End Source File # Begin Source File @@ -148,11 +148,11 @@ SOURCE=..\lkstore.c # End Source File # Begin Source File -SOURCE=.\lksym.c +SOURCE=..\lksym.c # End Source File # Begin Source File -SOURCE=.\strcmpi.c +SOURCE=..\..\strcmpi.c # End Source File # End Group # Begin Group "Header Files" @@ -160,11 +160,7 @@ SOURCE=.\strcmpi.c # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File -SOURCE=..\alloc.h -# End Source File -# Begin Source File - -SOURCE=.\aslink.h +SOURCE=..\aslink.h # End Source File # End Group # End Target diff --git a/as/link/mcs51/lkeval.c b/as/link/mcs51/lkeval.c deleted file mode 100644 index 90df0031..00000000 --- a/as/link/mcs51/lkeval.c +++ /dev/null @@ -1,396 +0,0 @@ -/* lkeval.c */ - -/* - * (C) Copyright 1989-1995 - * All Rights Reserved - * - * Alan R. Baldwin - * 721 Berkeley St. - * Kent, Ohio 44240 - */ - -#include -#include -#include "aslink.h" - -/*)Module lkeval.c - * - * The module lkeval.c contains the routines to evaluate - * arithmetic/numerical expressions. The functions in - * lkeval.c perform a recursive evaluation of the arithmetic - * expression read from the input text line. - * The expression may include binary/unary operators, brackets, - * symbols, labels, and constants in hexadecimal, decimal, octal - * and binary. Arithmetic operations are prioritized and - * evaluated by normal arithmetic conventions. - * - * lkeval.c contains the following functions: - * int digit() - * Addr_T eval() - * Addr_T expr() - * int oprio() - * Addr_T term() - * - * lkeval.c contains no local/static variables - */ - -/*)Function Addr_T eval() - * - * The function eval() evaluates a character string to a - * numerical value. - * - * local variables: - * int c character from input string - * int v value of character in current radix - * Addr_T n evaluation value - * - * global variables: - * int radix current number conversion radix - * - * functions called: - * int digit() lkeval.c - * char get() lklex.c - * char getnb() lklex.c - * VOID unget() lklex.c - * - * side effects: - * Input test is scanned and evaluated to a - * numerical value. - */ - -Addr_T -eval() -{ - register int c, v; - register Addr_T n; - - c = getnb(); - n = 0; - while ((v = digit(c, radix)) >= 0) { - n = n*radix + v; - c = get(); - } - unget(c); - return(n); -} - -/*)Function Addr_T expr(n) - * - * int n a firewall priority; all top - * level calls (from the user) - * should be made with n set to 0. - * - * The function expr() evaluates an expression and - * returns the value. - * - * local variables: - * int c current input text character - * int p current operator priority - * Addr_T v value returned by term() - * Addr_T ve value returned by a - * recursive call to expr() - * - * global variables: - * char ctype[] array of character types, one per - * ASCII character - * int lkerr error flag - * FILE * stderr c_library - * - * functions called: - * VOID expr() lkeval.c - * int fprintf() c_library - * int getnb() lklex.c - * int oprio() lkeval.c - * VOID term() lkeval.c - * VOID unget() lklex.c - * - * - * side effects: - * An expression is evaluated by scanning the input - * text string. - */ - -Addr_T -expr (n) -{ - register int c, p; - register Addr_T v, ve; - - v = term(); - while (ctype[c = getnb()] & BINOP) { - if ((p = oprio(c)) <= n) - break; - if ((c == '>' || c == '<') && c != get()) { - fprintf(stderr, "Invalid expression"); - lkerr++; - return(v); - } - ve = expr(p); - if (c == '+') { - v += ve; - } else - if (c == '-') { - v -= ve; - } else { - switch (c) { - - case '*': - v *= ve; - break; - - case '/': - v /= ve; - break; - - case '&': - v &= ve; - break; - - case '|': - v |= ve; - break; - - case '%': - v %= ve; - break; - - case '^': - v ^= ve; - break; - - case '<': - v <<= ve; - break; - - case '>': - v >>= ve; - break; - } - } - } - unget(c); - return(v); -} - -/*)Function Addr_T term() - * - * The function term() evaluates a single constant - * or symbol value prefaced by any unary operator - * ( +, -, ~, ', ", >, or < ). - * - * local variables: - * int c current character - * char id[] symbol name - * int n value of digit in current radix - * int r current evaluation radix - * sym * sp pointer to a sym structure - * Addr_T v evaluation value - * - * global variables: - * char ctype[] array of character types, one per - * ASCII character - * int lkerr error flag - * - * functions called: - * int digit() lkeval.c - * VOID expr() lkeval.c - * int fprintf() c_library - * int get() lklex.c - * VOID getid() lklex.c - * int getmap() lklex.c - * int getnb() lklex.c - * sym * lkpsym() lksym.c - * Addr_T symval() lksym.c - * VOID unget() lklex.c - * - * side effects: - * An arithmetic term is evaluated by scanning input text. - */ - -Addr_T -term() -{ - register int c, r, n; - register Addr_T v; - struct sym *sp; - char id[NCPS]; - - c = getnb(); - if (c == '#') { c = getnb(); } - if (c == '(') { - v = expr(0); - if (getnb() != ')') { - fprintf(stderr, "Missing delimiter"); - lkerr++; - } - return(v); - } - if (c == '-') { - return(0-expr(100)); - } - if (c == '~') { - return(~expr(100)); - } - if (c == '\'') { - return(getmap(-1)&0377); - } - if (c == '\"') { - if (hilo) { - v = (getmap(-1)&0377)<<8; - v |= getmap(-1)&0377; - } else { - v = getmap(-1)&0377; - v |= (getmap(-1)&0377)<<8; - } - return(v); - } - if (c == '>' || c == '<') { - v = expr(100); - if (c == '>') - v >>= 8; - return(v&0377); - } - if (ctype[c] & DIGIT) { - r = 10; - if (c == '0') { - c = get(); - switch (c) { - case 'b': - case 'B': - r = 2; - c = get(); - break; - case '@': - case 'o': - case 'O': - case 'q': - case 'Q': - r = 8; - c = get(); - break; - case 'd': - case 'D': - r = 10; - c = get(); - break; - case 'h': - case 'H': - case 'x': - case 'X': - r = 16; - c = get(); - break; - default: - break; - } - } - v = 0; - while ((n = digit(c, r)) >= 0) { - v = r*v + n; - c = get(); - } - unget(c); - return(v); - } - if (ctype[c] & LETTER) { - getid(id, c); - if ((sp = lkpsym(id, 0)) == NULL) { - fprintf(stderr, "Undefined symbol %8s\n", id); - lkerr++; - return(0); - } else { - return(symval(sp)); - } - } - return(0); -} - -/*)Function int digit(c, r) - * - * int c digit character - * int r current radix - * - * The function digit() returns the value of c - * in the current radix r. If the c value is not - * a number of the current radix then a -1 is returned. - * - * local variables: - * none - * - * global variables: - * char ctype[] array of character types, one per - * ASCII character - * - * functions called: - * none - * - * side effects: - * none - */ - -int -digit(c, r) -register int c, r; -{ - if (r == 16) { - if (ctype[c] & RAD16) { - if (c >= 'A' && c <= 'F') - return (c - 'A' + 10); - if (c >= 'a' && c <= 'f') - return (c - 'a' + 10); - return (c - '0'); - } - } else - if (r == 10) { - if (ctype[c] & RAD10) - return (c - '0'); - } else - if (r == 8) { - if (ctype[c] & RAD8) - return (c - '0'); - } else - if (r == 2) { - if (ctype[c] & RAD2) - return (c - '0'); - } - return (-1); -} - -/*)Function int oprio(c) - * - * int c operator character - * - * The function oprio() returns a relative priority - * for all valid unary and binary operators. - * - * local variables: - * none - * - * global variables: - * none - * - * functions called: - * none - * - * side effects: - * none - */ - -int -oprio(c) -register int c; -{ - if (c == '*' || c == '/' || c == '%') - return (10); - if (c == '+' || c == '-') - return (7); - if (c == '<' || c == '>') - return (5); - if (c == '^') - return (4); - if (c == '&') - return (3); - if (c == '|') - return (1); - return (0); -} diff --git a/as/link/mcs51/lklist.c b/as/link/mcs51/lklist.c deleted file mode 100644 index 5325ec89..00000000 --- a/as/link/mcs51/lklist.c +++ /dev/null @@ -1,1099 +0,0 @@ -/* lklist.c */ - -/* - * (C) Copyright 1989-1995 - * All Rights Reserved - * - * Alan R. Baldwin - * 721 Berkeley St. - * Kent, Ohio 44240 - * - * 28-Oct-97 JLH: - * - lstarea: show s_id as string rather than array [NCPS] - * - lstarea: show a_id as string rather than array [NCPS] - * 31-Oct-97 JLH: add NoICE output file genration in lstarea - * 02-Apr-98 JLH: add XDATA, DATA, BIT flags to area output - */ - -#include -#include -#include -#include "aslink.h" - -/*)Module lklist.c - * - * The module lklist.c contains the functions which - * output the linker .map file and produce a relocated - * listing .rst file. - * - * lklist.c contains the following functions: - * int dgt() - * VOID lstarea() - * VOID lkulist() - * VOID lkalist() - * VOID lkglist() - * VOID newpag() - * VOID slew() - * - * lklist.c contains no local variables. - */ - -/*)Function VOID slew(fp) - * - * FILE * fp output file handle - * - * The function slew() increments the page line counter. - * If the number of lines exceeds the maximum number of - * lines per page then a page skip and a page header are - * output. - * - * local variables: - * int i loop counter - * - * global variables: - * int lop current line number on page - * int xflag Map file radix type flag - * - * functions called: - * int fprintf() c_library - * VOID newpag() lklist.c - * - * side effects: - * The page line and the page count may be updated. - */ - -VOID -slew(fp) -FILE *fp; -{ - register int i; - - if (lop++ >= NLPP) { - newpag(fp); - if (xflag == 0) { - fprintf(fp, "Hexadecimal\n\n"); - } else - if (xflag == 1) { - fprintf(fp, "Octal\n\n"); - } else - if (xflag == 2) { - fprintf(fp, "Decimal\n\n"); - } - fprintf(fp, "Area Addr Size"); - fprintf(fp, " Decimal Bytes (Attributes)\n"); - for(i=0;i<4;++i) - fprintf(fp, " Value--Global"); - fprintf(fp, "\n\n"); - lop += 6; - } -} - -/*)Function VOID newpag() - * - * The function newpag() outputs a page skip, writes the - * first page header line, sets the line count to 1, and - * increments the page counter. - * - * local variables: - * none - * - * global variables: - * int lop current line number on page - * int page current page number - * - * functions called: - * int fprintf() c_library - * - * side effects: - * The page and line counters are updated. - */ - -VOID -newpag(fp) -FILE *fp; -{ - fprintf(fp, "\fASxxxx Linker %s, page %u.\n", VERSION, ++page); - lop = 1; -} - -/* Used for qsort call in lstsym */ -static int _cmpSymByAddr(const void *p1, const void *p2) -{ - struct sym **s1 = (struct sym **)(p1); - struct sym **s2 = (struct sym **)(p2); - int delta = ((*s1)->s_addr + (*s1)->s_axp->a_addr) - - ((*s2)->s_addr + (*s2)->s_axp->a_addr); - - /* Sort first by address, then by name. */ - if (delta) - { - return delta; - } - return strcmp((*s1)->s_id,(*s2)->s_id); -} - - -#if NCPS-8 - -/* NCPS != 8 */ -/*)Function VOID lstarea(xp) - * - * area * xp pointer to an area structure - * - * The function lstarea() creates the linker map output for - * the area specified by pointer xp. The generated output - * area header includes the area name, starting address, - * size of area, number of words (in decimal), and the - * area attributes. The symbols defined in this area are - * sorted by ascending address and output one per line - * in the selected radix. - * - * local variables: - * areax * oxp pointer to an area extension structure - * int c character value - * int i loop counter - * int j bubble sort update status - * char * ptr pointer to an id string - * int nmsym number of symbols in area - * Addr_T a0 temporary - * Addr_T ai temporary - * Addr_T aj temporary - * sym * sp pointer to a symbol structure - * sym ** p pointer to an array of - * pointers to symbol structures - * - * global variables: - * FILE *mfp Map output file handle - * sym *symhash[NHASH] array of pointers to NHASH - * linked symbol lists - * int xflag Map file radix type flag - * - * functions called: - * int fprintf() c_library - * VOID free() c_library - * char * malloc() c_library - * char putc() c_library - * VOID slew() lklist.c - * - * side effects: - * Map output generated. - */ - -VOID -lstarea(xp) -struct area *xp; -{ - register struct areax *oxp; - register int i; - /* int j; */ - register char *ptr; - int nmsym; - /* Addr_T a0; */ - Addr_T ai, aj; - struct sym *sp; - struct sym **p; - int memPage; - - putc('\n', mfp); - if (xflag == 0) { - fprintf(mfp, "Hexadecimal\n\n"); - } else - if (xflag == 1) { - fprintf(mfp, "Octal\n\n"); - } else - if (xflag == 2) { - fprintf(mfp, "Decimal\n\n"); - } - fprintf(mfp, "Area "); - fprintf(mfp, "Addr Size Decimal %s (Attributes)\n", - (xp->a_flag & A_BIT)?"Bits ":"Bytes");/* JCF: For BIT print bits...*/ - fprintf(mfp, "-------------------------------- "); - fprintf(mfp, "---- ---- ------- ----- ------------\n"); - /* - * Output Area Header - */ - ptr = &xp->a_id[0]; - fprintf(mfp, "%-32s", ptr ); /* JLH: width matches --- above */ - ai = xp->a_addr; - aj = xp->a_size; - if (xflag == 0) { - fprintf(mfp, " %04X %04X", ai, aj); - } else - if (xflag == 1) { - fprintf(mfp, " %06o %06o", ai, aj); - } else - if (xflag == 2) { - fprintf(mfp, " %05u %05u", ai, aj); - } - fprintf(mfp, " = %6u. %s ", aj, - (xp->a_flag & A_BIT)?"bits ":"bytes"); /* JCF: For BIT print bits...*/ - if (xp->a_flag & A_ABS) { - fprintf(mfp, "(ABS"); - } else { - fprintf(mfp, "(REL"); - } - if (xp->a_flag & A_OVR) { - fprintf(mfp, ",OVR"); - } else { - fprintf(mfp, ",CON"); - } - if (xp->a_flag & A_PAG) { - fprintf(mfp, ",PAG"); - } - - memPage = 0x00; - if (xp->a_flag & A_CODE) { - fprintf(mfp, ",CODE"); - memPage = 0x0C; - } - if (xp->a_flag & A_XDATA) { - fprintf(mfp, ",XDATA"); - memPage = 0x0D; - } - if (xp->a_flag & A_BIT) { - fprintf(mfp, ",BIT"); - memPage = 0x0B; - } - fprintf(mfp, ")"); - if (xp->a_flag & A_PAG) { - ai = (ai & 0xFF); - aj = (aj > 256); - if (ai || aj) { fprintf(mfp, " "); } - if (ai) { fprintf(mfp, " Boundary"); } - if (ai & aj) { fprintf(mfp, " /"); } - if (aj) { fprintf(mfp, " Length"); } - if (ai || aj) { fprintf(mfp, " Error"); } - } - - /* - * Find number of symbols in area - */ - nmsym = 0; - oxp = xp->a_axp; - while (oxp) { - for (i=0; is_axp) - ++nmsym; - sp = sp->s_sp; - } - } - oxp = oxp->a_axp; - } - if (nmsym == 0) { - putc('\n', mfp); - return; - } - - /* - * Allocate space for an array of pointers to symbols - * and load array. - */ - if ( (p = (struct sym **) malloc(nmsym*sizeof(struct sym *))) - == NULL) { - fprintf(mfp, "\nInsufficient space to build Map Segment.\n"); - return; - } - nmsym = 0; - oxp = xp->a_axp; - while (oxp) { - for (i=0; is_axp) { - p[nmsym++] = sp; - } - sp = sp->s_sp; - } - } - oxp = oxp->a_axp; - } - -#if 0 - /* - * Bubble Sort of Addresses in Symbol Table Array - */ - j = 1; - while (j) { - j = 0; - sp = p[0]; - a0 = sp->s_addr + sp->s_axp->a_addr; - for (i=1; is_addr + sp->s_axp->a_addr; - if (a0 > ai) { - j = 1; - p[i] = p[i-1]; - p[i-1] = sp; - } - a0 = ai; - } - } -#else - qsort(p, nmsym, sizeof(struct sym *), _cmpSymByAddr); -#endif - - /* - * Symbol Table Output - */ - - i = 0; - fprintf(mfp, "\n\n"); - fprintf(mfp, " Value Global\n"); - fprintf(mfp, " -------- --------------------------------"); - while (i < nmsym) { - fprintf(mfp, "\n"); - if (memPage != 0) - fprintf(mfp, " %02X:", memPage); - else - fprintf(mfp, " "); - - sp = p[i]; - aj = sp->s_addr + sp->s_axp->a_addr; - if (xflag == 0) { - fprintf(mfp, "%04X ", aj); - } else - if (xflag == 1) { - fprintf(mfp, "%06o ", aj); - } else - if (xflag == 2) { - fprintf(mfp, "%05u ", aj); - } - ptr = &sp->s_id[0]; - fprintf(mfp, "%s", ptr ); - - /* if cdb flag set the output cdb Information - and the symbol has a '$' sign in it then */ - if (dflag && - strchr(ptr,'$')) - fprintf(dfp,"L:%s:%X\n",ptr,aj); - - /* NoICE output of symbol */ - if (jflag) DefineNoICE( ptr, aj, memPage ); - - i++; - } - putc('\n', mfp); - free(p); -} - -#else - -/* NCPS == 8 */ -/*)Function VOID lstarea(xp) - * - * area * xp pointer to an area structure - * - * The function lstarea() creates the linker map output for - * the area specified by pointer xp. The generated output - * area header includes the area name, starting address, - * size of area, number of words (in decimal), and the - * area attributes. The symbols defined in this area are - * sorted by ascending address and output four per line - * in the selected radix. - * - * local variables: - * areax * oxp pointer to an area extension structure - * int c character value - * int i loop counter - * int j bubble sort update status - * char * ptr pointer to an id string - * int nmsym number of symbols in area - * Addr_T a0 temporary - * Addr_T ai temporary - * Addr_T aj temporary - * sym * sp pointer to a symbol structure - * sym ** p pointer to an array of - * pointers to symbol structures - * - * global variables: - * FILE *mfp Map output file handle - * sym *symhash[NHASH] array of pointers to NHASH - * linked symbol lists - * int xflag Map file radix type flag - * - * functions called: - * int fprintf() c_library - * VOID free() c_library - * char * malloc() c_library - * char putc() c_library - * VOID slew() lklist.c - * - * side effects: - * Map output generated. - */ - -VOID -lstarea(xp) -struct area *xp; -{ - register struct areax *oxp; - register c, i, j; - register char *ptr; - int nmsym; - Addr_T a0, ai, aj; - struct sym *sp; - struct sym **p; - int page; - - putc('\n', mfp); - slew(mfp); - /* - * Output Area Header - */ - ptr = &xp->a_id[0]; - while (ptr < &xp->a_id[NCPS]) { - if ((c = *ptr++) != 0) { - putc(c, mfp); - } else { - putc(' ', mfp); - } - } - ai = xp->a_addr; - aj = xp->a_size; - if (xflag == 0) { - fprintf(mfp, " %04X %04X", ai, aj); - } else - if (xflag == 1) { - fprintf(mfp, " %06o %06o", ai, aj); - } else - if (xflag == 2) { - fprintf(mfp, " %05u %05u", ai, aj); - } - fprintf(mfp, " = %6u. bytes ", aj); - if (xp->a_flag & A_ABS) { - fprintf(mfp, "(ABS"); - } else { - fprintf(mfp, "(REL"); - } - if (xp->a_flag & A_OVR) { - fprintf(mfp, ",OVR"); - } else { - fprintf(mfp, ",CON"); - } - if (xp->a_flag & A_PAG) { - fprintf(mfp, ",PAG"); - } - - page = 0x00; - if (xp->a_flag & A_CODE) { - fprintf(mfp, ",CODE"); - memPage = 0x0C; - } - if (xp->a_flag & A_XDATA) { - fprintf(mfp, ",XDATA"); - memPage = 0x0D; - } - if (xp->a_flag & A_BIT) { - fprintf(mfp, ",BIT"); - memPage = 0x0B; - } - fprintf(mfp, ")"); - if (xp->a_flag & A_PAG) { - ai = (ai & 0xFF); - aj = (aj > 256); - if (ai || aj) { fprintf(mfp, " "); } - if (ai) { fprintf(mfp, " Boundary"); } - if (ai & aj) { fprintf(mfp, " /"); } - if (aj) { fprintf(mfp, " Length"); } - if (ai || aj) { fprintf(mfp, " Error"); } - } - - /* - * Find number of symbols in area - */ - nmsym = 0; - oxp = xp->a_axp; - while (oxp) { - for (i=0; is_axp) - ++nmsym; - sp = sp->s_sp; - } - } - oxp = oxp->a_axp; - } - if (nmsym == 0) { - putc('\n', mfp); - slew(mfp); - return; - } - - /* - * Allocate space for an array of pointers to symbols - * and load array. - */ - if ( (p = (struct sym **) malloc(nmsym*sizeof(struct sym *))) - == NULL) { - fprintf(mfp, "\nInsufficient space to build Map Segment.\n"); - slew(mfp); - return; - } - nmsym = 0; - oxp = xp->a_axp; - while (oxp) { - for (i=0; is_axp) { - p[nmsym++] = sp; - } - sp = sp->s_sp; - } - } - oxp = oxp->a_axp; - } - -#if 0 - /* - * Bubble Sort of Addresses in Symbol Table Array - */ - j = 1; - while (j) { - j = 0; - sp = p[0]; - a0 = sp->s_addr + sp->s_axp->a_addr; - for (i=1; is_addr + sp->s_axp->a_addr; - if (a0 > ai) { - j = 1; - p[i] = p[i-1]; - p[i-1] = sp; - } - a0 = ai; - } - } -#else - qsort(p, nmsym, sizeof(struct sym *), _cmpSymByAddr); -#endif - - /* - * Symbol Table Output - */ - i = 0; - while (i < nmsym) { - fprintf(mfp, "\n"); - slew(mfp); - fprintf(mfp, " "); - sp = p[i]; - aj = sp->s_addr + sp->s_axp->a_addr; - if (xflag == 0) { - fprintf(mfp, " %04X ", aj); - } else - if (xflag == 1) { - fprintf(mfp, "%06o ", aj); - } else - if (xflag == 2) { - fprintf(mfp, " %05u ", aj); - } - ptr = &sp->s_id[0]; - fprintf(mfp, "%s", ptr ); - - /* NoICE output of symbol */ - if (jflag) DefineNoICE( ptr, aj, memPage ); - } - putc('\n', mfp); - free(p); - slew(mfp); -} -#endif - -/*)Function VOID lkulist(i) - * - * int i i # 0 process LST to RST file - * i = 0 copy remainder of LST file - * to RST file and close files - * - * The function lkulist() creates a relocated listing (.rst) - * output file from the ASxxxx assembler listing (.lst) - * files. The .lst file's program address and code bytes - * are changed to reflect the changes made by ASlink as - * the .rel files are combined into a single relocated - * output file. - * - * local variables: - * Addr_T pc current program counter address - * - * global variables: - * int hilo byte order - * int gline get a line from the LST file - * to translate for the RST file - * char rb[] read listing file text line - * FILE *rfp The file handle to the current - * output RST file - * int rtcnt count of data words - * int rtflg[] output the data flag - * Addr_T rtval[] relocated data - * FILE *tfp The file handle to the current - * LST file being scanned - * - * functions called: - * int fclose() c_library - * int fgets() c_library - * int fprintf() c_library - * VOID lkalist() lklist.c - * VOID lkglist() lklist.c - * - * side effects: - * A .rst file is created for each available .lst - * file associated with a .rel file. - */ - -VOID -lkulist(i) -int i; -{ - Addr_T pc; - - /* - * Exit if listing file is not open - */ - if (tfp == NULL) - return; - - /* - * Normal processing of LST to RST - */ - if (i) { - /* - * Evaluate current code address - */ - if (hilo == 0) { - pc = ((rtval[1] & 0xFF) << 8) + (rtval[0] & 0xFF); - } else { - pc = ((rtval[0] & 0xFF) << 8) + (rtval[1] & 0xFF); - } - - /* - * Line with only address - */ - if (rtcnt == 2) { - lkalist(pc); - - /* - * Line with address and code - */ - } else { - for (i=2; i < rtcnt; i++) { - if (rtflg[i]) { - lkglist(pc++, rtval[i] & 0xFF); - } - } - } - - /* - * Copy remainder of LST to RST - */ - } else { - if (gline == 0) - fprintf(rfp, "%s", rb); - - while (fgets(rb, sizeof(rb), tfp) != 0) { - fprintf(rfp, "%s", rb); - } - fclose(tfp); - tfp = NULL; - fclose(rfp); - rfp = NULL; - } -} - -/*)Function VOID lkalist(pc) - * - * int pc current program counter value - * - * The function lkalist() performs the following functions: - * - * (1) if the value of gline = 0 then the current listing - * file line is copied to the relocated listing file output. - * - * (2) the listing file is read line by line and copied to - * the relocated listing file until a valid source - * line number and a program counter value of the correct - * radix is found. The new relocated pc value is substituted - * and the line is written to the RST file. - * - * local variables: - * int i loop counter - * char str[] temporary string - * - * global variables: - * int gcntr data byte counter - * int gline get a line from the LST file - * to translate for the RST file - * char rb[] read listing file text line - * char *rp pointer to listing file text line - * FILE *rfp The file handle to the current - * output RST file - * FILE *tfp The file handle to the current - * LST file being scanned - * - * functions called: - * int dgt() lklist.c - * int fclose() c_library - * int fgets() c_library - * int fprintf() c_library - * int sprintf() c_library - * char * strncpy() c_library - * - * side effects: - * Lines of the LST file are copied to the RST file, - * the last line copied has the code address - * updated to reflect the program relocation. - */ - -VOID -lkalist(pc) -Addr_T pc; -{ - char str[8]; - int i; - - /* - * Exit if listing file is not open - */ -loop: if (tfp == NULL) - return; - - /* - * Copy current LST to RST - */ - if (gline == 0) { - fprintf(rfp, "%s", rb); - gline = 1; - } - - /* - * Clear text line buffer - */ - for (i=0,rp=rb; i -#include "strcmpi.h" int as_strcmpi (const char *s1, const char *s2) { diff --git a/configure b/configure index ae83b810..4ea48196 100755 --- a/configure +++ b/configure @@ -7321,7 +7321,7 @@ if test $OPT_DISABLE_DS400 = 0; then fi if test $OPT_DISABLE_HC08 = 0; then - ac_config_files="$ac_config_files src/hc08/Makefile as/hc08/Makefile" + ac_config_files="$ac_config_files src/hc08/Makefile as/hc08/Makefile as/link/hc08/Makefile" test $OPT_DISABLE_DEVICE_LIB = 0 && ac_config_files="$ac_config_files device/lib/hc08/Makefile" @@ -7900,6 +7900,7 @@ do "device/lib/ds400/Makefile" ) CONFIG_FILES="$CONFIG_FILES device/lib/ds400/Makefile" ;; "src/hc08/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/hc08/Makefile" ;; "as/hc08/Makefile" ) CONFIG_FILES="$CONFIG_FILES as/hc08/Makefile" ;; + "as/link/hc08/Makefile" ) CONFIG_FILES="$CONFIG_FILES as/link/hc08/Makefile" ;; "device/lib/hc08/Makefile" ) CONFIG_FILES="$CONFIG_FILES device/lib/hc08/Makefile" ;; "src/mcs51/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/mcs51/Makefile" ;; "as/mcs51/Makefile" ) CONFIG_FILES="$CONFIG_FILES as/mcs51/Makefile" ;; diff --git a/configure.in b/configure.in index a6a969b6..25ef046b 100755 --- a/configure.in +++ b/configure.in @@ -641,7 +641,8 @@ fi if test $OPT_DISABLE_HC08 = 0; then AC_CONFIG_FILES([src/hc08/Makefile - as/hc08/Makefile]) + as/hc08/Makefile] + as/link/hc08/Makefile]) test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_FILES([device/lib/hc08/Makefile]) fi diff --git a/sdcc.dsw b/sdcc.dsw index f6f49ec2..731efe92 100644 --- a/sdcc.dsw +++ b/sdcc.dsw @@ -228,7 +228,7 @@ Package=<4> ############################################################################### -Project: "link_hc08"=.\as\hc08\link_hc08.dsp - Package Owner=<4> +Project: "link_hc08"=.\as\link\hc08\link_hc08.dsp - Package Owner=<4> Package=<5> {{{ -- 2.47.2