Placing at absolute address in assembler source

Technical Note 17934

Arkitekturer:

ARM

Komponent:

assembler

Uppdaterad:

2020-05-07 15:19

Introduction

This technical note describes how to place an assembler symbol at an absolute memory address.

Discussion

You can place an assembler symbol at an absolute memory address in two ways:

With IAR Embedded Workbench for Arm version 7.40 (or later), placing assembler data using the ASEGN directive.

Placing a symbol, through a named section, when linking.

Placing assembler code requires these actions:

  • First, in assembler source code associate the code label with a named section.
  • Secondly, when linking, place that named section at an absolute memory address.

Example project for this technical note

TN_17934_test_project_IAR_Embedded_Workbench_for Arm_8_50_1.zip

Placing data using the ASEGN directive:

Use ASEGN to start a named absolute section placed at the memory address address. This can be used for both constant data and read/write data, as in this source example:

        ASEGN `.rodata`:CONST:NOROOT,08000H
        DATA
my_const:
        DC32 42

        ASEGN `.bss`:DATA:NOROOT,020008000H
        DATA
my_var:
        DS8 4

The result is that my_const is placed at 0x8000 and my_var is placed at 0x20008000.

Placing the symbol, through a named section, when linking:

Do these actions:

  • In the assembler source code: Associate the assembler symbol with a named section.
  • In the linker configuration (.icf) file: Place the named section at an absolute memory address.

In the following example, the symbol my_func is associated with the section .my_func_section.

        PUBLIC my_func

        SECTION .my_func_section:CODE:NOROOT(1)
        THUMB
my_func:
        MOV      R0,#+32768
        LDR      R0,[R0, #+0]
        BX       LR               ;; return
        REQUIRE my_const

By adding these lines in the linker configuration file, the named section will be placed (when linking) at the absolute memory address 0x00010000.

define symbol __MY_CODE__   = 0x00010000;
place at address mem:__MY_CODE__ { readonly section .my_func_section };
 

Conclusion

  • Absolute placement of data can be done with the ASEGN directive.
  • Absolute placement of code (can also be used for data) is performed in two steps.

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.