mirror of
https://github.com/fachat/xa65.git
synced 2024-12-27 10:32:23 +00:00
missing patches
This commit is contained in:
parent
4e90af6e29
commit
c46dae2105
@ -124,6 +124,7 @@ file65 file;
|
||||
unsigned char cmp[] = { 1, 0, 'o', '6', '5' };
|
||||
unsigned char hdr[26] = { 1, 0, 'o', '6', '5', 0 };
|
||||
|
||||
int verbose = 0;
|
||||
|
||||
void usage(FILE *fp)
|
||||
{
|
||||
@ -139,6 +140,7 @@ void usage(FILE *fp)
|
||||
" -U accept any undef'd labels after linking\n"
|
||||
" -L<name> accept specific given undef'd labels after linking\n"
|
||||
" -g<name> only export the globals defined with (multiple) -g options\n"
|
||||
" -v verbose output\n"
|
||||
" --version output version information and exit\n"
|
||||
" --help display this help and exit\n",
|
||||
programname);
|
||||
@ -186,6 +188,13 @@ int main(int argc, char *argv[]) {
|
||||
while(i<argc && argv[i][0]=='-') {
|
||||
/* process options */
|
||||
switch(argv[i][1]) {
|
||||
case 'v':
|
||||
j=1;
|
||||
while (argv[i][j]=='v') {
|
||||
verbose++;
|
||||
j++;
|
||||
}
|
||||
break;
|
||||
case 'G':
|
||||
noglob=1;
|
||||
break;
|
||||
@ -295,6 +304,19 @@ printf("tbase=%04x+len=%04x->%04x, file->tbase=%04x, f.tlen=%04x -> tdiff=%04x\n
|
||||
printf("zbase=%04x+len=%04x->%04x, file->zbase=%04x, f.zlen=%04x -> zdiff=%04x\n",
|
||||
zbase, tzlen, (zbase + tzlen), file->zbase, file->zlen, file->zdiff);
|
||||
*/
|
||||
|
||||
if (verbose > 0) {
|
||||
printf("Relocating file: %s\n", file->fname);
|
||||
printf(" text: from %04x to %04x (diff is %04x, length is %04x)\n",
|
||||
file->tbase, file->tbase + file->tdiff, file->tdiff, file->tlen);
|
||||
printf(" data: from %04x to %04x (diff is %04x, length is %04x)\n",
|
||||
file->dbase, file->dbase + file->ddiff, file->ddiff, file->dlen);
|
||||
printf(" bss: from %04x to %04x (diff is %04x, length is %04x)\n",
|
||||
file->bbase, file->bbase + file->bdiff, file->bdiff, file->blen);
|
||||
printf(" zero: from %02x to %02x (diff is %02x, length is %02x)\n",
|
||||
file->zbase, file->zbase + file->zdiff, file->zdiff, file->zlen);
|
||||
}
|
||||
|
||||
/* update globals (for result file) */
|
||||
ttlen += file->tlen;
|
||||
tdlen += file->dlen;
|
||||
@ -677,17 +699,21 @@ int len_reloc_seg(unsigned char *buf, int ri) {
|
||||
|
||||
unsigned char *reloc_globals(unsigned char *buf, file65 *fp) {
|
||||
int n, old, new, seg;
|
||||
char *name;
|
||||
|
||||
n = buf[0] + 256*buf[1];
|
||||
buf +=2;
|
||||
|
||||
while(n) {
|
||||
/*printf("relocating %s, ", buf);*/
|
||||
name = buf;
|
||||
while(*(buf++));
|
||||
seg = *buf;
|
||||
seg = *buf & 0x07;
|
||||
old = buf[1] + 256*buf[2];
|
||||
new = old + reldiff(seg);
|
||||
/*printf("old=%04x, seg=%d, rel=%04x, new=%04x\n", old, seg, reldiff(seg), new);*/
|
||||
if (verbose > 1) {
|
||||
printf("%s:%s: old=%04x, seg=%d, rel=%04x, new=%04x\n",
|
||||
fp->fname, name, old, seg, reldiff(seg), new);
|
||||
}
|
||||
buf[1] = new & 255;
|
||||
buf[2] = (new>>8) & 255;
|
||||
buf +=3;
|
||||
|
23
xa/src/xal.c
23
xa/src/xal.c
@ -707,6 +707,9 @@ int ll_pdef(char *t)
|
||||
return(E_NODEF);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write out the list of global labels in an o65 file
|
||||
*/
|
||||
int l_write(FILE *fp)
|
||||
{
|
||||
int i, afl, n=0;
|
||||
@ -716,25 +719,39 @@ int l_write(FILE *fp)
|
||||
fputc(0, fp);
|
||||
return 0;
|
||||
}
|
||||
// calculate number of global labels
|
||||
for (i=0;i<afile->la.lti;i++) {
|
||||
ltp=afile->la.lt+i;
|
||||
if((!ltp->blk) && (ltp->fl==1)) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
// write number of globals to file
|
||||
fputc(n&255, fp);
|
||||
fputc((n>>8)&255, fp);
|
||||
// iterate over labels and write out label
|
||||
for (i=0;i<afile->la.lti;i++)
|
||||
{
|
||||
ltp=afile->la.lt+i;
|
||||
if((!ltp->blk) && (ltp->fl==1)) {
|
||||
// write global name
|
||||
fprintf(fp, "%s",ltp->n);
|
||||
fputc(0,fp);
|
||||
|
||||
// segment byte
|
||||
afl = ltp->afl;
|
||||
/* hack to switch undef and abs flag from internal to file format */
|
||||
/*printf("label %s, afl=%04x, A_FMASK>>8=%04x\n", ltp->n, afl, A_FMASK>>8);*/
|
||||
if( (afl & (A_FMASK>>8)) < SEG_TEXT) afl^=1;
|
||||
// hack to switch undef and abs flag from internal to file format
|
||||
// if asolute of undefined (< SEG_TEXT, i.e. 0 or 1)
|
||||
// then invert bit 0 (0 = absolute)
|
||||
if( (afl & (A_FMASK>>8)) < SEG_TEXT) {
|
||||
afl^=1;
|
||||
}
|
||||
// remove residue flags, only write out real segment number
|
||||
// according to o65 file format definition
|
||||
afl = afl & (A_FMASK >> 8);
|
||||
fputc(afl,fp);
|
||||
|
||||
// value
|
||||
fputc(ltp->val&255, fp);
|
||||
fputc((ltp->val>>8)&255, fp);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user