11.2 Locating Objects at a Specific Address
In this example, the C language array
buf1
is located at a specific address in data memory. The address of buf1
can be confirmed by executing the program in the
simulator, or by examining the link
map.#include <stdio.h>
int __attribute__((address(0xa0000200))) buf1[128];
The equivalent array definition in assembly language appears below. The
.align
directive is optional and represents the
default alignment in data memory. Use of *
as a section
name causes the assembler to generate a unique name based on the source file
name..globl buf1
.section *,address(0xa0000200),bss
.align 2
.type buf1, @object
.size buf1, 512
buf1:
.space 512