Delphi Language Guide Delphi for Microsoft Win32 Delphi for the Microsoft. Net framework



Yüklə 0,84 Mb.
Pdf görüntüsü
səhifə282/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   278   279   280   281   282   283   284   285   ...   294
DelphiLanguageGuide

Expression Types
Every built-in assembler expression has a typeor, more correctly, a size, because the assembler regards the type
of an expression simply as the size of its memory location. For example, the type of an Integer variable is four,
because it occupies 4 bytes. The built-in assembler performs type checking whenever possible, so in the instructions
var
 QuitFlag: Boolean;
 OutBufPtr: Word;
 .
    .
    .
asm
238


 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.

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   278   279   280   281   282   283   284   285   ...   294




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin