Section 2: Compiler
57
TI
-
89 / TI
-
92 Plus Sierra C Assembler Reference Manual Not for Distribution
Beta Version February 2, 2001
specify a character constant containing the two characters whose values are
' \12 ' and ' 3 ', the construction ' \0123 ' must be used. To specify a character
constant containing the two characters whose values are ' \12 ' and ' z ', the
constructions ' \012z ' and ' \12z ' are both valid.
The sign of the character constant is determined by the most significant bit of the
character. For example, the character constant ' \xFF ' has the value -1, and the
character constant ' \x7F ' has the value +127. The value of a multi-character
character constant is determined by placing its characters (from right to left) into
successively higher order bytes of an integer (beginning with the lowest order
byte). Just as the sign of a single-character character constant is determined by
the value of bit 7, the sign of a four-character character constant is determined
by the value of bit 31. Two- and three-character character constants are always
positive.
The examples in Table 2.2 illustrate how character constants are evaluated.
Character Constant Hexadecimal Value Decimal Value
'\0' 0x0 0
'0' 0x30 48
'\x123' 0x23 35
'\x50' 0x50 80
'\x90' 0x90 -112
'\x08012' 0x803132 401202
'1234' 0x31323334 825373492
'\x040123' 0x40313233 1076965939
'\x080123' 0x80313233 -2144259533
Table 2.2: Character Constants
2.8. Character
Strings
A character string is a sequence of zero or more characters enclosed in double
quotes (e.g., "abc"). The same considerations that apply to characters and
escape sequences in character constants apply also to character strings.
Refer to Table 2.1 for the list of recognized escape sequences and the rules and
restrictions that apply. In a character string, the only difference in the use of the
escape sequence mechanism is that the single quote (
'
) can be specified
directly or with its escape sequence, whereas the double quote (
"
) must be
specified with its escape sequence.