Closed zu2 closed 1 week ago
--- ../Fuzix-Compiler-Kit/be-codegen-6800.c 2024-11-11 09:45:00 +++ be-codegen-6800.c 2024-11-11 23:51:18 @@ -502,6 +506,14 @@ add_b_const(r->value); return 1; } + } + if (s == 2 && r->op == T_LOCAL) { + v = r->value; + if (!cpu_is_09) + v++; + puts("\tsts @tmp\n\taddb @tmp+1\n\tadca @tmp"); + add_d_const(v); + return 1; } return write_opd(r, "add", "adc", 0); case T_MINUS:
sample program:
int main(int argc, char **argv) { int a[10]; int i; for (i=0; i<10; i++){ a[i] = i; } if (a[0] != 0) return 1; if (a[9] != 9) return 2; return 0; }
compile with -O3
remove pshb/psha & jsr __plus on a[i] = i
diff -u 9055-array.s.old 9055-array.s.new --- 9055-array.s.old 2024-11-11 23:50:48 +++ 9055-array.s.new 2024-11-11 23:32:11 @@ -117,21 +117,17 @@ lda 20,x lslb rola - pshb - psha sts @tmp - ldaa @tmp - ldab @tmp+1 - addb #3 + addb @tmp+1 + adca @tmp + addb #1 adca #0 - jsr __plus pshb psha ;make local ptr off 20, rlim 254 noff 20 + ldb 21,x + lda 20,x tsx - ldb 23,x - lda 22,x - tsx ldx ,x ins ins
Added an invalidate_d() and addd form for > 6800 and merged Thanks
sample program:
compile with -O3
remove pshb/psha & jsr __plus on a[i] = i