Loading a Real Constant
Writing code to load a floating-point or fixed-point real constant can be
challenging.
There are a couple of different ways to load a floating-point constant
into a register, but the best method depends on the value of the constant.
The
VMOV
instruction is the most efficient method, but only works for a
very specific set of values. A floating-point 0.0 is most easily created
using
VSUB.F32
to subtract a register from itself. All other values
require creating the constant in memory using a .float directive, and then
loading the constant into a register using the
VLDR
instruction.
Fixed-point reals are represented using integer data types, so loading
a fixed-point constant is no more difficult than loading an integer
constant. However, the challenge is determining the corresponding integer
value to use.
(Click anywhere to remove this message.)