SPRU513Z August 2001 – October 2023 SM320F28335-EP
Initialize Text
.string {expr1 | "string1"} [, ... , {exprn | "stringn"} ]
.cstring {expr1 | "string1"} [, ... , {exprn | "stringn"} ]
.pstring {expr1 | "string1"} [, ... , {exprn | "stringn"} ]
The .string , .cstring, and .pstring directives place 8-bit characters from a character string into the current section. With the .string directive, each 8-bit character has its own 16-bit word, but with the .pstring directive, the data is packed so that each word contains two 8-bit bytes. The expr or string can be one of the following:
The .cstring directive adds a NUL character needed by C; the .string directive does not add a NUL character. In addition, .cstring interprets C escapes (\\ \a \b \f \n \r \t \v \<octal>).
With .pstring, values are packed into words starting with the most significant byte of the word. Any unused space is padded with null bytes.
The assembler truncates any values that are greater than eight bits. Operands must fit on a single source statement line.
If you use a label, it points to the location of the first word that is initialized.
When you use .string , .cstring, and .pstring in a .struct/.endstruct sequence, the directive only defines a member's size; it does not initialize memory. For more information, see the .struct/.endstruct/.tag topic.
In this example, 8-bit values are placed into consecutive words in the current section.
1 000000 0041 Str_Ptr: .string "ABCD"
000001 0042
000002 0043
000003 0044
2
3 000004 0041 .string 41h, 42h, 43h, 44h
000005 0042
000006 0043
000007 0044
4
5 000008 4175 .pstring "Austin", "Houston"
000009 7374
00000a 696E
00000b 486F
00000c 7573
00000d 746F
00000e 6E00
6
7 00000f 0030 .string 36 + 12