Quick start manual
13-4
Delphi Language Guide
Assembler statement syntax
Assembly directives
The built-in assembler supports three assembly define directives: DB (define byte),
DW (define word), and DD (define double word). Each generates data corresponding
to the comma-separated operands that follow the directive.
The DB directive generates a sequence of bytes. Each operand can be a constant
expression with a value between –128 and 255, or a character string of any length.
Constant expressions generate one byte of code, and strings generate a sequence of
bytes with values corresponding to the ASCII code of each character.
The DW directive generates a sequence of words. Each operand can be a constant
expression with a value between –32,768 and 65,535, or an address expression. For an
address expression, the built-in assembler generates a near pointer—that is, a word
that contains the offset part of the address.
The DD directive generates a sequence of double words. Each operand can be a
constant expression with a value between –2,147,483,648 and 4,294,967,295, or an
address expression. For an address expression, the built-in assembler generates a far
pointer—that is, a word that contains the offset part of the address, followed by a
word that contains the segment part of the address.
The DQ directive defines a quad word for Int64 values.
The data generated by the DB, DW, and DD directives is always stored in the code
segment, just like the code generated by other built-in assembly statements. To
generate uninitialized or initialized data in the data segment, you should use Delphi
var or const declarations.
Some examples of DB, DW, and DD directives follow.
asm
DB FFH { One byte }
DB 0,99 { Two bytes }
DB 'A' { Ord('A') }
DB 'Hello world...',0DH,0AH { String followed by CR/LF }
DB 12,"string" { Delphi style string }
DW 0FFFFH { One word }
DW 0,9999 { Two words }
DW 'A' { Same as DB 'A',0 }
DW 'BA' { Same as DB 'A','B' }
DW MyVar { Offset of MyVar }
DW MyProc { Offset of MyProc }
DD 0FFFFFFFFH { One double-word }
DD 0,999999999 { Two double-words }
DD 'A' { Same as DB 'A',0,0,0 }
DD 'DCBA' { Same as DB 'A','B','C','D' }
DD MyVar { Pointer to MyVar }
DD MyProc { Pointer to MyProc }
end;