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


Symbols recognized by the built-in assembler



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

Symbols recognized by the built-in assembler
Symbol
Value
Class
Type
Label
Address of label
Memory reference Size of type
Constant
Value of constant
Immediate value
0
Type
0
Memory reference Size of type
Field
Offset of field
Memory
Size of type
Variable
Address of variable or address of a pointer to the variable Memory reference Size of type
Procedure Address of procedure
Memory reference Size of type
Function
Address of function
Memory reference Size of type
Unit
0
Immediate value
0
@Result
Result variable offset
Memory reference Size of type
With optimizations disabled, local variables (variables declared in procedures and functions) are always allocated
on the stack and accessed relative to EBP, and the value of a local variable symbol is its signed offset from EBP.
The assembler automatically adds [EBP] in references to local variables. For example, given the declaration
var Count: Integer;
within a function or procedure, the instruction
MOV        EAX,Count
assembles into 
MOV EAX,[EBP4]
.
236


The built-in assembler treats var parameters as a 32-bit pointers, and the size of a var parameter is always 4. The
syntax for accessing a var parameter is different from that for accessing a value parameter. To access the contents
of a var parameter, you must first load the 32-bit pointer and then access the location it points to. For example,
function Sum(var X, Y: Integer): Integer; stdcall;
    begin
         asm
                 MOV                EAX,X
                 MOV                EAX,[EAX]
                 MOV                EDX,Y
                 ADD                EAX,[EDX]
                 MOV                @Result,EAX
     end;
    end;
Identifiers can be qualified within asm statements. For example, given the declarations
 type
     TPoint = record
             X, Y: Integer;
     end;
     TRect = record
             A, B: TPoint;
     end;
    var
     P: TPoint;
     R: TRect;
the following constructions can be used in an asm statement to access fields.
MOV            EAX,P.X
MOV            EDX,P.Y
MOV            ECX,R.A.X
MOV            EBX,R.B.Y
A type identifier can be used to construct variables on the fly. Each of the following instructions generates the same
machine code, which loads the contents of [EDX] into EAX.
MOV            EAX,(TRect PTR [EDX]).B.X
MOV            EAX,TRect([EDX]).B.X
MOV            EAX,TRect[EDX].B.X
MOV            EAX,[EDX].TRect.B.X

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   276   277   278   279   280   281   282   283   ...   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