From 131b0e5634f67793d775702b1e01b768d4cad3d0 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Thu, 21 Jul 2022 10:12:18 +1200 Subject: [PATCH 1/2] Fix CLR flag handling Needs to set V flag depending on value for various cpu6 detection code to work --- cpu6.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/cpu6.c b/cpu6.c index 892dac8..2f5386b 100644 --- a/cpu6.c +++ b/cpu6.c @@ -1058,12 +1058,9 @@ static int dec(unsigned reg, unsigned val) static int clr(unsigned reg, unsigned v) { reg_write(reg, v); - alu_out &= ~(ALU_F | ALU_L | ALU_M); - if (v == 0) - alu_out |= ALU_V; - else - /* Gets us past the tests but is probably wrong */ - alu_out ^= ALU_V; + // Explicitly clears L and F flags + alu_out &= ~(ALU_L | ALU_F); + logic_flags(v); return 0; } @@ -1253,12 +1250,11 @@ static uint16_t dec16(uint16_t a, uint16_t imm) return r; } -/* Assume behaviour matches CLR */ static uint16_t clr16(uint16_t a, uint16_t imm) { - alu_out &= ~(ALU_F | ALU_L | ALU_M); -/* if (imm == 0) */ - alu_out |= ALU_V; + // Explicitly clears L and F flags + alu_out &= ~(ALU_L | ALU_F); + logic_flags16(imm); return imm; } From 5c480076191357dd0d12eda8f527bc3e526881ae Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Thu, 21 Jul 2022 10:13:22 +1200 Subject: [PATCH 2/2] stub parity enable/disable ops Now cpu6 detection works, code actually executes these --- cpu6.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cpu6.c b/cpu6.c index 2f5386b..90259c3 100644 --- a/cpu6.c +++ b/cpu6.c @@ -2398,6 +2398,14 @@ static int semaphore_op(void) { exit(1); } +/* 76 - Enable parity checking + * 86 - Disable parity checking + */ +static int parity_op(void) { + // unimplemented + return 0; +} + /* * The CPU has directly controlled flags for C N Z I * We know from the branch rules there is an internal V flag @@ -2487,6 +2495,8 @@ unsigned cpu6_execute_one(unsigned trace) return alu5x_op(); if (op == 0x67) return block_op(0x67, trace); + if (op == 0x76 || op == 0x86) + return parity_op(); if (op < 0x70) return x_op(); if (op == 0x77 || op == 0x78)