pc_prlib.7 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  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 11
  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 'a' into a packed array 'z'. 'ap' and 'zp'
  302. are pointers to 'a' and 'z'. 'ad' and 'zd'
  303. are pointers to the descriptors of 'a' and 'z'. 'i' is
  304. the index in 'a' of the first element to be packed.
  305. Pack until 'z' is full.
  306. .PD 0
  307. .IP _unp
  308. Unpack 'z' into 'a'. 'ap', 'zp', 'ad' and 'zd' are as for _pac. 'i' is
  309. the index in 'a' where the first element of 'z' is copied into.
  310. Unpack all elements of 'z'.
  311. .IP _asz
  312. Compute array size. Used for copying conformant arrays.
  313. .PD
  314. .PP
  315. .RE
  316. Debugging facilities:
  317. .RS
  318. The compiler allows you to verify assertions.
  319. It generates a call to the routine _ass to check the assertion at runtime.
  320. Another feature of the compiler is that it enables you to trace the
  321. procedure calling sequence. If the correct option is turned on, then
  322. a call to the procedure 'procentry' is generated at the start of each
  323. compiled procedure or function. Likewise, the routine 'procexit' is called
  324. just before a procedure or function exits.
  325. Default procedure 'procentry' and 'procexit' are available in this library.
  326. .IP _ass 10
  327. If 'b' is zero, then change eb[0] to 'line'
  328. (to give an error message with source line number) and call the error routine.
  329. .PD 0
  330. .IP procentry
  331. Print the name of the called procedure with up to seven argument words
  332. in decimal on standard output. Output must be declared in the program heading.
  333. .IP procexit
  334. Print the name of the procedure that is about to exit.
  335. Same remarks as for procentry.
  336. .PD
  337. .PP
  338. .RE
  339. Files:
  340. .RS
  341. .PP
  342. Most of the runtime routines are needed for file handling.
  343. For each file in your Pascal program a record of type file, as described
  344. above, is allocated, static if your file is declared in the outermost block,
  345. dynamic if it is declared in inner blocks.
  346. The fields in the file record are used for:
  347. .IP bufadr 10
  348. IO is buffered except for standard input and output if
  349. terminals are involved. The size of the buffer is the maximum of 512
  350. and the file element size.
  351. .PD 0
  352. .IP buflen
  353. The effective buffer length is the maximum number of file elements
  354. fitting in the buffer, multiplied by the element size.
  355. .IP size
  356. The file element size (1 or even).
  357. .IP flags
  358. Some flag bits are stored in the high byte and a magic pattern
  359. in the low byte provides detection of destroyed file
  360. information.
  361. .IP ptr
  362. Points to the file window inside the buffer.
  363. .IP count
  364. The number of bytes (the window inclusive) left in the buffer
  365. to be read or the number of free bytes (the window inclusive) for output files.
  366. .IP ufd
  367. The UNIX file descriptor for the file.
  368. .IP fname
  369. Points to the name of the file (INPUT for standard input,
  370. OUTPUT for standard output and LOCAL for local files).
  371. This field is used for generating error messages.
  372. .PD
  373. .PP
  374. The constants used by the file handling routines are:
  375. .IP WINDOW 10
  376. Bit in flags set if the window of an input file is initialized.
  377. Used to resolve the famous interactive input problem.
  378. .PD 0
  379. .IP EOFBIT
  380. Bit in flags set if end of file seen
  381. .IP ELNBIT
  382. Bit in flags set if linefeed seen
  383. .IP TXTBIT
  384. Bit in flags set for text files. Process linefeeds.
  385. .IP WRBIT
  386. Bit in flags set for output files
  387. .IP MAGIC
  388. Pattern for the low byte of flags
  389. .IP NFILES
  390. The maximum number of open files in UNIX
  391. .PD
  392. .PP
  393. .RE
  394. Prelude and postlude:
  395. .RS
  396. .PP
  397. These routines are called once for each Pascal program:
  398. .IP _ini
  399. When a file mentioned in the program heading is opened by reset or
  400. rewrite, its file pointer must be mapped onto one of the program
  401. arguments.
  402. The compiler knows how to map and therefore builds a table with
  403. a pointer to the file structure for each program argument.
  404. One of the first actions of the Pascal program is to call this procedure
  405. with this table as an argument.
  406. The global variable _extfl is used to save the address of this table.
  407. Another task of _ini is to initialize the standard input and output files.
  408. For standard output it must decide whether to buffer or not.
  409. If standard output is a terminal, then buffering is off by setting
  410. buflen to 1.
  411. Two other task of _ini are the copying of two pointers from
  412. the argument list to global memory, mainlb to _m_lb and hb to _hbase.
  413. The first contains the local base of the program body, the second
  414. contains the address of the hol containing the global variables
  415. of the program.
  416. A last task of _ini is to set the global variables _argc, _argv and _environ
  417. from args for
  418. possible reference later on.
  419. Args points to the argument count placed on the stack by the EM runtime system,
  420. see chapter 8 in [1].
  421. .PD 0
  422. .IP _hlt
  423. If the program is about to finish, the buffered files must be flushed.
  424. That is done by this procedure.
  425. .PD
  426. .PP
  427. .RE
  428. Opening and closing:
  429. .RS
  430. .PP
  431. Files in Pascal are opened for reading by reset and opened for writing by
  432. rewrite.
  433. Files to be rewritten may or may not exist already.
  434. Files not mentioned in the program heading are considered local files.
  435. The next steps must be done for reset and rewrite:
  436. .IP 1.
  437. If size is zero, then a text file must be opened with elements of
  438. size 1.
  439. .PD 0
  440. .IP 2.
  441. Find out if this file is mentioned in the program heading
  442. (scan table pointed to by _extfl).
  443. If not, then it is a local file and goto 7.
  444. .IP 3.
  445. If the file is standard input or output then return.
  446. .IP 4.
  447. If there are not enough arguments supplied, generate an error.
  448. .IP 5.
  449. If the file was already open, flush the buffer if necessary and close it.
  450. Note that reset may be used to force the buffer to be flushed.
  451. This is sometimes helpful against program or system crashes.
  452. .IP 6.
  453. If it is a reset, open the file, otherwise create it.
  454. In both cases goto 9.
  455. .IP 7.
  456. If the local file is to be written, then close it if it was open and
  457. create a new nameless file. First try to create it in /usr/tmp, then in /tmp
  458. and if both fail then try the current directory.
  459. See to it that the file is open for both reading and writing.
  460. .IP 8.
  461. If the local file is to be read
  462. and the file is opened already, then
  463. flush the buffer and seek to the beginning.
  464. Otherwise open a temporary file as described in 7.
  465. .IP 9.
  466. Initialize all the file record fields.
  467. .PD
  468. .PP
  469. The necessary procedures are:
  470. .IP _opn
  471. Reset a file
  472. .PD 0
  473. .IP _cre
  474. Rewrite a file
  475. .IP _cls
  476. Close a file. Closing of files is done for local files when the procedure
  477. in which they are declared exits.
  478. The compiler only closes local files if they are not part of a structured type.
  479. Files allocated in the heap are not closed when they are deallocated.
  480. There is an external routine 'pclose' in libP(VII), that may be called
  481. explicitly to do the closing in these cases.
  482. Closing may be necessary to flush buffers or to keep the number of
  483. simultaneously opened files below NFILES.
  484. Files declared in the outermost block are automatically closed when the
  485. program terminates.
  486. .PD
  487. .PP
  488. .RE
  489. General file IO:
  490. .RS
  491. .PP
  492. These routines are provided for general file IO:
  493. .IP _put
  494. Append the file element in the window to the file and advance the
  495. window.
  496. .IP _get
  497. Advance the file window so that it points to the next element
  498. of the file.
  499. For text files (TXTBIT on) the ELNBIT in flags is set if the new character
  500. in the window is a line feed (ASCII 10) and the character is then changed
  501. into a space.
  502. Otherwise the ELNBIT is cleared.
  503. .IP _wdw
  504. Return the current pointer to the file window.
  505. .IP _eof
  506. Test if you reached end of file.
  507. Is always true for output files.
  508. .PD
  509. .PP
  510. .RE
  511. Textfile routines:
  512. .RS
  513. .PP
  514. The rest of the routines all handle text files.
  515. .IP _eln
  516. Return true if the next character on an input file is an end-of-line marker.
  517. An error occurs if eof(f) is true.
  518. .PD 0
  519. .IP _rdc
  520. Return the character currently in the window and advance the window.
  521. .IP _rdi
  522. Build an integer from the next couple of characters on the file,
  523. starting with the character in the window.
  524. The integer may be preceded by spaces (and line feeds), tabs and a sign.
  525. There must be at least one digit.
  526. The first non-digit signals the end of the integer.
  527. .IP _rdl
  528. Like _rdi, but for longs.
  529. .IP _rdr
  530. Like _rdi, but for reals. Syntax is as required for Pascal.
  531. .IP _rln
  532. Skips the current line and clears the WINDOW flag, so that the
  533. next routine requiring an initialized window knows that it has to
  534. fetch the next character first.
  535. .IP _wrc
  536. Write a character, not preceeded by spaces.
  537. .IP _wsc
  538. Write a character, left padded with spaces up to a field width
  539. of 'w'.
  540. .IP _wri
  541. Write an integer, left padded with spaces up to a field width
  542. of 6.
  543. .IP _wsi
  544. Write an integer, left padded with spaces up to a field width
  545. of 'w'.
  546. .IP _wrl
  547. Write a long, left padded with spaces up to a field width
  548. of 11.
  549. .IP _wsl
  550. Write a long, left padded with spaces up to a field width
  551. of 'w'.
  552. .IP _wrr
  553. Write a real in scientific format,
  554. left padded with spaces up to a field width of 13.
  555. .IP _wsr
  556. Write a real in scientific format,
  557. left padded with spaces up to a field width of 'w'.
  558. .IP _wrf
  559. Write a real in fixed point format, with exactly 'ndigit' digits
  560. behind the decimal point, the last one rounded; it is left padded up to
  561. a field width of 'w'.
  562. .IP _wrs
  563. Write a string of length 'l', without additional spaces.
  564. .IP _wss
  565. Write a string of length 'l', left padded up to a field
  566. width of 'w'.
  567. .IP _wrb
  568. Write a boolean, represented by "true" or "false", left padded
  569. up to a field width of 5.
  570. .IP _wsb
  571. Write a boolean, represented by "true" or "false", left padded
  572. up to a field width of 'w'.
  573. .IP _wrz
  574. Write a C-type string up to the zero-byte.
  575. .IP _wsz
  576. Write a C-type string, left padded up to a field width of w.
  577. .IP _wln
  578. Write a line feed (ASCII 10).
  579. .IP _pag
  580. Write a form feed (ASCII 12).
  581. .PD
  582. .PP
  583. .RE
  584. All the routines to which calls are generated by the compiler are described above.
  585. They use the following global defined routines to do some of the work:
  586. .IP _rf 10
  587. Check input files for MAGIC and WRBIT.
  588. Initialize the window if WINDOW is cleared.
  589. .PD 0
  590. .IP _wf
  591. Check output files for MAGIC and WRBIT.
  592. .IP _incpt
  593. Advance the file window and read a new buffer if necessary.
  594. .IP _outcpt
  595. Write out the current buffer if necessary and advance the window.
  596. .IP _flush
  597. Flush the buffer if it is an output file.
  598. Append an extra line marker if EOLBIT is off.
  599. .IP _wstrin
  600. All output routines make up a string in a local buffer.
  601. They call _wstrin to output this buffer and to do the left padding.
  602. .IP _skipsp
  603. Skip spaces (and line feeds) on input files.
  604. .IP _getsig
  605. Read '+' or '-' if present.
  606. .IP _fstdig
  607. See to it that the next character is a digit. Otherwise error.
  608. .IP _nxtdig
  609. Check if the next character is a digit.
  610. .IP _getint
  611. Do the work for _rdi.
  612. .IP _ecvt
  613. Convert real into string of digits for printout in scientific notation.
  614. .IP _fcvt
  615. Convert real into string of digits for fixed point printout
  616. .IP -fif
  617. Split real into integer and fraction part
  618. .IP _fef
  619. Split real into exponent and fraction part
  620. .PD
  621. .PP
  622. The following global variables are used:
  623. .IP _lastp 10
  624. For heap management (see above).
  625. .PD 0
  626. .IP _highp
  627. For heap management (see above).
  628. .IP _extfl
  629. Used to save the argument p of _ini for later reference.
  630. .IP _hbase
  631. Used to save the argument hb of _ini for later reference.
  632. .IP _m_lb
  633. Used to store the local base of the main program.
  634. .IP _curfil
  635. Save the current file pointer, so that the
  636. error message can access the file name.
  637. .IP "_pargc, _pargv, _penvp"
  638. Used to access the arguments of the main program.
  639. .PD
  640. .SH FILES
  641. .IP /usr/em/lib/mach/*/lib/tail_pc 20
  642. The library used by ack[5] to link programs.
  643. .IP /usr/em/etc/pc_rterrors
  644. The error messages
  645. .PD
  646. .SH "SEE ALSO"
  647. .IP [1]
  648. A.S. Tanenbaum, Ed Keizer, Hans van Staveren & J.W. Stevenson
  649. "Description of a machine architecture for use of
  650. block structured languages" Informatica rapport IR-81.
  651. .PD 0
  652. .IP [2]
  653. K.Jensen & N.Wirth
  654. "PASCAL, User Manual and Report" Springer-Verlag.
  655. .IP [3]
  656. An improved version of the ISO standard proposal for the language Pascal
  657. ISO/TC97/SC5-N462, received November 1979.
  658. .IP [4]
  659. Ed Keizer, "The Amsterdam Compiler Kit reference manual".
  660. .br
  661. (try 'nroff /usr/emi/doc/pcref.doc').
  662. .IP [5]
  663. ack(I), pc_pem(VI)
  664. .PD
  665. .SH DIAGNOSTICS
  666. All errors discovered by this runtime system cause an EM TRP instruction
  667. to be executed. This TRP instruction expects the error number on top
  668. of the stack. See [1] for a more extensive treatment of the subject.
  669. .PP
  670. EM allows the user to specify a trap handling routine, called whenever
  671. an EM machine trap or a language or user defined trap occurs.
  672. One of the first actions in _ini is to specify that the routine _fatal,
  673. available in this library, will handle traps.
  674. This routine is called with an error code (0..252) as argument.
  675. The file "/usr/em/etc/pc_rterrors" is opened and searched for a message
  676. corresponding with this number.
  677. If the file can not be opened, or if the error number is not recorded
  678. in the file, then the same trap is generated again, but without
  679. a user-defined trap handler, so that the low levels generate an
  680. error message.
  681. Otherwise the following information is printed
  682. on file descriptor 2:
  683. .IP -
  684. The name of the Pascal program
  685. .PD 0
  686. .IP -
  687. The name of the file pointed to by _curfil, if the error number
  688. is between 96 and 127 inclusive.
  689. .IP -
  690. The error message (or the error number if not found).
  691. .IP -
  692. The source line number if not equal to 0.
  693. .PD
  694. .PP
  695. The routine _fatal stops the program as soon as the message is printed.
  696. .PP
  697. The following error codes are used by the Pascal runtime system:
  698. .IP 64
  699. more args expected
  700. .PD 0
  701. .IP 65
  702. error in exp
  703. .IP 66
  704. error in ln
  705. .IP 67
  706. error in sqrt
  707. .IP 68
  708. assertion failed
  709. .IP 69
  710. array bound error in pack
  711. .IP 70
  712. array bound error in unpack
  713. .IP 71
  714. only positive j in 'i mod j'
  715. .IP 72
  716. file not yet open
  717. .IP 73
  718. dispose error
  719. .sp
  720. .IP 96
  721. file xxx: not writable
  722. .IP 97
  723. file xxx: not readable
  724. .IP 98
  725. file xxx: end of file
  726. .IP 99
  727. file xxx: truncated
  728. .IP 100
  729. file xxx: reset error
  730. .IP 101
  731. file xxx: rewrite error
  732. .IP 102
  733. file xxx: close error
  734. .IP 103
  735. file xxx: read error
  736. .IP 104
  737. file xxx: write error
  738. .IP 105
  739. file xxx: digit expected
  740. .IP 106
  741. file xxx: non-ASCII char read
  742. .PD
  743. .PP
  744. .SH AUTHORS
  745. Johan Stevenson and Ard Verhoog, Vrije Universiteit.
  746. .SH BUGS
  747. Please report bugs to the authors.