From ec14557a1e90314c47b0642079e0408ec3153aa8 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 9 May 2015 00:23:56 -0700 Subject: [PATCH] ARM7: Make illegal instruction decoding consistent between ARM and Thumb --- CHANGES | 1 + src/arm/decoder-arm.c | 8 ++++++-- src/arm/decoder-thumb.c | 9 +++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index ca1a672a9..d6f70c4d9 100644 --- a/CHANGES +++ b/CHANGES @@ -48,6 +48,7 @@ Bugfixes: - ARM7: Handle writeback for PC in addressing modes 2 and 3 - GBA: Handle out-of-bounds I/O access - GBA: Fix bounds-checking on EEPROM access + - ARM7: Make illegal instruction decoding consistent between ARM and Thumb Misc: - Qt: Show multiplayer numbers in window title - Qt: Handle saving input settings better diff --git a/src/arm/decoder-arm.c b/src/arm/decoder-arm.c index 27f692de2..9dcc4bc77 100644 --- a/src/arm/decoder-arm.c +++ b/src/arm/decoder-arm.c @@ -380,8 +380,12 @@ DEFINE_DECODER_ARM(MRC, ILL, info->operandFormat = ARM_OPERAND_NONE;) // Begin miscellaneous definitions -DEFINE_DECODER_ARM(BKPT, BKPT, info->operandFormat = ARM_OPERAND_NONE;) // Not strictly in ARMv4T, but here for convenience -DEFINE_DECODER_ARM(ILL, ILL, info->operandFormat = ARM_OPERAND_NONE;) // Illegal opcode +DEFINE_DECODER_ARM(BKPT, BKPT, + info->operandFormat = ARM_OPERAND_NONE; + info->traps = 1;) // Not strictly in ARMv4T, but here for convenience +DEFINE_DECODER_ARM(ILL, ILL, + info->operandFormat = ARM_OPERAND_NONE; + info->traps = 1;) // Illegal opcode DEFINE_DECODER_ARM(MSR, MSR, info->affectsCPSR = 1; diff --git a/src/arm/decoder-thumb.c b/src/arm/decoder-thumb.c index fb6aed9f5..6bf389508 100644 --- a/src/arm/decoder-thumb.c +++ b/src/arm/decoder-thumb.c @@ -281,8 +281,13 @@ DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(POPR, ARM_SP, LDM, ARM_MEMORY_INCREMENT_AFTE DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(PUSH, ARM_SP, STM, ARM_MEMORY_DECREMENT_BEFORE, 0) DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(PUSHR, ARM_SP, STM, ARM_MEMORY_DECREMENT_BEFORE, 1 << ARM_LR) -DEFINE_THUMB_DECODER(ILL, ILL, info->traps = 1;) -DEFINE_THUMB_DECODER(BKPT, BKPT, info->traps = 1;) +DEFINE_THUMB_DECODER(ILL, ILL, + info->operandFormat = ARM_OPERAND_NONE; + info->traps = 1;) + +DEFINE_THUMB_DECODER(BKPT, BKPT, + info->operandFormat = ARM_OPERAND_NONE; + info->traps = 1;) DEFINE_THUMB_DECODER(B, B, int16_t immediate = (opcode & 0x07FF) << 5;