skyfex / zig-nrf-demo

Demonstrate Zig code on the nRF51/nRF52 microcontrollers
53 stars 4 forks source link

hard/soft float #2

Open andrewrk opened 6 years ago

andrewrk commented 6 years ago

this project uses --target-arch thumb. Before now it was my understanding that for each architecture target, such as thumb, it is known whether or not it has hardware float support. Are there multiple versions of thumb, some that have hardware float support, and some that do not?

skyfex commented 6 years ago

Yes, floating-point on ARM is essentially an extension that you can include or exclude when designing an SoC. Although for every architecture there is a default.

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491e/CIHCJIFE.html

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0472j/chr1359124231926.html

In GCC you would specify it like this: "-mfloat-abi=hard -mfpu=fpv4-sp-d16" or " -mfloat-abi=soft"

Another thing to be aware of with ARM is that "thumb" is not really a separate architecture, but a mode. Thumb is a compressed version of the instruction set. In GCC you can select wether to use thumb or the full instruction set from file to file, or even function to function.