
(*
**	8255 LPT test
**	by memon
*)


uses crt;

const
	lptbase=$378;
  lptdata=lptbase;
  lptstatus=lptbase+1;
  lptcontrol=lptbase+2;

  (*	from krisfaq

  Control

	7 6 5 4 3 2 1 0
	* * . . . . . .  Unused (undefined on read, ignored on write)
	. . * . . . . .  Bidirectional control
	. . . * . . . .  Interrupt control, 1=enable, 0=disable
	. . . . * . . .  Select . . (pin 17), 1=low, 0=high (inverted)
	. . . . . * . .  Initialize (pin 16), 1=high, 0=low (true)
	. . . . . . * .  Auto Feed  (pin 14), 1=low, 0=high (inverted)
	. . . . . . . *  Strobe . . (pin 1),  1=low, 0=high (inverted)
	*)

  NONE=1+2+4;

  A0=-1;
  A1=-2;
  WR=-4;
  RD=8;


  (*
  8255 Control word

  7 6 5 4 3 2 1 0
  ^ ^ ^ ^ ^ ^ ^ ^  [GROUP B]
  | |_| | | | | +- Port C (lower) 1=input,  0=output						1
  |  |  | | | +--- Port B         1=input,  0=output						2
  |  |  | | +----- Mode selection 1=mode0,  0=mode1							4
  |  |  | |
  |  |  | |        [GROUP A]
  |  |  | +------- Port C (upper) 1=input,  0=output						8
  |  |  +--------- Port A         1=input,  0=output						16
  |  +------------ Mode selection 00=mode0, 01=mode1, 1x=mode2	32, 64
  |
  +--------------- Mode set flag  1=active											128

  *)

  ctrl8255=128 + 2;	{Port B input}


begin

  port[lptcontrol]:=NONE;

	{alustetaan 8255}
	port[lptdata]:=ctrl8255;
  port[lptcontrol]:=NONE+A0+A1;				{set address}
  port[lptcontrol]:=NONE+A0+A1+WR;		{set write}

  {output 2 to port A}
	port[lptdata]:=3;
  port[lptcontrol]:=NONE;
  port[lptcontrol]:=NONE+WR;

  port[lptdata]:=0;

end.