4.6 Strings and Character Constants
A string enclosed in double quotes (") can be used only in conjunction with the DB directive and the MESSAGE/WARNING/ERROR directives. The string is taken literally, no escape sequences are recognized, and it is not NULL-terminated.
Quoted strings may be concatenated according to the ANSI C convention, i.e.,
"This is a " "long string"
is equivalent to "This is a long
string"
. This may be combined with Line Continuation to form long strings spanning multiple source
lines.
Character constants are enclosed in single quotes ('), and can be used anywhere an integer expression is allowed. The following C-style escape sequences are recognized, with the same meaning as in C:
Escape sequence |
Meaning |
---|---|
\n |
Newline (ASCII LF 0x0a) |
\r |
Carriage return (ASCII CR 0x0d) |
\a |
Alert bell (ASCII BEL 0x07) |
\b |
Backspace (ASCII BS 0x08) |
\f |
Form feed (ASCII FF 0x0c) |
\t |
Horizontal tab (ASCII HT 0x09) |
\v |
Vertical tab (ASCII VT 0x0b) |
\\ |
Backslash |
\0 |
Null character (ASCII NUL) |
\ooo (ooo = octal number) and \xhh (hh = hex number) are also recognized.
Examples
.db "Hello\n" // is equivalent to: .db 'H', 'e', 'l', 'l', 'o', '\\', 'n' .db '\0', '\177', '\xff'
To create the equivalent to the C-string "Hello, world\n", do as follows:
.db "Hello, world", '\n', 0