用porttalk22操作端口/Windows 9x变速齿轮#<br>刚找到的没试过<br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Button2: TButton;<br> Button3: TButton;<br> procedure Button1Click(Sender: TObject);<br> procedure Button2Click(Sender: TObject);<br> procedure Button3Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br>procedure Speed(count:word); stdcall;<br>const ExceptionUsed = $03; { 中断号也可以用其它的中断号}<br>var<br> IDT : array [0..5] of byte; { 保存中断描述符表}<br> lpOldGate : dword; {存放旧向量}<br>begin<br> asm<br> push ebx<br> sidt IDT {读入中断描述符表}<br> mov ebx, dword ptr [IDT+2]{IDT表基地址}<br> add ebx, 8*ExceptionUsed {计算中断在中断描述符表中的位置}<br> cli {关中断}<br> mov dx, word ptr [ebx+6] {取6,7字节 另外4字节用于门属性和选择子 }<br> shl edx, 16d {左移16位}<br> mov dx, word ptr [ebx] {取1,2字节 }<br> mov [lpOldGate], edx {保存旧的中断门}<br> mov eax, offset @@Ring0Code {修改向量,指向Ring0级代码段}<br> mov word ptr [ebx], ax {低16位,保存到1,2字}<br> shr eax, 16d<br> mov word ptr [ebx+6], ax {高16位,保存到6,7位}<br> int ExceptionUsed {发生中断}<br> mov ebx, dword ptr [IDT+2] {重新定位到中断描述符表中}<br> add ebx, 8*ExceptionUsed<br> mov edx, [lpOldGate]<br> mov word ptr [ebx], dx<br> shr edx, 16d<br> mov word ptr [ebx+6], dx {恢复被改了的向量}<br> pop ebx<br> jmp @@exit1<br> @@Ring0Code: {Ring0级代码段}<br> {0011 0100}<br> mov al,$34 {写入8253控制寄存器,设置写0号定时器}<br> out $43,al<br> mov ax,Count<br> out $40,al {写定时值低位}<br> mov al,ah<br> out $40,al {写定时值高位}<br> iretd {中断返回}<br> @@exit1:<br> end;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> Speed($6000); //慢<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br> Speed($1742); <br>end;<br><br>procedure TForm1.Button3Click(Sender: TObject);<br>begin<br> Speed($500); //快<br>end;<br><br>end.<br>