\ ran4 05.3.10 NAB
\ original by Gordon Charlton

BASE @  HEX 

: FuncG ( d dc1 dc2--d)
  >R >R DXOR  2DUP UM* \ d d1
  2SWAP DUP UM*  DINVERT
  ROT DUP UM*  D+
  SWAP R> R> DXOR  D+ ;

: PseudoDes ( d d--d d)
  2SWAP 2OVER
  BAA96887. 4B0F3B58. FuncG DXOR          
  2SWAP 2OVER
  1E17D32C. E874F0C3. FuncG DXOR           
  2SWAP 2OVER
  03BCDC3C. 6955C5A6. FuncG DXOR           
  2SWAP 2OVER
  0F33D1B2. 55A7CA46. FuncG DXOR ;

2VARIABLE Counter 
2VARIABLE Sequence#

: START-SEQUENCE
  ( dcounter dseq#)
  Sequence# 2!  Counter 2! ;

: RAN4 ( --d)
  Sequence# 2@
  Counter 2@  PseudoDes
  2SWAP 2DROP
  Counter 2@ 1. D+  Counter 2! ;
               
BASE !
