unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure outb(const port:word;const dbyte:byte);pascal;
    function inb(const port:word):byte;pascal;
    function receivebyte:byte;stdcall;
  end;var
  Form1: TForm1;implementation{$R *.dfm}
const
 com1=$3f8;
 com2=$2f8;
var
 com:word;
function tform1.receivebyte:byte;stdcall;
var
  status,res:byte;
 begin
   repeat
    status:=inb(com+5);
   until ((status and $01)=$01);
   res:=inb(com);
   receivebyte:=res;
 end;
function tform1.inb(const port:word):byte;pascal;
   begin
     asm
       mov dx,port
       in  al,dx
       mov @result,al
     end;
   end;
procedure tform1.outb(const port:word;const dbyte:byte);pascal;
  begin
    asm
      mov dx,port
      mov al,dbyte
      OUT dx,AL
    end;
  end;procedure TForm1.Button1Click(Sender: TObject);
begin
   receivebyte
end;procedure TForm1.Button2Click(Sender: TObject);
begin
  com:=com1;
  outb(com+3,$80);
  outb(com,$18);
  outb(com+1,$00);
  outb(com+3,$03);
end;end.
可运行到outb这个过程时
 out dx,al 总会出现‘privileged instruction’这样错误