SPRU513Y August 2001 – June 2022 SM320F28335-EP
Initialize Field
.fieldvalue[, size in bits]
The .field directive initializes a multiple-bit field within a single word (16 bits) of memory. This directive has two operands:
*** WARNING! line 21: W0001: Field value truncated to 1
.field 3, 1
Successive .field directives pack values into the specified number of bits starting at the current word. Fields are packed starting at the least significant part of the word, moving toward the most significant part as more fields are added. If the assembler encounters a field size that does not fit into the current word, it writes out the word, increments the SPC, and begins packing fields into the next word. You can use the .align directive with an operand of 1 to force the next .field directive to begin packing into a new word.
The .field directive is similar to the .bits directive (see the .bits topic). However, the .bits directive does not force alignment to a field boundary and does not automatically increment the SPC when a word boundary is reached.
Use the .align directive to force the next .field directive to begin packing a new word.
If you use a label, it points to the word that contains the specified field.
When you use .field in a .struct/.endstruct sequence, .field defines a member's size; it does not initialize memory. For more information, see the .struct/.endstruct/.tag topic.
This example shows how fields are packed into a word. The SPC does not change until a word is filled and the next word is begun.
1 ************************************
2 ** Initialize a 14-bit field. **
3 ************************************
4 000000 0ABC .field 0ABCh, 14
5
6 ************************************************
7 ** Initialize a 5-bit field in a new word. **
8 ************************************************
9 000001 000A L_F: .field 0Ah, 5
10
11 ************************************************
12 ** Initialize a 4-bit field in the same word. **
13 ************************************************
14 000001 018A X: .field 0Ch, 4
15 ************************************************
16 ** Relocatable field in the next 2 words. **
17 ************************************************
18 000002 0001' .field X
19 ************************************
20 ** Initialize a 32-bit field **
21 ************************************
22 000003 4321 .field 04321h, 32
000004 0000
Figure 6-5 shows how the directives in this example affect memory.