SPRU513Z August 2001 – October 2023 SM320F28335-EP
Assemble Into Named Section
.sect "section name "
.sect " section name " [,{RO|RW}] [,{ALLOC|NOALLOC}]
The .sect directive defines a named section that can be used like the default .text and .data sections. The .sect directive sets section name to be the current section; the lines that follow are assembled into the section name section.
The section name identifies the section. The section name must be enclosed in double quotes. A section name can contain a subsection name in the form section name :subsection name. See Chapter 2 for more information about sections.
If you are using EABI, the sections can be marked read-only (RO) or read-write (RW). Also, the sections can be marked for allocation (ALLOC) or no allocation (NOALLOC). These attributes can be specified in any order, but only one attribute from each set can be selected. RO conflicts with RW, and ALLOC conflicts with NOALLOC. If conflicting attributes are specified the assembler generates an error, for example:
"t.asm", ERROR! at line 1:[E0000] Attribute RO cannot be combined with attr RW
.sect "illegal_sect",RO,RW
This example defines two special-purpose sections, Sym_Defs and Vars, and assembles code into them.
1 ** Begin assembling into .text section. **
2 000000 .text
3 000000 FF20 MOV ACC, #78h ; Assembled into .text
000001 0078
4 000002 0936 ADD ACC, #36h ; Assembled into .text
5
6 ** Begin assembling into Sym_Defs section. **
7 000000 .sect "Sym_Defs"
8 000000 CCCD .float 0. ; Assembled into Sym_Defs
000001 3D4C
9 000002 00AA X: .word 0AAh ; Assembled into Sym_Defs
10 000003 FF10 ADD ACC, #X ; Assembled into Sym_Defs
000004 0002+
11
12 ** Begin assembling into Vars section. **
13 000000 .sect "Vars"
14 0010 WORD_LEN .set 16
15 0020 DWORD_LEN .set WORD_LEN * 2
16 0008 BYTE_LEN .set WORD_LEN / 2
17 0053 STR .set 53h
18
19 ** Resume assembling into .text section. **
20 000003 .text
21 000003 0942 ADD ACC, #42h ; Assembled into .text
22 000004 0003 .byte 3, 4 ; Assembled into .text
000005 0004
23
24 ** Resume assembling into Vars section. **
25 000000 .sect "Vars"
26 000000 000D .field 13, WORD_LEN
27 000001 000A .field 0Ah, BYTE_LEN
28 000002 0008 .field 10q, DWORD_LEN
000003 0000
29