Sam Vilmenay / Mbed 2 deprecated AssemblySort

Dependencies:   mbed

my_leds.s

Committer:
samvilm
Date:
2020-01-04
Revision:
2:968db132481b

File content as of revision 2:968db132481b:

   AREA asm_demo, CODE, READONLY
   EXPORT my_leds
my_leds
   PUSH    {R1, R2, R3, R4, LR}
   LDR R1, =0x2009C020 ; loading the base.
   AND R4, R0, #8 ;take biggest bit
   AND R3, R3, #0 
   ORR R3, R3, R4 ;put in R3
   LSL R3, R3, #1 ;shift for spacing for pins
   AND R4, R0, #6 ;take middle bits
   ORR R3, R3, R4 ;put in R3
   LSL R3, R3, #1 ;shift for spacing for pins
   AND R4, R0, #1 ;take first bit
   ORR R3, R3, R4 ;put in R3
   LSL R3, R3, #18 ;shift to pin location in hex
   STR R3, [R1, #0x18] ;turns on led with FIOSet
   
   BL      wait ; Call to wait
   STR R3, [R1, #0x1C] ;clears LED with FIOClear
   POP     {R1, R2, R3, R4, LR}
   BX      LR
   ALIGN   ; End of my_leds function
   
wait
   PUSH    {R1, R2}
   MOV.W R1, #1
   LDR R2, =5000000
           ; Omitted loop code goes here
loop_entry
        CMP R1, R2
        BGT loop_exit
        ADD R1,R1, #1
        B loop_entry
loop_exit
   POP     {R1, R2}
   BX      LR ; Return from wait
   ALIGN
   END