uses
  NumToStr,
  Crt;

procedure DispBin(W: Word);
var
  i: integer;
  m: word;
begin
  m:=$8000;
  for i:=1 to 16 do
  begin
    if (W and M)<>0 then Write('1')
    else Write('_');
    m:=m shr 1;
  end;
end;

type
  LW = record
    LW : word;
    HW : word;
  end;

Label N10;
Var
  A,B,C,D : Word;
  i       : integer;
Begin
  ClrScr;
  A:=$8000;

  { x16+x15+x2+1 }

  B:=$8005;

  { x16+x15+x2+1 }

  B:=$1021;

  C:=0;
  for i:=1 to 5000 do
  begin
    WriteLn;
    Write(i:5,'   ');
    DispBin(A);
    Write('   ',WordStrHex(A),'   ');
    if (A and $8000)<>0 then
    begin
      C:=(C shl 1)+1;
      A:=A shl 1;
      A:=A xor B;
    end
    else
    begin
      C:=C shl 1;
      A:=A shl 1;
    end;
    Write('   ');
    DispBin(C);
    if i=1 then
      D:=A
    else
      if D=A then
        goto N10;
    if keypressed then Exit;
  end;
N10:
End.
