Fuzix-Compiler-Kit icon indicating copy to clipboard operation
Fuzix-Compiler-Kit copied to clipboard

be-codegen-6800.c does not generate instructions for MC6800

Open zu2 opened this issue 4 months ago • 0 comments

T_AND/T_OR long and T_PLUS int/long

--- ../Fuzix-Compiler-Kit/be-codegen-6800.c	2024-10-07 15:42:20
+++ be-codegen-6800.c	2024-10-10 23:23:38
@@ -478,7 +478,7 @@
 		}
 		return write_opd(r, "sub", "sbc", 0);
 	case T_AND:
-		if (r->op == T_CONSTANT) {	/* No need to type check - canno tbe float */
+		if (r->op == T_CONSTANT) {	/* No need to type check - cannot be float */
 			v = r->value & 0xFFFF;
 			if ((v & 0xFF) != 0xFF) {
 				if (v & 0xFF)
@@ -510,6 +510,30 @@
 				else
 					printf("\tclra\n");
 				swap_d_y();
+			}else if(s == 4){
+				v = r->value >> 16;
+				if(((v>>8)&0xFF)!=0xFF){
+					printf("\tstaa @tmp\n");
+					printf("\tldaa @hireg\n");
+					if((v>>8)&0xFF){
+						printf("\tanda #%u\n",(v>>8)&0xFF);
+					}else{
+						printf("\tclra\n");
+					}
+					printf("\tstaa @hireg\n");
+					printf("\tldaa @tmp\n");
+				}
+				if((v&0xFF)!=0xFF){
+					printf("\tstab @tmp+1\n");
+					printf("\tldab @hireg+1\n");
+					if(v&0xFF){
+						printf("\tandb #%u\n",v&0xFF);
+					}else{
+						printf("\tclrb\n");
+					}
+					printf("\tstab @hireg+1\n");
+					printf("\tldab @tmp+1\n");
+				}
 			}
 			return 1;
 		}
@@ -532,9 +556,27 @@
 				swap_d_y();
 				if (v & 0xFF)
 					printf("\t%sb #%u\n", or_op, v & 0xFF);
+				v >>= 8;
 				if (v & 0xFF)
 					printf("\t%sa #%u\n", or_op, v & 0xFF);
 				swap_d_y();
+			}else if(s == 4){
+				v = r->value >> 16;
+				if(v & 0xFF){
+					printf("\tstab @tmp+1\n");
+					printf("\tldab @hireg+1\n");
+					printf("\torab #%u\n",v&0xFF);
+					printf("\tstab @hireg+1\n");
+					printf("\tldab @tmp+1\n");
+				}
+				v >>= 8;
+				if(v & 0xFF){
+					printf("\tstaa @tmp\n");
+					printf("\tldaa @hireg\n");
+					printf("\toraa #%u\n",v&0xFF);
+					printf("\tstaa @hireg\n");
+					printf("\tldaa @tmp\n");
+				}
 			}
 			return 1;
 		}
@@ -1627,6 +1669,12 @@
 		if ((cpu_has_d && s <= 2) || cpu_is_09)
 			return write_tos_opd(n, "add", "adc");
 		/* For 6800 punt to helper */
+		if (cpu == 6800){
+			unsigned off = make_tos_ptr();
+			opd_on_ptr(n,"add","adc",off);
+			adjust_s(s,1);
+			return 1;
+		}
 		return 0;
 	case T_AND:
 		return write_tos_op(n, "and");

zu2 avatar Oct 10 '24 14:10 zu2