Electronic – not able to compile this assembly code

armassemblycortex-m4programmingstm32f4

When assembling the code, I get the error : fpu.s(13): error: A1240E: Immediate value cannot be used with this operation

AREA PGRM, CODE, READONLY
ENTRY
EXPORT __main
__main
    LDR R0,=0XE000ED88
    LDR R1,[R0]
    ORR R1,R1,#(0xF << 20)
    STR R1,[R0]
    dsb



    VMOV.F32 S7, #0x419c0000
    VMOV.F32 S8, #0X41B40000
    VADD.F32 S9,S7,S8

LOOP    B LOOP
    END

Best Answer

In VMOV, the F32 format expects the following argument as immediate value:

Any number that can be expressed as \$\pm n \times 2^{–r}\$, where n and r are integers, 16 <= n <= 31, 0 <= r <= 7.

You have the following immediate values:

$$ \text{0x}419C0000 = 4199\times2^{18} \\ n = 4199 \quad r = -18 $$ and $$ \text{0x}41B40000 = 4205\times2^{18} \\ n = 4205\quad r = -18 $$

In both instructions, the immediate values are clearly out of the expected range. You should scale these parameters beforehand.