我自己写的一个嵌汇编的小东西
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, TeEngine, Series, ExtCtrls, TeeProcs, Chart;
type
TForm1 = class(TForm)
Button1: TButton;
Timer1: TTimer;
Edit2: TEdit;
Edit3: TEdit;
Timer2: TTimer;
Edit1: TEdit;
Button2: TButton;
Label1: TLabel;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
i,j:byte;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
i:=i+1;
edit3.text:=inttohex(i,2);
edit2.Text:=inttohex(j,2);
if i=$ff then
begin
j:=j+1;
end;
if j=$0f then
begin
timer1.Enabled:=false;
timer2.Enabled:=true;
end;
asm
mov dx, 300h
mov al, j
out dx, al;
mov dx, 301h
mov al, i
out dx, al
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
i:=$00;
j:=$00;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
h:integer;
begin
if edit1.text='' then
showmessage('请输入时间间隔')
else
begin
h:=strtoint(edit1.Text);
timer1.Interval:=h;
timer2.Interval:=h;
timer1.Enabled:=true;
end;
end;
procedure TForm1.Timer2Timer(Sender: TObject);
begin
i:=i-1;
edit3.text:=inttohex(i,2);
edit2.Text:=inttohex(j,2);
if i=$00 then
begin
j:=j-1;
end;
if j=$00 then
begin
timer2.Enabled:=false;
timer1.Enabled:=true;
end;
asm
mov dx, 300h
mov al, j
out dx, al;
mov dx, 301h
mov al, i
out dx, al
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
timer1.Enabled:=false;
timer2.Enabled:=false;
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if not (key in['0'..'9']) then
key :=#0;
end;
end.