program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
str: string;
{ Result := x + y }
function add1(x, y: Integer): Integer;
begin
asm
mov eax, x
add eax, y
mov @Result, eax
end;
end;
{ for I := 0 to Length(s) do s[i] := lower(s[i]) }
function test2(s: PChar): PChar;
begin
{ nest asm stmts inside a normal delphi proc then registers and flag are handled by delphi }
asm
mov ebx, s
xor esi, esi
@lab1:
cmp byte ptr [ebx + esi], 0
jz @lab2
or byte ptr [ebx + esi], $20
add esi, 1
jmp @lab1
@lab2:
mov @Result, ebx
end;
end;
begin
str := 'dO yOu kNoWn wHaT i MeAn?';
{ TODO -oUser -cConsole Main : Insert code here }
WriteLn(add1($FFFFFFFF, 2));
WriteLn(test2(PChar(str)));
end.
Delphi Inline Assembler
最新推荐文章于 2023-04-18 18:03:09 发布