For the curious, here's a short howto:
1) Create or upload an assembly file making sure the file extension is .s
2) Online compiler uses RVCT so you need to use ARM syntax. For example:
AREA |.text|, CODE, READONLY
EXPORT my_func
my_func
ADD R0, R1
BX LR
3) In C code, use extern "C" to link to your function:
extern "C" int my_func(int x, int y);
4) If you need to distinguish between two mbed models (ARM7 vs Cortex-M3), you can use the compiler define:
IF :DEF:TARGET_LPC1768
; can use Thumb2 here
ELSE
; only ARMv4[T] instructions allowed
ENDIF
For an example, see my FFT Port: FFT.
Note that if you need to use just a couple of instructions, it's much better to use an intrinsic (if available) or a piece of inline assembly.
For the curious, here's a short howto:
1) Create or upload an assembly file making sure the file extension is .s
2) Online compiler uses RVCT so you need to use ARM syntax. For example:
3) In C code, use extern "C" to link to your function:
extern "C" int my_func(int x, int y);
4) If you need to distinguish between two mbed models (ARM7 vs Cortex-M3), you can use the compiler define:
For an example, see my FFT Port: FFT.
Note that if you need to use just a couple of instructions, it's much better to use an intrinsic (if available) or a piece of inline assembly.