* asranlib/asranlib.c, link/lkar.h, link/lkar.c:
[fw/sdcc] / as / mcs51 / asmain.c
index 9e4b38907ac7d6bf205a094c357fec0508505aae..817f83f729ba8758f7edd6caed29c632fbe75bee 100644 (file)
@@ -1,13 +1,22 @@
-/* asmain.c */
+/* asmain.c
+
+   Copyright (C) 1989-1995 Alan R. Baldwin
+   721 Berkeley St., Kent, Ohio 44240
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 /*
- * (C) Copyright 1989-1995
- * All Rights Reserved
- *
- * Alan R. Baldwin
- * 721 Berkeley St.
- * Kent, Ohio  44240
- *
  * 29-Oct-97 JLH pass ";!" comments to output file
  */
 
@@ -213,8 +222,7 @@ int fatalErrors=0;
 char relFile[128];
 
 int
-main(argc, argv)
-char *argv[];
+main(int argc, char *argv[])
 {
         register char *p;
         register int c, i;
@@ -239,8 +247,8 @@ char *argv[];
 
                                 case 'c':
                                 case 'C':
-                                    ++cflag;
-                                    break;
+                                        ++cflag;
+                                        break;
 
                                 case 'g':
                                 case 'G':
@@ -314,9 +322,9 @@ char *argv[];
                                 if (lflag)
                                         lfp = afile(p, "lst", 1);
                                 if (oflag) {
-                                  ofp = afile(p, "rel", 1);
-                                  // save the file name if we have to delete it on error
-                                  strcpy(relFile,afn);
+                                        ofp = afile(p, "rel", 1);
+                                        // save the file name if we have to delete it on error
+                                        strcpy(relFile,afn);
                                 }
                                 if (sflag)
                                         tfp = afile(p, "sym", 1);
@@ -340,6 +348,7 @@ char *argv[];
                 radix = 10;
                 srcline[0] = 0;
                 page = 0;
+                org_cnt = 0;
                 stb[0] = 0;
                 lop  = NLPP;
                 cfile = 0;
@@ -424,8 +433,7 @@ char *argv[];
  */
 
 VOID
-asexit(i)
-int i;
+asexit(int i)
 {
         int j;
 
@@ -538,7 +546,7 @@ int i;
  */
 
 VOID
-asmbl()
+asmbl(void)
 {
         register struct mne *mp;
         register struct sym *sp;
@@ -932,6 +940,7 @@ loop:
                         ap->a_ap = areap;
                         strncpy(ap->a_id, id, NCPS);
                         ap->a_ref = areap->a_ref + 1;
+                        ap->a_addr = 0;
                         ap->a_size = 0;
                         ap->a_fuzz = 0;
                         ap->a_flag = uaf ? uf : (A_CON|A_REL);
@@ -946,8 +955,9 @@ loop:
         case S_ORG:
                 if (dot.s_area->a_flag & A_ABS) {
                         char buf[NCPS];
+
                         laddr = absexpr();
-                        sprintf(buf, "%s%x", abs_ap->a_id, laddr);
+                        sprintf(buf, "%s%x", abs_ap->a_id, org_cnt++);
                         if ((ap = alookup(buf)) == NULL) {
                                 ap = (struct area *) new (sizeof(struct area));
                                 *ap = *areap;
@@ -1131,10 +1141,7 @@ loop:
  */
 
 FILE *
-afile(fn, ft, wf)
-char *fn;
-char *ft;
-int wf;
+afile(char *fn, char *ft, int wf)
 {
         register char *p2, *p3;
         register int c;
@@ -1202,8 +1209,7 @@ int wf;
  */
 
 VOID
-newdot(nap)
-register struct area *nap;
+newdot(register struct area *nap)
 {
         register struct area *oap;
 
@@ -1265,9 +1271,7 @@ register struct area *nap;
  */
 
 VOID
-phase(ap, a)
-struct area *ap;
-Addr_T a;
+phase(struct area *ap, Addr_T a)
 {
         if (ap != dot.s_area || a != dot.s_addr)
                 err('p');
@@ -1284,6 +1288,7 @@ char *usetxt[] = {
         "  l    create list   output file1[LST]",
         "  o    create object output file1[REL]",
         "  s    create symbol output file1[SYM]",
+        "  c    generate sdcdb debug information",
         "  p    disable listing pagination",
         "  f    flag relocatable references by `    in listing file",
         " ff    flag relocatable references by mode in listing file",
@@ -1316,7 +1321,7 @@ char *usetxt[] = {
  */
 
 VOID
-usage()
+usage(void)
 {
         register char   **dp;