MODULE INITIALIZE;

CONST
  HW_STACK_SIZE = 128;	(* NUMBER OF BYTES RESERVED FOR HARDWARE STACK *)
			(* CHANGE IS HEAVY RECURSION IS USED *)

(*$I FIBDEF.LIB*)

VAR
  SYSMEM : 	EXTERNAL INTEGER;	(* TOP OF HEAP *)
  @SFP :	EXTERNAL INTEGER;	(* TOP OF RECURSION STACK *)
  @EFL :	^INTEGER;		(* USED BY FULLHEAP *)
  @FRL : 	RECORD
		  LINK : ^INTEGER;
		  SIZE : INTEGER
		END;			(* USED ALSO BY FULLHEAP *)

  INPUT,
  OUTPUT:	FIB;			(* DEFAULT CONSOLE FILES *)
		  
  @TFN:		STRING[2];		(* FOR TEMP. FILE NAMES  *)

  @SYSIN,
  @SYSOU:	INTEGER;		(* I/O VECTORS *)

  @RNC,
  @WNC:		EXTERNAL INTEGER;	(* REALLY SUBROUTINES BUT JUST *)
					(* NEED THESE TO GET THEIR ADDRESSES *)


(*$E-*) (* HIDE GETSP *)

FUNCTION GETSP:INTEGER;
VAR
  TEMPINT:	INTEGER;		(* FOR CAPTURING STACK POINTER *)
BEGIN
  INLINE("LXI H / 0 / 0 / "DAD SP / "SHLD / TEMPINT);
  GETSP := TEMPINT
END;

(*$E+*)

PROCEDURE @INI;
BEGIN
  @FRL.LINK := NIL;
  @FRL.SIZE := 0;
  @EFL := NIL;
  SYSMEM := ADDR(SYSMEM) + 2;		(* SO SYSMEM POINTS TO FREE AREA *)
  @SFP := GETSP - HW_STACK_SIZE;
  @TFN := '00';
  WITH INPUT DO
    BEGIN
      IOSIZE := 1;
      BUFLEN := 1;
      OPTION := FCONIO;
      FTEXT := TRUE;
      FBUFFER[0] := ' ';
      FBUFADR := WRD(ADDR(INPUT.FBUFFER))
    END;

  WITH OUTPUT DO
    BEGIN
      IOSIZE := 1;
      BUFLEN := 1;
      OPTION := FCONIO;
      FTEXT := TRUE;
      FBUFFER[0] := ' ';
      FBUFADR := WRD(ADDR(OUTPUT.FBUFFER))
    END;

  @SYSIN := ADDR(@RNC);
  @SYSOU := ADDR(@WNC)

END;

MODEND.

