This repository was archived by the owner on Dec 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
This repository was archived by the owner on Dec 23, 2025. It is now read-only.
be-code-6800.c Pointer dereference is wrong #180
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
test program. it fails 1.
struct complex {
int r;
int i;
};
void complex_add(struct complex *com_1, struct complex *com_2, struct complex *com_3){
com_3->r = com_1->r + com_2->r;
com_3->i = com_1->i + com_2->i;
}
void complex_add2(struct complex *com_1, struct complex *com_2, struct complex *com_3){
(*com_3).r = (*com_1).r + (*com_2).r;
(*com_3).i = (*com_1).i + (*com_2).i;
}
main(){
struct complex com01, com02, com03;
com01.r=2;
com01.i=3;
com02.r=4;
com02.i=8;
complex_add(&com01,&com02,&com03);
if (com01.r + com02.r != com03.r)
return 1;
if (com01.i + com02.i != com03.i)
return 2;
complex_add2(&com01,&com02,&com03);
if (com01.r + com02.r != com03.r)
return 11;
if (com01.i + com02.i != com03.i)
return 12;
return 0;
}
Part of the compiled program.
The ldx 4,x for the second node has not been generated.
_complex_add:
;make local ptr off 2, rlim 254 noff 2
tsx
ldx 2,x
ldb 1,x
lda 0,x
;make local ptr off 4, rlim 254 noff 4
tsx
addb 5,x
adca 4,x
;make local ptr off 6, rlim 254 noff 6
ldx 6,x
stb 1,x
sta 0,x
patch. works fine.
This patch fixes op16_on_node, but similar fixes are needed for other opXX_on_node.
--- ../Fuzix-Compiler-Kit.head/be-code-6800.c 2024-12-05 18:32:32.401041117 +0000
+++ be-code-6800.c 2024-12-07 07:35:01.435900981 +0000
@@ -595,10 +595,16 @@
switch(r->op) {
case T_LSTORE:
case T_LREF:
- case T_LDEREF:
off = make_local_ptr(v + off, 254);
op16_on_ptr(op, op2, off);
break;
+ case T_LDEREF:
+ off = make_local_ptr(v + off, 254);
+ printf("\tldx %u,x\n", off);
+ invalidate_x();
+ v = r->val2;
+ op16_on_ptr(op, op2, v);
+ break;
case T_CONSTANT:
printf("\t%sb #<%u\n", op, (v + off) & 0xFFFF);
printf("\t%sa #>%u\n", op2, (v + off) & 0xFFFF);
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request