Handling complex assembler expressions
Technical Note 28162
ARM, RH850, RISC-V, RL78, RX, SH, STM8
5/12/2020 10:01 AM
This technical note describes how to handle complex assembler expressions that trigger one of these diagnostic messages:
Error: Expression is too complex Error: Expression is too complex
Note: The error message will point to a later line in the source. That is, the unsupported expression is somewhere above the line to which the error message points.
The Elf object format has this limitation:
An assembler expression can only refer to one symbol that is resolved when linking.
Therefore, it is not possible to use two symbols in an expression, if both these symbols are resolved when linking.
This example cannot be assembled, as there is one expression with two symbols to be resolved when linking.
Stack_Size EQU 0x00000800 ;; fixed value Stack_Mem DS8 Stack_Size Heap_Size EQU 0x00001000 ;; fixed value Heap_Mem DS8 Heap_Size set_up LDR R2, = (Heap_Mem + Stack_Mem)
Rewrite the source as several assembler statements:
set_up LDR R0, = Heap_Mem LDR R1, = Stack_Mem ADD R2,R0,R1
It is possible to write assembler expressions which are too complex to express in the ELF output format.
As a workaround, rewrite the assembler expression as several expressions.
All product names are trademarks or registered trademarks of their respective owners.