projects
/
fw
/
sdcc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* as/hc08/lkaomf51.c (OutputName),
[fw/sdcc]
/
as
/
z80
/
asmain.c
diff --git
a/as/z80/asmain.c
b/as/z80/asmain.c
index 6bde5db2ceef5f04d143accfcf467f7413b46da0..50ccb2b22e55cee6ccd5279f8a959521134bcd00 100644
(file)
--- a/
as/z80/asmain.c
+++ b/
as/z80/asmain.c
@@
-17,16
+17,13
@@
#include <setjmp.h>
#include <string.h>
#include <setjmp.h>
#include <string.h>
-#if !defined(_MSC_VER)
-#include <alloc.h>
-#endif
-
#ifdef SDK
#include <stdlib.h>
#include <math.h>
#undef HUGE
#endif
#include "asm.h"
#ifdef SDK
#include <stdlib.h>
#include <math.h>
#undef HUGE
#endif
#include "asm.h"
+#include "z80.h"
/*)Module asmain.c
*
/*)Module asmain.c
*
@@
-91,7
+88,7
@@
* int fflag -f(f), relocations flagged flag
* int flevel IF-ELSE-ENDIF flag will be non
* zero for false conditional case
* int fflag -f(f), relocations flagged flag
* int flevel IF-ELSE-ENDIF flag will be non
* zero for false conditional case
- *
addr_t
fuzz tracks pass to pass changes in the
+ *
Addr_T
fuzz tracks pass to pass changes in the
* address of symbols caused by
* variable length instruction formats
* int gflag -g, make undefined symbols global flag
* address of symbols caused by
* variable length instruction formats
* int gflag -g, make undefined symbols global flag
@@
-138,7
+135,7
@@
* VOID diag() assubr.c
* VOID err() assubr.c
* int fprintf() c-library
* VOID diag() assubr.c
* VOID err() assubr.c
* int fprintf() c-library
- * int
getline()
aslex.c
+ * int
as_getline()
aslex.c
* VOID list() aslist.c
* VOID lstsym() aslist.c
* VOID minit() ___mch.c
* VOID list() aslist.c
* VOID lstsym() aslist.c
* VOID minit() ___mch.c
@@
-163,6
+160,21
@@
main(int argc, char **argv)
register int c, i;
struct area *ap;
register int c, i;
struct area *ap;
+ /* Check to make sure there are the right number of filenames */
+ /* before openning any of them */
+#ifdef SDK
+ inpfil = -2;
+#else /* SDK */
+ inpfil = -1;
+#endif /* SDK */
+ for (i=1; i<argc; ++i) {
+ p = argv[i];
+ if (*p != '-')
+ inpfil++;
+ }
+ if (inpfil < 0)
+ usage();
+
#ifdef SDK
inpfil = -2;
#else /* SDK */
#ifdef SDK
inpfil = -2;
#else /* SDK */
@@
-299,7
+311,7
@@
main(int argc, char **argv)
dot.s_area = &dca;
symp = ˙
minit();
dot.s_area = &dca;
symp = ˙
minit();
- while (getline()) {
+ while (
as_
getline()) {
cp = cb;
cpt = cbt;
ep = eb;
cp = cb;
cpt = cbt;
ep = eb;
@@
-405,7
+417,7
@@
int i;
* ASCII character
* int flevel IF-ELSE-ENDIF flag will be non
* zero for false conditional case
* ASCII character
* int flevel IF-ELSE-ENDIF flag will be non
* zero for false conditional case
- *
addr_t
fuzz tracks pass to pass changes in the
+ *
Addr_T
fuzz tracks pass to pass changes in the
* address of symbols caused by
* variable length instruction formats
* int ifcnd[] array of IF statement condition
* address of symbols caused by
* variable length instruction formats
* int ifcnd[] array of IF statement condition
@@
-417,7
+429,7
@@
int i;
* int incline[] current include file line
* int incfil current file handle index
* for include files
* int incline[] current include file line
* int incfil current file handle index
* for include files
- *
addr_t
laddr address of current assembler line
+ *
Addr_T
laddr address of current assembler line
* or value of .if argument
* int lmode listing mode
* int lop current line number on page
* or value of .if argument
* int lmode listing mode
* int lop current line number on page
@@
-432,7
+444,7
@@
int i;
* int tlevel current conditional level
*
* functions called:
* int tlevel current conditional level
*
* functions called:
- *
addr_t
absexpr() asexpr.c
+ *
Addr_T
absexpr() asexpr.c
* area * alookup() assym.c
* VOID clrexpr() asexpr.c
* int digit() asexpr.c
* area * alookup() assym.c
* VOID clrexpr() asexpr.c
* int digit() asexpr.c
@@
-446,7
+458,7
@@
int i;
* char getnb() aslex.c
* VOID getst() aslex.c
* sym * lookup() assym.c
* char getnb() aslex.c
* VOID getst() aslex.c
* sym * lookup() assym.c
- * VOID machin
()
___mch.c
+ * VOID machin
e()
___mch.c
* mne * mlookup() assym.c
* int more() aslex.c
* VOID * new() assym.c
* mne * mlookup() assym.c
* int more() aslex.c
* VOID * new() assym.c
@@
-481,7
+493,7
@@
asmbl()
#ifdef SDK
double f1, f2;
unsigned int mantissa, exponent;
#ifdef SDK
double f1, f2;
unsigned int mantissa, exponent;
- const
signed
char readbuffer[80];
+ const char readbuffer[80];
#endif
laddr = dot.s_addr;
lmode = SLIST;
#endif
laddr = dot.s_addr;
lmode = SLIST;
@@
-559,12
+571,13
@@
loop:
* symbol, assembler directive, or assembler mnemonic is
* being processed.
*/
* 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();
}
qerr();
}
+ }
getid(id, c);
c = getnb();
/*
getid(id, c);
c = getnb();
/*
@@
-759,9
+772,9
@@
loop:
{
f2 = floor(log(fabs(f1))/log(2))+1;
{
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;
mantissa &=0xffffff;
- exponent =
f2 + 0x40
;
+ exponent =
(unsigned int) (f2 + 0x40)
;
if (f1<0)
exponent |=0x80;
}
if (f1<0)
exponent |=0x80;
}
@@
-841,7
+854,7
@@
loop:
break;
case S_MODUL:
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');
if (pass == 0) {
if (module[0]) {
err('m');
@@
-852,6
+865,19
@@
loop:
lmode = SLIST;
break;
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);
case S_GLOBL:
do {
getid(id, -1);
@@
-1026,30
+1052,36
@@
char *fn;
char *ft;
int wf;
{
char *ft;
int wf;
{
- register char *p
1, *p
2, *p3;
+ register char *p2, *p3;
register int c;
FILE *fp;
register int c;
FILE *fp;
- p1 = fn;
p2 = afn;
p3 = ft;
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;
*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 (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);
if ((fp = fopen(afn, wf?"w":"r")) == NULL) {
fprintf(stderr, "%s: cannot %s.\n", afn, wf?"create":"open");
asexit(1);
@@
-1074,7
+1106,7
@@
int wf;
*
* global variables:
* sym dot defined as sym[0]
*
* global variables:
* sym dot defined as sym[0]
- *
addr_t
fuzz tracks pass to pass changes in the
+ *
Addr_T
fuzz tracks pass to pass changes in the
* address of symbols caused by
* variable length instruction formats
*
* address of symbols caused by
* variable length instruction formats
*
@@
-1103,7
+1135,7
@@
register struct area *nap;
/*)Function VOID phase(ap, a)
*
* area * ap pointer to area
/*)Function VOID phase(ap, a)
*
* area * ap pointer to area
- *
addr_t
a address in area
+ *
Addr_T
a address in area
*
* Function phase() compares the area ap and address a
* with the current area dot.s_area and address dot.s_addr
*
* Function phase() compares the area ap and address a
* with the current area dot.s_area and address dot.s_addr
@@
-1127,7
+1159,7
@@
register struct area *nap;
VOID
phase(ap, a)
struct area *ap;
VOID
phase(ap, a)
struct area *ap;
-
addr_t
a;
+
Addr_T
a;
{
if (ap != dot.s_area || a != dot.s_addr)
err('p');
{
if (ap != dot.s_area || a != dot.s_addr)
err('p');