4 ; Main definitions for Sledgehammer (TMA & MDW)
6 ; © 1994-1998 Straylight
9 ;----- Licensing note -------------------------------------------------------
11 ; This file is part of Straylight's Sledgehammer debugger.
13 ; Sledgehammer is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
18 ; Sledgehammer is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ; GNU General Public License for more details.
23 ; You should have received a copy of the GNU General Public License
24 ; along with Sledgehammer. If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ;----- Standard header ------------------------------------------------------
32 ;----- External dependencies ------------------------------------------------
42 ;----- Module information ---------------------------------------------------
44 AREA |Hammer$$Code|,CODE,READONLY
47 quartz_name DCB "Sledgehammer",0
49 ;----- SWI information ------------------------------------------------------
51 EXPORT quartz_swiChunk
52 quartz_swiChunk EQU &4A380
54 EXPORT quartz_swiNames
55 quartz_swiNames DCB "Sledgehammer",0
57 DCB "SetDissOptions",0 ;Sledgehammer_0
58 DCB "DissAddress",0 ;Sledgehammer_1
59 DCB "Disassemble",0 ;Sledgehammer_2
60 DCB "Assemble",0 ;Sledgehammer_3
61 DCB "Step",0 ;Sledgehammer_4
62 DCB "StepAddr",0 ;Sledgehammer_5
63 DCB "SetBP",0 ;Sledgehammer_6
64 DCB "RemoveBP",0 ;Sledgehammer_7
65 DCB "Translate",0 ;Sledgehammer_8
66 DCB "BreakPoint",0 ;Sledgehammer_9
72 CMP R11,#(%10-%00)/4 ;Is the SWI in range?
73 ADDCC PC,PC,R11,LSL #2 ;Yes -- dispatch it then
74 B %10quartz_swiCode ;Return an error if not
76 ; --- SWI dispatch table ---
78 00 B diss_setOptions ;Sledgehammer_SetDissOptions
79 B diss_address ;Sledgehammer_DissAddress
80 B diss_disassemble ;Sledgehammer_Disassemble
81 B asm_assemble ;Sledgehammer_Assemble
82 B armEmul ;Sledgehammer_Step
83 B ae_addr ;Sledgehammer_StepAddr
84 B brkpt_set ;Sledgehammer_BreakSet
85 B brkpt_remove ;Sledgehammer_Remove
86 B brkpt_translate ;Sledgehammer_Translate
87 B brkpt_hardBreak ;Sledgehammer_BreakPoint
89 ; --- Unknown SWI found ---
91 10 ADR R0,hammer__badSwi ;Point at the error block
92 ORRS PC,R14,#V_flag ;And return the error
94 hammer__badSwi DCD &1E6
95 DCB "Unknown Sledgehammer operation",0
99 ;---- Some standard routines ------------------------------------------------
101 ; --- hammer_confirm ---
103 ; On entry: R0 == pointer to confirmation message
105 ; On exit: C set to proceed with whatever it was you wanted to confirm
107 ; Use: Displays a message with a confirmation prompt and waits
108 ; for a response from the user.
110 EXPORT hammer_confirm
113 STMFD R13!,{R0-R2,R14} ;Save some registers
114 SWI XOS_Write0 ;Display caller's message
115 SWI XOS_WriteS ;And now display the prompt
118 MOV R0,#229 ;Set escape action
119 MOV R1,#1 ;Just generate key code
120 MOV R2,#0 ;Set the state
123 00 SWI XOS_ReadC ;Read a byte from the user
124 CMP R0,#13 ;Is it return?
125 CMPNE R0,#32 ;Or a space
126 MOVEQ R0,#'y' ;Yes -- take that as a yes
127 CMP R0,#27 ;Was it escape?
128 MOVEQ R0,#'n' ;Yes -- guess that's a no
129 ORR R0,R0,#&20 ;Make it lower case
130 CMP R0,#'y' ;Is it a yes?
131 CMPNE R0,#'n' ;Or a no, that'll do too
132 BNE %00hammer_confirm ;Neither -- try again then
134 SWI XOS_WriteI+' ' ;Put a space in nicely
135 SWI XOS_WriteC ;Display the response
136 SWI OS_NewLine ;And move to the next line
137 CMP R0,#'y' ;Was it a yes again?
139 MOV R0,#229 ;Set escape action
140 MOV R2,#0 ;Set the state
141 SWI XOS_Byte ;Restore the old action
143 LDMFD R13!,{R0-R2,R14} ;Restore the registers
144 ORREQS PC,R14,#C_flag ;If so, set C on exit
145 BICNES PC,R14,#C_flag ;Otherwise clear it
149 ; --- hammer_getStack ---
153 ; On exit R13 == pointer to the sledghammer stack
155 ; Use: Returns a pointer to the sledgehammer stack!
157 EXPORT hammer_getStack
160 LDR R13,hammer__wSpace ;Get workspace pointer
161 ADD R13,R13,#:INDEX: ws__stackBase
162 MOVS PC,R14 ;Return to caller
168 ;----- Workspace ------------------------------------------------------------
174 ws__stackTop # 1024 ;Just a 1K stack
175 ws__stackBase # 0 ;The top of the stack!
177 ws__size EQU {VAR}-ws__start ;The workspace size
179 AREA |Quartz$$Table|,CODE,READONLY
186 ;----- That's all folks -----------------------------------------------------