Express floating point constant from EQU symbolic name

490 Views Asked by At

I'm programming in ARM assembly in DS-5 5.28, targetting cortex-a8 with floating point and Neon.

When expressing constants with EQU, like

M EQU 5

then I can use the constant in the rest of the program, in particular when allocating constants in data memory like e.g:

mydata  DCD  M

Now, if I want to allocate a floating point constant as 32-bit binary, I can do:

myfloat  DCFS  5

or indifferently:

myfloat  DCFS  5.0

But the following gives syntax error:

myfloat  DCFS  M

I've tried all sort of tricks like DCFS (M+0.0) or M EQU 5.0, but nothing is accepted by the assembler, and I can't find directives to cast constants, and not even an Arm forum that seems suitable. Nor I'd like to hard-code constants (that may change) more than once in the code.

EDIT 1

I've tried with macros, same error (A1194E: Bad floating-point number):

    MACRO
$label  FP_CONSTANT  $value
$label  DCFS    $value
    MEND

; use:
myfloat  FP_CONSTANT  M

I would like to check if I wrote it correctly by disassembling the result, but compilation fails so there's no object to disassemble.

1

There are 1 best solutions below

4
fuz On

The EQU directive defines a symbol to take a specific value. Symbol values are addresses which are in turn integers. You can't give a symbol a floating point number as a value.

As an alternative, read the manual of your assembler. Most assemblers have the capability to define macros which should allow you to give a symbolic name to a floating point constant by defining it as a macro.