From b45eb6247ddd8ef31a045ead21c659e7c5ecef44 Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Sat, 10 Aug 2024 09:29:23 +0200 Subject: [PATCH] Trap if add would switch instruction set. --- src/emucore/CortexM0.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/emucore/CortexM0.cxx b/src/emucore/CortexM0.cxx index eeb6953cf..961ec562a 100644 --- a/src/emucore/CortexM0.cxx +++ b/src/emucore/CortexM0.cxx @@ -999,6 +999,9 @@ CortexM0::err_t CortexM0::execute(uInt16 inst, uInt8 op) rc = ra + rb; if(rd == 15) { + if ((rc & 1) == 0) + return errIntrinsic(ERR_INVALID_OPERATING_MODE, read_register(15) - 4); + rc &= ~1; //write_register may f this as well rc += 2; //The program counter is special }