char temp[NCPS];
struct sym *sp;
int j;
- struct area *dseg_ap=NULL;
+ struct area *dseg_ap = NULL;
+ struct area *abs_ap = NULL;
struct sym *sp_dseg_s=NULL, *sp_dseg_l=NULL;
for(j=0; j<256; j++) idatamap[j]=' ';
memset(codemap, 0, sizeof(codemap));
+ /* first sort all absolute areas to the front */
+ ap = areap;
+ /* no need to check first area, it's in front anyway */
+ while (ap && ap->a_ap)
+ {
+ if (ap->a_ap->a_flag & A_ABS)
+ {/* next area is absolute, move it to front,
+ reversed sequence is no problem for absolutes */
+ abs_ap = ap->a_ap;
+ ap->a_ap = abs_ap->a_ap;
+ abs_ap->a_ap = areap;
+ areap = abs_ap;
+ }
+ ap = ap->a_ap;
+ }
+
ap = areap;
while (ap)
{
to compute the byte size of BSEG_BYTES: */
if (!strcmp(ap->a_id, "BSEG"))
{
- ap->a_ap->a_axp->a_size = ((ap->a_addr + ap->a_size + 7)/8); /*Bits to bytes*/
+ ap->a_ap->a_axp->a_size = ((ap->a_addr + ap->a_size + 7)/8); /*Bits to bytes*/
}
else if (!strcmp(ap->a_id, "DSEG"))
{
fchar='3';
else if(!strcmp(tap->a_id, "BSEG_BYTES"))
fchar='B';
+ else if(!strcmp(tap->a_id, "BIT_BANK"))
+ fchar='T';
else
fchar=' ';/*???*/
}
fprintf(stderr, ErrMsg, taxp->a_size, taxp->a_size>1?"s":"", tap->a_id);
lkerr++;
}
- }
+ }
for(j=0; j<ramlimit; j++)
{
}
}
}
+ else if (fchar=='T') /*Bit addressable bytes in internal RAM*/
+ {
+ /*Find the size of the space currently used for this areax overlay*/
+ for(j=0x20, size=0; j<0x30; j++)
+ if(idatamap[j]==fchar) size++;
+
+ /*If more space required, release the previously allocated areax in
+ internal RAM and search for a bigger one*/
+ if((int)taxp->a_size>size)
+ {
+ size=(int)taxp->a_size;
+
+ for(j=0x20; j<0x30; j++)
+ if(idatamap[j]==fchar) idatamap[j]=' ';
+
+ /*Search for a space large enough in data memory for this overlay areax*/
+ for(j=0x20, k=0; j<0x30; j++)
+ {
+ if(idatamap[j]==' ')
+ k++;
+ else
+ k=0;
+ if(k==(int)taxp->a_size) break;
+ }
+
+ if(k==(int)taxp->a_size)
+ {
+ taxp->a_addr = j-k+1;
+ if(addr<(unsigned int)0x30)
+ {
+ for(j=0x2F; (j>=0x20)&&(idatamap[j]==' '); j--);
+ if(j>=0x20) addr=j+1;
+ }
+ }
+
+ /*Mark the memory used for overlay*/
+ if(k==(int)taxp->a_size)
+ {
+ for(j=taxp->a_addr; (j<(int)(taxp->a_addr+taxp->a_size)) && (j<0x30); j++)
+ idatamap[j]=fchar;
+
+ /*Set the new size of the data memory area*/
+ size=ramlimit-addr;
+ }
+ else /*Couldn't find a chunk big enough: report the problem.*/
+ {
+ tap->a_unaloc=taxp->a_size;
+ fprintf(stderr, ErrMsg, taxp->a_size, taxp->a_size>1?"s":"", tap->a_id);
+ lkerr++;
+ }
+ }
+
+ for(j=0x20; j<0x30; j++)
+ {
+ if (idatamap[j]==fchar)
+ {
+ addr=j;
+ tap->a_addr=addr;
+ taxp->a_addr=addr;
+ break;
+ }
+ }
+ }
else /*Overlay areas not in internal ram*/
{
taxp->a_addr = addr;