When backend-byte is enabled, the access to the global variables of 6800 becomes strange. I'm looking for the cause of this, but I can't find it.
I made the following modifications to the current latest fizix CC for testing.
--- ../Fuzix-Compiler-Kit/be-codegen-6800.c 2024-11-22 02:02:22.472094724 +0000
+++ be-codegen-6800.c 2024-11-22 02:04:05.088549955 +0000
@@ -31,7 +31,10 @@
#include "compiler.h"
#include "backend.h"
#include "backend-6800.h"
+#include "backend-byte.h"
+void dump_tree(register struct node *n, unsigned depth);
+void byte_label_tree(register struct node *n, unsigned opt);
/*
* Helpers for code generation and tracking
@@ -74,6 +77,7 @@
propagation */
struct node *gen_rewrite(struct node *n)
{
+ byte_label_tree(n, BTF_RELABEL);
return n;
}
sample program:
char x[8];
int main(int argc, char *argv[])
{
char k=7;
for(k=0; k<8; k++){
x[k]=-1;
}
return 0;
}
Before applying the byte_label_tree change to be-codegen-6800.c.
seems good.
tsx
ldb 0,x
clra
addb #<_x+0
adca #>_x+0
staa @tmp
stab @tmp+1
ldx @tmp
ldab #255
stb 0,x
After applying the byte_label_tree changes to be-codegen-6800.c
The address cannot be calculated correctly because adca #0 is missing.
;:load:
;T_EQ v0 t8 f6 NORETURN, UCHAR
; T_PLUS v0 t8 f1 UCHAR
; T_NAME v0 t9 f0 UCHAR x
; T_CAST v0 t18 f0 USHORT
; T_DEREF v0 t8 f0 UCHAR
; T_LOCAL v0 t8 f1 UCHAR k
; T_CONSTANT vffffffffffffffff t8 f0 UCHAR
;:rewritten:
;T_EQ v0 t8 f706 NORETURN,BYTEROOT,BYTEOP, UCHAR
; T_PLUS v0 t9 f301 BYTEOP, UCHAR
; T_NAME v0 t9 f800 BYTETAIL, UCHAR x
; 2003 v0 t8 f800 BYTETAIL, UCHAR k
; T_CONSTANT vffffffffffffffff t8 fb00 BYTEOP,BYTETAIL, UCHAR
ldb #<_x+0
lda #>_x+0
;make local ptr off 0, rlim 255 noff 0
tsx
addb 0,x
staa @tmp
stab @tmp+1
ldx @tmp
ldab #255
stb 0,x