| |||||||||||||
Technical Support On-Line Manuals RealView Compiler User's Guide | Support for floating-point operations
The ARM processor core does not contain floating-point hardware. Floating-point arithmetic must be supported separately, either:
The differences between software and hardware support for floating-point arithmetic are illustrated with Example 4.1, which shows a function implementing floating-point arithmetic operations in C. Example 4.1. Floating-point operations
float foo(float num1, float num2)
{
float temp, temp2;
temp = num1 + num2;
temp2 = num2 * num2;
return temp2-temp;
}
When the C code of Example 4.1 is compiled with the command-line option Example 4.2. Support for floating-point operations in software
||foo|| PROC
PUSH {r4-r6, lr}
MOV r4, r1
BL __aeabi_fadd
MOV r5, r0
MOV r1, r4
MOV r0, r4
BL __aeabi_fmul
MOV r1, r5
POP {r4-r6, lr}
B __aeabi_fsub
ENDP
When the C code of Example 4.1 is compiled with the command-line option Example 4.3. Support for floating-point operations in hardware ||foo|| PROC VADD.F32 s2, s0, s1 VMUL.F32 s0, s1, s1 VSUB.F32 s0, s0, s2 BX lr ENDP In practice, code that makes use of hardware support for floating-point arithmetic is more compact and offers better performance than code that performs floating-point arithmetic in software. However, hardware support for floating-point arithmetic requires a VFP coprocessor. The default option is to support floating-point arithmetic using the software floating-point library | ||||||||||||
| |||||||||||||