X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=as%2Fz80%2Fasmain.c;h=0570e36af807f82951bdcb9edf887e276a11869d;hb=2338e302e1e48dcc790238c8dcec3dce6b2db727;hp=0da2d11ab657aec792d4b91365deae6c00540007;hpb=0b99bef5b1367674d02eaab92f5d92cecbbff4c8;p=fw%2Fsdcc diff --git a/as/z80/asmain.c b/as/z80/asmain.c index 0da2d11a..0570e36a 100644 --- a/as/z80/asmain.c +++ b/as/z80/asmain.c @@ -17,16 +17,13 @@ #include #include -#if !defined(_MSC_VER) -#include -#endif - #ifdef SDK #include #include #undef HUGE #endif #include "asm.h" +#include "z80.h" /*)Module asmain.c * @@ -446,7 +443,7 @@ int i; * char getnb() aslex.c * VOID getst() aslex.c * sym * lookup() assym.c - * VOID machin() ___mch.c + * VOID machine() ___mch.c * mne * mlookup() assym.c * int more() aslex.c * VOID * new() assym.c @@ -559,12 +556,13 @@ loop: * symbol, assembler directive, or assembler mnemonic is * being processed. */ - if ((ctype[c] & LETTER) == 0) - if (flevel) { - return; - } else { + if ((ctype[c] & LETTER) == 0) { + if (flevel) { + return; + } else { qerr(); } + } getid(id, c); c = getnb(); /* @@ -759,9 +757,9 @@ loop: { f2 = floor(log(fabs(f1))/log(2))+1; - mantissa = (0x1000000*fabs(f1))/exp(f2*log(2)); + mantissa = (unsigned int) ((0x1000000*fabs(f1))/exp(f2*log(2))) ; mantissa &=0xffffff; - exponent = f2 + 0x40; + exponent = (unsigned int) (f2 + 0x40) ; if (f1<0) exponent |=0x80; } @@ -841,7 +839,7 @@ loop: break; case S_MODUL: - getst(id, -1); + getst(id, getnb()); // a module can start with a digit if (pass == 0) { if (module[0]) { err('m'); @@ -852,6 +850,19 @@ loop: lmode = SLIST; break; + case S_OPTSDCC: + p = optsdcc; + if ((c = getnb()) != 0) { + do { + if (p < &optsdcc[NINPUT-1]) + *p++ = c; + } while ((c = get()) != 0); + } + *p = 0; + unget(c); + lmode = SLIST; + break; + case S_GLOBL: do { getid(id, -1); @@ -1026,30 +1037,36 @@ char *fn; char *ft; int wf; { - register char *p1, *p2, *p3; + register char *p2, *p3; register int c; FILE *fp; - p1 = fn; p2 = afn; p3 = ft; - while ((c = *p1++) != 0 && c != FSEPX) { - if (p2 < &afn[FILSPC-4]) - *p2++ = c; - } + + strcpy (afn, fn); + p2 = strrchr (afn, FSEPX); // search last '.' + if (!p2) + p2 = afn + strlen (afn); + if (p2 > &afn[FILSPC-4]) // truncate filename, if it's too long + p2 = &afn[FILSPC-4]; *p2++ = FSEPX; - if (*p3 == 0) { - if (c == FSEPX) { - p3 = p1; - } else { - p3 = dsft; - } + + // choose a file-extension + if (*p3 == 0) { // extension supplied? + p3 = strrchr (fn, FSEPX); // no: extension in fn? + if (p3) + ++p3; + else + p3 = dsft; // no: default extension } - while ((c = *p3++) != 0) { + + while ((c = *p3++) != 0) { // strncpy if (p2 < &afn[FILSPC-1]) *p2++ = c; } *p2++ = 0; + if ((fp = fopen(afn, wf?"w":"r")) == NULL) { fprintf(stderr, "%s: cannot %s.\n", afn, wf?"create":"open"); asexit(1);