Delphi+汇编例子1(求和的比较)
2006-02-04 13:39:26 来源:WEB开发网-----以前学汇编的时候做的测试。第一个程序只是给您个印象,后面还有一个帖子,在详细说说。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Shape1: TShape;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Button1: TButton;
Button2: TButton;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Button3: TButton;
PRocedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
//procedure Button3Click(Sender: TObject);
//procedure BtCalcuClick(sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
function Sum1(X,Y:integer):integer;
function Sum2(X,Y:integer):integer;stdcall;
function Sum3(var X,Y:integer):integer;stdcall;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i,j:integer;
begin
label1.Caption:=inttostr(sum1(2,3));
label2.Caption:=inttostr(sum2(2,3));
i:=2;
j:=3;
label3.Caption:=inttostr(sum1(i,j));
end;
//delphi程序求和
function Sum1(X,Y:integer):integer;
begin
result:=X+Y;
end;
//汇编求和1---
function Sum2(X,Y:integer):integer;stdcall;
begin
asm
mov eax,X
add eax,Y
mov @result,eax
end;
end;
//汇编求和2---
function Sum3(var X,Y:integer):integer;stdcall;
begin
asm
mov eax,X
mov eax,[eax]
mov edx,Y
add eax,[edx]
mov @result,eax
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
{procedure TForm1.Button3Click(Sender: TObject);
var
QuitFlag:Boolean;
OutBufPtr:Word;
begin
asm
mov al,QuitFlag
mov bx,OutBufPtr
end;
end;}
end.
- ››Delphi实现把10进制转换成16进制的函数进制转化
- ››Delphi中将字符串按给定字符分隔(似split函数功能...
- ››Delphi 动态创建窗体,锁定窗口赋值
- ››Delphi 与 VC 共享接口和对象
- ››Delphi图像处理 -- 表面模糊
- ››Delphi之多线程实例
- ››Delphi SelectSingleNode的使用 根据节点属性获取...
- ››Delphi接口详述
- ››delphi 远程调试
- ››Delphi与DirectX之DelphiX(34): TDIB.Lightness()...
- ››Delphi Application.MessageBox详解
- ››Delphi只能运行一个程序实例的两种方法
更多精彩
赞助商链接