1
0
mirror of https://github.com/fachat/xa65.git synced 2025-04-06 20:37:09 +00:00

Proper reset of segment between p1 and p2; err out when using segment pseudo-ops in abs mode

This commit is contained in:
Andre Fachat 2019-10-31 22:08:50 +01:00
parent 003f35f45b
commit 602cc72d96
8 changed files with 53 additions and 20 deletions

View File

@ -393,7 +393,7 @@ int main(int argc,char *argv[])
segment = SEG_TEXT;
} else {
/* prime old_segment in r_mode with SEG_TEXT */
segment = SEG_TEXT;
segment = SEG_ABS;
r_mode(RMODE_ABS);
}
@ -462,13 +462,13 @@ int main(int argc,char *argv[])
seg_pass2();
if(!relmode) {
/* prime old_segment in r_mode with SEG_TEXT */
segment = SEG_TEXT;
r_mode(RMODE_ABS);
if(relmode) {
r_mode(RMODE_RELOC);
segment = SEG_TEXT;
} else {
r_mode(RMODE_RELOC);
segment = SEG_TEXT;
/* prime old_segment in r_mode with SEG_TEXT */
segment = SEG_ABS;
r_mode(RMODE_ABS);
}
er=pass2();
}

View File

@ -479,48 +479,44 @@ printf(" wrote %02x %02x %02x %02x %02x %02x\n",
dsb_len = 0;
} else
if(n==Ktext) {
/* if(segment!=SEG_ABS) { */
segment = relmode ? SEG_TEXT : SEG_ABS;
t[0]=Ksegment;
t[1]=segment;
*ll=2;
er=E_OKDEF;
/* } else {
er=E_ILLSEGMENT;
} */
} else
if(n==Kdata) {
/* if(segment!=SEG_ABS) { */
if(relmode) {
segment = SEG_DATA;
t[0]=Ksegment;
t[1]=SEG_DATA;
*ll=2;
er=E_OKDEF;
/* } else {
} else {
er=E_ILLSEGMENT;
} */
}
} else
if(n==Kbss) {
/* if(segment!=SEG_ABS) { */
if(relmode) {
segment = SEG_BSS;
t[0]=Ksegment;
t[1]=SEG_BSS;
*ll=2;
er=E_OKDEF;
/* } else {
} else {
er=E_ILLSEGMENT;
} */
}
} else
if(n==Kzero) {
/* if(segment!=SEG_ABS) { */
if(relmode) {
segment = SEG_ZERO;
t[0]=Ksegment;
t[1]=SEG_ZERO;
*ll=2;
er=E_OKDEF;
/* } else {
} else {
er=E_ILLSEGMENT;
} */
}
} else
if (n==Kbin) {
int j;
@ -1512,6 +1508,7 @@ fprintf(stderr, "address mode: %i address: %i\n", am, vv[0]);
}
} else
if(am==11 || am==16) {
/* relative, relative long */
if((segment!=SEG_ABS) && (!rlt[0])) {
er=E_ILLPOINTER;
} else {

View File

@ -0,0 +1,9 @@
default: test1
test1:
../../xa test1.s -o test1.o || exit 0 && exit 1
../../xa -R test1.s -o test1.o
../hextool -cmp=ok < test1.o
clean:
rm -f *.o

BIN
xa/tests/relocmode/ok Normal file

Binary file not shown.

View File

@ -0,0 +1,7 @@
lda foo
.data
foo .byt $aa

View File

@ -0,0 +1,8 @@
default: test1
test1:
../../xa -R -LLIB6502 test1.s -o test1.o
../hextool -cmp=ok < test1.o
clean:
rm -f *.o

BIN
xa/tests/reset_segment/ok Normal file

Binary file not shown.

View File

@ -0,0 +1,12 @@
; forward reference
; results in illegal ptr arithmetic when segment
; is not reset between pass1 and pass2
bne foo
foo
.data