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ə281/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   277   278   279   280   281   282   283   284   ...   294
DelphiLanguageGuide

Expression Classes
The built-in assembler divides expressions into three classes: registers, memory references, and immediate values.
An expression that consists solely of a register name is a register expression. Examples of register expressions are
AX, CL, DI, and ES. Used as operands, register expressions direct the assembler to generate instructions that
operate on the CPU registers.
Expressions that denote memory locations are memory references. Delphi's labels, variables, typed constants,
procedures, and functions belong to this category.
237


Expressions that aren't registers and aren't associated with memory locations are immediate values. This group
includes Delphi's untyped constants and type identifiers.
Immediate values and memory references cause different code to be generated when used as operands. For
example,
const
 Start = 10;
var
 Count: Integer;
    .
    .
    .
asm
 MOV            EAX,Start                                        { MOV EAX,xxxx }
 MOV            EBX,Count                                        { MOV EBX,[xxxx] }
 MOV            ECX,[Start]                                { MOV ECX,[xxxx] }
 MOV            EDX,OFFSET Count            { MOV EDX,xxxx }
end;
Because Start is an immediate value, the first MOV is assembled into a move immediate instruction. The second
MOV, however, is translated into a move memory instruction, as Count is a memory reference. In the third MOV,
the brackets convert Start into a memory reference (in this case, the word at offset 10 in the data segment). In the
fourth MOV, the OFFSET operator converts Count into an immediate value (the offset of Count in the data segment).
The brackets and OFFSET operator complement each other. The following asm statement produces identical
machine code to the first two lines of the previous asm statement.
asm
 MOV            EAX,OFFSET [Start]
 MOV            EBX,[OFFSET Count]
end;
Memory references and immediate values are further classified as either relocatable or absolute. Relocation is the
process by which the linker assigns absolute addresses to symbols. A relocatable expression denotes a value that
requires relocation at link time, while an absolute expression denotes a value that requires no such relocation.
Typically, expressions that refer to labels, variables, procedures, or functions are relocatable, since the final address
of these symbols is unknown at compile time. Expressions that operate solely on constants are absolute.
The built-in assembler allows you to carry out any operation on an absolute value, but it restricts operations on
relocatable values to addition and subtraction of constants.

Yüklə 0,84 Mb.

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