diff gen_x86.c @ 2226:d15c68157288

Fix implementation ot 68K trapv instruction
author Michael Pavone <pavone@retrodev.com>
date Mon, 05 Sep 2022 12:00:02 -0700
parents e45a317802bd
children
line wrap: on
line diff
--- a/gen_x86.c	Mon Sep 05 01:15:15 2022 -0700
+++ b/gen_x86.c	Mon Sep 05 12:00:02 2022 -0700
@@ -1157,7 +1157,7 @@
 	if (size == SZ_B) {
 		fatal_error("imul immediate only supports 16-bit sizes and up");
 	}
-	
+
 	x86_ir(code, OP_IMUL, dst, 0, val, src, size);
 }
 
@@ -1713,6 +1713,9 @@
 {
 	check_alloc_code(code, 5);
 	code_ptr out = code->cur;
+	if (src >= AH && src <= BH || dst >= AH && dst <= BH) {
+		fatal_error("attempt to use *H reg in a bit instruction with bit number in register. opcode = %X\n", op2);
+	}
 	if (size == SZ_W) {
 		*(out++) = PRE_SIZE;
 	}
@@ -1741,6 +1744,9 @@
 {
 	check_alloc_code(code, 9);
 	code_ptr out = code->cur;
+	if (src >= AH && src <= BH) {
+		fatal_error("attempt to use *H reg in a bit instruction with bit number in register. opcode = %X\n", op2);
+	}
 	if (size == SZ_W) {
 		*(out++) = PRE_SIZE;
 	}
@@ -1778,6 +1784,12 @@
 {
 	check_alloc_code(code, 6);
 	code_ptr out = code->cur;
+	if (dst >= AH && dst <= BH) {
+		//bit instructions are never 8-bit so we can't directly specify the high byte regs
+		//but we can simulate that by adjusting the bit we're testing
+		dst -= AH;
+		val += 8;
+	}
 	if (size == SZ_W) {
 		*(out++) = PRE_SIZE;
 	}
@@ -2163,7 +2175,7 @@
 	code->stack_off += 32;
 	adjust += 32;
 #endif
-	
+
 	return stack_args * sizeof(void *) + adjust;
 }