Handling complex assembler expressions

Technical Note 28162

Arkitekturer:

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

Komponent:

assembler

Uppdaterad:

2020-05-12 10:01

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.

Det här innehållet finns tyvärr inte på svenska.

Vår webbplats finns främst på vårt koncernspråk engelska, förutom det innehåll för investerare som vi är lagstadgade att kommunicera på svenska. Vi rekommenderar att du besöker vår globala webbplats på engelska för att få en bättre upplevelse.

Vi stöder inte längre Internet Explorer. För att få bästa möjliga upplevelse av iar.com rekommenderar vi att du uppgraderar till en modern webbläsare som Chrome eller Edge.