Delphi In-Line ASM Calls

Delphi is able to make direct Assembler calls within procedures. Fred Bulback's .dlls are therefore not required.

The following routines are provided by Ken Hopkins ...

procedure outToPort(portAddr : smallint ; value : smallint);

{ Written by Ken Hopkins  - May 2002                     }
{ Permission is granted for non-commercial use.   }

var
    byteValue : Byte;
begin
      byteValue := Byte(value);
      asm
         push dx
         mov dx,portAddr
         mov al, byteValue
         out dx,al
         pop dx
      end;
end;

function inFromPort(portAddr : smallint) : smallint;
var
    byteValue : byte;
begin
    asm
         push dx
         mov dx, portAddr
         in al,dx
         mov byteValue,al
         pop dx
     end;
     inFromPort := smallint(byteValue) and $00FF;
end;