SPRUI03E June 2015 – January 2023
Assemble Into the .text Section
.text
The .text sets .text as the current section. Lines that follow this directive will be assembled into the .text section, which usually contains executable code. The section program counter is set to 0 if nothing has yet been assembled into the .text section. If code has already been assembled into the .text section, the section program counter is restored to its previous value in the section.
The .text section is the default section. Therefore, at the beginning of an assembly, the assembler assembles code into the .text section unless you use a .data or .sect directive to specify a different section.
For more information about sections, see Chapter 3.
This example assembles code into the .text and .data sections.
1 ******************************************
2 ** Begin assembling into .data section. **
3 ******************************************
4 00000000 .data
5 00000000 00000005 .byte 5,6
00000001 00000006
6
7 ******************************************
8 ** Begin assembling into .text section. **
9 ******************************************
10 00000000 .text
11 00000000 00000001 .byte 1
12 00000001 00000002 .byte 2,3
00000002 00000003
13
14 ******************************************
15 ** Resume assembling into .data section.**
16 ******************************************
17 00000002 .data
18 00000002 00000007 .byte 7,8
00000003 00000008
19
20 ******************************************
21 ** Resume assembling into .text section.**
22 ******************************************
23 00000003 .text
24 00000003 00000004 .byte 4