Program serial_adc; {Serial port AD converter circuit control program by Tomi Engdahl} Uses Crt; Const combase=$2f8; MCR=combase+4; LCR=combase+3; MSR=combase+6; Procedure Initialize_converter; Begin Port[MCR]:=3; Port[LCR]:=0; End; Function Read_value:byte; Var value:byte; count:byte; Begin value:=0; Port[MCR]:=1; For count:=0 to 7 Do Begin value:=value SHL 1; Port[LCR]:=64; If (port[MSR] and $10)=$10 Then Inc(value); Port[LCR]:=0; End; Port[MCR]:=3; Read_value:=value; End; Begin Initialize_converter; Repeat Writeln(Read_value); Until KeyPressed; End.