X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=as%2Fmcs51%2Flkarea.c;h=d13f104ea186fc9d682e3fa584567ff62fc5b735;hb=7942cea7bfeb130ce6ba4eb3a786beed371ec559;hp=b535f2599b7f7c38f2c9c01881fadf80ed866144;hpb=b09af35f2f1cde7649d3ac4a6f5d2af6d97895a0;p=fw%2Fsdcc diff --git a/as/mcs51/lkarea.c b/as/mcs51/lkarea.c index b535f259..d13f104e 100644 --- a/as/mcs51/lkarea.c +++ b/as/mcs51/lkarea.c @@ -15,7 +15,6 @@ #include #include -#include #include "aslink.h" /*)Module lkarea.c @@ -75,7 +74,7 @@ * int lkerr error flag * * functions called: - * addr_t eval() lkeval.c + * Addr_T eval() lkeval.c * VOID exit() c_library * int fprintf() c_library * VOID getid() lklex.c @@ -288,7 +287,7 @@ char *id; * define the starting address and length of each area. * * local variables: - * addr_t rloc ;current relocation address + * Addr_T rloc ;current relocation address * char temp[] ;temporary string * struct symbol *sp ;symbol structure * @@ -317,10 +316,13 @@ char *id; VOID lnkarea() { - addr_t rloc[4]; + Addr_T rloc[4]; int locIndex; char temp[NCPS]; struct sym *sp; + /*JCF: used to save the REG_BANK_[0-3] and SBIT_BYTES area pointers*/ + struct area *ta[5]; + int j; rloc[0] = rloc[1] = rloc[2] = rloc[3] = 0; ap = areap; @@ -376,6 +378,29 @@ lnkarea() sp->s_type |= S_DEF; } + + /*JCF: Since area BSEG is defined just before BSEG_BYTES, use the bit size of BSEG + to compute the byte size of BSEG_BYTES: */ + if (!strcmp(ap->a_id, "BSEG")) { + ap->a_ap->a_axp->a_size=(ap->a_addr/8)+((ap->a_size+7)/8); /*Bits to bytes*/ + } + else if (!strcmp(ap->a_id, "REG_BANK_0")) ta[0]=ap; + else if (!strcmp(ap->a_id, "REG_BANK_1")) ta[1]=ap; + else if (!strcmp(ap->a_id, "REG_BANK_2")) ta[2]=ap; + else if (!strcmp(ap->a_id, "REG_BANK_3")) ta[3]=ap; + else if (!strcmp(ap->a_id, "BSEG_BYTES")) + { + ta[4]=ap; + for(j=4; j>1; j--) + { + /*If upper register banks are not used roll back the rellocation counter*/ + if ( (ta[j]->a_size==0) && (ta[j-1]->a_size==0) ) + { + rloc[0]-=8; + } + else break; + } + } ap = ap->a_ap; } } @@ -391,8 +416,8 @@ lnkarea() * function. * * local variables: - * addr_t size size of area - * addr_t addr address of area + * Addr_T size size of area + * Addr_T addr address of area * areax * taxp pointer to an areax structure * * global variables: @@ -410,7 +435,7 @@ VOID lnksect(tap) register struct area *tap; { - register addr_t size, addr; + register Addr_T size, addr; register struct areax *taxp; size = 0;