SPRUI03E June 2015 – January 2023
Reserve Uninitialized Space
symbol .usect "section name", size in bytes[, alignment[, bank offset] ]
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 .text section **
3 ***************************************************
4 00000000 .text
5 00000000 008001A0 MV A0,A1
6
7 ***************************************************
8 ** Reserve 2 bytes in var1. **
9 ***************************************************
10 00000000 ptr .usect "var1",2
11 00000004 0100004C- LDH *+B14(ptr),A2 ; still in .text
12
13 ***************************************************
14 ** Reserve 100 bytes in var1 **
15 ***************************************************
16 00000002 array .usect "var1",100
17 00000008 01800128- MVK array,A3 ; still in .text
18 0000000c 01800068- MVKH array,A3
19
20 ***************************************************
21 ** Reserve 50 bytes in var1 **
22 ***************************************************
23 00000066 dflag .usect "var1",50
24 00000010 02003328- MVK dflag,A4
25 00000014 02000068- MVKH dflag,A4
26
27 ***************************************************
28 ** Reserve 100 bytes in var1 **
29 ***************************************************
30 00000000 vec .usect "var2",100
31 00000018 0000002A- MVK vec,B0 ; still in .text
32 0000001c 0000006A- MVKH vec,B0