2
\$\begingroup\$

After reading ARM Compiler version 5's manual, it says that for devices without a floating point unit, floats are dealt with through software implementations, which is likely going to be slower than having a hardware unit.

However, I couldn't find any information on how the ARM Compiler 5 would deal with double precision floats on devices with single-precision FPUs. My assumption would be that it would also use a software implementation as if the FPU didn't exist, but in my code, I tried looking at the disassembly, and it appears that the FPU-specific instructions are being used!

For example,

   696:         spectral_line[2] = 6869.955;     /* B */ 
0x0800250A ED9F0B81  VLDR          d0,[pc,#0x204]
0x0800250E ED800B04  VSTR          d0,[r0,#0x10]

this above assembly code segment was generated by the ARM 5 compiler, even though spectral_line is an array of doubles!

How/what is the compiler doing here to handle the double-precision numbers?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I don't know about the ARM specifically but many processors use a "trap" or software interrupt to handle unimplemented instructions. When the processor sees an instruction that is not implemented, it runs an interrupt service routine which figures out what instruction was attempted and then provides a software emulation of that function. From the application perspective it looks like the unimplemented instruction just ran really slowly. \$\endgroup\$ Mar 22, 2018 at 14:03
  • \$\begingroup\$ It depends on your compiler options: embeddedartistry.com/blog/2017/10/9/… \$\endgroup\$
    – pjc50
    Mar 22, 2018 at 14:03

1 Answer 1

4
\$\begingroup\$

and it appears that the FPU-specific instructions are being used!

That is indeed correct. You have both load and store instructions available on the single precisition FPUs, but none of the actual calculation instructions.

Note that this may make some software calculations using double slower, as function arguments will reside in the FPU but must be transferred back to CPU registers in order to actually use them.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.