diff options
author | Robert de Bath <rdebath@poboxes.com> | 1996-03-24 17:45:55 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-10-23 23:29:43 +0200 |
commit | fe22c37817ce338fbbc90b239320248c270957fa (patch) | |
tree | d9550410c4a20bdd382fcc58d2d3d7c5e04e5245 /as | |
parent | a7aba15e8efffb1c5d3097656f1a93955a64f01f (diff) | |
parent | 42192453ea219b80d0bf9f41e51e36d3d4d0740b (diff) | |
download | dev86-fe22c37817ce338fbbc90b239320248c270957fa.tar.gz |
Import Dev86-0.0.4.tar.gzv0.0.4
Diffstat (limited to 'as')
-rw-r--r-- | as/Makefile | 29 | ||||
-rw-r--r-- | as/as.c | 10 | ||||
-rw-r--r-- | as/assemble.c | 6 | ||||
-rw-r--r-- | as/const.h | 2 | ||||
-rw-r--r-- | as/error.c | 1 | ||||
-rw-r--r-- | as/genlist.c | 6 | ||||
-rw-r--r-- | as/genobj.c | 16 | ||||
-rw-r--r-- | as/gensym.c | 6 | ||||
-rw-r--r-- | as/macro.c | 9 | ||||
-rw-r--r-- | as/mops.c | 18 | ||||
-rw-r--r-- | as/pops.c | 30 | ||||
-rw-r--r-- | as/readsrc.c | 7 | ||||
-rw-r--r-- | as/table.c | 17 | ||||
-rw-r--r-- | as/type.h | 2 |
14 files changed, 86 insertions, 73 deletions
diff --git a/as/Makefile b/as/Makefile index d7468a9..a4c5456 100644 --- a/as/Makefile +++ b/as/Makefile @@ -1,14 +1,32 @@ -CFLAGS =-O -LDFLAGS = + +ifneq ($(TOPDIR),) +include $(TOPDIR)/Make.defs +else +CC=bcc +LDFLAGS=-s +endif OBJS =as.o assemble.o error.o express.o \ genbin.o genlist.o genobj.o gensym.o \ macro.o mops.o pops.o readsrc.o \ scan.o table.o typeconv.o -as: $(OBJS) - $(CC) $(LDFLAGS) $(OBJS) -o as - chmem =182000 as +all: as86 + +as86: $(OBJS) + $(CC) $(LDFLAGS) $(OBJS) -o as86 + +install: all + install -d $(LIBDIR) + install -m 755 as86 $(LIBDIR) + +typeconv.o: dummy + -cp -p ../ld/typeconv.o . + +dummy: + +clean: + rm -f *.o as86 as.o: const.h type.h byteord.h macro.h file.h flag.h globvar.h assemble.o: const.h type.h address.h globvar.h opcode.h scan.h @@ -25,3 +43,4 @@ pops.o: const.h type.h address.h flag.h globvar.h opcode.h scan.h readsrc.o: const.h type.h flag.h file.h globvar.h macro.h scan.h source.h scan.o: const.h type.h globvar.h scan.h table.o: const.h type.h globvar.h opcode.h scan.h + @@ -21,7 +21,6 @@ void *malloc P((unsigned size)); char *strcpy P((char *s1, const char *s2)); unsigned strlen P((const char *s)); #else -#undef NULL #include <stdlib.h> #include <string.h> #endif @@ -31,7 +30,6 @@ int close P((int fd)); int creat P((const char *path, int mode)); int write P((int fd, const void *buf, unsigned nbytes)); #else -#undef NULL #include <sys/types.h> #include <fcntl.h> #include <unistd.h> @@ -53,7 +51,9 @@ FORWARD void summary P((fd_t fd)); FORWARD void summ_number P((unsigned num)); FORWARD void usage P((void)); +#ifndef USERMEM #define USERMEM (sizeof(int) <= 2 ? (unsigned) 0xAC00 : (unsigned) 0x28000L) +#endif PUBLIC int main(argc, argv) int argc; @@ -146,7 +146,11 @@ char *message; { int fd; +#ifdef O_BINARY + if ((fd = open(name, O_RDWR|O_BINARY|O_CREAT|O_TRUNC, CREAT_PERMS)) < 0 || fd > 255) +#else if ((fd = creat(name, CREAT_PERMS)) < 0 || fd > 255) +#endif as_abort(message); return fd; } @@ -157,7 +161,7 @@ char **argv; { char *arg; bool_t isnextarg; - char *nextarg; + char *nextarg = 0; if (argc <= 1) usage(); diff --git a/as/assemble.c b/as/assemble.c index c438ce6..1fdef1a 100644 --- a/as/assemble.c +++ b/as/assemble.c @@ -155,7 +155,7 @@ PUBLIC void assemble() while (TRUE) { asline(); - if (label != NULL) /* must be confirmed if still set */ + if (label != NUL_PTR) /* must be confirmed if still set */ { /* it is nulled by EQU, COMM and SET */ #ifndef MC6809 #define NEEDENDLABEL ILLAB @@ -172,7 +172,7 @@ PUBLIC void assemble() if ((mcount | popflags) == 0) /* unaccompanied label, display adr like EQU and SET */ showlabel(); - label = NULL; /* reset for next line */ + label = NUL_PTR; /* reset for next line */ } skipline(); listline(); @@ -210,7 +210,7 @@ PRIVATE void asline() if (!ifflag) /* not assembling, just test for IF/ELSE/ELSEIF/ENDIF */ { - if (symptr == NULL || !(symptr->type & MNREGBIT) || + if (symptr == NUL_PTR || !(symptr->type & MNREGBIT) || symptr->data & REGBIT || symptr->value_reg_or_op.op.routine >= MIN_NONCOND) return; @@ -41,7 +41,7 @@ #define FORWARD static #define PRIVATE static #define PUBLIC -#define NULL 0 +#define NUL_PTR ((void*)0) /* O/S constants */ @@ -6,7 +6,6 @@ #ifdef STDC_HEADERS_MISSING char *strcpy P((char *s1, const char *s2)); #else -#undef NULL #include <string.h> #endif diff --git a/as/genlist.c b/as/genlist.c index e179fcf..eb3b277 100644 --- a/as/genlist.c +++ b/as/genlist.c @@ -14,14 +14,12 @@ void *memset P((void *s, int c, unsigned n)); unsigned strlen P((const char *s)); #else -#undef NULL #include <string.h> #endif #ifdef POSIX_HEADERS_MISSING int write P((int fd, const void *buf, unsigned nbytes)); #else -#undef NULL #include <sys/types.h> #include <unistd.h> #endif @@ -186,8 +184,8 @@ PUBLIC void listline() { if (!listpre) { - if (errcount || list.current && (!macflag || mcount != 0) || - macflag && maclist.current) + if (errcount || (list.current && (!macflag || mcount != 0)) || + (macflag && maclist.current)) list1(lstfil); if (errcount) { diff --git a/as/genobj.c b/as/genobj.c index 80b03ce..2992232 100644 --- a/as/genobj.c +++ b/as/genobj.c @@ -11,14 +11,12 @@ char *strcpy P((char *s1, const char *s2)); char *strrchr P((const char *s, int c)); unsigned strlen P((const char *s)); #else -#undef NULL #include <string.h> #endif #ifdef POSIX_HEADERS_MISSING int write P((int fd, const void *buf, unsigned nbytes)); #else -#undef NULL #include <sys/types.h> #include <unistd.h> #endif @@ -371,22 +369,22 @@ PUBLIC void objheader() /* build array of imported/exported symbols */ symosiz = 0; - if (truefilename == NULL) + if (truefilename == NUL_PTR) truefilename = filnamptr; nameptr = strrchr(truefilename, DIRCHAR); - strcpy(module_name, nameptr != NULL ? nameptr + 1 : truefilename); - if ((nameptr = strrchr(module_name, '.')) != NULL) + strcpy(module_name, nameptr != NUL_PTR ? nameptr + 1 : truefilename); + if ((nameptr = strrchr(module_name, '.')) != NUL_PTR) *nameptr = 0; strsiz = strlen(module_name) + 1; align(heapptr); for (hashptr = spt, arrext = copyptr = (struct sym_s **) heapptr; hashptr < spt_top;) - if ((symptr = *hashptr++) != NULL) + if ((symptr = *hashptr++) != NUL_PTR) do { if ((symptr->type & EXPBIT || symptr->data & IMPBIT) || - !globals_only_in_obj && symptr->name[0] != '.' && - !(symptr->type & (MNREGBIT | MACBIT | VARBIT))) + (!globals_only_in_obj && symptr->name[0] != '.' && + !(symptr->type & (MNREGBIT | MACBIT | VARBIT)))) { if (copyptr >= (struct sym_s **) heapend) { @@ -412,7 +410,7 @@ PUBLIC void objheader() ++numext; } } - while ((symptr = symptr->next) != NULL); + while ((symptr = symptr->next) != NUL_PTR); heapptr = (char *) (copytop = copyptr); /* calculate length of text, and number of seg size bytes in header */ diff --git a/as/gensym.c b/as/gensym.c index bc773db..c5c6d1b 100644 --- a/as/gensym.c +++ b/as/gensym.c @@ -10,14 +10,12 @@ void *memset P((void *s, int c, unsigned n)); int strcmp P((const char *s1, const char *s2)); #else -#undef NULL #include <string.h> #endif #ifdef POSIX_HEADERS_MISSING int write P((int fd, const void *buf, unsigned nbytes)); #else -#undef NULL #include <sys/types.h> #include <unistd.h> #endif @@ -51,7 +49,7 @@ PUBLIC void gensym() align(heapptr); for (hashptr = spt, symlptr = copyptr = (struct sym_s **) heapptr; hashptr < spt_top;) - if ((symptr = *hashptr++) != NULL) + if ((symptr = *hashptr++) != NUL_PTR) do if (!(symptr->type & (MACBIT | MNREGBIT | VARBIT))) { @@ -66,7 +64,7 @@ PUBLIC void gensym() ++label_count; labels_length += symptr->length + 3; /* 3 for type, value */ } - while ((symptr = symptr->next) != NULL); + while ((symptr = symptr->next) != NUL_PTR); sort_symbols: sort(symlptr, copyptr, TRUE); /* sort on name */ @@ -11,7 +11,6 @@ #ifdef STDC_HEADERS_MISSING int strncmp P((const char *s1, const char *s2, unsigned n)); #else -#undef NULL #include <string.h> #endif @@ -39,7 +38,7 @@ struct sym_s *symptr; ++maclevel; (--macstak)->text = (char *) symptr->value_reg_or_op.value; macstak->parameters = param1 = macpar; - param1->next = NULL; + param1->next = NUL_PTR; *(stringptr = build_number(++macnum, 3, param1->string)) = 0; macpar = (struct schain_s *) (stringptr + 1); /* TODO: alignment */ @@ -70,7 +69,7 @@ struct sym_s *symptr; } *stringptr = 0; param1->next = macpar; /* ptr from previous */ - (param1 = macpar)->next = NULL; + (param1 = macpar)->next = NUL_PTR; /* this goes nowhere */ macpar = (struct schain_s *) (stringptr + 1); /* but is finished OK - TODO align */ @@ -95,12 +94,12 @@ PUBLIC void pmacro() { bool_t saving; bool_t savingc; - struct sym_s *symptr; + struct sym_s *symptr=0; saving = /* prepare for bad macro */ savingc = FALSE; /* normally don't save comments */ macload = TRUE; /* show loading */ - if (label != NULL) + if (label != NUL_PTR) error(ILLAB); else if (sym != IDENT) error(LABEXP); @@ -547,7 +547,7 @@ register struct ea_s *eap; mcount += asize; } else if (lastexp.offset != 0x0 || - eap->base == BPREG && eap->index == NOREG || + (eap->base == BPREG && eap->index == NOREG) || eap->base == EBPREG) { postb |= MEM1_MOD; @@ -917,8 +917,8 @@ register struct ea_s *eap; if (!(lastexp.data & UNDBIT) && lastexp.offset != 0x1) { if (eap->base <= MAX16BITINDREG || - lastexp.offset != 0x2 && lastexp.offset != 0x4 && - lastexp.offset != 0x8) + (lastexp.offset != 0x2 && lastexp.offset != 0x4 && + lastexp.offset != 0x8)) error(ILL_SCALE); else { @@ -1107,16 +1107,16 @@ PUBLIC void mbswap() PUBLIC void mcall() { - opcode_pt far; + opcode_pt far_diff; bool_t indirect; register struct sym_s *symptr; - far = 0x0; + far_diff = 0x0; if (sym == IDENT && (symptr = gsymptr)->type & MNREGBIT && symptr->data & SIZEBIT && symptr->value_reg_or_op.op.routine == FAROP) { - far = 0x8; + far_diff = 0x8; getsym(); } indirect = FALSE; @@ -1174,7 +1174,7 @@ PUBLIC void mcall() opcode = 0x20; else opcode = 0x10; - postb |= opcode + far; + postb |= opcode + far_diff; opcode = 0xFF; } } @@ -1589,9 +1589,9 @@ PUBLIC void mgroup1() { if (target.indcount == 0x0 && (target.base == ALREG || target.base == AXREG || - target.base == EAXREG && + (target.base == EAXREG && (source.displ.data & (FORBIT | RELBIT | UNDBIT) || - !is8bitsignedoffset(source.displ.offset)))) + !is8bitsignedoffset(source.displ.offset))))) { opcode |= 0x04 | segword; buildimm(&source, FALSE); @@ -72,7 +72,7 @@ PUBLIC bool_pt checksegrel(symptr) register struct sym_s *symptr; { if ((symptr->type & LABIT || - symptr->data & IMPBIT && !(symptr->data & UNDBIT)) && + (symptr->data & IMPBIT && !(symptr->data & UNDBIT))) && ((symptr->data ^ lcdata) & (RELBIT | SEGM))) { error(SEGREL); @@ -220,7 +220,7 @@ unsigned char impbits; while (TRUE) { - if ((symptr = needlabel()) != NULL) + if ((symptr = needlabel()) != NUL_PTR) { if (symptr->type & COMMBIT) error(ALREADY); @@ -428,7 +428,7 @@ error_pt errnum; lineptr = oldlineptr; sym = oldsym; symname = oldsymname; - label = NULL; + label = NUL_PTR; } PRIVATE struct sym_s *needlabel() @@ -439,7 +439,7 @@ PRIVATE struct sym_s *needlabel() (symptr = gsymptr)->type & (MACBIT | MNREGBIT | VARBIT)) { error(LABEXP); - return NULL; + return NUL_PTR; } return symptr; } @@ -506,7 +506,7 @@ PUBLIC void pbss() PUBLIC void pcomm() { - if (label == NULL) + if (label == NUL_PTR) labelerror(MISLAB); else if (label->type & VARBIT) labelerror(VARLAB); /* variable cannot be COMM'd */ @@ -520,11 +520,11 @@ PUBLIC void pcomm1() { unsigned oldseg; - if (label != NULL) + if (label != NUL_PTR) labelerror(ILLAB); oldseg = lcdata & SEGM; setloc(BSSLOC); - if ((label = needlabel()) != NULL && checksegrel(label)) + if ((label = needlabel()) != NUL_PTR && checksegrel(label)) { /* Like import. */ if (label->type & (EXPBIT | LABIT)) @@ -583,7 +583,7 @@ PUBLIC void pelsifc() PUBLIC void pendb() { - if (label != NULL) + if (label != NUL_PTR) labelerror(ILLAB); if (blocklevel == 0) error(ENDBBAD); @@ -645,7 +645,7 @@ PUBLIC void pequ() { register struct sym_s *labptr; - if ((labptr = label) == NULL) + if ((labptr = label) == NUL_PTR) labelerror(MISLAB); else if (labptr->type & COMMBIT) showredefinedlabel(); /* common cannot be EQU'd */ @@ -812,7 +812,7 @@ PUBLIC void pimport() error(NOIMPORT); while (TRUE) { - if ((symptr = needlabel()) != NULL && checksegrel(symptr)) + if ((symptr = needlabel()) != NUL_PTR && checksegrel(symptr)) { if (symptr->type & (COMMBIT | EXPBIT | LABIT)) /* IMPORT is null if label (to be) declared */ @@ -855,7 +855,7 @@ PUBLIC void plist() PUBLIC void ploc() { - if (label != NULL) + if (label != NUL_PTR) labelerror(ILLAB); absexpres(); if (!(lastexp.data & UNDBIT)) @@ -892,7 +892,7 @@ PUBLIC void pmap() PUBLIC void porg() { - if (label != NULL) + if (label != NUL_PTR) labelerror(ILLAB); absexpres(); if (!((lcdata = lastexp.data) & UNDBIT)) @@ -914,7 +914,7 @@ PUBLIC void prmb() PUBLIC void psect() { - if (label != NULL) + if (label != NUL_PTR) labelerror(ILLAB); while (sym == IDENT) { @@ -947,7 +947,7 @@ PUBLIC void pset() { register struct sym_s *labptr; - if ((labptr = label) == NULL) + if ((labptr = label) == NUL_PTR) labelerror(MISLAB); else if (labptr->type & COMMBIT) labelerror(RELAB); /* common cannot be SET'd */ @@ -1024,7 +1024,7 @@ PUBLIC void showlabel() lastexp.data = labptr->data; lastexp.offset = labptr->value_reg_or_op.value; popflags = POPLONG | POPHI | POPLO; - label = NULL; /* show handled by COMM, EQU or SET */ + label = NUL_PTR; /* show handled by COMM, EQU or SET */ } /* set location segment */ diff --git a/as/readsrc.c b/as/readsrc.c index 39bd063..f74db84 100644 --- a/as/readsrc.c +++ b/as/readsrc.c @@ -23,7 +23,6 @@ off_t lseek P((int fd, off_t offset, int whence)); int open P((const char *path, int oflag, ...)); int read P((int fd, void *buf, unsigned nbytes)); #else -#undef NULL #include <sys/types.h> #include <fcntl.h> #include <unistd.h> @@ -220,7 +219,7 @@ PUBLIC void readline() char *oldbufptr; struct schain_s *parameters; char paramnum; - unsigned char remaining; /* space remaining in line + 2 */ + unsigned int remaining; /* space remaining in line + 2 */ /* value 0 not used except for temp predec */ /* value 1 means error already gen */ /* values 1 and 2 mean no space */ @@ -244,9 +243,9 @@ PUBLIC void readline() { parameters = macstak->parameters; for (paramnum = *bufptr++; paramnum-- != '0';) - if ((parameters = parameters->next) == NULL) + if ((parameters = parameters->next) == NUL_PTR) break; - if (parameters != NULL) + if (parameters != NUL_PTR) { for (oldbufptr = bufptr, bufptr = parameters->string; *bufptr++ != 0;) @@ -9,7 +9,6 @@ #ifdef STDC_HEADERS_MISSING int memcmp P((const void *s1, const void *s2, unsigned n)); #else -#undef NULL #include <string.h> #endif @@ -809,7 +808,7 @@ unsigned char data; * If string is not found and ifflag is TRUE, string is added to table, with * type = 0 * data = inidata (RELBIT | UNDBIT, possibly with IMPBIT | SEGM) - * Returns pointer to symbol entry (NULL if not found and not installed) + * Returns pointer to symbol entry (NUL_PTR if not found and not installed) * unless symbol table overflows, when routine aborts. */ @@ -855,7 +854,7 @@ PUBLIC struct sym_s *lookup() nameptr = symname; if ((symptr = *(hashptr = spt + (hashval ^ (hconv(nameptr[0]) << 1)) % SPTSIZ)) - != NULL) + != NUL_PTR) { do { @@ -873,9 +872,9 @@ PUBLIC struct sym_s *lookup() if (memcmp(symptr->name, nameptr, length) == 0) return symptr; } - while ((symptr = symptr->next) != NULL); + while ((symptr = symptr->next) != NUL_PTR); - /* Calculate last non-NULL hash ptr. + /* Calculate last non-NUL_PTR hash ptr. * This is faster than keeping hashptr up to date in previous loop * since most lookups are successful and hash ptr is not needed. */ @@ -884,10 +883,10 @@ PUBLIC struct sym_s *lookup() symptr = *hashptr; hashptr = &symptr->next; } - while (symptr->next != NULL); + while (symptr->next != NUL_PTR); } if (!ifflag) - return NULL; + return NUL_PTR; align(heapptr); if (heapptr >= heapend) fatalerror(SYMOV); @@ -900,7 +899,7 @@ PUBLIC struct sym_s *lookup() symptr->type = 0; symptr->data = inidata; symptr->length = length; - symptr->value_reg_or_op.value = (unsigned) (symptr->next = NULL); + symptr->value_reg_or_op.value = (unsigned) (symptr->next = NUL_PTR); heapptr = symptr->name; do *heapptr++ = *nameptr++; @@ -917,7 +916,7 @@ unsigned hashval; register struct sym_s *symptr; printf("%04x ", hashval); - for (symptr = spt[hashval]; symptr != NULL; symptr = symptr->next) + for (symptr = spt[hashval]; symptr != NUL_PTR; symptr = symptr->next) printf("%s ", symptr->name); printf("\n"); } @@ -46,7 +46,7 @@ typedef unsigned long u32_T; struct sym_s { - struct sym_s *next; /* next symbol in hash chain (NULL if none) */ + struct sym_s *next; /* next symbol in hash chain (NUL_PTR if none) */ /* zero offset because it is accessed most */ unsigned char type; unsigned char data; /* flags valid for expressions as well as syms*/ |