2020-03-23 02:36 AM
Hi,
I want to use a double precision input parameter for an inline assembler function, for example
int32_t Double2Long(double a) {
int32_t c;
asm (
" vcvtr.s32.f64 s0,%[in] \n\t"
" vmov %[out],s0 \n\t"
: [out] "=r" (c) /* output */
: [in] "w" (a) /* Input */
: "s0" /* clobber */
);
return c;
}
Contraint "w" does not work, the assembler uses s14 instead of a double precision register (Error: invalid instruction shape -- `vcvtr.s32.f64 s0,s14'). "d" as constraint is not accepted, so I checked all letters from a to z and A to Z. Nothing works, the assembler either uses rn or sn or [sp] or says "impossible constraint" . Does anyone know how to do it?
Best regards
Hartmut
2020-03-23 08:50 AM
The magic incantation is
vcvtr.s32.f64 s0,%P[in]
//note the P here ^
Godbolt has some trouble compiling it except with gcc 5.4 https://godbolt.org/z/q5vW8F
but it works on my PC e.g. with gcc-arm-none-eabi-8-2018-q4-major too.
Source of the secrets: https://hardwarebug.org/2010/07/06/arm-inline-asm-secrets/
2020-03-23 09:13 AM
Thanks a lot, that works. I was always looking for the right constraint and did not think that it could be coded as an operand code...