Commit 73fbcc05 authored by Jeffrey Lee's avatar Jeffrey Lee

Rework *memoryi implementation to avoid alignment faults during Thumb disassembly on ARMv6+

Detail:
  s/Debugger - Reworked MemoryI_Code:
  * Avoid alignment faults when disassembling Thumb instructions by using LDRH or LDR-and-shift depending on compile-time architecture
  * Split ARM & Thumb disassembly into two seperate paths to (perhaps) increase readability
  * Cleaned up the code so it only reads each memory location once
Admin:
  Tested on rev C2 beagleboard.
  Current thumb disassembler looks like it could do with a bit of an overhaul when full support for the 32bit encodings is added.
  *memoryi code could also be made a bit nicer if we don't mind thumb disassembly failing if attempted on a CPU that can't (reliably) LDRH.


Version 1.81. Tagged as 'Debugger-1_81'
parent e06a1f48
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "1.80"
Module_Version SETA 180
Module_MajorVersion SETS "1.81"
Module_Version SETA 181
Module_MinorVersion SETS ""
Module_Date SETS "30 Jan 2010"
Module_ApplicationDate SETS "30-Jan-10"
Module_Date SETS "22 Mar 2010"
Module_ApplicationDate SETS "22-Mar-10"
Module_ComponentName SETS "Debugger"
Module_ComponentPath SETS "castle/RiscOS/Sources/Programmer/Debugger"
Module_FullVersion SETS "1.80"
Module_HelpVersion SETS "1.80 (30 Jan 2010)"
Module_FullVersion SETS "1.81"
Module_HelpVersion SETS "1.81 (22 Mar 2010)"
END
/* (1.80)
/* (1.81)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.80
#define Module_MajorVersion_CMHG 1.81
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 30 Jan 2010
#define Module_Date_CMHG 22 Mar 2010
#define Module_MajorVersion "1.80"
#define Module_Version 180
#define Module_MajorVersion "1.81"
#define Module_Version 181
#define Module_MinorVersion ""
#define Module_Date "30 Jan 2010"
#define Module_Date "22 Mar 2010"
#define Module_ApplicationDate "30-Jan-10"
#define Module_ApplicationDate "22-Mar-10"
#define Module_ComponentName "Debugger"
#define Module_ComponentPath "castle/RiscOS/Sources/Programmer/Debugger"
#define Module_FullVersion "1.80"
#define Module_HelpVersion "1.80 (30 Jan 2010)"
#define Module_LibraryVersionInfo "1:80"
#define Module_FullVersion "1.81"
#define Module_HelpVersion "1.81 (22 Mar 2010)"
#define Module_LibraryVersionInfo "1:81"
......@@ -243,6 +243,7 @@
GET Hdr:FPEmulator
GET Hdr:ResourceFS
GET Hdr:CPU.FPA
GET Hdr:CPU.Arch
GET Hdr:Debugger
......@@ -3175,11 +3176,8 @@ MemoryI_Code Entry "r6-r11"
BICNE r7, r7, #1
TEQS r9, r7 ; If same, ensure we do one word
BNE %FT05
ADD r7, r7, r6
ADDEQ r7, r7, r6
05
BL SwapAllBreakpoints
10 ; Loop doing disassembly until ESCape or ended
......@@ -3190,44 +3188,64 @@ MemoryI_Code Entry "r6-r11"
BL DisplayHexWord_R9 ; Display address
BLVC MarkPC
EXIT VS
MOVVC r2, r6 ; Display characters at address
BLVC DisplayCharacters
TEQ r6, #4
BNE %FT40
; ARM disassembly
MOV r0, r9
BL do_readW
MOV r4, r1
BL DisplayCharactersR ; Display R6 chars contained in R4
EXIT VS
SWI XOS_WriteS
DCB " : ", 0
ALIGN
EXIT VS
Push "r0, r1"
MOV r0, r9
BL do_readW
MOV r10, r1
Pull "r0, r1"
TEQS r6, #4
BNE %F40
BL DisplayHexWord
B %F45
40 BL DisplayHexHalfword
BLVC MarkBreakpoints
MOVVC r0, r1
MOVVC r1, r9
SWIVC XDebugger_Disassemble
B %FT55
40 ; Thumb disassembly
; This code will probably want updating once we can decode all the new 32bit encodings
[ NoARMv5
; We may be running on a machine without LDRH, or without proper support for it (e.g. RiscPC)
; To avoid alignment faults on ARMv6+, load an aligned word and shift it ourselves
BIC r0, r9, #2
BL do_readW
TST r9, #2
MOVNE r1, r1, LSR #16
|
; ARMv5+, safe to LDRH
MOV r0, r9
BL do_readH
]
45 BLVC MarkBreakpoints
MOV r4, r1
BL DisplayCharactersR ; Display R6 chars contained in R4
EXIT VS
SWI XOS_WriteS
DCB " : ", 0
ALIGN
EXIT VS
Push "r1"
MOV r0, r9
BL do_readW
MOV r0, r1
Pull "r1"
MOV r1, r9
TEQS r6, #4
BNE %F50
SWI XDebugger_Disassemble
B %F55
50 SWI XDebugger_DisassembleThumb
MOV r10, r1
BL DisplayHexHalfword
BLVC MarkBreakpoints
MOVVC r0, r1
MOVVC r1, r9
SWIVC XDebugger_DisassembleThumb
55 MOVVC r0, r1
SWIVC XOS_Write0
......@@ -5195,6 +5213,18 @@ DisplayCharacters Entry "r0-r2, r4-r5, r9", 8 ; "r0-r3, r9"
BLO %BT10
EXIT
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; In r4, r5 = data to display
; r6 = number of chars to print (1-8)
; Out VS: r0 -> error
; VC: all preserved
DisplayCharactersR ALTENTRY
MOV r9, #0
MOV r2, r6
B %BT15
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; In r8 = number to display
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment