SPRU513Y August 2001 – June 2022 SM320F28335-EP
Reserve Uninitialized Space
symbol .usect "section name", size in words[, blocking flag[, alignment] ]
The .usect directive reserves space for variables in an uninitialized, named section. This directive is similar to the .bss directive (see .bss topic); both simply reserve space for data and that space has no contents. However, .usect defines additional sections that can be placed anywhere in memory, independently of the .bss section.
Initialized sections directives (.text, .data, and .sect) tell the assembler to pause assembling into the current section and begin assembling into another section. A .usect or .bss directive encountered in the current section is simply assembled, and assembly continues in the current section.
Variables that can be located contiguously in memory can be defined in the same specified section; to do so, repeat the .usect directive with the same section name and the subsequent symbol (variable name).
For more information about sections, see Chapter 3.
This example uses the .usect directive to define two uninitialized, named sections, var1 and var2. The symbol ptr points to the first word reserved in the var1 section. The symbol array points to the first word in a block of 100 words reserved in var1, and dflag points to the first word in a block of 50 words in var1. The symbol vec points to the first word reserved in the var2 section.
Figure 6-7 shows how this example reserves space in two uninitialized sections, var1 and var2.
1 *******************************************
2 ** Assemble into .text section. **
3 *******************************************
4 000000 .text
5 000000 9A03 MOV AL, #03h
6
7 *******************************************
8 ** Reserve 1 word in var1. **
9 *******************************************
10 000000 ptr .usect "var1", 1
11
12 *******************************************
13 ** Reserve 100 words in var1. **
14 *******************************************
15 000001 array .usect "var1", 100
16
17 000001 9C03 ADD AL, #03h ; Still in .text
18
19 *******************************************
20 ** Reserve 50 words in var1. **
21 *******************************************
22 000065 dflag .usect "var1", 50
23
24 000002 08A9 ADD AL, #dflag ; Still in .text
000003 0065-
25
26 *******************************************
27 ** Reserve 100 words in var2. **
28 *******************************************
29 000000 vec .usect "var2", 100
30
31 000004 08A9 ADD AL, #vec ; Still in .text
000005 0000-
32
33 *******************************************
34 ** Declare an external .usect symbol **
35 *******************************************
36 .global array