1
0
mirror of https://github.com/fachat/xa65.git synced 2024-06-08 23:29:30 +00:00

pass all tests

This commit is contained in:
Andre Fachat 2023-10-12 17:46:50 +02:00
parent 1058e05c63
commit 8175681d48
7 changed files with 49 additions and 13 deletions

View File

@ -77,7 +77,8 @@ int a_term(signed char *s, int *v, int *l, int xpc, int *pfl, int *label, int f)
if(afl) *pfl=A_HIGH | ((afl<<8) & A_FMASK) | (*v & 255);
*v=(*v>>8)&255;
}
else {
else
if(s[pp]!=T_END) {
er=ag_term(s,P_START,v,&afl, label);
bfl = afl & (A_MASK>>8);
if(bfl && (bfl != (A_ADR>>8)) ) {
@ -85,6 +86,8 @@ int a_term(signed char *s, int *v, int *l, int xpc, int *pfl, int *label, int f)
errout(W_ADDRACC);
}
if(afl) *pfl = A_ADR | ((afl<<8) & A_FMASK);
} else {
er = E_SYNTAX;
}
*l=pp;

View File

@ -25,6 +25,7 @@
#undef LISTING_DEBUG
#undef DEBUG_CONV
#undef DEBUG_CAST
#undef DEBUG_RELOC
/*
#define DEBUG_AM
@ -528,17 +529,22 @@ fprintf(stderr, "- p1 %d starting -\n", pc[segment]);
if(n==Kpcdef)
{
int tmp;
if(!(er=a_term(t+1,&tmp /*&pc[SEG_ABS]*/,&l,pc[segment],&afl,&label,0)))
// get parameter for *=
er=a_term(t+1,&tmp,&l,pc[segment],&afl,&label,0);
// found?
if(!er)
{
i=1;
wval(i,tmp /*pc[SEG_ABS]*/, 0); /* writes T_VALUE, 3 bytes value, plus one byte */
wval(i,tmp, 0); /* writes T_VALUE, 3 bytes value, plus one byte */
t[i++]=T_END;
*ll=7;
er=E_OKDEF;
/*printf("set pc=%04x, oldsegment=%d, pc[segm]=%04x, ",
#ifdef DEBUG_RELOC
printf("set pc=%04x, oldsegment=%d, pc[segm]=%04x, ",
pc[SEG_ABS], segment, pc[segment]);
printf(" wrote %02x %02x %02x %02x %02x %02x, %02x, %02x\n",
t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7]);*/
t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7]);
#endif
if(segment==SEG_TEXT) {
pc[SEG_ABS] = tmp;
r_mode(RMODE_ABS);
@ -550,10 +556,14 @@ printf(" wrote %02x %02x %02x %02x %02x %02x, %02x, %02x\n",
}
}
/*printf("newsegment=%d, pc[ABS]=%04x\n", segment, pc[SEG_ABS]);*/
} else { /* TODO: different error code */
} else {
// no param found, only "*=".
// if we ABS, we switch back to reloc
#ifdef DEBUG_RELOC
printf("reloc: er=%d, l=%d, segment=%d, pc[%d]=%04x, pc[abs(%d)]=%04x, pc[text(%d)]=%04x\n",
er, l, segment, segment, pc[segment], SEG_ABS, pc[SEG_ABS],SEG_TEXT, pc[SEG_TEXT]);
#endif
if((segment==SEG_ABS) && (er==E_SYNTAX && l==0)) {
/*printf("reloc: oldseg=%d, pc[oldseg]=%04x, pc[abs]=%04x, pc[text]=%04x\n",
segment, pc[segment], pc[SEG_ABS], pc[SEG_TEXT]);*/
t[0]=Kreloc;
i=1;
wval(i,pc[SEG_TEXT], 0);
@ -628,6 +638,7 @@ printf(" wrote %02x %02x %02x %02x %02x %02x, %02x, %02x\n",
t[1]=segment;
*ll=2;
er=E_OKDEF;
r_mode(RMODE_RELOC); // use of segments always switches of ABS reloc mode
} else
if(n==Kdata) {
if(relmode) {
@ -636,6 +647,7 @@ printf(" wrote %02x %02x %02x %02x %02x %02x, %02x, %02x\n",
t[1]=SEG_DATA;
*ll=2;
er=E_OKDEF;
r_mode(RMODE_RELOC); // use of segments always switches of ABS reloc mode
} else {
er=E_ILLSEGMENT;
}
@ -647,6 +659,7 @@ printf(" wrote %02x %02x %02x %02x %02x %02x, %02x, %02x\n",
t[1]=SEG_BSS;
*ll=2;
er=E_OKDEF;
r_mode(RMODE_RELOC); // use of segments always switches of ABS reloc mode
} else {
er=E_ILLSEGMENT;
}
@ -658,6 +671,7 @@ printf(" wrote %02x %02x %02x %02x %02x %02x, %02x, %02x\n",
t[1]=SEG_ZERO;
*ll=2;
er=E_OKDEF;
r_mode(RMODE_RELOC); // use of segments always switches of ABS reloc mode
} else {
er=E_ILLSEGMENT;
}

View File

@ -8,9 +8,8 @@ tests: mixabs1 mixabs2 clean
mixabs1: mixabsolute.a65
${XA} $<
hexdump -C a.o65 > a.hex
cmp mixabs1.out a.hex
@echo This should fail
${XA} $< || exit 0 && exit 1
mixabs2: mixabsolute.a65
${XA} -R $<
@ -20,5 +19,5 @@ mixabs2: mixabsolute.a65
cmp mixabs2.out b.hex
clean:
# rm -f a.err a.o65 a.hex b.o65 b.hex
rm -f a.err a.o65 a.hex b.o65 b.hex

View File

@ -0,0 +1,7 @@
00000000 01 00 6f 36 35 00 00 00 00 a0 0c 00 00 04 02 00 |..o65...........|
00000010 00 40 00 00 04 00 00 00 00 00 00 ad 00 a0 ad 00 |.@..............|
00000020 20 ad 06 a0 ad 09 a0 00 04 00 00 02 82 06 82 03 | ...............|
00000030 82 00 01 83 00 05 00 6c 31 00 02 00 a0 6c 32 00 |.......l1....l2.|
00000040 01 00 20 6c 32 61 00 02 06 a0 6c 33 00 03 00 04 |.. l2a....l3....|
00000050 6c 34 00 02 09 a0 |l4....|
00000056

View File

@ -7,6 +7,10 @@ l1 lda l1
l2 lda l2
*=
l2a lda l2a
.data
l3 .word l3
@ -16,3 +20,4 @@ l3 .word l3
l4 lda l4

View File

@ -7,4 +7,4 @@ test1:
../hextool -cmp=ok2 < test2.o
clean:
rm -f *.o
rm -f *.o a.o65

View File

@ -0,0 +1,8 @@
*=$1234
*=