diff --git a/lang/cem/cemcom.ansi/ch3mon.c b/lang/cem/cemcom.ansi/ch3mon.c index 41b27740..40cc4402 100644 --- a/lang/cem/cemcom.ansi/ch3mon.c +++ b/lang/cem/cemcom.ansi/ch3mon.c @@ -20,7 +20,7 @@ #include "sizes.h" extern char options[]; -extern arith full_mask[/*MAXSIZE*/]; /* cstoper.c */ +extern arith full_mask[/*MAXSIZE + 1*/]; /* cstoper.c */ char *symbol2str(); ch3mon(oper, expp) diff --git a/lang/cem/cemcom.ansi/cstoper.c b/lang/cem/cemcom.ansi/cstoper.c index ddd7bf68..c86f122b 100644 --- a/lang/cem/cemcom.ansi/cstoper.c +++ b/lang/cem/cemcom.ansi/cstoper.c @@ -16,7 +16,8 @@ #include "Lpars.h" #include "assert.h" -arith full_mask[MAXSIZE];/* full_mask[1] == 0XFF, full_mask[2] == 0XFFFF, .. */ +/* full_mask[1] == 0XFF, full_mask[2] == 0XFFFF, .. */ +arith full_mask[MAXSIZE + 1]; #ifndef NOCROSS arith max_int; /* maximum integer on target machine */ arith max_unsigned; /* maximum unsigned on target machine */ @@ -247,7 +248,7 @@ init_cst() while (!(bt < 0)) { bt = (bt << 8) + 0377, i++; - if (i == MAXSIZE) + if (i > MAXSIZE) fatal("array full_mask too small for this machine"); full_mask[i] = bt; } diff --git a/modules/src/em_code/em.c b/modules/src/em_code/em.c index 8a2f16e4..f13ab28d 100644 --- a/modules/src/em_code/em.c +++ b/modules/src/em_code/em.c @@ -353,7 +353,7 @@ C_magic() } /*** the compact code generating routines ***/ -#define fit16i(x) ((x) >= (long)0xFFFF8000 && (x) <= (long)0x00007FFF) +#define fit16i(x) ((x) >= (long)(-0x8000) && (x) <= (long)0x7FFF) #define fit8u(x) ((x) <= 0xFF) /* x is already unsigned */ void diff --git a/plat/pc86/boot.s b/plat/pc86/boot.s index d517c1e4..53480969 100644 --- a/plat/pc86/boot.s +++ b/plat/pc86/boot.s @@ -23,7 +23,7 @@ ! If you ever need to change the boot code, this needs adjusting. I recommend ! a hex editor. -PADDING = 0xB9 +PADDING = 0xB7 ! Some definitions. @@ -45,8 +45,8 @@ start2: mov ax, cs mov ds, ax - mov es, ax mov ss, ax + ! Defer setting es until after probing the drive. ! Initialise the stack, which will start at the top of our segment and work ! down. @@ -65,10 +65,13 @@ start2: call write_string ! Probe the drive to figure out its geometry. + ! This might clobber es. - push dx + push dx mov ax, 0x0800 ! service number int 0x13 + mov ax, cs ! restore es + mov es, ax pop ax jc cant_boot diff --git a/util/ack/util.c b/util/ack/util.c index 6c8f1a68..a3d2d051 100644 --- a/util/ack/util.c +++ b/util/ack/util.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include "ack.h" @@ -83,19 +84,26 @@ char *firstblank(str) char *str ; { } /* VARARGS1 */ -fatal(fmt,p1,p2,p3,p4,p5,p6,p7) char *fmt ; { +void fatal(const char* fmt, ...) +{ /* Fatal internal error */ + va_list ap; + va_start(ap, fmt); fprintf(STDOUT,"%s: fatal internal error, ",progname) ; - fprintf(STDOUT,fmt,p1,p2,p3,p4,p5,p6,p7); + vfprintf(STDOUT, fmt, ap); fprintf(STDOUT,"\n") ; quit(-2) ; } /* VARARGS1 */ -vprint(fmt,p1,p2,p3,p4,p5,p6,p7) char *fmt ; { +void vprint(const char* fmt, ...) +{ /* Diagnostic print, no auto NL */ - fprintf(STDOUT,fmt,p1,p2,p3,p4,p5,p6,p7); + va_list ap; + va_start(ap, fmt); + vfprintf(STDOUT, fmt, ap); + va_end(ap); } #ifdef DEBUG @@ -108,30 +116,38 @@ prns(s) register char *s ; { #endif /* VARARGS1 */ -fuerror(fmt,p1,p2,p3,p4,p5,p6,p7) char *fmt ; { +void fuerror(const char *fmt, ...) { /* Fatal user error */ + va_list ap; + va_start(ap, fmt); fprintf(STDOUT,"%s: ",progname) ; - fprintf(STDOUT,fmt,p1,p2,p3,p4,p5,p6,p7); + vfprintf(STDOUT, fmt, ap); fprintf(STDOUT,"\n") ; quit(-1) ; } /* VARARGS1 */ -werror(fmt,p1,p2,p3,p4,p5,p6,p7) char *fmt ; { +void werror(const char *fmt, ...) { /* Warning user error, w_flag */ + va_list ap; if ( w_flag ) return ; + va_start(ap, fmt); fprintf(STDOUT,"%s: warning, ",progname) ; - fprintf(STDOUT,fmt,p1,p2,p3,p4,p5,p6,p7); + vfprintf(STDOUT, fmt, ap); fprintf(STDOUT,"\n") ; + va_end(ap); } /* VARARGS1 */ -error(fmt,p1,p2,p3,p4,p5,p6,p7) char *fmt ; { +void error(const char *fmt, ...) { /* User error, it is the callers responsibility to quit */ + va_list ap; + va_start(ap, fmt); fprintf(STDOUT,"%s: ",progname) ; - fprintf(STDOUT,fmt,p1,p2,p3,p4,p5,p6,p7); + vfprintf(STDOUT, fmt, ap); fprintf(STDOUT,"\n") ; n_error++ ; + va_end(ap); } do_flush() { diff --git a/util/amisc/aslod.c b/util/amisc/aslod.c index b3408800..e436438b 100644 --- a/util/amisc/aslod.c +++ b/util/amisc/aslod.c @@ -140,42 +140,29 @@ void emits(struct outsect* section) } -void iconvert(char* buf, char* str, char* fmt) -{ - register char *nf, *ni, *no ; - int last, i ; - long value ; - ni=buf ; no=str ; nf=fmt ; - while ( last = *nf++ ) { - last -= '0' ; - if ( last<1 || last >9 ) fatal("illegal out.h format string\n"); - value=0 ; - i=last ; - while ( i-- ) { - value = (value<<8) + (ni[i]&0xFF) ; - } - switch ( last ) { - case 0 : break ; - case 1 : *no= value ; break ; - case 2 : *(unsigned short *)no = value ; break ; - case 4 : *(long *)no = value ; break ; - default : - fatal("illegal out.h format string\n"); - } - ni += last ; no += last ; - } -} +/* Macros from modules/src/object/obj.h */ +#define Xchar(ch) ((ch) & 0377) +#define uget2(c) (Xchar((c)[0]) | ((unsigned) Xchar((c)[1]) << 8)) +#define get4(c) (uget2(c) | ((long) uget2((c)+2) << 16)) /* Read the ack.out file header. */ int rhead(FILE* f, struct outhead* head) { - char buf[sizeof(struct outhead)]; + char buf[SZ_HEAD], *c; if (fread(buf, sizeof(buf), 1, f) != 1) return 0; - - iconvert(buf, (char*) head, SF_HEAD); + + c = buf; + head->oh_magic = uget2(c); c += 2; + head->oh_stamp = uget2(c); c += 2; + head->oh_flags = uget2(c); c += 2; + head->oh_nsect = uget2(c); c += 2; + head->oh_nrelo = uget2(c); c += 2; + head->oh_nname = uget2(c); c += 2; + head->oh_nemit = get4(c); c += 4; + head->oh_nchar = get4(c); return 1; } @@ -183,12 +170,17 @@ int rhead(FILE* f, struct outhead* head) int rsect(FILE* f, struct outsect* sect) { - char buf[sizeof(struct outsect)]; + char buf[SZ_SECT], *c; if (fread(buf, sizeof(buf), 1, f) != 1) return 0; - - iconvert(buf, (char*) sect, SF_SECT); + + c = buf; + sect->os_base = get4(c); c += 4; + sect->os_size = get4(c); c += 4; + sect->os_foff = get4(c); c += 4; + sect->os_flen = get4(c); c += 4; + sect->os_lign = get4(c); return 1 ; } diff --git a/util/ass/ass80.c b/util/ass/ass80.c index 66e5a31e..614dbaf4 100644 --- a/util/ass/ass80.c +++ b/util/ass/ass80.c @@ -189,7 +189,13 @@ cons_t xgetarb(l,f) int l; FILE *f ; { shift=0 ; val=0 ; while ( l-- ) { - val += ((cons_t)(c = ctrunc(xgetc(f))))< 8 && ((shift>>3)&1)) { diff --git a/util/ass/assci.c b/util/ass/assci.c index 52a6484e..d3d0b969 100644 --- a/util/ass/assci.c +++ b/util/ass/assci.c @@ -849,8 +849,28 @@ extxcon(header) { return ; } +/* Added atol() that ignores overflow. --Ceriel */ +long atol(s) + register char *s; +{ + register long total = 0; + register unsigned digit; + int minus = 0; + + while (*s == ' ' || *s == '\t') s++; + if (*s == '+') s++; + else if (*s == '-') { + s++; + minus = 1; + } + while ((digit = *s++ - '0') < 10) { + total *= 10; + total += digit; + } + return(minus ? -total : total); +} + extvcon(header) { - extern long atol() ; /* * generate data for a constant initialized by a string. */ diff --git a/util/int/do_conv.c b/util/int/do_conv.c index 6752933a..cab003fe 100644 --- a/util/int/do_conv.c +++ b/util/int/do_conv.c @@ -357,22 +357,22 @@ DoCFU() wtrap(WILLCONV, EILLINS); } f = fpop(4L); - npush((long) f, 2L); + npush((unsigned long) f, 2L); return; case 44: f = fpop(4L); - npush((long) f, 4L); + npush((unsigned long) f, 4L); return; case 82: if (wsize == 4) { wtrap(WILLCONV, EILLINS); } f = fpop(8L); - npush((long) f, 2L); + npush((unsigned long) f, 2L); return; case 84: f = fpop(8L); - npush((long) f, 4L); + npush((unsigned long) f, 4L); return; default: wtrap(WILLCONV, EILLINS);