From fb7f15f20842df4ef364703fe47b842371f8bccc Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Wed, 16 Mar 2022 20:09:09 +0100 Subject: [PATCH] code clean-up --- cpu.cpp | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/cpu.cpp b/cpu.cpp index a06fdd6..a071152 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -960,26 +960,16 @@ bool cpu::condition_code_operations(const uint16_t instr) } if ((instr & ~31) == 0b10100000) { // set condition bits - if (instr & 0b10000) { - if (instr & 0b1000) - setPSW_n(true); - if (instr & 0b0100) - setPSW_z(true); - if (instr & 0b0010) - setPSW_v(true); - if (instr & 0b0001) - setPSW_c(true); - } - else { - if (instr & 0b1000) - setPSW_n(false); - if (instr & 0b0100) - setPSW_z(false); - if (instr & 0b0010) - setPSW_v(false); - if (instr & 0b0001) - setPSW_c(false); - } + bool state = !!(instr & 0b10000); + + if (instr & 0b1000) + setPSW_n(state); + if (instr & 0b0100) + setPSW_z(state); + if (instr & 0b0010) + setPSW_v(state); + if (instr & 0b0001) + setPSW_c(state); return true; }