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:
parent
003f35f45b
commit
602cc72d96
14
xa/src/xa.c
14
xa/src/xa.c
@ -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();
|
||||
}
|
||||
|
23
xa/src/xat.c
23
xa/src/xat.c
@ -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 {
|
||||
|
9
xa/tests/relocmode/Makefile
Normal file
9
xa/tests/relocmode/Makefile
Normal 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
BIN
xa/tests/relocmode/ok
Normal file
Binary file not shown.
7
xa/tests/relocmode/test1.s
Normal file
7
xa/tests/relocmode/test1.s
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
lda foo
|
||||
|
||||
.data
|
||||
|
||||
foo .byt $aa
|
||||
|
8
xa/tests/reset_segment/Makefile
Normal file
8
xa/tests/reset_segment/Makefile
Normal 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
BIN
xa/tests/reset_segment/ok
Normal file
Binary file not shown.
12
xa/tests/reset_segment/test1.s
Normal file
12
xa/tests/reset_segment/test1.s
Normal 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
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user