From b2f8982f8293ed6b875f2251b4a01011d1786428 Mon Sep 17 00:00:00 2001 From: Tat-Chee Wan (USM) Date: Wed, 6 Jul 2011 08:25:06 +0800 Subject: fix bug in b and bl offset calculation, code cleanup. B/BL Instruction Parsing routine was not calculating the correct offset. Cleanup debugger stack frame access logic --- Debugger/debug_opcodes.S | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Debugger/debug_opcodes.S') diff --git a/Debugger/debug_opcodes.S b/Debugger/debug_opcodes.S index e460e83..6f203fd 100644 --- a/Debugger/debug_opcodes.S +++ b/Debugger/debug_opcodes.S @@ -683,9 +683,9 @@ _dbg_get_aborted_instr: * If not, then the following instruction is at the address following the address of the opcode in R4 (Default Following Instruction Address in R6). */ 2: - teq r0, #0 /* Check if it is ARM or Thumb instruction */ - beq _following_instr_is_arm -_following_instr_is_thumb: + teq r0, #0 /* Check if current instruction is ARM or Thumb instruction */ + beq _following_instr_addr_for_arm +_following_instr_addr_for_thumb: add r6, r6, #2 /* Store default following Thumb instruction address to R6 */ orr r6, r6, #BKPT_STATE_THUMB_FLAG /* Set b0 to indicate Thumb instruction */ /* R4: Candidate Instruction Opcode @@ -696,7 +696,7 @@ _following_instr_is_thumb: /* We must set this the Thumb bit only within the instruction handler since BX would switch modes */ b _exit_dbg_following_instruction_addr -_following_instr_is_arm: +_following_instr_addr_for_arm: add r6, r6, #4 /* Store default following ARM instruction address to R6 */ /* R4: Candidate Instruction Opcode * R5[3:0]: CPSR condition codes @@ -1233,7 +1233,7 @@ _arm_b_bl_blx_handler: _arm_b_bl_blx_get_offset: and r0, r4, #(BYTE2|BYTE1|BYTE0) /* Encoded Branch offset in R4[23:0] */ lsl r0, r0, #(32-24) /* Shift to R0[31:8] */ - asr r0, r0, #(32-25) /* Actual Signed offset = Encode Offset x 2 in R0[25:0] */ + asr r0, r0, #(32-26) /* Actual Signed offset = Encode Offset x 4 in R0[25:0] */ add r1, r6, #4 /* R1: (PC+4) + 4 */ add r0, r0, r1 /* Calculate Branch Target Address R0: (PC+8) + signed offset */ -- cgit v1.2.3