{ex5.debugboo 92/03/18 nm -e ex5p.debugboo} $standard_level 'os_features'$ $type_coercion 'representation'$ $tables on, statement_number on, code_offsets on, list_code on$ $optimize off$ {============================================================== Note: This program uses PRINT in an effort to avoid using the Pascal/XL I/O package (e.g., writeln). This shortens the amount of code emitted by the compiler, which makes it easier to use as a tool for teaching about Debug. --------------------------------------------------------------- Program description: Show print values from 1 to lim, where lim is a parameter. --------------------------------------------------------------- Exercise 5: The program usually goes into an infinite loop, printing numbers 1... (i.e., not stopping at "lim"). Find and fix the problem. Note: you can use control-Y to abort the program during testing. ===============================================================} program ex5 (parm); type byte = 0..255; {occupies 1 byte} pac80 = packed array [1..80] of char; var buf : pac80; len : integer; parm : shortint; Function ascii : shortint; intrinsic; Procedure debug; intrinsic; Procedure hpdebug; intrinsic; Procedure print; intrinsic; Procedure terminate; intrinsic; Procedure xcontrap; intrinsic; {*************************************************} procedure cy_handler; begin terminate; end {cy_handler proc}; {*************************************************} procedure print_numbers (lim : integer); var ktr : integer; sum : integer; begin sum := 0; while ktr < lim do begin len := ascii (ktr, 10, buf); print (buf, -len, 0); ktr := ktr + 1; end; end {print_numbers proc}; {*************************************************} procedure initialize; var sysglob : integer; old_plabel : integer; begin xcontrap (baddress (cy_handler), old_plabel); sysglob := hex ('c0000000'); end {initialize proc}; {*************************************************} begin initialize; print_numbers (10); print_numbers (10); end.