DEFINITION MODULE Program;(*voorlopige versie;wordt aangevuld. *)


FROM SYSTEM IMPORT ADDRESS;
FROM GEMX IMPORT ErrorProcessorType;
EXPORT QUALIFIED AddShutDowner,NormalExit,FatalError,SimpleAlert, Mode ;

TYPE ShutDownProc = PROCEDURE();

VAR oldErrorProcessor : ErrorProcessorType ;

PROCEDURE AddShutDowner(formal : ShutDownProc);
PROCEDURE NormalExit;
PROCEDURE FatalError (VAR s : ARRAY OF CHAR);
PROCEDURE SimpleAlert(VAR s : ARRAY OF CHAR);

PROCEDURE Mode ( stack : ADDRESS ) : ADDRESS ;
(* We use TRAP #1 , function number 20h     *)
(* 'stack' can be:
   -1=0FFFFFFFFh = proc returns 1 for super mode, 0 for user mode
    0= supervisor stack will be same as user stack when going from
       user to super mode. Then old value of systemstack pointer
       will be returned, so you can (and have) to reset this system
       stack pointer. The call toggles you between super and user mode.
  /***********************************************/
  MODULE TEST; (* Demo: how to use this all *)
  FROM Program IMPORT Mode;
  VAR savedssp,dummy : ADDRESS;
  BEGIN /* now doing user mode actions */
  savedssp := Mode(0);
   /* now super mode, using user stack as system stack */
   /* do here the super things */
   dummy := Mode(savedssp);
   /* now back in user mode, stack ok. */
  END TEST.
  /************************************************/
*)

END Program.
