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ə288/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   284   285   286   287   288   289   290   291   ...   294
DelphiLanguageGuide

Bitwise exclusive OR. Both expressions must be absolute immediate values, and the result is an absolute
immediate value.
241


Assembly Procedures and Functions (Win32 Only)
You can write complete procedures and functions using inline assembly language code, without including a
begin...end
 statement. This topic covers these issues:
Compiler Optimizations.
Function Results.
The inline assembler is available only on the Win32 Delphi compiler.
Compiler Optimizations
An example of the type of function you can write is as follows:
function LongMul(X, Y: Integer): Longint;
  asm
       MOV        EAX,X
                IMUL Y 
        end
The compiler performs several optimizations on these routines:
No code is generated to copy value parameters into local variables. This affects all string-type value parameters
and other value parameters whose size isn't 1, 2, or 4 bytes. Within the routine, such parameters must be treated
as if they were var parameters.
Unless a function returns a string, variant, or interface reference, the compiler doesn't allocate a function result
variable; a reference to the @Result symbol is an error. For strings, variants, and interfaces, the caller always
allocates an @Result pointer.
The compiler only generates stack frames for nested routines, for routines that have local parameters, or for
routines that have parameters on the stack.
Locals is the size of the local variables and Params is the size of the parameters. If both Locals and Params
are zero, there is no entry code, and the exit code consists simply of a RET instruction.
The automatically generated entry and exit code for the routine looks like this:
PUSH            EBP                                    ;Present if Locals <> 0 or Params <> 0
MOV                EBP,ESP                    ;Present if Locals <> 0 or Params <> 0
SUB                ESP,Locals        ;Present if Locals <> 0
.
.
.
MOV                ESP,EBP                    ;Present if Locals <> 0
POP                EBP                                    ;Present if Locals <> 0 or Params <> 0
RET                Params                        ;Always present
If locals include variants, long strings, or interfaces, they are initialized to zero but not finalized.

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   284   285   286   287   288   289   290   291   ...   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