1*44159Sbosticprogram fproc(output); 2*44159Sbostic var 3*44159Sbostic i :integer; 4*44159Sbostic 5*44159Sbostic procedure print(function frtn :integer); 6*44159Sbostic begin 7*44159Sbostic write(frtn:3,' formal routine ='); 8*44159Sbostic end; 9*44159Sbostic 10*44159Sbostic procedure lvl1(function form: integer); 11*44159Sbostic label 1; 12*44159Sbostic var 13*44159Sbostic loc :integer; 14*44159Sbostic 15*44159Sbostic function eval :integer; 16*44159Sbostic begin 17*44159Sbostic if loc = 8 then begin 18*44159Sbostic writeln(' non-local jump'); 19*44159Sbostic goto 1; 20*44159Sbostic end; 21*44159Sbostic eval := loc; 22*44159Sbostic end; 23*44159Sbostic 24*44159Sbostic begin 25*44159Sbostic loc := i; 26*44159Sbostic i := i - 1; 27*44159Sbostic if (loc = 4) or (loc = 8) then 28*44159Sbostic lvl1(eval) 29*44159Sbostic else if loc > 0 then 30*44159Sbostic lvl1(form); 31*44159Sbostic1: write('Stack frame:',loc:3,' formal print ='); 32*44159Sbostic print(form); 33*44159Sbostic writeln(form:3); 34*44159Sbostic end; 35*44159Sbostic 36*44159Sbostic function geval :integer; 37*44159Sbostic begin 38*44159Sbostic geval := i; 39*44159Sbostic end; 40*44159Sbostic 41*44159Sbostic begin 42*44159Sbostic writeln('This should print levels 0-3, with formal values of 4.'); 43*44159Sbostic writeln('Level 4 should jump to level 8.'); 44*44159Sbostic writeln('Finally levels 8-10 should print with formal values of -1.'); 45*44159Sbostic i := 10; 46*44159Sbostic lvl1(geval); 47*44159Sbostic end. 48