From 52cd604eb1762b716fcd49d7db25b8e9080b4717 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Fri, 19 Aug 2022 14:30:40 +0200 Subject: [PATCH] Emulator: Do not store overflown bits --- src/cpu.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cpu.cpp b/src/cpu.cpp index d9b770a..ab98215 100644 --- a/src/cpu.cpp +++ b/src/cpu.cpp @@ -9,6 +9,7 @@ #include "cpu.h" #include "ruc/format/print.h" +#include "ruc/meta/assert.h" CPU::CPU(uint32_t frequency) : ProcessingUnit(frequency) @@ -60,8 +61,12 @@ void CPU::add(uint8_t opcode, uint8_t immediate) // A = A + r m_a += immediate; + + // Drop overflown bits, the 'A' register is 8-bit + m_a &= 0xff; break; default: + VERIFY_NOT_REACHED(); break; } }