SLAU131Y October 2004 – June 2021
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 the .data section. *
3 ********************************************
4 0000 .data
5 0000 000A .byte 0Ah, 0Bh
0001 000B
6 0002 0011 coeff .word 011h,0x22,0x33
0004 0022
0006 0033
7
8 ********************************************
9 * Begin assembling into the .text section. *
10 ********************************************
11 0000 .text
12 0000 0041 START: .string "A", "B", "C"
0001 0042
0002 0043
13 0003 0058 $END: .string "X", "Y", "Z"
0004 0059
0005 005A
14 0006 403A MOV.W #0x1234,R10
0008 1234
15 000a 521A ADD.W &coeff+1,R10
000c 0003!
16
17 ********************************************
18 * Resume assembling into .data section. *
19 ********************************************
20 0008 .data
21 0008 000C .byte 0Ch, 0Dh
0009 000D
22
23 ********************************************
24 * Resume assembling into .text section. *
25 ********************************************
26 000e .text
27 000e 0051 .string "QUIT"
000f 0055
0010 0049
0011 0054