1(* 2 * Copyright (c) 1980, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)fproc.p 8.1 (Berkeley) 06/06/93 8 *) 9 10program fproc(output); 11 var 12 i :integer; 13 14 procedure print(function frtn :integer); 15 begin 16 write(frtn:3,' formal routine ='); 17 end; 18 19 procedure lvl1(function form: integer); 20 label 1; 21 var 22 loc :integer; 23 24 function eval :integer; 25 begin 26 if loc = 8 then begin 27 writeln(' non-local jump'); 28 goto 1; 29 end; 30 eval := loc; 31 end; 32 33 begin 34 loc := i; 35 i := i - 1; 36 if (loc = 4) or (loc = 8) then 37 lvl1(eval) 38 else if loc > 0 then 39 lvl1(form); 401: write('Stack frame:',loc:3,' formal print ='); 41 print(form); 42 writeln(form:3); 43 end; 44 45 function geval :integer; 46 begin 47 geval := i; 48 end; 49 50 begin 51 writeln('This should print levels 0-3, with formal values of 4.'); 52 writeln('Level 4 should jump to level 8.'); 53 writeln('Finally levels 8-10 should print with formal values of -1.'); 54 i := 10; 55 lvl1(geval); 56 end. 57