        AREA ThumbSub, CODE, READONLY   ; name this block of code
        ENTRY                           ; mark first instruction to execute
        CODE32                          ; Subsequent instructions are ARM 
header
        ADR     r0, start + 1           ; Processor starts in ARM state, 
        BX      r0                      ; so small ARM code header used 
                                    ; to call Thumb main program.

        NOP
        NOP

        CODE16                          ; Subsequent instructions are Thumb. 
start
        MOV     r0, #10                 ; Set up parameters
        MOV     r1, #3
        BL      doadd                   ; Call subroutine
	ADR	r0,stop			; Return to ARM state
	BX	r0
doadd
        ADD     r0, r0, r1              ; Subroutine code
        MOV     pc, lr                  ; Return from subroutine.

	CODE32
stop
        MOV     r0, #0x18               ; angel_SWIreason_ReportException
        LDR     r1, =0x20026            ; ADP_Stopped_ApplicationExit
        SWI     0xAB                    ; Angel semihosting Thumb SWI 

        END                             ; Mark end of file

