[arm-gnu] Regarding Double Data Type Support on Cortex M4
Vikas R
vikasr at renuelectronics.com
Tue Jun 5 12:30:58 UTC 2012
Hello Carlos,
As per your suggestion we translated c code in to assembly. Here
are the findings :--
Our C Code :-
void double_test(void)
{
volatile double AA = 10.2;
volatile double BB = 10.2;
volatile double CC = 5.1;
if(AA == 10.2)
{
volatile int i;
i = 0;
}
BB = AA;
}
Equivalent ASM code generated by compiler is ;--
double_test():
d728: b510 push {r4, lr}
d72a: a30e add r3, pc, #56 ;(adr r3, d764
<double_test+0x3c>)
d72c: e9d3 2300 ldrd r2, r3, [r3]
d730: a10e add r1, pc, #56 ;(adr r1, d76c
<double_test+0x44>)
d732: e9d1 0100 ldrd r0, r1, [r1]
d736: b088 sub sp, #32
d738: e9cd 2304 strd r2, r3, [sp, #16]
d73c: e9cd 2302 strd r2, r3, [sp, #8]
d740: e9cd 0100 strd r0, r1, [sp]
d744: e9dd 0104 ldrd r0, r1, [sp, #16]
d748: 4c05 ldr r4, [pc, #20]; (d760
<double_test+0x38>)
d74a: 47a0 blx r4
d74c: b108 cbz r0, d752 <double_test+0x2a>
d74e: 2300 movs r3, #0
d750: 9307 str r3, [sp, #28]
d752: e9dd 2304 ldrd r2, r3, [sp, #16]
d756: e9cd 2302 strd r2, r3, [sp, #8]
d75a: b008 add sp, #32
d75c: bd10 pop {r4, pc}
d75e: bf00 nop
d760: 000334b4 .word 0x000334b4
d764: 66666666 .word 0x66666666
d768: 40246666 .word 0x40246666
d76c: 66666666 .word 0x66666666
d770: 40146666 .word 0x40146666
Also corresponding map file is attached with this mail.
Our Points :--
1) When variables AA,BB and CC are not defined as volatile, hard
fault does not occure, because compiler is optimizing the code.
2) Above code is generated by keeping FPU is enabled.
Thanks and Regards,
Vikas Raskar
-----Original Message-----
From: Carlos O'Donell [mailto:carlos_odonell at mentor.com]
Sent: 04/06/2012 8:53 PM
To: arm-gnu at codesourcery.com; vikasr at renuelectronics.com; Freddie Chopin
Subject: Re: [arm-gnu] Regarding Double Data Type Support on Cortex M4
On 6/4/2012 2:22 AM, Vikas R wrote:
> Hello Carlos,
> Thanks for your prompt reply.
>
> I made changes suggested by you (i.e. I added
`-mfpu=fpv4-sp-d16
> -mfloat-abi=softfp)option in command, but it is still not working.
Processor
> goes in to hard fault for the "double" data types.
>
> I have also tried following command for emulated "float" data
> type keeping FPU disabled but still not working.
>
> arm-none-eabi-gcc -Wall -mfpu=fpv4-sp-d16 -mfloat-abi=soft
> -mcpu=cortex-m4 -mthumb -Qn -Os -mlong-calls -c main.c -o main.o
>
> we are using Code Sourcery G++ Light Version 4.5.2.
>
> Is it possible to support "float" and "double" data types
without
> enabling FPU?
[including the public list this time around]
Yes, that's what -mfloat-abi=soft does.
If `-mfloat-abi=soft' doesn't work then something else is wrong with your
application.
Try using `arm-none-eabi-objdump -ldr <binary>' and review the instructions
being used in your final application.
When you debug this *exactly* which instruction causes the fault?
Cheers,
Carlos.
--
Carlos O'Donell
Mentor Graphics / CodeSourcery
carlos_odonell at mentor.com
carlos at codesourcery.com
+1 (613) 963 1026
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Map.txt
URL: <http://sourcerytools.com/pipermail/arm-gnu/attachments/20120605/3cf61f78/attachment.txt>
More information about the arm-gnu
mailing list