Defining String Variables:
A string is an array of bytes, usually terminated by a '$' sign.
A string of characters may be defined in three different ways.
For instance, the following definitions are equivalent ways
of defining a string "abc":
String definitions |
version1 db "abc" ;string constant
version2 db ‘a’, ‘b’, ‘c’ ;character constants
version3 db 97, 98, 99 ;ASCII codes
|
The first version uses the method of high level languages and simply encloses
the string in quotes. This is the preferred method.
The second version defines a string by specifying a list of the character
constants that make up the string.
The third version defines a string by specifying a list of the ASCII codes
that make up the string We may also combine the above methods to define a
string as in the following example:
Combined definitions |
message db "Hello world", 13, 10, ‘$’
|
In the above definition, the string message contains ‘Hello world’
followed by Return (ASCII 13), Line-feed (ASCII 10) and the ‘$’ character.
This method is very useful if we wish to include control characters
(such as Return) in a string. The string is terminated with the ‘$’ character
because the DOS 09 for displaying strings expects the string to be terminated
by the ‘$’ character.