pc_prlib.7 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. .\" $Header$
  2. .TH PC_PRLIB VII
  3. .ad
  4. .SH NAME
  5. pc_prlib \- library of Pascal runtime routines
  6. .SH SYNOPSIS
  7. .ta 11n
  8. type alpha=packed array[1..8] of char;
  9. .br
  10. pstring= ^packed array[] of char;
  11. function _abi(i:integer):integer;
  12. .br
  13. function _abl(i:long):long;
  14. .br
  15. function _mdi(j,i:integer):integer;
  16. .br
  17. function _mdl(j,i:long):long;
  18. .br
  19. function _abr(r:real):real;
  20. .br
  21. function _sin(r:real):real;
  22. .br
  23. function _cos(r:real):real;
  24. .br
  25. function _atn(r:real):real;
  26. .br
  27. function _exp(r:real):real;
  28. .br
  29. function _log(r:real):real;
  30. .br
  31. function _sqt(r:real):real;
  32. .br
  33. function _rnd(r:real):real;
  34. type compared=-1..1;
  35. .br
  36. gotoinfo=record
  37. .br
  38. pcoffset:^procedure; { procedure id. without static link }
  39. .br
  40. nlocals: integer;
  41. .br
  42. end;
  43. function _bcp(sz:integer; s2,s1:pstring):compared;
  44. .br
  45. function _bts(size,high,low:integer; base:^set 0..(8*size-1))
  46. :set of 0..(8*size-1);
  47. .br
  48. procedure _gto(lb:^integer; p:^gotoinfo);
  49. procedure _new(size:integer; var p:^integer);
  50. .br
  51. procedure _dis(size:integer; var p:^integer);
  52. .br
  53. procedure _sav(var p:^integer);
  54. .br
  55. procedure _rst(var p:^integer);
  56. type arrdescr=record
  57. .br
  58. lowbnd: integer;
  59. .br
  60. diffbnds:integer;
  61. .br
  62. elsize: integer;
  63. .br
  64. end;
  65. .br
  66. arr1=array[] of ?;
  67. .br
  68. arr2=packed array[] of ?;
  69. procedure _pac(var ad,zd:arrdescr; var zp:arr2; i:integer;
  70. .br
  71. var ap:arr1);
  72. .br
  73. procedure _unp(var ad,zd:arrdescr; i:integer; var ap:arr1;
  74. .br
  75. var zp:arr2;);
  76. .br
  77. function _asz(var dp:arrdescr):integer;
  78. procedure _ass(line:integer; b:boolean);
  79. .br
  80. procedure procentry(var name:alpha);
  81. .br
  82. procedure procexit(var name:alpha);
  83. const lowbyte=[0..7];
  84. .br
  85. MAGIC =[1,3,5,7];
  86. .br
  87. WINDOW =[11];
  88. .br
  89. ELNBIT =[12];
  90. .br
  91. EOFBIT =[13];
  92. .br
  93. TXTBIT =[14];
  94. .br
  95. WRBIT =[15];
  96. .br
  97. type file=record
  98. .br
  99. ptr: ^char;
  100. .br
  101. flags: set of [0..15];
  102. .br
  103. fname: string;
  104. .br
  105. ufd: 0..15;
  106. .br
  107. size: integer;
  108. .br
  109. count: 0..buflen;
  110. .br
  111. buflen: max(512,size) div size * size;
  112. .br
  113. bufadr: packed array[1..max(512,size)]
  114. .br
  115. of char;
  116. .br
  117. end;
  118. .br
  119. filep=^file;
  120. .br
  121. const NFILES=15;
  122. .br
  123. _extfl:^array[] of filep;
  124. procedure _ini(var args:integer; var hb:integer;
  125. var p:array[] of filep; var mainlb:integer);
  126. .br
  127. procedure _hlt(status:0..255);
  128. procedure _opn(size:integer; f:filep);
  129. .br
  130. procedure _cre(size:integer; f:filep);
  131. .br
  132. procedure _cls(f:filep);
  133. procedure _get(f:filep);
  134. .br
  135. procedure _put(f:filep);
  136. .br
  137. function _wdw(f:filep):^char;
  138. .br
  139. function _efl(f:filep):boolean;
  140. function _eln(f:filep):boolean;
  141. .br
  142. function _rdc(f:filep):char;
  143. .br
  144. function _rdi(f:filep):integer;
  145. .br
  146. function _rdl(f:filep):long;
  147. .br
  148. function _rdr(f:filep):real;
  149. .br
  150. procedure _rln(f:filep);
  151. .br
  152. procedure _wrc(c:char; f:filep);
  153. .br
  154. procedure _wsc(w:integer; c:char; f:filep);
  155. .br
  156. procedure _wri(i:integer; f:filep);
  157. .br
  158. procedure _wsi(w:integer; i:integer; f:filep);
  159. .br
  160. procedure _wrl(l:long; f:filep);
  161. .br
  162. procedure _wsl(w:integer; l:long; f:filep);
  163. .br
  164. procedure _wrr(r:real; f:filep);
  165. .br
  166. procedure _wsr(w:integer; r:real; f:filep);
  167. .br
  168. procedure _wrf(ndigit:integer; w:integer; r:real; f:filep);
  169. .br
  170. procedure _wrs(l:integer; s:pstring; f:filep);
  171. .br
  172. procedure _wss(w:integer; l:integer; s:pstring; f:filep);
  173. .br
  174. procedure _wrb(b:boolean; f:filep);
  175. .br
  176. procedure _wsb(w:integer; b:boolean; f:filep);
  177. .br
  178. procedure _wrz(s:string; f:filep);
  179. .br
  180. procedure _wsz(w:integer; s:string; f:filep);
  181. .br
  182. procedure _wln(f:filep);
  183. .br
  184. procedure _pag(f:filep);
  185. .SH DESCRIPTION
  186. This library is used by the Pascal to EM compiler and
  187. contains all the runtime routines for standard Pascal programs.
  188. Most routines are written in C, a few in EM assembly language.
  189. These routines can be divided into several categories.
  190. A description of each category with its routines follows.
  191. .PP
  192. Arithmetic routines:
  193. .RS
  194. .IP _abi
  195. Compute the absolute value of an integer.
  196. .PD 0
  197. .IP _abl
  198. Compute the absolute value of a long.
  199. .IP _mdi
  200. Perform the Pascal modulo operation on integers.
  201. .IP _mdl
  202. Perform the Pascal modulo operation on longs.
  203. .IP _abr
  204. Compute the absolute value of a real.
  205. .IP _sin
  206. Compute the sine of a real.
  207. .IP _cos
  208. Compute the cosine of a real.
  209. .IP _atn
  210. Compute the arc tangent of a real.
  211. .IP _exp
  212. Compute the e-power of a real.
  213. .IP _log
  214. Compute the natural logarithm of a real.
  215. .IP _sqt
  216. Compute the square root of a real.
  217. .IP _rnd
  218. Return a real that when truncated will
  219. result in the nearest integer (-3.5->-4).
  220. .PD
  221. .PP
  222. .RE
  223. Miscellaneous routines:
  224. .RS
  225. .IP _bcp
  226. Compare two strings. Use dictionary ordering with the ASCII
  227. character set. The EM instruction CMU can not be used, because it needs
  228. an even number of bytes.
  229. .PD 0
  230. .IP _bts
  231. Include a range of elements from low to high in a set of size bytes
  232. at address base.(size can be divided by the wordsize)
  233. .IP _gto
  234. Execute a non-local goto. Lb points to the
  235. local base of the target procedure.
  236. A lb of zero indicates a jump to the program body, the lb of the main
  237. program is found in _m_lb, which is set by _ini.
  238. The new EM stack pointer is calculated by adding the number of locals
  239. to the new local base
  240. (jumping into statements is not allowed; there are no local generators
  241. in Pascal!).
  242. .PD
  243. .PP
  244. .RE
  245. Heap management:
  246. .RS
  247. .PP
  248. There is one way to allocate new heap space (_new), but two different
  249. incompatible ways to deallocate it.
  250. .PP
  251. The most general one is by using dispose (_dis).
  252. A circular list of free blocks, ordered from low to high addresses, is maintained.
  253. Merging free blocks is done when a new block enters the free list.
  254. When a new block is requested (_new), the free list is searched using a
  255. first fit algorithm.
  256. Two global variables are needed:
  257. .IP _highp 10
  258. Points to the free block with the highest address.
  259. .PD 0
  260. .IP _lastp
  261. Points to the most recently entered free block or to a block
  262. in the neighborhood of the most recently allocated block.
  263. .PD
  264. The free list is empty, when one of these pointers (but then at the same
  265. time both) is zero.
  266. .PP
  267. The second way to deallocate heap space is by using
  268. mark (_sav) and release (_rst). Mark saves the current value of the
  269. heap pointer HP in the program variable passed as a parameter.
  270. By calling release with this old HP value as its argument, the old HP value
  271. is restored, effectively deallocating all blocks requested between
  272. the calls to mark and release.
  273. The heap is used as second stack in this case.
  274. .PP
  275. It will be clear that these two ways of deallocating heap space
  276. can not be used together.
  277. To be able to maintain the free list, all blocks must be a multiple
  278. of n bytes long, with a minimum of n bytes,
  279. where n is the sum of the size of a word and a pointer in the
  280. EM implementation used.
  281. .PP
  282. In summary:
  283. .IP _new
  284. Allocate heap space.
  285. .PD 0
  286. .IP _dis
  287. Deallocate heap space.
  288. .IP _sav
  289. Save the current value of HP.
  290. .IP _rst
  291. Restore an old value of HP.
  292. .PD
  293. .PP
  294. .RE
  295. Array operations:
  296. .RS
  297. .PP
  298. The only useful form of packing implemented, is packing bytes into words.
  299. All other forms of packing and unpacking result in a plain copy.
  300. .IP _pac
  301. Pack an unpacked array \fIa\fP into a packed array \fIz\fP.
  302. \fIap\fP and \fIzp\fP
  303. are pointers to \fIa\fP and \fIz\fP. \fIad\fP and \fIzd\fP
  304. are pointers to the descriptors of \fIa\fP and \fIz\fP. \fIi\fP is
  305. the index in \fIa\fP of the first element to be packed.
  306. Pack until \fIz\fP is full.
  307. .PD 0
  308. .IP _unp
  309. Unpack \fIz\fP into \fIa\fP.
  310. \fIap\fP, \fIzp\fP, \fIad\fP and \fIzd\fP are as for _pac. \fIi\fP is
  311. the index in \fIa\fP where the first element of \fIz\fP is copied into.
  312. Unpack all elements of \fIz\fP.
  313. .IP _asz
  314. Compute array size. Used for copying conformant arrays.
  315. .PD
  316. .PP
  317. .RE
  318. Debugging facilities:
  319. .RS
  320. The compiler allows you to verify assertions.
  321. It generates a call to the routine _ass to check the assertion at runtime.
  322. Another feature of the compiler is that it enables you to trace the
  323. procedure calling sequence. If the correct option is turned on, then
  324. a call to the procedure \fIprocentry\fP is generated at the start of each
  325. compiled procedure or function. Likewise, the routine \fIprocexit\fP is called
  326. just before a procedure or function exits.
  327. Default procedure \fIprocentry\fP
  328. and \fIprocexit\fP are available in this library.
  329. .IP _ass 10
  330. If \fIb\fP is zero, then change eb[0] to \fIline\fP
  331. (to give an error message with source line number) and call the error routine.
  332. .PD 0
  333. .IP procentry
  334. Print the name of the called procedure with up to seven argument words
  335. in decimal on standard output. Output must be declared in the program heading.
  336. .IP procexit
  337. Print the name of the procedure that is about to exit.
  338. Same remarks as for procentry.
  339. .PD
  340. .PP
  341. .RE
  342. Files:
  343. .RS
  344. .PP
  345. Most of the runtime routines are needed for file handling.
  346. For each file in your Pascal program a record of type file, as described
  347. above, is allocated, static if your file is declared in the outermost block,
  348. dynamic if it is declared in inner blocks.
  349. The fields in the file record are used for:
  350. .IP bufadr 10
  351. IO is buffered except for standard input and output if
  352. terminals are involved. The size of the buffer is the maximum of 512
  353. and the file element size.
  354. .PD 0
  355. .IP buflen
  356. The effective buffer length is the maximum number of file elements
  357. fitting in the buffer, multiplied by the element size.
  358. .IP size
  359. The file element size (1 or even).
  360. .IP flags
  361. Some flag bits are stored in the high byte and a magic pattern
  362. in the low byte provides detection of destroyed file
  363. information.
  364. .IP ptr
  365. Points to the file window inside the buffer.
  366. .IP count
  367. The number of bytes (the window inclusive) left in the buffer
  368. to be read or the number of free bytes (the window inclusive) for output files.
  369. .IP ufd
  370. The UNIX file descriptor for the file.
  371. .IP fname
  372. Points to the name of the file (INPUT for standard input,
  373. OUTPUT for standard output and LOCAL for local files).
  374. This field is used for generating error messages.
  375. .PD
  376. .PP
  377. The constants used by the file handling routines are:
  378. .IP WINDOW 10
  379. Bit in flags set if the window of an input file is initialized.
  380. Used to resolve the famous interactive input problem.
  381. .PD 0
  382. .IP EOFBIT
  383. Bit in flags set if end of file seen
  384. .IP ELNBIT
  385. Bit in flags set if linefeed seen
  386. .IP TXTBIT
  387. Bit in flags set for text files. Process linefeeds.
  388. .IP WRBIT
  389. Bit in flags set for output files
  390. .IP MAGIC
  391. Pattern for the low byte of flags
  392. .IP NFILES
  393. The maximum number of open files in UNIX
  394. .PD
  395. .PP
  396. .RE
  397. Prelude and postlude:
  398. .RS
  399. .PP
  400. These routines are called once for each Pascal program:
  401. .IP _ini
  402. When a file mentioned in the program heading is opened by reset or
  403. rewrite, its file pointer must be mapped onto one of the program
  404. arguments.
  405. The compiler knows how to map and therefore builds a table with
  406. a pointer to the file structure for each program argument.
  407. One of the first actions of the Pascal program is to call this procedure
  408. with this table as an argument.
  409. The global variable _extfl is used to save the address of this table.
  410. Another task of _ini is to initialize the standard input and output files.
  411. For standard output it must decide whether to buffer or not.
  412. If standard output is a terminal, then buffering is off by setting
  413. buflen to 1.
  414. Two other task of _ini are the copying of two pointers from
  415. the argument list to global memory, mainlb to _m_lb and hb to _hbase.
  416. The first contains the local base of the program body, the second
  417. contains the address of the hol containing the global variables
  418. of the program.
  419. A last task of _ini is to set the global variables _argc, _argv and _environ
  420. from args for
  421. possible reference later on.
  422. Args points to the argument count placed on the stack by the EM runtime system,
  423. see chapter 8 in [1].
  424. .PD 0
  425. .IP _hlt
  426. If the program is about to finish, the buffered files must be flushed.
  427. That is done by this procedure.
  428. .PD
  429. .PP
  430. .RE
  431. Opening and closing:
  432. .RS
  433. .PP
  434. Files in Pascal are opened for reading by reset and opened for writing by
  435. rewrite.
  436. Files to be rewritten may or may not exist already.
  437. Files not mentioned in the program heading are considered local files.
  438. The next steps must be done for reset and rewrite:
  439. .IP 1.
  440. If size is zero, then a text file must be opened with elements of
  441. size 1.
  442. .PD 0
  443. .IP 2.
  444. Find out if this file is mentioned in the program heading
  445. (scan table pointed to by _extfl).
  446. If not, then it is a local file and goto 7.
  447. .IP 3.
  448. If the file is standard input or output then return.
  449. .IP 4.
  450. If there are not enough arguments supplied, generate an error.
  451. .IP 5.
  452. If the file was already open, flush the buffer if necessary and close it.
  453. Note that reset may be used to force the buffer to be flushed.
  454. This is sometimes helpful against program or system crashes.
  455. .IP 6.
  456. If it is a reset, open the file, otherwise create it.
  457. In both cases goto 9.
  458. .IP 7.
  459. If the local file is to be written, then close it if it was open and
  460. create a new nameless file. First try to create it in /usr/tmp, then in /tmp
  461. and if both fail then try the current directory.
  462. See to it that the file is open for both reading and writing.
  463. .IP 8.
  464. If the local file is to be read
  465. and the file is opened already, then
  466. flush the buffer and seek to the beginning.
  467. Otherwise open a temporary file as described in 7.
  468. .IP 9.
  469. Initialize all the file record fields.
  470. .PD
  471. .PP
  472. The necessary procedures are:
  473. .IP _opn
  474. Reset a file
  475. .PD 0
  476. .IP _cre
  477. Rewrite a file
  478. .IP _cls
  479. Close a file. Closing of files is done for local files when the procedure
  480. in which they are declared exits.
  481. The compiler only closes local files if they are not part of a structured type.
  482. Files allocated in the heap are not closed when they are deallocated.
  483. There is an external routine \fIpclose\fP in libP(VII), that may be called
  484. explicitly to do the closing in these cases.
  485. Closing may be necessary to flush buffers or to keep the number of
  486. simultaneously opened files below NFILES.
  487. Files declared in the outermost block are automatically closed when the
  488. program terminates.
  489. .PD
  490. .PP
  491. .RE
  492. General file IO:
  493. .RS
  494. .PP
  495. These routines are provided for general file IO:
  496. .IP _put
  497. Append the file element in the window to the file and advance the
  498. window.
  499. .IP _get
  500. Advance the file window so that it points to the next element
  501. of the file.
  502. For text files (TXTBIT on) the ELNBIT in flags is set if the new character
  503. in the window is a line feed (ASCII 10) and the character is then changed
  504. into a space.
  505. Otherwise the ELNBIT is cleared.
  506. .IP _wdw
  507. Return the current pointer to the file window.
  508. .IP _eof
  509. Test if you reached end of file.
  510. Is always true for output files.
  511. .PD
  512. .PP
  513. .RE
  514. Textfile routines:
  515. .RS
  516. .PP
  517. The rest of the routines all handle text files.
  518. .IP _eln
  519. Return true if the next character on an input file is an end-of-line marker.
  520. An error occurs if eof(f) is true.
  521. .PD 0
  522. .IP _rdc
  523. Return the character currently in the window and advance the window.
  524. .IP _rdi
  525. Build an integer from the next couple of characters on the file,
  526. starting with the character in the window.
  527. The integer may be preceded by spaces (and line feeds), tabs and a sign.
  528. There must be at least one digit.
  529. The first non-digit signals the end of the integer.
  530. .IP _rdl
  531. Like _rdi, but for longs.
  532. .IP _rdr
  533. Like _rdi, but for reals. Syntax is as required for Pascal.
  534. .IP _rln
  535. Skips the current line and clears the WINDOW flag, so that the
  536. next routine requiring an initialized window knows that it has to
  537. fetch the next character first.
  538. .IP _wrc
  539. Write a character, not preceeded by spaces.
  540. .IP _wsc
  541. Write a character, left padded with spaces up to a field width
  542. of \fIw\fP.
  543. .IP _wri
  544. Write an integer, left padded with spaces up to a field width
  545. of 6.
  546. .IP _wsi
  547. Write an integer, left padded with spaces up to a field width
  548. of \fIw\fP.
  549. .IP _wrl
  550. Write a long, left padded with spaces up to a field width
  551. of 11.
  552. .IP _wsl
  553. Write a long, left padded with spaces up to a field width
  554. of \fIw\fP.
  555. .IP _wrr
  556. Write a real in scientific format,
  557. left padded with spaces up to a field width of 13.
  558. .IP _wsr
  559. Write a real in scientific format,
  560. left padded with spaces up to a field width of \fIw\fP.
  561. .IP _wrf
  562. Write a real in fixed point format, with exactly \fIndigit\fP digits
  563. behind the decimal point, the last one rounded; it is left padded up to
  564. a field width of \fIw\fP.
  565. .IP _wrs
  566. Write a string of length \fIl\fP, without additional spaces.
  567. .IP _wss
  568. Write a string of length \fIl\fP, left padded up to a field
  569. width of \fIw\fP.
  570. .IP _wrb
  571. Write a boolean, represented by "true" or "false", left padded
  572. up to a field width of 5.
  573. .IP _wsb
  574. Write a boolean, represented by "true" or "false", left padded
  575. up to a field width of \fIw\fP.
  576. .IP _wrz
  577. Write a C-type string up to the zero-byte.
  578. .IP _wsz
  579. Write a C-type string, left padded up to a field width of w.
  580. .IP _wln
  581. Write a line feed (ASCII 10).
  582. .IP _pag
  583. Write a form feed (ASCII 12).
  584. .PD
  585. .PP
  586. .RE
  587. All the routines to which calls are generated by the compiler are described above.
  588. They use the following global defined routines to do some of the work:
  589. .IP _rf 10
  590. Check input files for MAGIC and WRBIT.
  591. Initialize the window if WINDOW is cleared.
  592. .PD 0
  593. .IP _wf
  594. Check output files for MAGIC and WRBIT.
  595. .IP _incpt
  596. Advance the file window and read a new buffer if necessary.
  597. .IP _outcpt
  598. Write out the current buffer if necessary and advance the window.
  599. .IP _flush
  600. Flush the buffer if it is an output file.
  601. Append an extra line marker if EOLBIT is off.
  602. .IP _wstrin
  603. All output routines make up a string in a local buffer.
  604. They call _wstrin to output this buffer and to do the left padding.
  605. .IP _skipsp
  606. Skip spaces (and line feeds) on input files.
  607. .IP _getsig
  608. Read '+' or '-' if present.
  609. .IP _fstdig
  610. See to it that the next character is a digit. Otherwise error.
  611. .IP _nxtdig
  612. Check if the next character is a digit.
  613. .IP _getint
  614. Do the work for _rdi.
  615. .IP _ecvt
  616. Convert real into string of digits for printout in scientific notation.
  617. .IP _fcvt
  618. Convert real into string of digits for fixed point printout
  619. .IP -fif
  620. Split real into integer and fraction part
  621. .IP _fef
  622. Split real into exponent and fraction part
  623. .PD
  624. .PP
  625. The following global variables are used:
  626. .IP _lastp 10
  627. For heap management (see above).
  628. .PD 0
  629. .IP _highp
  630. For heap management (see above).
  631. .IP _extfl
  632. Used to save the argument p of _ini for later reference.
  633. .IP _hbase
  634. Used to save the argument hb of _ini for later reference.
  635. .IP _m_lb
  636. Used to store the local base of the main program.
  637. .IP _curfil
  638. Save the current file pointer, so that the
  639. error message can access the file name.
  640. .IP "_pargc, _pargv, _penvp"
  641. Used to access the arguments of the main program.
  642. .PD
  643. .SH FILES
  644. .IP /usr/em/lib/mach/*/lib/tail_pc 20
  645. The library used by ack[5] to link programs.
  646. .IP /usr/em/etc/pc_rterrors
  647. The error messages
  648. .PD
  649. .SH "SEE ALSO"
  650. .IP [1]
  651. A.S. Tanenbaum, Ed Keizer, Hans van Staveren & J.W. Stevenson
  652. "Description of a machine architecture for use of
  653. block structured languages" Informatica rapport IR-81.
  654. .PD 0
  655. .IP [2]
  656. K.Jensen & N.Wirth
  657. "PASCAL, User Manual and Report" Springer-Verlag.
  658. .IP [3]
  659. An improved version of the ISO standard proposal for the language Pascal
  660. ISO/TC97/SC5-N462, received November 1979.
  661. .IP [4]
  662. Ed Keizer, "The Amsterdam Compiler Kit reference manual".
  663. .br
  664. (try \fInroff /usr/emi/doc/pcref.doc\fP).
  665. .IP [5]
  666. ack(I), pc_pem(VI)
  667. .PD
  668. .SH DIAGNOSTICS
  669. All errors discovered by this runtime system cause an EM TRP instruction
  670. to be executed. This TRP instruction expects the error number on top
  671. of the stack. See [1] for a more extensive treatment of the subject.
  672. .PP
  673. EM allows the user to specify a trap handling routine, called whenever
  674. an EM machine trap or a language or user defined trap occurs.
  675. One of the first actions in _ini is to specify that the routine _fatal,
  676. available in this library, will handle traps.
  677. This routine is called with an error code (0..252) as argument.
  678. The file "/usr/em/etc/pc_rterrors" is opened and searched for a message
  679. corresponding with this number.
  680. If the file can not be opened, or if the error number is not recorded
  681. in the file, then the same trap is generated again, but without
  682. a user-defined trap handler, so that the low levels generate an
  683. error message.
  684. Otherwise the following information is printed
  685. on file descriptor 2:
  686. .IP -
  687. The name of the Pascal program
  688. .PD 0
  689. .IP -
  690. The name of the file pointed to by _curfil, if the error number
  691. is between 96 and 127 inclusive.
  692. .IP -
  693. The error message (or the error number if not found).
  694. .IP -
  695. The source line number if not equal to 0.
  696. .PD
  697. .PP
  698. The routine _fatal stops the program as soon as the message is printed.
  699. .PP
  700. The following error codes are used by the Pascal runtime system:
  701. .IP 64
  702. more args expected
  703. .PD 0
  704. .IP 65
  705. error in exp
  706. .IP 66
  707. error in ln
  708. .IP 67
  709. error in sqrt
  710. .IP 68
  711. assertion failed
  712. .IP 69
  713. array bound error in pack
  714. .IP 70
  715. array bound error in unpack
  716. .IP 71
  717. only positive j in \fIi mod j\fP
  718. .IP 72
  719. file not yet open
  720. .IP 73
  721. dispose error
  722. .sp
  723. .IP 96
  724. file xxx: not writable
  725. .IP 97
  726. file xxx: not readable
  727. .IP 98
  728. file xxx: end of file
  729. .IP 99
  730. file xxx: truncated
  731. .IP 100
  732. file xxx: reset error
  733. .IP 101
  734. file xxx: rewrite error
  735. .IP 102
  736. file xxx: close error
  737. .IP 103
  738. file xxx: read error
  739. .IP 104
  740. file xxx: write error
  741. .IP 105
  742. file xxx: digit expected
  743. .IP 106
  744. file xxx: non-ASCII char read
  745. .PD
  746. .PP
  747. .SH AUTHORS
  748. Johan Stevenson and Ard Verhoog, Vrije Universiteit.
  749. .SH BUGS
  750. Please report bugs to the authors.