AREA reg_dump,CODE,READONLY SWI_ANGEL EQU 0x123456 ;SWI number for Angel semihosting MACRO $l Exit ;Angel SWI call to terminate execution $l MOV r0, #0x18 ;select Angel SWIreason_ReportException(0x18) LDR r1, =0x20026 ;report ADP_Stopped_ApplicationExit SWI SWI_ANGEL ;ARM semihosting SWI MEND MACRO $l WriteC ;Angel SWI call to output character in [r1] $l MOV r0, #0x3 ;select Angel SYS_WRITEC function SWI SWI_ANGEL MEND ENTRY ;code entry point MOV r0, #0 MOV r1, #1 MOV r2, #2 MOV r3, #3 MOV r4, #4 MOV r5, #5 MOV r6, #6 MOV r7, #7 MOV r8, #8 MOV r9, #9 MOV r10, #10 MOV r11, #11 MOV r12, #12 MOV r13, #13 MOV r14, #14 BL RegDump Exit ;finish RegDump STR r14, r14tmp ADR r14, RegStore STMIA r14!, {r0-r13} LDR r12, r14tmp STR r12, [r14] ADR r12, RegStore MOV r4, #14 ;loop count NxtReg RSB r3, r4, #14 CMP r3, #9 ;0-9 or A-F ADDGT r0, r3, #"A"-10 ;ASCII alphabetic ADDLE r0, r3, #"0" ;ASCII numeric STRB r0, RegTxt+1 ;store character to print BL TextOut RegTxt = "rX = ",0 ALIGN LDR r2, [r12, r3,lsl #2] BL HexOut BL TextOut = &0a, &0d, 0 SUBS r4, r4, #1 BGE NxtReg ADR r14, RegStore LDMIA r14, {r0-r13,r15} r14tmp DCD 0 RegStore % 68 RegEnd CHAROUT DCD 0 HexOut ;output contents of register 2 MOV r3, #8 ;nibble count = 8 ADR r1, CHAROUT LOOP MOV r0, r2, LSR #28 ;get top nibble CMP r0, #9 ;0-9 or A-F ADDGT r0, r0, #"A"-10 ;ASCII alphabetic ADDLE r0, r0, #"0" ;ASCI numeric STR r0, [r1] ;store character to print WriteC ;print character MOV r2, r2, LSL #4 ;shift left one nibble SUBS r3, r3, #1 ;decrement nibble count BNE LOOP ;if more do next nibble MOV pc, r14 ;return TextOut ;output string starting at [r14] MOV r0, #0x3 ;select Angel SYS_WRITEC function NxtTxt LDRB r1, [r14], #1 ;get next character CMP r1, #0 ;test for end mark SUBNE r1, r14, #1 ;setup r1 for call to SWI SWINE SWI_ANGEL ;if not end, print.. BNE NxtTxt ; ..and loop ADD r14, r14, #3 ;pass next word boundary BIC r14, r14, #3 ;round back to boundary MOV pc, r14 ;return END