fix align bug

This commit is contained in:
Andre Fachat 2023-12-01 22:52:10 +01:00
parent e51b1e7f41
commit 59a635ce37
42 changed files with 183 additions and 3 deletions

View File

@ -39,4 +39,6 @@
t[i++] = f & 255; \
} while (0)
#define wval_len 5 /* number of bytes stored in wval() call */
#endif /* __XA65_XAD_H__ */

View File

@ -834,12 +834,12 @@ printf("reloc: er=%d, l=%d, segment=%d, pc[%d]=%04x, pc[abs(%d)]=%04x, pc[text(%
t[0]=Kdsb;
i=1;
bl=tmp=(tmp - (pc[segment] & (tmp-1))) & (tmp-1);
wval(i,tmp, 0);
wval(i,tmp, 0); // 5 byte
t[i++]=',';
tmp2= 0xea;
wval(i,tmp2, 0); /* nop opcode */
wval(i,tmp2, 0); /* nop opcode, another 5 byte */
t[i++]=T_END;
*ll=9;
*ll=wval_len * 2 + 3; //13; //9;
er=E_OKDEF;
} else {
*ll=0; /* ignore if aligned right */

100
xa/tests/align/Makefile Normal file
View File

@ -0,0 +1,100 @@
XA=../../xa
default: all
all: t01 t02 t03 t11 t12 t13 t21 t22 t23 t31 t32 t33 t41 t42 t43
# BSD only has suffix rules
.SUFFIXES: .o65 .hex .a65
#%.o65: %.s
.a65.o65:
${XA} -R -c -o $@ $<
#%.hex: %.o65
.o65.hex:
../hextool $< > $@
###############################################
# text segment correctly aligned
t01: t01.o65
cmp $@.o65 $@.ok
t02: t02.o65
cmp $@.o65 $@.ok
t03: t03.o65
cmp $@.o65 $@.ok
###############################################
# data segment correctly aligned
t11: t11.o65
cmp $@.o65 $@.ok
t12: t12.o65
cmp $@.o65 $@.ok
t13: t13.o65
cmp $@.o65 $@.ok
###############################################
# text segment incorrectly aligned
t21: t01.a65
${XA} -R -c -bt 1025 -o $@.o65 $< 2> $@.msg
cmp $@.msg $@.mok
cmp $@.o65 $@.ok
t22: t02.a65
${XA} -R -c -bt 1025 -o $@.o65 $< 2> $@.msg
cmp $@.msg $@.mok
cmp $@.o65 $@.ok
t23: t03.a65
${XA} -R -c -bt 1025 -o $@.o65 $< 2> $@.msg
cmp $@.msg $@.mok
cmp $@.o65 $@.ok
###############################################
# text segment correctly aligned, but data segment not (even if empty)
t31: t01.a65
${XA} -R -c -bd 1025 -o $@.o65 $< 2> $@.msg
cmp $@.msg $@.mok
cmp $@.o65 $@.ok
t32: t02.a65
${XA} -R -c -bd 1025 -o $@.o65 $< 2> $@.msg
cmp $@.msg $@.mok
cmp $@.o65 $@.ok
t33: t03.a65
${XA} -R -c -bd 1025 -o $@.o65 $< 2> $@.msg
cmp $@.msg $@.mok
cmp $@.o65 $@.ok
###############################################
# data segment incorrectly aligned
t41: t11.a65
${XA} -R -c -bd 1025 -o $@.o65 $< 2> $@.msg
cmp $@.msg $@.mok
cmp $@.o65 $@.ok
t42: t12.a65
${XA} -R -c -bd 1025 -o $@.o65 $< 2> $@.msg
cmp $@.msg $@.mok
cmp $@.o65 $@.ok
t43: t13.a65
${XA} -R -c -bd 1025 -o $@.o65 $< 2> $@.msg
cmp $@.msg $@.mok
cmp $@.o65 $@.ok
clean:
rm -f *.o65 *.hex

10
xa/tests/align/t01.a65 Normal file
View File

@ -0,0 +1,10 @@
.text
tay
.align 2
tay

BIN
xa/tests/align/t01.ok Normal file

Binary file not shown.

10
xa/tests/align/t02.a65 Normal file
View File

@ -0,0 +1,10 @@
.text
tay
.align 4
tay

BIN
xa/tests/align/t02.ok Normal file

Binary file not shown.

10
xa/tests/align/t03.a65 Normal file
View File

@ -0,0 +1,10 @@
.text
tay
.align 256
tay

BIN
xa/tests/align/t03.ok Normal file

Binary file not shown.

10
xa/tests/align/t11.a65 Normal file
View File

@ -0,0 +1,10 @@
.data
tay
.align 2
tay

BIN
xa/tests/align/t11.ok Normal file

Binary file not shown.

10
xa/tests/align/t12.a65 Normal file
View File

@ -0,0 +1,10 @@
.data
tay
.align 4
tay

BIN
xa/tests/align/t12.ok Normal file

Binary file not shown.

10
xa/tests/align/t13.a65 Normal file
View File

@ -0,0 +1,10 @@
.data
tay
.align 256
tay

BIN
xa/tests/align/t13.ok Normal file

Binary file not shown.

1
xa/tests/align/t21.mok Normal file
View File

@ -0,0 +1 @@
Warning: text segment ($0401) start address doesn't align to 2!

1
xa/tests/align/t21.msg Normal file
View File

@ -0,0 +1 @@
Warning: text segment ($0401) start address doesn't align to 2!

BIN
xa/tests/align/t21.ok Normal file

Binary file not shown.

1
xa/tests/align/t22.mok Normal file
View File

@ -0,0 +1 @@
Warning: text segment ($0401) start address doesn't align to 4!

1
xa/tests/align/t22.msg Normal file
View File

@ -0,0 +1 @@
Warning: text segment ($0401) start address doesn't align to 4!

BIN
xa/tests/align/t22.ok Normal file

Binary file not shown.

1
xa/tests/align/t23.mok Normal file
View File

@ -0,0 +1 @@
Warning: text segment ($0401) start address doesn't align to 256!

1
xa/tests/align/t23.msg Normal file
View File

@ -0,0 +1 @@
Warning: text segment ($0401) start address doesn't align to 256!

BIN
xa/tests/align/t23.ok Normal file

Binary file not shown.

1
xa/tests/align/t31.mok Normal file
View File

@ -0,0 +1 @@
Warning: data segment ($0401) start address doesn't align to 2!

1
xa/tests/align/t31.msg Normal file
View File

@ -0,0 +1 @@
Warning: data segment ($0401) start address doesn't align to 2!

BIN
xa/tests/align/t31.ok Normal file

Binary file not shown.

1
xa/tests/align/t32.mok Normal file
View File

@ -0,0 +1 @@
Warning: data segment ($0401) start address doesn't align to 4!

1
xa/tests/align/t32.msg Normal file
View File

@ -0,0 +1 @@
Warning: data segment ($0401) start address doesn't align to 4!

BIN
xa/tests/align/t32.ok Normal file

Binary file not shown.

1
xa/tests/align/t33.mok Normal file
View File

@ -0,0 +1 @@
Warning: data segment ($0401) start address doesn't align to 256!

1
xa/tests/align/t33.msg Normal file
View File

@ -0,0 +1 @@
Warning: data segment ($0401) start address doesn't align to 256!

BIN
xa/tests/align/t33.ok Normal file

Binary file not shown.

1
xa/tests/align/t41.mok Normal file
View File

@ -0,0 +1 @@
Warning: data segment ($0401) start address doesn't align to 2!

1
xa/tests/align/t41.msg Normal file
View File

@ -0,0 +1 @@
Warning: data segment ($0401) start address doesn't align to 2!

BIN
xa/tests/align/t41.ok Normal file

Binary file not shown.

1
xa/tests/align/t42.mok Normal file
View File

@ -0,0 +1 @@
Warning: data segment ($0401) start address doesn't align to 4!

1
xa/tests/align/t42.msg Normal file
View File

@ -0,0 +1 @@
Warning: data segment ($0401) start address doesn't align to 4!

BIN
xa/tests/align/t42.ok Normal file

Binary file not shown.

1
xa/tests/align/t43.mok Normal file
View File

@ -0,0 +1 @@
Warning: data segment ($0401) start address doesn't align to 256!

1
xa/tests/align/t43.msg Normal file
View File

@ -0,0 +1 @@
Warning: data segment ($0401) start address doesn't align to 256!

BIN
xa/tests/align/t43.ok Normal file

Binary file not shown.