Mega Code Archive

 
Categories / Delphi / Examples
 

How to read a byte from the parallel port

Title: How to read a byte from the parallel port? Question: How to read a byte from the parallel port? Answer: value:=port[$379]; { read from port } and port[$379]:=value; { write to port } Var BytesRead : BYTE; begin asm { Read port (LPT1) via Inline asm } MOV dx,$379; IN al,dx; MOV BytesRead,al; end; BytesRead:=(BytesRead OR $07); { OR and then XOR the data } BytesRead:=(BytesRead XOR $80); { to mask the unused bits }