Delphi Programming/Assembler in Delphi
< Delphi ProgrammingSince Turbo Pascal 1.0, the use of assembly code within Borland (currently Embarcadero) languages was quite easy.
In Delphi, simply put an assembly block between asm...end; within a code block, or you can declare a whole function procedure as assembler.
Global or local variables can be used normally, but of course they will work as pointers.
Examples:
function StrLen (S : Pchar ) : cardinal;
begin
asm
MOV EDX, EDI
MOV EDI, EAX
MOV ECX,0FFFFFFFFh
XOR AL, AL
REPNE SCASB
MOV EAX, 0FFFFFFFEh
SUB EAX, ECX
MOV EDI, EDX
end;
end;
function StrLen (S : Pchar) : cardinal; assembler;
asm
MOV EDX, EDI
MOV EDI, EAX
MOV ECX, 0FFFFFFFFh
XOR AL, AL
REPNE SCASB
MOV EAX, 0FFFFFFFEh
SUB EAX, ECX
MOV EDI, EDX
end;
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.