DEFINITION MODULE PsStk;

FROM items IMPORT ITEM, REGISTER, MODE, 
                  ConditionCode, Operator, MonOperator;

EXPORT QUALIFIED PseudStk, top, base, ResultItem,
                 pop, push, DoAnyPendingOp, 
		 SetDyadicOp, ClearPendingOp,
		 PseudoStackEmpty, NotOnPsStk,
		 Push, Pop, PopToD0, IncTop,
		 MoveIntoScratchSpace, SetMonadicOp,
		 FreeAnyRegUsedBy, PutInScratchSpace,
		 DyadicOpPending, BooleanOpPending,
		 DoBooleanOp, PutPsStkOnRealStack,
		 DecTopOfPsStk, MonadicOpPending,
                 NOTPendingRelationalOp,
                 RemoveAnyOther, AssertEmptyPsStk,
                 PsStkState, STATE, STATEBIT,
		 StoreParams, ResetScratchHwm,
		 StoreParamsNotTop, ScratchHwm,
		 StoreParamsNotBottom;

TYPE
    STATEBIT = (GB, SlaveAddrReg, STOTed);
    STATE    = SET OF STATEBIT;

CONST base = 0;
      PseudStkUpb = 100;
      NotOnPsStk = PseudStkUpb + 1;

VAR PseudStk         : ARRAY [1..PseudStkUpb] OF ITEM;
    PsStkState       : ARRAY [1..PseudStkUpb] OF STATE;
    top              : [0..PseudStkUpb];
    ResultItem       : ITEM;
    DyadicOpPending  : BOOLEAN;
    MonadicOpPending : BOOLEAN;
    ScratchHwm       : CARDINAL;

PROCEDURE pop (VAR dest : ITEM);
PROCEDURE push (VAR Item : ITEM);
PROCEDURE IncTop;
PROCEDURE DoAnyPendingOp ();
PROCEDURE SetDyadicOp (op : Operator);
PROCEDURE SetMonadicOp (op : MonOperator);
PROCEDURE ClearPendingOp (Dyadic : BOOLEAN);
PROCEDURE PseudoStackEmpty () : BOOLEAN;
PROCEDURE Push (mode : MODE; 
                register : REGISTER; 
                dispOrData : INTEGER); 
PROCEDURE Pop (mode : MODE; 
               register : REGISTER; 
               dispOrData : INTEGER); 
PROCEDURE PopToD0 ();
PROCEDURE FreeAnyRegUsedBy (PsStkPosn : CARDINAL);
PROCEDURE MoveIntoScratchSpace (posn : CARDINAL);
PROCEDURE PutInScratchSpace (reg : REGISTER);
PROCEDURE BooleanOpPending () : BOOLEAN;
PROCEDURE DoBooleanOp () : ConditionCode;
PROCEDURE PutPsStkOnRealStack (limit : CARDINAL);
PROCEDURE DecTopOfPsStk (num : CARDINAL);
PROCEDURE NOTPendingRelationalOp () : BOOLEAN;
PROCEDURE AssertEmptyPsStk;
PROCEDURE RemoveAnyOther (VAR item : ITEM; limit : CARDINAL);
PROCEDURE StoreParams () : INTEGER;
PROCEDURE ResetScratchHwm;
PROCEDURE StoreParamsNotTop () : INTEGER;
PROCEDURE StoreParamsNotBottom () : INTEGER;
END PsStk.






