EtchedPixels / Fuzix-Compiler-Kit

Fuzix C Compiler Project
Other
45 stars 11 forks source link

be-code-6800.c Fix x reg tracking and reduce tsx #133

Closed zu2 closed 11 hours ago

zu2 commented 1 day ago
--- ../Fuzix-Compiler-Kit/be-code-6800.c    2024-10-26 08:56:57
+++ be-code-6800.c  2024-10-26 21:01:59
@@ -438,12 +438,16 @@
    /* HACK: for the moment disable this stuff whilst we debug the
       rest of the code as the make_local_ptr tracking is currently
       totally broken */
-   if (1 || x_fprel == 0 ||  noff < 0) {
+   if (x_fprel == 0 ||  noff < 0) {
        printf("\ttsx\n");
        x_fprel = 1;
        x_fpoff = 0;
-   } else
+   } else {
        off = noff;
+       if(off<=rlim){
+           return off;
+       }
+   }

    off += sp;
    if (off <= rlim)
@@ -483,6 +487,8 @@
    between register so we sometimes need to build ops against top of stack */
 unsigned make_tos_ptr(void)
 {
+   if((x_fpoff==sp) && (x_fprel==1))
+       return 0;
    puts("\ttsx");
    x_fpoff = sp;
    x_fprel = 1;
EtchedPixels commented 1 day ago

It's somewhat more complicated to fix than that. I think I've now got it right but it will need more testing and checking. See 2abf16d0ab8869499d88b1e177a675aaa4fa62cb