; Area Definition and Entry Point
AREA Reset, CODE, READONLY
ENTRY
; Exception Vectors
Vectors
LDR PC, Reset_Addr
LDR PC, SWI_Addr
Reset_Addr DCD Reset_Handler
SWI_Addr DCD SWI_Handler
; Reset Handler
Reset_Handler
MSR CPSR_C, #0x10 ; Set User mode (unprivileged mode)
LDR R1, =65090 ; Last 5 digits of BITS ID (65090)
LDR R2, =65090 ; Last 5 digits of BITS ID (65090)
SWI 0x090 ; SWI number in hexadecimal (090 in decimal)
STOP
B STOP
; SWI Handler
SWI_Handler
LDR SP, =0x40000100 ; Initialize stack pointer
STMFD SP!, {R1-R2} ; Push parameters R1 and R2 to the stack
; Retrieve parameters from the stack
LDMFD SP!, {R1-R2} ; Pop parameters from stack into R1 and R2
ADD R3, R1, R2 ; Add values in R1 and R2, store result in R3
MOVS PC, LR ; Return from SWI, restoring the state
STOP1
B STOP1
END