Examples Delphi

Title: Read and write IO ports
Question:
Answer:
With Delphi 1 you could write and read the ports via the global
array 'ports'. This is not longer valid with '32-bit' Delphi.
These two functions can be used within every delphi version:
function InPort(PortAddr:word): byte;
{$IFDEF WIN32}
assembler; stdcall;
asm
mov dx,PortAddr
in al,dx
end;
{$ELSE}
begin
Result := Port[PortAddr];
end;
{$ENDIF}
procedure OutPort(PortAddr:
word; Databyte: byte);
{$IFDEF WIN32}
assembler; stdcall;
asm
mov al,Databyte
mov dx,PortAddr
out dx,al
end;
{$ELSE}
begin
Port[PortAddr] := DataByte;
end;
{$ENDIF}