I found when trying to run some existing STM8 code of mine, that the emulator was failing with illegal opcode errors or giving incorrect results. After a lot of debugging, managed to track the problem down to being caused by the CPU emulation missing implementations for certain ADDW instruction variants!
The variants that are missing are ADDW Y, (addr8, SP) and ADDW Y, #imm16. The former gets mishandled as an ADC A, (X) instruction; the latter as ADC A, #imm8.
I found when trying to run some existing STM8 code of mine, that the emulator was failing with illegal opcode errors or giving incorrect results. After a lot of debugging, managed to track the problem down to being caused by the CPU emulation missing implementations for certain
ADDW
instruction variants!The variants that are missing are
ADDW Y, (addr8, SP)
andADDW Y, #imm16
. The former gets mishandled as anADC A, (X)
instruction; the latter asADC A, #imm8
.I am currently working on a fix for this.