SPRUI03E June 2015 – January 2023
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 bytes in the current section. The label Str_Ptr has the value 0h, which is the location of the first initialized byte.
1 00000000 00000041 Str_Ptr: .string "ABCD"
00000001 00000042
00000002 00000043
00000003 00000044
2 00000004 00000041 .string 41h, 42h, 43h, 44h
00000005 00000042
00000006 00000043
00000007 00000044
3 00000008 00000041 .string "Austin", "Houston"
00000009 00000075
0000000a 00000073
0000000b 00000074
0000000c 00000069
0000000d 0000006E
0000000e 00000048
0000000f 0000006F
00000010 00000075
00000011 00000073
00000012 00000074
00000013 0000006F
00000014 0000006E
4 00000015 00000030 .string 36 + 12