看不懂
This syntax of an assembler statement is
Label: Prefix Opcode Operand1, Operand2
where Label is a label, Prefix is an assembler prefix opcode (operation code), Opcode is an assembler instruction opcode or directive, and Operand is an assembler expression. Label and Prefix are optional. Some opcodes take only one operand, and some take none.
Comments are allowed between assembler statements, but not within them. For example,
MOV AX,1 {Initial value} { OK }
MOV CX,100 {Count} { OK }
MOV {Initial value} AX,1
{ Error! }
MOV CX, {Count} 100 { Error! }
The built-in assembler supports three assembler 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 ?28 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 ?2,768 and 65,535, or an address expression. For an address expression, the built-in assembler generates a near pointer梩hat 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 ?,147,483,648 and 4,294,967,295, or an address expression. For an address expression, the built-in assembler generates a far pointer梩hat is, a word that contains the offset part of the address, followed by a word that contains the segment part of the address.
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 assembler statements. To generate uninitialized or initialized data in the data segment, you should use Object Pascal var or const declarations.
Some examples of DB, DW, and DD directives follow.
asm
DB 0FFH { One byte }
DB 0,99 { Two bytes }
DB 'A' { Ord('A') }
DB 'Hello world...',0DH,0AH { String followed by CR/LF }
DB 12,"Delphi" { Object Pascal 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;
In Turbo Assembler, when an identifier precedes a DB, DW, or DD directive, it causes the declaration of a byte-, word-, or double-word-sized variable at the location of the directive. For example, Turbo Assembler allows the following:
ByteVar DB ?
WordVar DW ?
IntVar DD ?
...
MOV AL,ByteVar
MOV BX,WordVar
MOV ECX,IntVar
The built-in assembler doesn抰 support such variable declarations. The only kind of symbol that can be defined in an inline assembler statement is a label. All variables must be declared using Object Pascal syntax
the preceding construction can be replaced by
var
ByteVar: Byte;
WordVar: Word;
IntVar: Integer;
...
asm
MOV AL,ByteVar
MOV BX,WordVar
MOV ECX,IntVar
end;
You can write complete procedures and functions using inline assembler code, without including a begin...end statement. For example,
function LongMul(X, Y: Integer): Longint;
asm
MOV EAX,X
IMUL Y
end;