Quick start manual

Inline assembly code
13-13
Expressions
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
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.
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.