EtchedPixels / Fuzix-Compiler-Kit

Fuzix C Compiler Project
Other
49 stars 14 forks source link

be-code-6800.c gen_fast_div() tst/bpl is shorter than bit #$80/beq #127

Closed zu2 closed 1 month ago

zu2 commented 1 month ago

The 6809/6803/68hc11 are also one byte shorter.

diff -u ../Fuzix-Compiler-Kit/be-code-6800.c be-code-6800.c
--- ../Fuzix-Compiler-Kit/be-code-6800.c    2024-10-24 17:13:18
+++ be-code-6800.c  2024-10-24 17:16:54
@@ -1019,7 +1058,7 @@
    } else {
        /* Round towards zero */
        unsigned m = (n - 1) & 0xFFFF;
-       printf("\tbita #0x80\n\tbeq X%u\n", ++label);
+       printf("\ttsta\n\tbpl X%u\n", ++label);
        if (cpu_has_d)
            printf("\taddd #%u\n", m);
        else {
zu2 commented 1 month ago
--- ../Fuzix-Compiler-Kit/support6800/__castl.s 2024-10-13 22:57:57
+++ support6800/__castl.s   2024-10-11 12:48:29
@@ -6,8 +6,8 @@
 __cast_l:
    clr @hireg
    clr @hireg+1
-   bita #0x80
-   beq extpv
+   tsta
+   bpl extpv
    dec @hireg
    dec @hireg+1
 extpv:
EtchedPixels commented 1 month ago

Thanks