From 80afec7d3daed0a55a63785d349026eaf2d46154 Mon Sep 17 00:00:00 2001 From: MaartenBrock Date: Sat, 14 Jul 2007 08:47:32 +0000 Subject: [PATCH] * as/link/aslink.h, * as/link/hc08/lkihx.c, * as/link/hc08/lkrloc.c, * as/link/mcs51/lkihx.c, * as/link/mcs51/lkrloc.c: renamed ihxEntendedLinearAddress to ihxExtendedLinearAddress * as/link/mcs51/lkrloc.c (relr), * as/mcs51/asout.c (outr11, outr19): handle absolute destination for acall/ajmp, see bug 830513 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4884 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 12 +++++ as/link/aslink.h | 2 +- as/link/hc08/lkihx.c | 14 ++--- as/link/hc08/lkrloc.c | 2 +- as/link/mcs51/lkihx.c | 14 ++--- as/link/mcs51/lkrloc.c | 5 +- as/mcs51/asout.c | 117 +++++++++++++++++++++++------------------ 7 files changed, 99 insertions(+), 67 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7b4a91e4..4f3f4505 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2007-07-14 Maarten Brock + + * as/link/aslink.h, + * as/link/hc08/lkihx.c, + * as/link/hc08/lkrloc.c, + * as/link/mcs51/lkihx.c, + * as/link/mcs51/lkrloc.c: renamed ihxEntendedLinearAddress to + ihxExtendedLinearAddress + * as/link/mcs51/lkrloc.c (relr), + * as/mcs51/asout.c (outr11, outr19): handle absolute destination for + acall/ajmp, see bug 830513 + 2007-07-13 Maarten Brock * src/SDCCcse.c (replaceAllSymBySym): renamed siaddr to isaddr, diff --git a/as/link/aslink.h b/as/link/aslink.h index 086a7e11..15d6e0f9 100644 --- a/as/link/aslink.h +++ b/as/link/aslink.h @@ -808,7 +808,7 @@ extern VOID s19(); /* lkihx.c */ extern VOID ihx(); -extern VOID ihxEntendedLinearAddress(Addr_T); +extern VOID ihxExtendedLinearAddress(Addr_T); extern VOID ihxNewArea(); /* lkstore.c */ diff --git a/as/link/hc08/lkihx.c b/as/link/hc08/lkihx.c index ff75e931..824e4152 100644 --- a/as/link/hc08/lkihx.c +++ b/as/link/hc08/lkihx.c @@ -22,7 +22,7 @@ * lkihx.c contains the following functions: * VOID hexRecord(addr, rtvalIndex) * VOID ihx(i) - * VOID ihxEntendedLinearAddress(a) + * VOID ihxExtendedLinearAddress(a) * * local variables: hexPageOverrun, lastHexAddr */ @@ -113,7 +113,7 @@ unsigned int lastHexAddr = 0; * * functions called: * int fprintf() c_library - * ihxEntendedLinearAddress() lkihx.c + * ihxExtendedLinearAddress() lkihx.c * hexRecord() lkihx.c (recursion) * * side effects: @@ -138,7 +138,7 @@ hexRecord(unsigned addr, int rtvalIndex) if (lastHexAddr > addr) { overrun = hexPageOverrun + 1; - ihxEntendedLinearAddress(lastExtendedAddress + overrun); + ihxExtendedLinearAddress(lastExtendedAddress + overrun); hexPageOverrun = overrun; hexRecord(addr, rtvalIndex); return; @@ -156,7 +156,7 @@ hexRecord(unsigned addr, int rtvalIndex) if (rflag) { fprintf(ofp, "%02X\n", (0-chksum) & 0xff); overrun = hexPageOverrun + 1; - ihxEntendedLinearAddress(lastExtendedAddress + overrun); + ihxExtendedLinearAddress(lastExtendedAddress + overrun); hexPageOverrun = overrun; hexRecord(0, i + 1); return; @@ -225,11 +225,11 @@ ihxNewArea() lastHexAddr = 0; } -/*)Function ihxEntendedLinearAddress(i) +/*)Function ihxExtendedLinearAddress(i) * * Addr_T i 16 bit extended linear address. * - * The function ihxEntendedLinearAddress() writes an extended + * The function ihxExtendedLinearAddress() writes an extended * linear address record (type 04) to the output file. * * local variables: @@ -246,7 +246,7 @@ ihxNewArea() * hexPageOverrun and lastHexAddr is cleared */ VOID -ihxEntendedLinearAddress(Addr_T a) +ihxExtendedLinearAddress(Addr_T a) { Addr_T chksum; diff --git a/as/link/hc08/lkrloc.c b/as/link/hc08/lkrloc.c index acd9ee99..cfa15d1e 100644 --- a/as/link/hc08/lkrloc.c +++ b/as/link/hc08/lkrloc.c @@ -549,7 +549,7 @@ VOID relr(VOID) if (rflag) { - ihxEntendedLinearAddress(extendedAddress); + ihxExtendedLinearAddress(extendedAddress); } else if (extendedAddress) { diff --git a/as/link/mcs51/lkihx.c b/as/link/mcs51/lkihx.c index cc9c4218..415408fc 100644 --- a/as/link/mcs51/lkihx.c +++ b/as/link/mcs51/lkihx.c @@ -22,7 +22,7 @@ * lkihx.c contains the following functions: * VOID hexRecord(addr, rtvalIndex) * VOID ihx(i) - * VOID ihxEntendedLinearAddress(a) + * VOID ihxExtendedLinearAddress(a) * * local variables: hexPageOverrun, lastHexAddr */ @@ -113,7 +113,7 @@ unsigned int lastHexAddr = 0; * * functions called: * int fprintf() c_library - * ihxEntendedLinearAddress() lkihx.c + * ihxExtendedLinearAddress() lkihx.c * hexRecord() lkihx.c (recursion) * * side effects: @@ -138,7 +138,7 @@ hexRecord(unsigned addr, int rtvalIndex) if ( (lastHexAddr > addr) && (rflag) ) { overrun = hexPageOverrun + 1; - ihxEntendedLinearAddress(lastExtendedAddress + overrun); + ihxExtendedLinearAddress(lastExtendedAddress + overrun); hexPageOverrun = overrun; hexRecord(addr, rtvalIndex); return; @@ -155,7 +155,7 @@ hexRecord(unsigned addr, int rtvalIndex) if (rflag) { fprintf(ofp, "%02X\n", (0-chksum) & 0xff); overrun = hexPageOverrun + 1; - ihxEntendedLinearAddress(lastExtendedAddress + overrun); + ihxExtendedLinearAddress(lastExtendedAddress + overrun); hexPageOverrun = overrun; hexRecord(0, i + 1); return; @@ -223,11 +223,11 @@ ihxNewArea() lastHexAddr = 0; } -/*)Function ihxEntendedLinearAddress(i) +/*)Function ihxExtendedLinearAddress(i) * * Addr_T i 16 bit extended linear address. * - * The function ihxEntendedLinearAddress() writes an extended + * The function ihxExtendedLinearAddress() writes an extended * linear address record (type 04) to the output file. * * local variables: @@ -244,7 +244,7 @@ ihxNewArea() * hexPageOverrun and lastHexAddr is cleared */ VOID -ihxEntendedLinearAddress(Addr_T a) +ihxExtendedLinearAddress(Addr_T a) { Addr_T chksum; diff --git a/as/link/mcs51/lkrloc.c b/as/link/mcs51/lkrloc.c index a7721baf..fc50964a 100644 --- a/as/link/mcs51/lkrloc.c +++ b/as/link/mcs51/lkrloc.c @@ -326,6 +326,9 @@ VOID relr(VOID) return; } reli = symval(s[rindex]); + } else if ((IS_R_J11(mode) || IS_R_J19(mode)) && (rindex == 0xFFFF)) { + /* absolute acall/ajmp address */ + reli = 0; } else { if (rindex >= hp->h_narea) { fprintf(stderr, "R area error\n"); @@ -555,7 +558,7 @@ VOID relr(VOID) if (rflag) { - ihxEntendedLinearAddress(extendedAddress); + ihxExtendedLinearAddress(extendedAddress); } else if (extendedAddress) { diff --git a/as/mcs51/asout.c b/as/mcs51/asout.c index c2ef5bfc..c5fa425f 100644 --- a/as/mcs51/asout.c +++ b/as/mcs51/asout.c @@ -1363,41 +1363,48 @@ 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; - } + /* 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; - /* 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; + 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; + 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; @@ -1417,32 +1424,42 @@ outr19(struct expr * esp, int op, int r) 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; - } + /* 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; - /* 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; + 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; -- 2.30.2