* as/z80/z80mch.c: fixed bug #1704376: missing as-z80 errors
[fw/sdcc] / as / hc08 / asout.c
index 363a2c1214c0b65b65c1eb54da8dcc45e859fab0..9ba6f4d07cfeaf44db1844e9a6ad033dca2ead58 100644 (file)
@@ -1,13 +1,22 @@
-/* asout.c */
+/* asout.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
- *
  * 28-Oct-97 JLH: 
  *          - outsym: show s_id as string rather than array [NCPS]
  *           - Added outr11 to support 8051's 11 bit destination address
@@ -231,7 +240,7 @@ char        *relp = { &rel[0] };
  */
 
 VOID
-outab(b)
+outab(int b)
 {
        if (pass == 2) {
                out_lb(b,0);
@@ -266,7 +275,7 @@ outab(b)
  */
 
 VOID
-outaw(w)
+outaw(int w)
 {
        if (pass == 2) {
                out_lw(w,0);
@@ -656,9 +665,7 @@ outr24(struct expr *esp, int r)
  */
 
 VOID
-outdp(carea, esp)
-register struct area *carea;
-register struct expr *esp;
+outdp(register struct area *carea, register struct expr *esp)
 {
        register int n, r;
 
@@ -703,7 +710,7 @@ register struct expr *esp;
  */
 
 VOID
-outall()
+outall(void)
 {
        if (oflag && pass==2)
                outbuf("R");
@@ -731,7 +738,7 @@ outall()
  */
 
 VOID
-outdot()
+outdot(void)
 {
        if (oflag && pass==2) {
                fprintf(ofp, "T");
@@ -771,7 +778,7 @@ outdot()
  */
 
 VOID
-outchk(nt, nr)
+outchk(int nt, int nr)
 {
        register struct area *ap;
 
@@ -812,8 +819,7 @@ outchk(nt, nr)
  */
 
 VOID
-outbuf(s)
-char *s;
+outbuf(char *s)
 {
        if (txtp > &txt[2]) {
                fprintf(ofp, "T");
@@ -870,7 +876,7 @@ char *s;
  */
 
 VOID
-outgsd()
+outgsd(void)
 {
        register struct area *ap;
        register struct sym  *sp;
@@ -991,8 +997,7 @@ outgsd()
  */
 
 VOID
-outarea(ap)
-register struct area *ap;
+outarea(register struct area *ap)
 {
        register char *ptr;
        register int c;
@@ -1004,7 +1009,7 @@ register struct area *ap;
                        putc(c, ofp);
        }
        if (xflag == 0) {
-               fprintf(ofp, " size %X flags %X\n", ap->a_size, ap->a_flag);
+               fprintf(ofp, " size %X flags %X addr %X\n", ap->a_size, ap->a_flag, ap->a_addr);
        } else
        if (xflag == 1) {
                fprintf(ofp, " size %o flags %o\n", ap->a_size, ap->a_flag);
@@ -1039,8 +1044,7 @@ register struct area *ap;
  */
 
 VOID
-outsym(sp)
-register struct sym *sp;
+outsym(register struct sym *sp)
 {
        register char *ptr;       
 
@@ -1121,8 +1125,7 @@ out(char *p, int n)
  */
 
 VOID
-out_lb(b,t)
-register int b,t;
+out_lb(register int b, register int t)
 {
        if (cp < &cb[NCODE]) {
                *cp++ = b;
@@ -1154,8 +1157,7 @@ register int b,t;
  */
 
 VOID
-out_lw(n,t)
-register int n,t;
+out_lw(register int n, register int t)
 {
        if (hilo) {
                out_lb(hibyte(n),t ? t|R_HIGH : 0);
@@ -1225,8 +1227,7 @@ out_l24(int n, int t)
  */
 
 VOID
-out_rw(n)
-register int n;
+out_rw(register int n)
 {
        if (hilo) {
                *relp++ = hibyte(n);
@@ -1259,8 +1260,7 @@ register int n;
  */
 
 VOID
-out_tw(n)
-register int n;
+out_tw(register int n)
 {
        if (hilo) {
                *txtp++ = hibyte(n);
@@ -1327,7 +1327,7 @@ out_t24(int n)
  */
 
 int
-lobyte(n)
+lobyte(int n)
 {
        return (n&0377);
 }
@@ -1353,7 +1353,7 @@ lobyte(n)
  */
 
 int
-hibyte(n)
+hibyte(int n)
 {
        return ((n>>8)&0377);
 }
@@ -1390,44 +1390,51 @@ byte3(int n)
  * 11 bit address.  This form of address is used only on the 8051 and 8048.
  */
 VOID
-outr11(esp, op, r)
-register struct expr *esp;
-int op;
-int r;
+outr11(register struct expr *esp, int op, int r)
 {
-       register int n;
-
-       if (pass == 2) {
-               if (esp->e_flag==0 && esp->e_base.e_ap==NULL) {
-                       /* equated absolute destination.  Assume value
-                         * relative to current area */
-                        esp->e_base.e_ap = dot.s_area;
-               }
-
-                /* Relocatable destination.  Build THREE
-                 * byte output: relocatable word, followed
-                 * by op-code.  Linker will combine them.
-                 * Listing shows only the address.
-                 */
-               r |= R_WORD | esp->e_rlcf;
-                out_lw(esp->e_addr,r|R_RELOC);
-                if (oflag) {
-                        outchk(3, 5);
-                        out_tw(esp->e_addr);
-                        *txtp++ = op;
-
-                        if (esp->e_flag) {
-                                n = esp->e_base.e_sp->s_ref;
-                                r |= R_SYM;
-                        } else {
-                                n = esp->e_base.e_ap->a_ref;
+        register int n;
+
+        if (pass == 2) {
+                if (esp->e_flag==0 && esp->e_base.e_ap==NULL) {
+                        /* Absolute destination.
+                         * Listing shows only the address.
+                         */
+                        out_lw(esp->e_addr,0);
+                        if (oflag) {
+                                outchk(3, 0);
+                                out_tw(esp->e_addr);
+                                *txtp++ = op;
+
+                                write_rmode(r);
+                                *relp++ = txtp - txt - 3;
+                                out_rw(0xFFFF);
+                        }
+                } else {
+                        /* Relocatable destination.  Build THREE
+                         * byte output: relocatable word, followed
+                         * by op-code.  Linker will combine them.
+                         * Listing shows only the address.
+                         */
+                        r |= R_WORD | esp->e_rlcf;
+                        out_lw(esp->e_addr,r|R_RELOC);
+                        if (oflag) {
+                                outchk(3, 5);
+                                out_tw(esp->e_addr);
+                                *txtp++ = op;
+
+                                if (esp->e_flag) {
+                                        n = esp->e_base.e_sp->s_ref;
+                                        r |= R_SYM;
+                                } else {
+                                        n = esp->e_base.e_ap->a_ref;
+                                }
+                                write_rmode(r);
+                                *relp++ = txtp - txt - 3;
+                                out_rw(n);
                         }
-                        write_rmode(r);
-                        *relp++ = txtp - txt - 3;
-                        out_rw(n);
                 }
-       }
-       dot.s_addr += 2;
+        }
+        dot.s_addr += 2;
 }
 
 /*
@@ -1440,37 +1447,47 @@ int r;
 VOID
 outr19(struct expr * esp, int op, int r)
 {
-       register int n;
-
-       if (pass == 2) {
-               if (esp->e_flag==0 && esp->e_base.e_ap==NULL) {
-                       /* equated absolute destination.  Assume value
-                         * relative to current area */
-                        esp->e_base.e_ap = dot.s_area;
-               }
-
-                /* Relocatable destination.  Build FOUR
-                 * byte output: relocatable 24-bit entity, followed
-                 * by op-code.  Linker will combine them.
-                 * Listing shows only the address.
-                 */
-               r |= R_WORD | esp->e_rlcf;
-                out_l24(esp->e_addr,r|R_RELOC);
-                if (oflag) {
-                        outchk(4, 5);
-                        out_t24(esp->e_addr);
-                        *txtp++ = op;
+        register int n;
+
+        if (pass == 2) {
+                if (esp->e_flag==0 && esp->e_base.e_ap==NULL) {
+                        /* Absolute destination.
+                         * Listing shows only the address.
+                         */
+                        out_lw(esp->e_addr,0);
+                        if (oflag) {
+                                outchk(4, 0);
+                                out_t24(esp->e_addr);
+                                *txtp++ = op;
+
+                                write_rmode(r);
+                                *relp++ = txtp - txt - 4;
+                                out_rw(0xFFFF);
+                        }
+                } else {
+                        /* Relocatable destination.  Build FOUR
+                         * byte output: relocatable 24-bit entity, followed
+                         * by op-code.  Linker will combine them.
+                         * Listing shows only the address.
+                         */
+                        r |= R_WORD | esp->e_rlcf;
+                        out_l24(esp->e_addr,r|R_RELOC);
+                        if (oflag) {
+                                outchk(4, 5);
+                                out_t24(esp->e_addr);
+                                *txtp++ = op;
                         
-                        if (esp->e_flag) {
-                                n = esp->e_base.e_sp->s_ref;
-                                r |= R_SYM;
-                        } else {
-                                n = esp->e_base.e_ap->a_ref;
+                                if (esp->e_flag) {
+                                        n = esp->e_base.e_sp->s_ref;
+                                        r |= R_SYM;
+                                } else {
+                                        n = esp->e_base.e_ap->a_ref;
+                                }
+                                write_rmode(r);
+                                *relp++ = txtp - txt - 4;
+                                out_rw(n);
                         }
-                        write_rmode(r);
-                        *relp++ = txtp - txt - 4;
-                        out_rw(n);
                 }
-       }
-       dot.s_addr += 3;
+        }
+        dot.s_addr += 3;
 }