cancel
Showing results for 
Search instead for 
Did you mean: 

Floating Point instructions (assembly) do nothing

RMyer.1
Associate III

Hi All,

I cannot figure out why the series of instructions below is not working for me (device is a STM32F303x6).

This is just me fiddling around getting to know the CPU, I have this setting so the FP opcodes are accepted by the compiler, and it seems to be compiling what I do just fine.

.fpu fpv4-sp-d16

I have enabled the Floating Point Co-Processor as specified in the Cortex-M4 programmers manual (PM0214): Set bits 20-23 in CPACR.

But still the code below does nothing with the 's' registers.

movw          r4, #4096      // Put a test value into r4

vmov          s15, r4        // Copy r4 value into s15 Flt register for conversion to float

vcvt.f32.u32  s15, s15, #32  // Convert s15 'U32 value 4096' to f32 (result should be s15 = 0x45800000)

When I look at the s15 register values (in STM32CubeIDE) when debugging the code it never changes, the transfer of the value from r4 doesn't even seem to happen.

I can't see what I am doing wrong for the value to never be transferred in to the floating point register. Anyone traveled this road before? I'm hoping I just forgot to set something else up in the CPU.

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions

Try moving it back to a processor register, like R0 and return from a subroutine

This gets me 0x35800000 (0.000000954)

vcvt.f32.u32  s15, s15, #32

This gets me 0x45800000 (4096.0)

vcvt.f32.u32  s15, s15

Did this in Keil

fputest
		export fputest
          movw          r3, #4096      ; Put a test value into r4
          vmov          s15, r3        ; Copy r4 value into s15 Flt register for conversion to float
          vcvt.f32.u32  s15, s15 ;, #32  ; Convert s15 'U32 value 4096' to f32 (result should be s15 = 0x45800000)
          vmov   		r0, s15
          bx     		lr

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

2 REPLIES 2

Try moving it back to a processor register, like R0 and return from a subroutine

This gets me 0x35800000 (0.000000954)

vcvt.f32.u32  s15, s15, #32

This gets me 0x45800000 (4096.0)

vcvt.f32.u32  s15, s15

Did this in Keil

fputest
		export fputest
          movw          r3, #4096      ; Put a test value into r4
          vmov          s15, r3        ; Copy r4 value into s15 Flt register for conversion to float
          vcvt.f32.u32  s15, s15 ;, #32  ; Convert s15 'U32 value 4096' to f32 (result should be s15 = 0x45800000)
          vmov   		r0, s15
          bx     		lr

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thanks, that does the same for me as well (result ends up as 0x35800000 when I move it back out of the s15 register).

As I stepped through the code I never saw the s15 register change though, maybe that is just how it is.

But thanks, at least I know now if I want to 'see' the result on screen I can just vmov the result out to a normal register.