文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Delphi子过程参数传递

Delphi子过程参数传递

时间:2010-12-30  来源:Jekhn

 

代码
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1
= class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function _AddFunc(pa,pb,pc,pd,pe:Integer):Integer;
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

function TForm1._AddFunc(pa, pb, pc, pd, pe: Integer): Integer;
asm
xor eax,eax
add eax,edx
add eax,ecx
add eax,[esp
+8]
add eax,[esp
+12]
add eax,[esp
+16]
end;

procedure TForm1.Button1Click(Sender: TObject);
var
iSum: Integer;
begin
iSum :
= _AddFunc(10,20,30,40,50);
ShowMessageFmt(
'Integer Sum:%d',[iSum]);
end;

function addFunc(pa,pb,pc,pd: Byte):Byte;overload;assembler;
asm
add al,dl
add al,cl
add al,[esp
+8]
end;

function addFunc(pa,pb,pc,pd: Word):Word;overload;assembler;
asm
add ax,dx
add ax,cx
add ax,[esp
+8]
end;

function addFunc(pa,pb,pc,pd: Integer):Integer;overload;assembler;
asm
add eax,edx
add eax,ecx
add eax,[esp
+8]
end;

function addFunc(pa,pb,pc,pd,pe: Integer):Integer;overload;assembler;
asm
add eax,edx
add eax,ecx
add eax,[esp
+8]
add eax,[esp
+12]
end;

procedure TForm1.Button2Click(Sender: TObject);
var
bSum: Byte;
wSum: Word;
iSum: Integer;
begin
bSum :
= addFunc(1,2,3,4);
wSum :
= addFunc(3,4,5,6);
iSum :
= addFunc(10,20,30,40,50);
ShowMessageFmt(
'Byte Sum:%d',[bSum]);
ShowMessageFmt(
'Word Sum:%d',[wSum]);
ShowMessageFmt(
'Integer Sum:%d',[iSum]);
end;

function addFuncNew(pa,pb,pc,pd,pe: Integer):Integer;assembler;
asm
add eax,edx
add eax,ecx
add eax,[esp
+8]
add eax,[esp
+12]
end;

procedure TForm1.Button3Click(Sender: TObject);
asm
push ebp
mov ebp,esp
add esp,
-16
mov eax,
10
mov edx,
20
mov ecx,
30
push
40 //esp := esp + 4
push
50 //esp := esp + 4
call addFuncNew
lea edx,[esp
+4] //4,8 ok, 12:error
call system.IntToStr
mov eax,[esp
+4]
call showMessage
add esp,
16
mov esp,ebp
pop ebp
end;

end.

 

 

相关阅读 更多 +
排行榜 更多 +
我是班长去广告版下载

我是班长去广告版下载

模拟经营 下载
什么鸭小游戏安卓版下载

什么鸭小游戏安卓版下载

策略塔防 下载
极光影院官方最新版本2025下载

极光影院官方最新版本2025下载

趣味娱乐 下载