From 768750ee2a79366300d4e1038abbc9e46fcc3a2e Mon Sep 17 00:00:00 2001 From: arbee Date: Thu, 16 Nov 2017 21:06:48 -0500 Subject: arm7: Implement BLX Rn instruction for ARM9. NDS ARM9 BIOS gets to the first checkpoint. [R. Belmont] --- src/devices/cpu/arm7/arm7dasm.cpp | 10 +++++++++- src/devices/cpu/arm7/arm7ops.cpp | 12 ++++++++++++ src/mame/drivers/nds.cpp | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/devices/cpu/arm7/arm7dasm.cpp b/src/devices/cpu/arm7/arm7dasm.cpp index 3d38ea29872..df0a98b6435 100644 --- a/src/devices/cpu/arm7/arm7dasm.cpp +++ b/src/devices/cpu/arm7/arm7dasm.cpp @@ -212,7 +212,7 @@ static uint32_t arm7_disasm( std::ostream &stream, uint32_t pc, uint32_t opcode if( (opcode&0xfe000000)==0xfa000000 ) //bits 31-25 == 1111 101 (BLX - v5) { - /* BLX */ + /* BLX(1) */ util::stream_format( stream, "BLX" ); dasmflags = DASMFLAG_STEP_OVER; @@ -220,6 +220,14 @@ static uint32_t arm7_disasm( std::ostream &stream, uint32_t pc, uint32_t opcode WriteBranchAddress( stream, pc, opcode, true ); } + else if( (opcode&0x0ff000f0)==0x01200030 ) // (BLX - v5) + { + /* BLX(2) */ + util::stream_format( stream, "BLX" ); + dasmflags = DASMFLAG_STEP_OVER; + WritePadding(stream, start_position); + util::stream_format( stream, "R%d",(opcode&0xf)); + } else if( (opcode&0x0ffffff0)==0x012fff10 ) //bits 27-4 == 000100101111111111110001 { /* Branch and Exchange (BX) */ diff --git a/src/devices/cpu/arm7/arm7ops.cpp b/src/devices/cpu/arm7/arm7ops.cpp index 5b71b7e8d9f..39a1eb502c2 100644 --- a/src/devices/cpu/arm7/arm7ops.cpp +++ b/src/devices/cpu/arm7/arm7ops.cpp @@ -1660,6 +1660,18 @@ void arm7_cpu_device::arm7ops_0123(uint32_t insn) R15--; } } + else if ((insn & 0x0ff000f0) == 0x01200030) // BLX Rn - v5 + { + // save link address + SetRegister(14, R15 + 4); + + R15 = GetRegister(insn & 0x0f); + // If new PC address has A0 set, switch to Thumb mode + if (R15 & 1) { + set_cpsr(GET_CPSR|T_MASK); + R15--; + } + } else if ((insn & 0x0ff000f0) == 0x01600010) // CLZ - v5 { uint32_t rm = insn&0xf; diff --git a/src/mame/drivers/nds.cpp b/src/mame/drivers/nds.cpp index c9844a0702b..f418b5465e8 100644 --- a/src/mame/drivers/nds.cpp +++ b/src/mame/drivers/nds.cpp @@ -113,7 +113,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( nds_arm9_map, AS_PROGRAM, 32, nds_state ) AM_RANGE(0x00000000, 0x00007fff) AM_RAM // Instruction TCM - AM_RANGE(0x02000000, 0x023fffff) AM_RAM AM_SHARE("mainram") + AM_RANGE(0x02000000, 0x023fffff) AM_RAM AM_MIRROR(0x00400000) AM_SHARE("mainram") AM_RANGE(0x04000000, 0x0400ffff) AM_READWRITE(arm9_io_r, arm9_io_w) AM_RANGE(0xffff0000, 0xffff0fff) AM_ROM AM_MIRROR(0x1000) AM_REGION("arm9", 0) ADDRESS_MAP_END -- cgit v1.2.3