changeset 171:f03db3db48fb

Implement EORI CCR/SR
author Mike Pavone <pavone@retrodev.com>
date Sun, 06 Jan 2013 14:00:45 -0800
parents 7d1b04537377
children c61507f897e4
files m68k_to_x86.c
diffstat 1 files changed, 26 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/m68k_to_x86.c	Sun Jan 06 13:58:33 2013 -0800
+++ b/m68k_to_x86.c	Sun Jan 06 14:00:45 2013 -0800
@@ -2726,8 +2726,32 @@
 		dst = mov_ir(dst, 0, FLAG_V, SZ_B);
 		dst = m68k_save_result(inst, dst, opts);
 		break;
-	/*case M68K_EORI_CCR:
-	case M68K_EORI_SR:*/
+	case M68K_EORI_CCR:
+	case M68K_EORI_SR:
+		dst = cycles(dst, 20);
+		//TODO: If ANDI to SR, trap if not in supervisor mode
+		if (inst->src.params.immed & 0x1) {
+			dst = xor_ir(dst, 1, FLAG_C, SZ_B);
+		}
+		if (inst->src.params.immed & 0x2) {
+			dst = xor_ir(dst, 1, FLAG_V, SZ_B);
+		}
+		if (inst->src.params.immed & 0x4) {
+			dst = xor_ir(dst, 1, FLAG_Z, SZ_B);
+		}
+		if (inst->src.params.immed & 0x8) {
+			dst = xor_ir(dst, 1, FLAG_N, SZ_B);
+		}
+		if (inst->src.params.immed & 0x10) {
+			dst = xor_irdisp8(dst, 1, CONTEXT, 0, SZ_B);
+		}
+		if (inst->op == M68K_ORI_SR) {
+			dst = xor_irdisp8(dst, inst->src.params.immed >> 8, CONTEXT, offsetof(m68k_context, status), SZ_B);
+			if (inst->src.params.immed & 0x700) {
+				dst = call(dst, (uint8_t *)do_sync);
+			}
+		}
+		break;
 	case M68K_EXG:
 		dst = cycles(dst, 6);
 		if (dst_op.mode == MODE_REG_DIRECT) {