MOV AL,QuitFlag
MOV BX,OutBufPtr
end;
the assembler
checks that the size of
QuitFlag
is one (a byte), and that the size of
OutBufPtr
is two (a word).
The instruction
MOV DL,OutBufPtr
produces an error because DL is a byte-sized register and
OutBufPtr
is a word. The type of a memory reference
can
be changed through a typecast; these are correct ways of writing the previous instruction:
MOV DL,BYTE PTR OutBufPtr
MOV DL,Byte(OutBufPtr)
MOV DL,OutBufPtr.Byte
These MOV instructions all refer to the first (least significant)
byte of the
OutBufPtr
variable.
In some cases, a memory reference is untyped. One example is an immediate value (Buffer) enclosed in square
brackets:
procedure Example(var Buffer);
asm
MOV AL, [Buffer]
MOV CX, [Buffer]
MOV EDX, [Buffer]
end;
The built-in assembler permits these instructions, because the expression [Buffer] has no typeit just means "the
contents of the location indicated by Buffer," and the type can be determined from the first operand (byte for AL,
word for CX, and double-word for EDX.
In cases where the type can't be determined
from another operand, the built-in assembler requires an explicit
typecast. For example,
INC BYTE PTR [ECX]
IMUL WORD PTR [EDX]
The following table summarizes the predefined type symbols that the built-in assembler
provides in addition to any
currently declared Delphi types.
Dostları ilə paylaş: