The built-in assembler supports
two types of constant: numeric constants and string constants.
Numeric constants must be
integers, and their values must be between -2,147,483,648 and 4,294,967,295.
By default, numeric constants use
decimal notation, but the built-in assembler also supports binary, octal, and
hexadecimal. Binary notation is selected by writing a B after the number, octal
notation by writing an O after the number, and hexadecimal notation by writing
an H after the number or a $ before the number.
Numeric constants must start with
one of the digits 0 through 9 or the $ character. When you write a
hexadecimal constant using the H suffix, an extra zero is required in front of
the number if the first significant digit is one of the digits A through F. For
example, 0BAD4H and $BAD4 are hexadecimal constants, but BAD4H is an identifier
because it starts with a letter.
String constants must be enclosed
in single or double quotation marks. Two consecutive quotation marks of the
same type as the enclosing quotation marks count as only one character. Here
are some examples of string constants:
'Z'
'Delphi'
'Linux'
"That's all folks"
'"That''s all folks," he
said.'
'100'
'"'
"'"
String constants of any length are
allowed in DB directives, and cause allocation of a sequence of bytes
containing the ASCII values of the characters in the string. In all other
cases, a string constant can be no longer than four characters and denotes a
numeric value which can participate in an expression. The numeric value of a
string constant is calculated as
Ord(Ch1) + Ord(Ch2) shl 8 +
Ord(Ch3) shl 16 + Ord(Ch4) shl 24
where Ch1 is the rightmost (last)
character and Ch4 is the leftmost (first) character. If the string is
shorter than four characters, the leftmost characters are assumed to be zero.
The following table shows string constants and their numeric values.
|
String |
Value |
|
'a' |
00000061H |
|
'ba' |
00006261H |
|
'cba' |
00636261H |
|
'dcba' |
64636261H |
|
'a ' |
00006120H |
|
' a' |
20202061H |
|
'a' * 2 |
000000E2H |
|
'a'-'A' |
00000020H |
|
not 'a' |
FFFFFF9EH |
内建汇编程序支持两种类型的常量:数字常量(numeric constants)和串常量(string constants)。
数字常量必须是整数,它们的值必须在-2,147,483,648和4,294,967,295之间。
缺省情况下,数字常量使用十进制表示,但内建汇编程序也支持二进制、八进制和十六进制。二进制表示时需要在数字之后附加一个B,八进制表示需要在数字之后附加一个O,十六进制表示需要在数字之后附加一个H或者在数字之前添加一个 $ 字符。
数字常量必须以数字0到9或 $ 字符开始。当使用H后缀书写一个十六进制的常量时,如果第一个有效数字在数字A到F之间,那么需要额外添加一个零。例如,0BAD4H和$BAD4都是十六进制的数字常量,而BAD4H由于以字母开始因此是一个标识符。
串常量必须以单引号或双引号标记封装。作为封装标记、类型相同的两个连续的引号标记被计算作为一个字符。下面是串常量的一些范例:
'Z'
'Delphi'
'Linux'
"That's all folks"
'"That''s all folks," he
said.'
'100'
'"'
"'"
DB指示中允许任意长度的串常量,结果是一个字节序列的分配,该字节中包含了串中字符的ASCII值。在其他所有情况中,串常量可以不长于4个字节并且表示一个数字值,该值可以参与表达式。串常量的数字值计算为
Ord(Ch1) + Ord(Ch2) shl 8 +
Ord(Ch3) shl 16 + Ord(Ch4) shl 24
这里的Ch1是最右端(最后一个)的字符,Ch4是最左端(第一个)的字符。如果串短于4个字节,那么最左边的字符被假定为零。下表列出了串常量及其相应的数字值。
|
串 |
值 |
|
'a' |
00000061H |
|
'ba' |
00006261H |
|
'cba' |
00636261H |
|
'dcba' |
64636261H |
|
'a ' |
00006120H |
|
' a' |
20202061H |
|
'a' * 2 |
000000E2H |
|
'a'-'A' |
00000020H |
|
not 'a' |
FFFFFF9EH |