SLAU131Y October 2004 – June 2021
Reserve Uninitialized Space
symbol .usect "section name", size in bytes[, 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 byte reserved in the var1 section. The symbol array points to the first byte in a block of 100 bytes reserved in var1, and dflag points to the first byte in a block of 50 bytes in var1. The symbol vec points to the first byte reserved in the var2 section.
Figure 6-8 shows how this example reserves space in two uninitialized sections, var1 and var2.
1 ******************************************************
2 ** Assemble into the .text section. **
3 ******************************************************
4 0000 .text
5 0000 403B MOV #0x3,R11
0002 0003
6
7 ******************************************************
8 ** Reserve 2 bytes in the var1 section. **
9 ******************************************************
10 0000 ptr .usect "var1",2
11
12 ******************************************************
13 ** Reserve 100 bytes in the var1 section. **
14 ******************************************************
15 0002 array .usect "var1",100
16
17 0004 503B ADD #37,R11
0006 0025
18
19 ******************************************************
20 ** Reserve 50 bytes in the var1 section. **
21 ******************************************************
22 0066 dflag .usect "var1",50
23
24 0008 503C ADD #dflag-array,R12
000a 0064
25
26 ******************************************************
27 ** Reserve 100 bytes in the var2 section. **
28 ******************************************************
29 0000 vec .usect "var2",100
30
31 000c 5C0B ADD R12,R11
32
33 ******************************************************
34 ** Declare a .usect symbol to be external. **
35 ******************************************************
36 .global array