int64 (long long) Division Problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

int64 (long long) Division Problem

1,528 Views
lpcware
NXP Employee
NXP Employee
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]
0 Kudos
Reply
3 Replies

1,178 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DaveR on Tue Dec 06 08:18:18 MST 2011
I tested the fix you provided and it resolved the issue. Thanks for your help. I'm very impressed by your quick response to my post and the speed at which you were able to provide a solution. Great job!
0 Kudos
Reply

1,178 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Sun Dec 04 06:25:48 MST 2011
There is indeed a problem here, which only affects the Redlib Cortex-M0 implementation of the AEABI  signed long long divide routine.

The attached ZIP file contains a fixed library archive. This will be incoporated into the next LPCXpresso 4 release - but I thought you might want to check it out now.

To install, extract the [FONT=Courier New][SIZE=2]libcr_eabihelpers.a[/SIZE][/FONT] file from the ZIP file and place it into the directory

[FONT=Courier New][SIZE=2]<install_dir>\lpcxpresso\Tools\lib\gcc\arm-none-eabi\4.5.1\armv6-m[/SIZE][/FONT]

[I would suggest backing up the original file first.]

Regards,
CodeRedSupport
0 Kudos
Reply

1,178 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Fri Dec 02 09:18:12 MST 2011
Thanks for the report. We'll check out your findings.

Regards,
CodeRedSupport
0 Kudos
Reply