EtchedPixels / Fuzix-Compiler-Kit

Fuzix C Compiler Project
Other
49 stars 13 forks source link

support6800/ missing __abx, __adx #119

Closed zu2 closed 1 month ago

zu2 commented 1 month ago

I couldn't decide whether it would be better to save A and B on the caller side or on the __abx/adx side. Here, pshb/psha are omitted as they are saved on the caller side.

;
;   Adds the value of the accumulator to X.
;   messing up D
;
    .export __abx
    .export __adx
    .code

__abx:
    stx @tmp    ; X where we can manipulate it
    addb @tmp+1
    adca #0
    stab @tmp+1
    staa @tmp
    ldx @tmp
    rts

__adx:
    stx @tmp    ; X where we can manipulate it
    addb @tmp+1
    adca @tmp
    stab @tmp+1
    staa @tmp
    ldx @tmp
    rts

When compiling a program with a large local array, tracking of A and B fails. I added invalidate_work(), but there must be a better way.

--- ../Fuzix-Compiler-Kit/be-code-6800.c    2024-10-11 05:18:39
+++ be-code-6800.c  2024-10-11 09:28:00
@@ -503,6 +509,7 @@
        return rlim;
    } else {
        /* This case is (thankfully) fairly rare */
+       invalidate_work();
        printf("\tpshb\n\tpsha\n");
        load_d_const(off);
        printf("\tjsr __adx\n");
EtchedPixels commented 1 month ago

Added - I've tweaked the invalidates but there may be another underlying bug somewhere

Not sure where we should save. You are probably right it should be saved in the called functions for size reasons