lol 0
cmu EM_WSIZE
zge *1
- loc M2_UOVFL
+ loc M2_UUVFL
trp
1
lol EM_WSIZE
ldl 0
cmu EM_LSIZE
zge *1
- loc M2_UOVFL
+ loc M2_UUVFL
trp
1
ldl EM_LSIZE
; SIG is called with one parameter:
; - procedure instance identifier (PROC)
; and returns the old traphandler.
-; only the procedure identifier inside the PROC is used.
+ exa _handler
exp $SIG
pro $SIG, 0
+ lae _handler
+ loi EM_PSIZE
lal PROC
loi EM_PSIZE
- sig
+ lae _handler
+ sti EM_PSIZE
ret EM_PSIZE
end ?
Version: $Header$
*)
+(*
+ Wirth's 3rd edition certainly is confusing: mostly it uses Allocate, but
+ the module at the end of the book defines ALLOCATE. To avoid problems,
+ I included them both.
+*)
+
FROM SYSTEM IMPORT ADDRESS;
PROCEDURE ALLOCATE(VAR a : ADDRESS; size : CARDINAL);
killed.
*)
+ PROCEDURE Allocate(VAR a : ADDRESS; size : CARDINAL);
+ (* Identical to ALLOCATE *)
+
PROCEDURE DEALLOCATE(VAR a : ADDRESS; size : CARDINAL);
(* Free the area at address "a" with the given size. The area
must have been allocated by "ALLOCATE", with the same size.
*)
+ PROCEDURE Deallocate(VAR a : ADDRESS; size : CARDINAL);
+ (* Identical to DEALLOCATE *)
+
PROCEDURE Available(size : CARDINAL) : BOOLEAN;
(* Return TRUE if an area with the given size could be allocated.
*)
Compacted: BOOLEAN; (* avoid recursive reorganization *)
FirstBlock: BucketPtr;
- PROCEDURE Allocate(size: CARDINAL) : ADDRESS;
+ PROCEDURE MyAllocate(size: CARDINAL) : ADDRESS;
VAR nu : INTEGER;
b : INTEGER;
p, q: BucketPtr;
IF brk = ILLBREAK THEN
ReOrganize();
Compacted := TRUE;
- brk := Allocate(size);
+ brk := MyAllocate(size);
Compacted := FALSE;
RETURN brk;
END;
p^.BSIZE := nu;
p^.BNEXT := USED;
RETURN ADR(p^.BSTORE);
+ END MyAllocate;
+
+ PROCEDURE Allocate(VAR a: ADDRESS; size: CARDINAL);
+ BEGIN
+ ALLOCATE(a, size);
END Allocate;
PROCEDURE ALLOCATE(VAR a: ADDRESS; size: CARDINAL);
BEGIN
- a := Allocate(size);
+ a := MyAllocate(size);
IF a = NIL THEN
Message("out of core");
HALT;
PROCEDURE Available(size: CARDINAL): BOOLEAN;
VAR a: ADDRESS;
BEGIN
- a:= Allocate(size);
+ a:= MyAllocate(size);
IF a # NIL THEN
DEALLOCATE(a, size);
RETURN TRUE;
RETURN FALSE;
END Available;
+ PROCEDURE Deallocate(VAR a: ADDRESS; size: CARDINAL);
+ BEGIN
+ DEALLOCATE(a, size);
+ END Deallocate;
+
PROCEDURE DEALLOCATE(VAR a: ADDRESS; size: CARDINAL);
VAR p: BucketPtr;
BEGIN
ERRFORLOOP = 68; (* value of FOR-loop control variable changed
in loop
*)
+ ERRCARDUVFL = 69; (* CARDINAL underflow *)
TYPE TrapHandler = EM.TrapHandler;
{ M2_NORESULT, "no RETURN from procedure function"},
{ M2_UOVFL, "cardinal overflow"},
{ M2_FORCH, "Warning: FOR-loop control variable was changed in the body"},
+ { M2_UUVFL, "cardinal underflow"},
{ -1, 0}
};
#define STACKSIZE 2048 /* maximum stack size for a coroutine */
+ exa _handler
exa _environ
exa _argv
exa _argc
exa _StackSize
exp $_catch
+_handler
+ bss EM_PSIZE,0,0
_environ
bss EM_PSIZE,0,0
_argv
mainroutine
bss 2*EM_PSIZE,0,0
+ inp $trap_handler
+ pro $trap_handler,0
+ lol 0 ; trap number
+ lae _handler
+ loi EM_PSIZE
+ cai
+ asp EM_WSIZE
+ rtt
+ end 0
+
exp $m_a_i_n
pro $m_a_i_n, STACKSIZE
lol 0
ste _argc ; save argument count
- lpi $_catch
+ lpi $trap_handler
sig
asp EM_PSIZE
cal $_M2M