 
// File LIBHDRFULL
 
// Version: E1.12
 
// Annotated version of BCPL library header file for ICL 2900 under EMAS
 
// Copyright R.D. Eager   University of Kent   MCMLXXXIII
 
// History:
//  E1.0   - Initial version
//  E1.1   - Addition of 'changesize' and 'discard.id' functions.
//  E1.2   - Renamed to LIBHDRFULL; compressed version created as LIBHDR.
//  E1.3   - Removal of 'settrim'; addition of 'writeseg' and 'console'.
//  E1.4   - Removal of BCnn series of error codes
//  E1.5   - Addition of 'endobey' routine.
//  E1.6   - Addition of 'stackdirection' constant.
//  E1.7   - Addition of synonym 'timeofday' for 'tod'.
//  E1.8   - Addition of manifest constants 'firstfreeglobal' and 'minint'.
//  E1.9   - Addition of 'muldiv' function and 'result2' global.
//  E1.10  - Addition of SEEK function.
//  E1.11  - Correction to specification of 'changesize' (one parameter only).
//  E1.12  - Addition of 'getvec' function and 'freevec' routine.
 
 
GLOBAL $(glob
 
                        //      Convention for describing file manipulation
                        //      is:-
                        //      D = ddname, a BCPL string holding a filename
                        //      C = an EMAS channel number (in the range 1-80)
                        //      S = stream pointer (strp), a positive value used by the library
                        //      E = error code, a negative value
                        //      COS = current output stream
                        //      CIS = current input stream
                        //      [  ] = type of arguments and result
                        //      (  ) = environment used by call
 
                        // *** Global 0 is reserved for system use! ***
 
 
start           : 1     // rt  entry point
comreg          : 2     // v   word address of subsystem COMREG array
ssmessage       : 3     // fn  returns BCPL address of appropriate subsystem error message [E,D -> message]
stop            : 4     // rt  terminates execution, setting RETURN CODE to value of parameter
dirmessage      : 5     // fn  returns BCPL address of appropriate Director error message [E -> message]
profile         : 6     // v   controls profile counting
globalsize      : 7     // v   number of globals
stackbase       : 8     // v   byte address of base of stack (LNB of START)
close           : 9     // rt  closes all open streams; unsets selections
 
findinput       :10     // fn  creates input stream from file/device [D -> S,E]
findoutput      :11     // fn  creates output stream from file/device [D -> S,E]
selectinput     :14     // fn  selects input stream as current [S -> 0,E]
selectoutput    :15     // fn  selects output stream as current [S -> 0,E]
sysin           :16     // v   default input stream pointer
sysout          :17     // v   default output stream pointer
endread         :18     // fn  terminates current input stream; unsets selection [(CIS) -> 0,E]
endwrite        :19     // fn  terminates current output stream; unsets selection [(COS) -> 0,E]
journal         :20     // v   output stream pointer for terminal or job journal
 
writeseg        :21     // fn  writes a record to current output [(COS) vec,vecsize -> 0,E]
rdch            :22     // fn  reads a character from current input [(CIS) -> CH,E]
wrch            :23     // fn  writes a character to current output [(COS) CH -> 0,E]
input           :24     // fn  returns currently selected input stream pointer [(CIS) -> S,E]
output          :25     // fn  returns currently selected output stream pointer [(COS) -> S,E]
readrec         :26     // fn  reads a record from current input [(CIS) vec,vecsize -> R,E]
writerec        :27     // fn  writes a record + newline to current output [(COS) vec,vecsize -> 0,E]
prompt          :28     // rt  sets current input prompt [prompt]
unrdch          :29     // rt  'unreads' the last character from current input stream [(CIS)]
 
foreground      :30     // v   'true' if running in a foreground job, else 'false'
param           :31     // v   parameter passed to program as a BCPL string
username        :32     // v   string
jobname         :33     // v   string (null if not running in background)
result2         :34     // v   auxiliary result code

date            :35     // fn  returns date as string [vec 2 -> vecwithdate]
tod             :36     // fn  returns time of day as string [vec 1 -> vecwithtime]
timeofday       :36     // fn  returns time of day as string [vec 1 -> vecwithtime] (synonym)

getconad        :38     // fn  returns connect address of file associated with strp [S -> conad,E]
 
muldiv          :39     // fn  performs scaled arithmetic [a,b,c -> a*b/c]
renamefile      :40     // fn  renames a file [oldname,newname -> 0,E]
deletefile      :41     // fn  deletes a file [name -> 0,E]
seek            :42     // fn  positions a file [(CIS) -> 0,E]
getvec          :48     // fn  allocates store [size -> address, 0]
freevec         :49     // rt  frees store [address]
 
level           :51     // fn  returns LNB for use by 'longjump'
longjump        :52     // rt  causes non-local jump
aptovec         :53     // fn  good old 'aptovec' [fn,vecsize -> fnresult]
astoeb          :54     // v   address of ASCII to EBCDIC translation table
ebtoas          :55     // v   address of EBCDIC to ASCII translation table
packstring      :56     // fn  packs up string from vector [vec,string -> offsetoflastwordused]
unpackstring    :57     // rt  unpacks string into vector [string,vec]
getbyte         :58     // fn  takes 2 arguments, 's' and 'n'; returns character 'n' of string 's'
putbyte         :59     // rt  takes 3 arguments, 's', 'n' and 'ch'; it replaces the 'n'th character of string 's' with 'ch'
 
rewind          :60     // fn  repositions currently selected input to start [(CIS) -> S,E]
endtoinput      :61     // fn  closes currently selected output; reopens for input [(COS) -> S,E]
changesize      :62     // fn  changes size of file as specified [size -> 0,E]
 
newpage         :67     // rt  prints a formfeed on current output
writeo          :68     // rt  same as writeoct(number,11)
writeh          :69     // rt  same as writehex(number,8)
 
newline         :70     // rt  prints a newline on current output
writen          :71     // rt  writes a decimal number (minimum width)
writed          :72     // rt  takes 2 arguments, 'n' and 'd'; writes 'n' as a decimal number, width 'd'
writehex        :73     // rt  similar to 'writed', but writes a hex number
writeoct        :74     // rt  similar to 'writed', but writes an octal number
writes          :75     // rt  write a string
writef          :76     // rt  general purpose format driven o/p rtn
readn           :77     // fn  reads a decimal number [ -> number]
terminator      :78     // v   terminating char from 'readn' or 'readnumber'
readnumber      :79     // fn  reads a number in given radix [radix -> number]
 
translate       :80     // rt  performs table translation function [byteaddressofstring,length,table]
validate        :81     // fn  validates access permission [addr -> N]
move            :82     // rt  moves bytes in store [length,byteaddressofsource,byteaddressofdestination]
interrupt       :84     // fn  obtains last multi-character INT: message [vec3 -> vec3]

endobey         :87     // rt  force end-of-file on current OBEY input
console         :88     // rt  perform terminal operation [entry, lvalue1, lvalue2]
stackvecs       :89     // v   controls use of on-stack or temporary file workspace by 'aptovec'
 
backtrace       :90     // rt  gives trace of last few function entries
postmortem      :91     // rt  unwinds the BCPL stack and prints it
mapglobals      :92     // rt  prints contents of global vector within specified limits
mapstore        :93     // rt  prints routine names, addresses and profile counts
abort           :94     // rt  calls G90, G91, G92, G93, G95, G96
userpostmortem  :95     // rt  user-supplied postmortem routine
mapstatics      :96     // rt  prints values of STATIC variables

discard.id      :97     // rt  re-allow contingencies [-> 0,E]
incont          :98     // v   contingency re-entrancy flag
contingency     :99     // rt  entered by run-time system when a contingency occurs
 
 
 
$)glob
 
 
MANIFEST        $(man           // System Manifest Constants
 
endstreamch     = -1
bytesperword    = 4
bitsperword     = 32
maxint          = 2147483647
minint          = -2147483648
maxstrlength    = 255
firstfreeglobal = 100
stackdirection  = +1
 
$)man
 
// End of file LIBHDRFULL
 
