EtchedPixels / Fuzix-Compiler-Kit

Fuzix C Compiler Project
Other
49 stars 13 forks source link

be-codegen-6800.c gencast() MC6800 sign extend #125

Closed zu2 closed 1 month ago

zu2 commented 1 month ago
--- ../Fuzix-Compiler-Kit/be-codegen-6800.c     2024-10-23 08:39:07
+++ be-codegen-6800.c   2024-10-23 14:35:06
@@ -1352,7 +1410,25 @@
                        }
                        /* TODO: 6309 has sexw */
                }
-               return 0;
+               /* TODO: 6800 sign extend */
+               if(rs==1){
+                       printf("\tclra\n");
+                       printf("\tasrb\n");
+                       printf("\trolb\n");
+                       printf("\tsbca #0\n");
+                       if(ls==4){
+                               printf("\tstaa @hireg\n\tstaa @hireg+1\n");
+                       }
+               }else if(ls==4 && rs==2){
+                       printf("\tpshb\n");
+                       printf("\tclrb\n");
+                       printf("\tasra\n");
+                       printf("\trola\n");
+                       printf("\tsbcb #0\n");
+                       printf("\tstab @hireg\n\tstab @hireg+1\n");
+                       printf("\tpulb\n");
+               }
+               return 1;
EtchedPixels commented 1 month ago

Reworked a bit to keep 6809/68HC11 happy etc and merged