You are reading a single comment by @fanoush and its replies.
Click here to read the full conversation.
-
Because JavaScript uses doubles you need to be able to convert to float and back.
This could be done before entering your inlineC code if float type was supported directly. And there is the Float32Array - this is part of javascript standard so javascript can already convert it for you to float type.
The top part of the diff is calling the function I pasted earlier (d2f), in the same compilation unit.
It gets the return value directly from S0.
The bottom part is calling libgcc's __aeabi_d2f, in a library. The difference is the
vmov s14, r0
, it loads a float value from an int register.Both used the exact same compilation flags.
Because JavaScript uses doubles you need to be able to convert to float and back.
Interesting, I didn't know about those. That's probably what's going on in the diff above. I'll do some more testing.
Edit: It seems d2f gets called with hardfp by default and adding
__attribute__((pcs("aapcs")))
it gets called by softfp (tested on the online EspruinoCompiler, not my own). Anyway, d2f can be called by either mode now since it returns the result in both R0 and S0.