Several directives assemble values for the
current section. For example:
- The .byte and .char
directives place one or more 8-bit values into consecutive 16-bit words of the current section. These
directives are similar to .word, .int, and .long, except that the width of each value is
restricted to 8 bits.
- The .field and .bits
directives place a single value into a specified number of bits in the current word. With
.field, you can pack multiple fields into a single word; the assembler does not increment
the SPC until a word is filled. If a field will not fit in the space remaining in the
current word, .field will insert zeros to fill the current word and then place the field
in the next word. The .bits directive is similar but does not force alignment to a field
boundary. See the .field topic and .bits topic.
Figure 5-1 shows how fields are packed into a word. Using the following assembled code, notice
that the SPC does not change
(the fields are packed
into the same
word):
1 000000 0003 .field 3, 3
2 000000 0008 .field 8, 6
3 000000 0010 .field 16, 5
- The
.float and .xfloat directives calculate the single-precision (32-bit) IEEE
floating-point representation of a single floating-point value and store it in a word in
the current section that is aligned to a word boundary.
- The
.int and .word directives place one or more 16-bit values into consecutive
16-bit fields (words) in the current section. The .int and .word directives automatically
align to a word boundary.
- The
.long and .xlong directives place one or more 32-bit values into
consecutive 32-bit fields (words) in the current section. The .long directive
automatically aligns to a word boundary.
- The .xldouble directive calculates
the double-precision (64-bit) IEEE floating-point representation of a double
floating-point value and stores it into consecutive 32-bit fields (words) in the current
section that is aligned to a word boundary. Note that the .double directive is not
a synonym and is not recommended.
- The .string
, .cstring, and .pstring
directives place 8-bit characters from one or more character strings into the current
section. The .string and .cstring directives are similar to .byte, placing an 8-bit
character in each consecutive 16-bit
word of the current section. The .cstring directive adds a NUL character needed by
C; the .string directive does not add a NUL character. With the .pstring directive, the data is packed so that each word contains two 8-bit
bytes.
- The .ubyte, .uchar,
.uint, .ulong, and .uword directives are provided as unsigned versions
of their respective signed directives. These directives are used primarily by the C/C++
compiler to support unsigned types in C/C++.
Note:
Directives that Initialize Constants When Used in a .struct/.endstruct Sequence: The
.bits, .byte, .char, .int, .long,
.word, .ubyte, .uchar, .uint, .ulong, .uword, .string, .pstring, .float, .xfloat,
.xldouble, and .field directives do not
initialize memory when they are part of a .struct/ .endstruct sequence; rather, they define
a member’s size. For more information, see the
.struct/.endstruct directives.
Figure 5-2 compares the .byte, .word, .long, and .string directives using the
following assembled
code:
1 000000 00AB .byte 0ABh
2 000001 CDEF .word 0CDEFh
3 000002 CDEF .long 089ABCDEFh
000003 89AB
4 000004 0068 .string "help"
000005 0065
000006 006C
000007 0070