s

Dependencies:   mbed

Committer:
aallaire3
Date:
Thu Jan 18 18:13:24 2018 +0000
Revision:
0:208fc50f22f9
shshss

Who changed what in which revision?

UserRevisionLine numberNew contents of line
aallaire3 0:208fc50f22f9 1 AREA asm_func, CODE, READONLY
aallaire3 0:208fc50f22f9 2 EXPORT my_asm
aallaire3 0:208fc50f22f9 3
aallaire3 0:208fc50f22f9 4 my_asm
aallaire3 0:208fc50f22f9 5
aallaire3 0:208fc50f22f9 6 LDR R1, =0x2009C000 // pushbutton at p8
aallaire3 0:208fc50f22f9 7 LDR R2, =0x2009C040 // led at p21
aallaire3 0:208fc50f22f9 8
aallaire3 0:208fc50f22f9 9 MOV.W R3, #0x000020   ; 0x000020 = 1<<5 all "0"s with a "1" in bit 5
aallaire3 0:208fc50f22f9 10 ; value passed from C compiler code is in R0 - compare to a "0" 
aallaire3 0:208fc50f22f9 11 CMP R1, #0          ; value == 0 ?
aallaire3 0:208fc50f22f9 12 ; (If-Then-Else) on next two instructions using equal cond from the zero flag
aallaire3 0:208fc50f22f9 13 ITE EQ
aallaire3 0:208fc50f22f9 14 ; STORE if EQ - clear led 1 port bit using GPIO FIOCLR register and mask
aallaire3 0:208fc50f22f9 15 STREQ R3, [R2,#0x5C]  ; if==0, clear LED1 bit
aallaire3 0:208fc50f22f9 16 ; STORE if NE - set led 1 port bit using GPIO FIOSET register and mask
aallaire3 0:208fc50f22f9 17   STRNE R3, [R1,#0x58]  ; if==1, set LED1 bit
aallaire3 0:208fc50f22f9 18 ; Return to C using link register (Branch indirect using LR - a return)
aallaire3 0:208fc50f22f9 19 BX LR
aallaire3 0:208fc50f22f9 20 END