Content originally posted in LPCWare by DaveR on Thu Dec 01 15:51:25 MST 2011
[FONT=Arial]I have the LPC1114 LPCXpresso board (OM11049) and the free Code Red LPCXpresso Eclipse (v4.1.0 Build 190) and found what appears to be a bug with 64-bit integer division ([FONT=Courier New]int64_t[/FONT], [FONT=Courier New]long long[/FONT]) for the Cortex-M0. GCC does a C code long long int division by calling the built-in AEABI helper function [FONT=Courier New]__aeabi_ldivmod[/FONT] which performs the division calculation. It does the calculation correctly but doesn't push/pop R6 and R7 which consequently corrupts the stack and scrambles the local variables. I found out, after a lot of searching, that you can write your own AEABI helper functions and link them in before the built-in ones as sort of a patch. This is done in LPCXpresso for LPC1200 projects when the "Enable use of RomDivide library by compiled code" option is selected. As far as I can tell, my fixed version of [FONT=Courier New]__aeabi_ldivmod[/FONT] works fine, but if anyone could confirm this I'd appreciate it. I'm new to LPCXpresso and ARM in general.
Please find attached an LPCXpresso project that demos the patch.
[/FONT]