jim hamblen
/
C_to_asm
An example calling assembly from C. Assembly source is in a *.s file
Diff: main.cpp
- Revision:
- 0:ef242c5b2981
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Sep 29 02:44:55 2010 +0000 @@ -0,0 +1,23 @@ +#include "mbed.h" +// This progam will blink LED1 and LED4 +// using assembly language for LED1 and +// API functions for LED4 +// declare external assembly language function (in a *.s file) +extern "C" int my_asm(int value); +// declare LED outputs +DigitalOut myled1(LED1); +DigitalOut myled4(LED4); + +int main() { + int value = 0; + // loop forever + while(1) { + //call assembly language function to control LED1 + my_asm(value); + //API function to control LED4 + myled4 = value; + // flip value and wait + value = ~ value; + wait(0.2); + } +}