From 42fe341091f3fa4c15b4014645e989955cc2d59b Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Wed, 23 Mar 2022 17:52:59 +0100 Subject: [PATCH] micro opt for div --- cpu.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cpu.cpp b/cpu.cpp index cff25a4..5779d6e 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -501,10 +501,12 @@ bool cpu::additional_double_operand_instructions(const uint16_t instr) int32_t quot = R0R1 / divider; uint16_t rem = R0R1 % divider; + // TODO: handle results out of range + setRegister(reg, quot); setRegister(reg + 1, rem); - setPSW_n(R0R1 / divider < 0); + setPSW_n(quot < 0); setPSW_z(quot == 0); setPSW_v(quot > 0xffff || quot < -0xffff); setPSW_c(false);