fork download
  1. ; Area Definition and Entry Point
  2. AREA Reset, CODE, READONLY
  3. ENTRY
  4.  
  5. ; Exception Vectors
  6. Vectors
  7. LDR PC, Reset_Addr
  8. LDR PC, SWI_Addr
  9.  
  10. Reset_Addr DCD Reset_Handler
  11. SWI_Addr DCD SWI_Handler
  12.  
  13. ; Reset Handler
  14. Reset_Handler
  15. MSR CPSR_C, #0x10 ; Set User mode (unprivileged mode)
  16. LDR R1, =65090 ; Last 5 digits of BITS ID (65090)
  17. LDR R2, =65090 ; Last 5 digits of BITS ID (65090)
  18. SWI 0x090 ; SWI number in hexadecimal (090 in decimal)
  19.  
  20. STOP
  21. B STOP
  22.  
  23. ; SWI Handler
  24. SWI_Handler
  25. LDR SP, =0x40000100 ; Initialize stack pointer
  26. STMFD SP!, {R1-R2} ; Push parameters R1 and R2 to the stack
  27.  
  28. ; Retrieve parameters from the stack
  29. LDMFD SP!, {R1-R2} ; Pop parameters from stack into R1 and R2
  30.  
  31. ADD R3, R1, R2 ; Add values in R1 and R2, store result in R3
  32.  
  33. MOVS PC, LR ; Return from SWI, restoring the state
  34.  
  35. STOP1
  36. B STOP1
  37.  
  38.  
Success #stdin #stdout 0.03s 25864KB
stdin
Standard input is empty
stdout
; 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