From ab5d9cbe69b47e549e128baeadfc6258dcaeed79 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Sun, 21 Aug 2022 23:41:26 +0200 Subject: [PATCH] Emulator: Fix loading 16-bit immediate value The 8 lower bits are read first. The 8 higher bits come afterwards! --- src/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpu.h b/src/cpu.h index c10bde5..85cb025 100644 --- a/src/cpu.h +++ b/src/cpu.h @@ -55,7 +55,7 @@ private: uint8_t peekMemory(int32_t offset = 0) const; uint8_t consumeMemory(); - uint32_t immediate16() { return (consumeMemory() << 8) | consumeMemory(); } + uint32_t immediate16() { return consumeMemory() | (consumeMemory() << 8); } void setBc(uint32_t value); void setDe(uint32_t value);