mirror of
https://github.com/fachat/xa65.git
synced 2025-04-11 22:37:02 +00:00
fix a bug in -U code
This commit is contained in:
parent
cec82b56da
commit
845657b0fc
@ -55,6 +55,7 @@ typedef struct LabOcc {
|
||||
*/
|
||||
typedef struct {
|
||||
int blk;
|
||||
int origblk; // only for fl=3
|
||||
int val;
|
||||
int len;
|
||||
int fl; /* 0 = label value not valid/known,
|
||||
|
15
xa/src/xal.c
15
xa/src/xal.c
@ -200,6 +200,7 @@ int lg_toglobal(char *s ) {
|
||||
ltp=afile->la.lt+n;
|
||||
ltp->fl=3;
|
||||
ltp->afl=SEG_UNDEF;
|
||||
ltp->origblk=ltp->blk;
|
||||
ltp->blk=0;
|
||||
}
|
||||
return er;
|
||||
@ -297,7 +298,7 @@ int l_def(char *s, int *l, int *x, int *f)
|
||||
/* redefinition of label */
|
||||
*l=ltp->len+i;
|
||||
} else
|
||||
if(ltp->fl == 0 || ltp->fl == 3)
|
||||
if(ltp->fl == 0)
|
||||
{
|
||||
/* label has not been defined yet, (e.g. pass1 forward ref), so we try to set it. */
|
||||
*l=ltp->len+i;
|
||||
@ -306,6 +307,16 @@ int l_def(char *s, int *l, int *x, int *f)
|
||||
else
|
||||
ltp->blk=b;
|
||||
|
||||
} else
|
||||
if(ltp->fl == 3)
|
||||
{
|
||||
/* label has been defined as -U undef'd label so far - we need to check */
|
||||
*l=ltp->len+i;
|
||||
if(b_ltest(ltp->origblk,b))
|
||||
er=E_LABDEF;
|
||||
else
|
||||
ltp->blk=b;
|
||||
|
||||
} else
|
||||
er=E_LABDEF;
|
||||
} else
|
||||
@ -319,6 +330,7 @@ int l_def(char *s, int *l, int *x, int *f)
|
||||
ltp->fl=0;
|
||||
ltp->is_cll=cll_fl;
|
||||
}
|
||||
//printf("l_def NODEF: n=%d, s=%s\n", n, ltp->n);
|
||||
}
|
||||
|
||||
*x=n;
|
||||
@ -523,6 +535,7 @@ void l_set(int n, int v, int afl)
|
||||
ltp->val = v;
|
||||
ltp->fl = 1;
|
||||
ltp->afl = afl;
|
||||
|
||||
//printf("l_set('%s'(%d), v=$%04x, afl=%d\n",ltp->n, n, v, afl);
|
||||
}
|
||||
|
||||
|
@ -4,11 +4,20 @@
|
||||
|
||||
XA=../../xa
|
||||
|
||||
tests: undef1 undef2 undef3 clean
|
||||
tests: bannerf undef1 undef4 undef5f undef6f banner undef2 undef3 undef5 undef6 clean
|
||||
|
||||
|
||||
banner:
|
||||
@echo =======================================
|
||||
@echo All tests meant to fail have done so correctly;
|
||||
@echo The following tests should pass
|
||||
|
||||
bannerf:
|
||||
@echo =======================================
|
||||
@echo The following should fail
|
||||
|
||||
undef1: undef.a65
|
||||
@echo This should fail
|
||||
@echo These should fail
|
||||
${XA} $< || exit 0 && exit 1
|
||||
${XA} -R $< || exit 0 && exit 1
|
||||
${XA} -R -U -DFAIL $< || exit 0 && exit 1
|
||||
@ -16,18 +25,45 @@ undef1: undef.a65
|
||||
|
||||
undef2: undef.a65
|
||||
${XA} -R -Ll1 -Ll3 $<
|
||||
file65 -V a.o65
|
||||
reloc65 -bt 40960 -o b.o65 a.o65
|
||||
hexdump -C b.o65 > b.hex
|
||||
cmp undef2.out b.hex
|
||||
|
||||
undef3: undef.a65
|
||||
${XA} -R -U $<
|
||||
file65 -V a.o65
|
||||
reloc65 -bt 40960 -o b.o65 a.o65
|
||||
hexdump -C b.o65 > b.hex
|
||||
cmp undef2.out b.hex
|
||||
|
||||
undef4: undef4.a65
|
||||
@echo These should fail
|
||||
${XA} $< || exit 0 && exit 1
|
||||
${XA} -R $< || exit 0 && exit 1
|
||||
${XA} -R -Ll1 $< || exit 0 && exit 1
|
||||
${XA} -R -U $< || exit 0 && exit 1
|
||||
|
||||
undef5f: undef5.a65
|
||||
@echo These should fail
|
||||
${XA} $< || exit 0 && exit 1
|
||||
${XA} -R $< || exit 0 && exit 1
|
||||
${XA} -R -Ll1 $< || exit 0 && exit 1
|
||||
|
||||
undef5: undef5.a65
|
||||
${XA} -R -U $<
|
||||
hexdump -C a.o65 > a.hex
|
||||
cmp undef5.out a.hex
|
||||
|
||||
undef6f: undef6.a65
|
||||
@echo These should fail
|
||||
${XA} $< || exit 0 && exit 1
|
||||
${XA} -R $< || exit 0 && exit 1
|
||||
${XA} -R -Ll1 $< || exit 0 && exit 1
|
||||
|
||||
undef6: undef6.a65
|
||||
${XA} -R -U $<
|
||||
hexdump -C a.o65 > a.hex
|
||||
cmp undef6.out a.hex
|
||||
|
||||
clean:
|
||||
rm -f a.err a.o65 a.hex b.o65 b.hex
|
||||
|
||||
|
14
xa/tests/undef/undef4.a65
Normal file
14
xa/tests/undef/undef4.a65
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
.text
|
||||
|
||||
lda l1
|
||||
|
||||
.(
|
||||
|
||||
.(
|
||||
|
||||
lda l1
|
||||
|
||||
.)
|
||||
l1
|
||||
.)
|
16
xa/tests/undef/undef5.a65
Normal file
16
xa/tests/undef/undef5.a65
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
.text
|
||||
|
||||
|
||||
.(
|
||||
|
||||
.(
|
||||
|
||||
lda l1
|
||||
|
||||
.)
|
||||
l1
|
||||
.)
|
||||
|
||||
lda l1
|
||||
|
4
xa/tests/undef/undef5.out
Normal file
4
xa/tests/undef/undef5.out
Normal file
@ -0,0 +1,4 @@
|
||||
00000000 01 00 6f 36 35 00 00 00 00 10 06 00 00 04 00 00 |..o65...........|
|
||||
00000010 00 40 00 00 04 00 00 00 00 00 00 ad 03 10 ad 00 |.@..............|
|
||||
00000020 00 01 00 6c 31 00 02 82 03 80 00 00 00 00 00 00 |...l1...........|
|
||||
00000030
|
26
xa/tests/undef/undef6.a65
Normal file
26
xa/tests/undef/undef6.a65
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
.text
|
||||
|
||||
|
||||
.(
|
||||
|
||||
.(
|
||||
|
||||
lda l1
|
||||
|
||||
.)
|
||||
l1
|
||||
.)
|
||||
|
||||
.(
|
||||
|
||||
.(
|
||||
|
||||
lda l1
|
||||
|
||||
.)
|
||||
l1
|
||||
.)
|
||||
|
||||
lda l1
|
||||
|
5
xa/tests/undef/undef6.out
Normal file
5
xa/tests/undef/undef6.out
Normal file
@ -0,0 +1,5 @@
|
||||
00000000 01 00 6f 36 35 00 00 00 00 10 09 00 00 04 00 00 |..o65...........|
|
||||
00000010 00 40 00 00 04 00 00 00 00 00 00 ad 03 10 ad 06 |.@..............|
|
||||
00000020 10 ad 00 00 01 00 6c 31 00 02 82 03 82 03 80 00 |......l1........|
|
||||
00000030 00 00 00 00 00 |.....|
|
||||
00000035
|
Loading…
x
Reference in New Issue
Block a user