; ; hammer.s ; ; Main definitions for Sledgehammer (TMA & MDW) ; ; © 1994-1998 Straylight ; ;----- Licensing note ------------------------------------------------------- ; ; This file is part of Straylight's Sledgehammer debugger. ; ; Sledgehammer is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2, or (at your option) ; any later version. ; ; Sledgehammer is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with Sledgehammer. If not, write to the Free Software Foundation, ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ;----- Standard header ------------------------------------------------------ GET libs:header GET libs:swis ;----- External dependencies ------------------------------------------------ GET quartz:quartz GET sh.armEmul GET sh.asm GET sh.diss GET sh.brkpt IMPORT ae_addr ;----- Module information --------------------------------------------------- AREA |Hammer$$Code|,CODE,READONLY EXPORT quartz_name quartz_name DCB "Sledgehammer",0 ;----- SWI information ------------------------------------------------------ EXPORT quartz_swiChunk quartz_swiChunk EQU &4A380 EXPORT quartz_swiNames quartz_swiNames DCB "Sledgehammer",0 DCB "SetDissOptions",0 ;Sledgehammer_0 DCB "DissAddress",0 ;Sledgehammer_1 DCB "Disassemble",0 ;Sledgehammer_2 DCB "Assemble",0 ;Sledgehammer_3 DCB "Step",0 ;Sledgehammer_4 DCB "StepAddr",0 ;Sledgehammer_5 DCB "SetBP",0 ;Sledgehammer_6 DCB "RemoveBP",0 ;Sledgehammer_7 DCB "Translate",0 ;Sledgehammer_8 DCB "BreakPoint",0 ;Sledgehammer_9 DCB 0 EXPORT quartz_swiCode quartz_swiCode ROUT CMP R11,#(%10-%00)/4 ;Is the SWI in range? ADDCC PC,PC,R11,LSL #2 ;Yes -- dispatch it then B %10quartz_swiCode ;Return an error if not ; --- SWI dispatch table --- 00 B diss_setOptions ;Sledgehammer_SetDissOptions B diss_address ;Sledgehammer_DissAddress B diss_disassemble ;Sledgehammer_Disassemble B asm_assemble ;Sledgehammer_Assemble B armEmul ;Sledgehammer_Step B ae_addr ;Sledgehammer_StepAddr B brkpt_set ;Sledgehammer_BreakSet B brkpt_remove ;Sledgehammer_Remove B brkpt_translate ;Sledgehammer_Translate B brkpt_hardBreak ;Sledgehammer_BreakPoint ; --- Unknown SWI found --- 10 ADR R0,hammer__badSwi ;Point at the error block ORRS PC,R14,#V_flag ;And return the error hammer__badSwi DCD &1E6 DCB "Unknown Sledgehammer operation",0 LTORG ;---- Some standard routines ------------------------------------------------ ; --- hammer_confirm --- ; ; On entry: R0 == pointer to confirmation message ; ; On exit: C set to proceed with whatever it was you wanted to confirm ; ; Use: Displays a message with a confirmation prompt and waits ; for a response from the user. EXPORT hammer_confirm hammer_confirm ROUT STMFD R13!,{R0-R2,R14} ;Save some registers SWI XOS_Write0 ;Display caller's message SWI XOS_WriteS ;And now display the prompt DCB " [yn]",0 MOV R0,#229 ;Set escape action MOV R1,#1 ;Just generate key code MOV R2,#0 ;Set the state SWI XOS_Byte ;Do it 00 SWI XOS_ReadC ;Read a byte from the user CMP R0,#13 ;Is it return? CMPNE R0,#32 ;Or a space MOVEQ R0,#'y' ;Yes -- take that as a yes CMP R0,#27 ;Was it escape? MOVEQ R0,#'n' ;Yes -- guess that's a no ORR R0,R0,#&20 ;Make it lower case CMP R0,#'y' ;Is it a yes? CMPNE R0,#'n' ;Or a no, that'll do too BNE %00hammer_confirm ;Neither -- try again then SWI XOS_WriteI+' ' ;Put a space in nicely SWI XOS_WriteC ;Display the response SWI OS_NewLine ;And move to the next line CMP R0,#'y' ;Was it a yes again? MOV R0,#229 ;Set escape action MOV R2,#0 ;Set the state SWI XOS_Byte ;Restore the old action LDMFD R13!,{R0-R2,R14} ;Restore the registers ORREQS PC,R14,#C_flag ;If so, set C on exit BICNES PC,R14,#C_flag ;Otherwise clear it LTORG ; --- hammer_getStack --- ; ; On entry: -- ; ; On exit R13 == pointer to the sledghammer stack ; ; Use: Returns a pointer to the sledgehammer stack! EXPORT hammer_getStack hammer_getStack ROUT LDR R13,hammer__wSpace ;Get workspace pointer ADD R13,R13,#:INDEX: ws__stackBase MOVS PC,R14 ;Return to caller LTORG hammer__wSpace DCD 0 ;----- Workspace ------------------------------------------------------------ ^ 0,R12 ws__start # 0 ws__stackTop # 1024 ;Just a 1K stack ws__stackBase # 0 ;The top of the stack! ws__size EQU {VAR}-ws__start ;The workspace size AREA |Quartz$$Table|,CODE,READONLY DCD ws__size DCD hammer__wSpace DCD 0 DCD 0 ;----- That's all folks ----------------------------------------------------- END