SLAU131Y October 2004 – June 2021
Initialize Text
.string {expr1 | "string1"} [, ... , {exprn | "stringn"} ]
.cstring {expr1 | "string1"} [, ... , {exprn | "stringn"} ]
The .string and .cstring directives place 8-bit characters from a character string into the current section. 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>).
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 byte that is initialized.
When you use .string and .cstring 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 0000 0041 Str_Ptr: .string "ABCD"
0001 0042
0002 0043
0003 0044
2 0004 0041 .string 41h, 42h, 43h, 44h
0005 0042
0006 0043
0007 0044
3 0008 0041 .string "Austin", "Houston", "Dallas"
0009 0075
000a 0073
000b 0074
000c 0069
000d 006E
000e 0048
000f 006F
0010 0075
0011 0073
0012 0074
0013 006F
0014 006E
0015 0044
0016 0061
0017 006C
0018 006C
0019 0061
001a 0073
4 001b 0030 .string 36 + 12