0

When writing an ARM assembly program one can use data type directives to initialise some values. For example, in the example below we are initializing a single float:

label: .single 0.0

However, when storage space is a matter, on the ARM platform one has a choice of using half sized floats. However, there does not appear to be a data type directive that allows one to initialise half sized floats from the assembly code.

What would be the easiest way to initialize a half precision float in an ARM assembly program?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Werdok
  • 181
  • 1
  • 9
  • 2
    Which assembler do you use? Did you have a look at the assembler manual? – fuz Dec 18 '20 at 13:00
  • GCC is the compiler. I ran a bunch of google searches to basically find out that there is no such data type directive, hence the question. – Werdok Dec 18 '20 at 13:19
  • 5
    Don't use Google, read [the manual](https://sourceware.org/binutils/docs/as/)! And [on this page](https://sourceware.org/binutils/docs/as/ARM-Directives.html#ARM-Directives), it says that the directive `.float16` can be used for this purpose. – fuz Dec 18 '20 at 13:24
  • @fuz: might as well post that as an answer, so future readers who do google will find it I guess. This is certainly borderline between "we don't need a question for every separate directive" vs. "obscure specific thing that SO is good for". – Peter Cordes Dec 19 '20 at 03:38
  • That directive did not work though @PeterCordes. I gave up and just moved onto using 32 bits, might try half floats at some other stage. Half precision floats certainly feel like second class citizens in the current state of computing science. – Werdok Dec 19 '20 at 12:57
  • 1
    Works for me with `arm-none-eabi-as` from Binutils 2.35.1. Probably your version is older. Yes, support for half-precision floats is usually much newer than single and double, probably that directive was only added recently. They're also a 2nd-class citizen in most hardware, e.g. x86 only has hardware support for packed conversion from/to float, not for actual computation on half-floats, so you can save memory bandwidth but not ALU throughput. (This may change with some upcoming AVX512 stuff, at least for brain-floats, BF16). – Peter Cordes Dec 19 '20 at 15:20

0 Answers0