unit Portu;{derived (simplified) from winport.pas from DSP}
interface
{ gettime               timegettime timer
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
}


function PortIn(P: Word): Byte;
procedure PortOut(P: Word; b: Byte);

implementation
{$IFDEF WIN32}

function PortIn(p:word):byte; stdcall;
begin
  asm
    push edx
    push eax
    mov  dx,p
    in   al,dx
    mov  @result,al
    pop  eax
    pop  edx
  end;
end;

procedure portout(p:word;b:byte); stdcall;
begin
  asm
    push	edx
    push	eax
    mov		dx,p
    mov		al,b
    out		dx,al
    pop		eax
    pop		edx
  end;
end;

{
function PortIn(PortNo: Word): Byte; assembler;register;
asm
  mov dx,PortNo
  cli
  in  al,dx
  sti
  mov result,al
end;


procedure PortOut(PortNo: Word; Data: Byte); assembler;
asm
  mov  dx,PortNo
  mov  al,Data
  cli
  out  dx,al
  sti
end;
}
{$ELSE}

function PortIn(PortNo: Word): Byte;
begin
  PortIn := Port[PortNo];
end;

procedure PortOut(PortNo: Word; Data: Byte);
begin
  Port[PortNo] := Data;
end;
{$ENDIF}

end.
