Handling complex assembler expressions

Technical Note 28162

Targets:
ARM, RH850, RISC-V, RL78, RX, SH, STM8

Component:
Assembler

Updated:
5/12/2020 7:52 AM

Introduction

This technical note describes how to handle complex assembler expressions that trigger one of these diagnostic messages:

Error[472]: Expression is too complex
Error[109]: 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.

Discussion

Background

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.

Example

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)

Suggestion

Rewrite the source as several assembler statements:

set_up
LDR R0, = Heap_Mem
LDR R1, = Stack_Mem
ADD R2,R0,R1

Conclusion

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.

RELATED TECH NOTES

© IAR Systems 1995-2020 - All rights reserved.

We use cookies on this website to provide you with a better experience. You need to accept cookies to continue using this site. Cookies