![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
s
Revision 0:208fc50f22f9, committed 2018-01-18
- Comitter:
- aallaire3
- Date:
- Thu Jan 18 18:13:24 2018 +0000
- Commit message:
- shshss
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jan 18 18:13:24 2018 +0000 @@ -0,0 +1,10 @@ +#include "mbed.h" + +extern "C" int my_asm(); + +int main() { + + while(1) { + my_asm(); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Jan 18 18:13:24 2018 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/64910690c574 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/my_asm.s Thu Jan 18 18:13:24 2018 +0000 @@ -0,0 +1,20 @@ + AREA asm_func, CODE, READONLY + EXPORT my_asm + +my_asm + + LDR R1, =0x2009C000 // pushbutton at p8 + LDR R2, =0x2009C040 // led at p21 + + MOV.W R3, #0x000020 ; 0x000020 = 1<<5 all "0"s with a "1" in bit 5 +; value passed from C compiler code is in R0 - compare to a "0" + CMP R1, #0 ; value == 0 ? +; (If-Then-Else) on next two instructions using equal cond from the zero flag + ITE EQ +; STORE if EQ - clear led 1 port bit using GPIO FIOCLR register and mask + STREQ R3, [R2,#0x5C] ; if==0, clear LED1 bit +; STORE if NE - set led 1 port bit using GPIO FIOSET register and mask + STRNE R3, [R1,#0x58] ; if==1, set LED1 bit +; Return to C using link register (Branch indirect using LR - a return) + BX LR + END \ No newline at end of file