1 //  Declarations for common BCPL library routines for Multics.
  2 //  Last modified on 09/05/73 at 03:57:35 by R F Mabee.
  3 //  Largely rewritten for 6180 Multics; installed in June 1973 by R F Mabee.
  4 //  First version installed in September 1971 by R F Mabee.
  5 
  6 external            //  Functions to perform mathematical operations not provided by the language.
  7      $(   MaxI = "bcpl_arithmetic_$MaxI"                    //  i := MaxI (j, k)
  8           MaxR = "bcpl_arithmetic_$MaxR"                    //  x := MaxR (y, z)
  9           MinI = "bcpl_arithmetic_$MinI"                    //  i := MinI (j, k)
 10           MinR = "bcpl_arithmetic_$MinR"                    //  x := MinR (y, z)
 11           AbsI = "bcpl_arithmetic_$AbsI"                    //  i := AbsI (j)
 12           AbsR = "bcpl_arithmetic_$AbsR"                    //  x := AbsR (y)
 13           SquareRoot = "bcpl_arithmetic_$SquareRoot"        //  x := SquareRoot (y)
 14           IpowerI = "bcpl_arithmetic_$IpowerI"              //  i := IpowerI (j, k)
 15           RpowerI = "bcpl_arithmetic_$RpowerI"              //  x := RpowerI (y, k)
 16           RpowerR = "bcpl_arithmetic_$RpowerR"              //  x := RpowerR (y, z)
 17           RandomI = "bcpl_arithmetic_$RandomI"              //  i := RandomI ()
 18           RandomR = "bcpl_arithmetic_$RandomR"              //  x := RandomR ()
 19           Logarithm = "bcpl_arithmetic_$Logarithm"          //  x := Logarithm (y)
 20           Exponential = "bcpl_arithmetic_$Exponential"      //  x := Exponential (y)
 21      $)
 22 external            //  Routines to manipulate strings.  Caller must supply space to hold string results.
 23      $(   Packstring = "bcpl_machine_code_$Packstring"      //  Packstring (Unpacked, Space)
 24           Unpackstring = "bcpl_machine_code_$Unpackstring"  //  Unpackstring (String, Space)
 25           CopyString = "bcpl_strings_$CopyString"           //  CopyString (String, Space)
 26           EqualString = "bcpl_strings_$EqualString"         //  if EqualString (StringA, StringB) do ...
 27           CompareStrings = "bcpl_strings_$CompareStrings"   //  CollatingOrder := CompareStrings (StringA, StringB)
 28           Concatenate = "bcpl_strings_$Concatenate"         //  s := Concatenate (Space, Maxlen, StrA, StrB, ...)
 29           Substr = "bcpl_strings_$Substr"                   //  s := Substr (Space, String, Index, [Length])
 30           Subch = "bcpl_machine_code_$Subch"                //  Ch := Subch (String, Index)
 31           Length = "bcpl_strings_$Length"                   //  Len := Length (String)
 32           SetLength = "bcpl_strings_$SetLength"             //  SetLength (String, Len)
 33           LengthInWords = "bcpl_strings_$LengthInWords"     //  Len := LengthInWords (String)
 34           Index = "bcpl_strings_$Index"                     //  i := Index (StringA, StringB)
 35           IndexCh = "bcpl_strings_$IndexCh"                 //  i := IndexCh (String, Ch)
 36           StringToChar = "bcpl_strings_$StringToChar"       //  Char := StringToChar (String)
 37           CharToString = "bcpl_strings_$CharToString"       //  String := CharToString (Char, Space)
 38           MakePl1String = "bcpl_strings_$MakePl1String"     //  Pl1String := MakePl1String (BcplString, Space, Len)
 39           MakeBcplString = "bcpl_strings_$MakeBcplString"   //  s := MakeBcplString (Pl1String, Len, Space)
 40      $)
 41 external            //  Functions to convert values from one representation to another.
 42      $(   RtoI = "bcpl_machine_code_$RtoI"                  //  i := RtoI (x)
 43           ItoR = "bcpl_machine_code_$ItoR"                  //  x := ItoR (i)
 44           ConvertStoN = "bcpl_conversions_$ConvertStoN"     //  r := ConvertStoN (String, [Base])
 45           ConvertNtoS = "bcpl_conversions_$ConvertNtoS"     //  String := ConvertNtoS (i, Space, [Base, [Digits]])
 46           ConvertFtoS = "bcpl_conversions_$ConvertFtoS"     //  String := ConvertFtoS (x, Space, [Digits])
 47           RemoveEscapes = "bcpl_conversions_$RemoveEscapes" //  s := RemoveEscapes (String, Space)
 48           InsertEscapes = "bcpl_conversions_$InsertEscapes" //  s := InsertEscapes (String, Space)
 49           FormDate = "bcpl_conversions_$FormDate"           //  FormDate (Seconds, Space10, GMTsw)
 50      $)
 51 external            //  Miscellaneous routines to extend the power of the language.
 52      $(   Longjump = "bcpl_machine_code_$Longjump"          //  Longjump (Label, Psaved)
 53           Level = "bcpl_machine_code_$Level"                //  Psaved := Level ()
 54           Bcall = "bcpl_machine_code_$Bcall"                //  r := Bcall (F, n, (list A1, A2, .. An))
 55           Pl1Call = "bcpl_machine_code_$Pl1Call"            //  Pl1Call (Routine, ArglistAddress)
 56           Move = "bcpl_machine_code_$Move"                  //  Move (ToPtr, FromPtr, WordCount)
 57           MoveBits = "bcpl_machine_code_$MoveBits"          //  MoveBits (ToPtr, ToBit, FromPtr, FromBit, BitCount)
 58           ScanChar = "bcpl_machine_code_$ScanChar"          //  Offset := ScanChar (Ptr, Offset, Length, Ch)
 59           NumbArgs = "bcpl_machine_code_$NumbArgs"          //  Nargs := NumbArgs ()
 60           NewvecInit = "bcpl_filesys_lib_$NewvecInit"       //  NewvecInit (Space, Size)
 61           NewvecCleanup = "bcpl_filesys_lib_$NewvecCleanup" //  NewvecCleanup ()
 62           Newvec = "bcpl_filesys_lib_$Newvec"               //  v := Newvec (Size - 1)
 63           Freevec = "bcpl_filesys_lib_$Freevec"             //  Freevec (v)
 64           Allocate = "bcpl_filesys_lib_$Allocate"           //  v := Allocate (Size)
 65           Findadr = "bcpl_filesys_lib_$Findadr"             //  Ptr := Findadr (Name)
 66      $)
 67 external            //  BCPL stream I/O routines.
 68      $(   Open = "bcpl_stream_io_$Open"                     //  Stream := Open (Options, Name, [Length, Delimiter])
 69           Close = "bcpl_stream_io_$Close"                   //  Close (StreamA, StreamB, ...)
 70           Readch = "bcpl_machine_code_$Readch"              //  Readch (Stream, lv Ch)
 71           Writech = "bcpl_machine_code_$Writech"            //  Writech (Stream, Ch)
 72           WriteS = "bcpl_stream_io_$WriteS"                 //  WriteS (Stream, String)
 73           WriteN = "bcpl_stream_io_$WriteN"                 //  WriteN (Stream, i)
 74           Format = "bcpl_stream_io_$Format"                 //  Format (Stream, ControlString, A1, A2, ...)
 75           FormatString = "bcpl_stream_io_$FormatString"     //  FormatString (Space, MaxLen, ControlString, A1, A2, ...)
 76           Writeout = "bcpl_stream_io_$Writeout"             //  Writeout (Stream)
 77           Flushinput = "bcpl_stream_io_$Flushinput"         //  Flushinput (Stream)
 78           ResetStream = "bcpl_stream_io_$ResetStream"       //  ResetStream (Stream, Offset)
 79           StreamOffset = "bcpl_stream_io_$StreamOffset"     //  Offset := StreamOffset (Stream)
 80           StreamLength = "bcpl_stream_io_$StreamLength"     //  Length := StreamLength (Stream)
 81           StreamPointer = "bcpl_stream_io_$StreamPointer"   //  Ptr := StreamPointer (Stream)
 82      $)
 83 external            //  Interface to Multics file system.  Note: Dirname and Entryname are PL/I strings.
 84      $(   ExpandPathname = "bcpl_filesys_lib_$ExpandPathname" // s := ExpandPathname (RelativePath, Space)
 85           JoinPathname = "bcpl_filesys_lib_$JoinPathname"   //  s := JoinPathname (Dirname, Entryname, Space)
 86           SplitPathname = "bcpl_filesys_lib_$SplitPathname" //  SplitPathname (AbsolutePath, Dirname, Entryname)
 87           FindSegment = "bcpl_filesys_lib_$FindSegment"     //  Ptr := FindSegment (Pathname, lv BitCount)
 88           MakeSegment = "bcpl_filesys_lib_$MakeSegment"     //  Ptr := MakeSegment (Pathname)
 89           GetPathname = "bcpl_filesys_lib_$GetPathname"     //  s := GetPathname (Pointer, Space)
 90           MakeTempSeg = "bcpl_filesys_lib_$MakeTempSeg"     //  Ptr := MakeTempSeg (Number, Purpose)
 91           DeleteTempSeg = "bcpl_filesys_lib_$DeleteTempSeg" //  DeleteTempSeg (Number, Purpose)
 92           Terminate = "bcpl_filesys_lib_$Terminate"         //  Terminate (Pointer)
 93           SetBitCount = "bcpl_filesys_lib_$SetBitCount"     //  SetBitCount (Pointer, BitCount)
 94           RawClockTime = "bcpl_machine_code_$RawClockTime"  //  RawTime := RawClockTime (Space2)
 95           TimeToSeconds = "bcpl_machine_code_$TimeToSeconds" // TimeNow := TimeToSeconds (RawTime)
 96           GetCpuUsage = "bcpl_filesys_lib_$GetCpuUsage"     //  MicrosecondsUsed := GetCpuUsage ()
 97      $)
 98 external            //  Interface to Multics command level features.
 99      $(   Pl1NumbArgs = "bcpl_command_lib_$Pl1NumbArgs"     //  Nargs := Pl1NumbArgs ()
100           Pl1ArgPtr = "bcpl_command_lib_$Pl1ArgPtr"         //  Ptr := Pl1ArgPtr (ArgIndex)
101           Pl1Descriptor = "bcpl_command_lib_$Pl1Descriptor" //  D := Pl1Descriptor (ArgIndex)
102           Pl1ArgString = "bcpl_command_lib_$Pl1ArgString"   //  s := Pl1ArgString (ArgIndex, Space, [MaxLen])
103           Pl1ReturnString = "bcpl_command_lib_$Pl1ReturnString" // Pl1ReturnString (String)
104           ConcatenateArgs = "bcpl_command_lib_$ConcatenateArgs" // s := ConcatenateArgs (FirstIndex, Space, MaxLen)
105           OptionParse = "bcpl_command_lib_$OptionParse"     //  OptionParse (GetNextCommandArg, Nopts, OptionsList,
106           GetNextCommandArg = "bcpl_command_lib_$GetNextCommandArg"   //        PointersList, FlagsList, PutName)
107           Complain = "bcpl_command_lib_$Complain"           //  Complain (ControlString, [A1, A2, A3])
108           BCPLaddr = "bcpl_machine_code_$BCPLaddr"          //  Pointer := BCPLaddr (ITSaddress)
109           ITS = "bcpl_machine_code_$ITS"                    //  ITSaddress := ITS (Pointer, Space, [BitOffset])
110           SetOverflowMask = "bcpl_machine_code_$SetOverflowMask" // SetOverflowMask (true -> Inhibit, Enable)
111           SetHandler = "bcpl_command_lib_$SetHandler"       //  SetHandler (Name, Handler, Space16)
112           RevertHandler = "bcpl_command_lib_$RevertHandler" //  RevertHandler (Name)
113      $)
114 
115 global              //  Library currently reserves all cells below 60 and may expand up to 99.
116      $(   OUTPUT : 32; INPUT : 33
117           MONITOR : 34; CONSOLE : 35
118           Ch : 36
119           ProgramID : 37                //  Must be set to name of program before calling Complain or MakeTempSeg.
120           Errcode : 38; IOstatus : 39   //  Used by Complain; set by some library routines.
121           ArgIndex : 40                 //  Used by GetNextCommandArg.
122      $)
123 
124 manifest            //  Description of object machine, etc.
125      $(   Machine = 6180
126           WordSize = 36
127           ByteSize = 9                  //  Bits per character in strings.
128           CountSize = 18                //  Bits for string length field.
129           Left = 18; Right = $8777777
130           Endofstreamch = $87777
131           Null = $8007777000001         //  Multics uses this for empty pointer.
132      $)
133 manifest            //  These are the options referred to in the declaration of Open.
134      $(   Pointer = 1; Console = 2; StreamName = 3          //  Type.  Specify exactly one.
135           PathName = 4; EntryName = 5; SearchName = 6
136           Read = 16; Write = 32; Append = 48                //  Direction.  Logor into Type.
137           MultiSegmentFile = 128                            //  May be logor'ed into above.
138      $)
139 manifest            //  These are the flags that appear in the list given to OptionParse.
140      $(   OptNegatable = 1                                  //  Logor any combination of these values.
141           OptNegate = 2
142           OptGetNext = 4
143           OptConvert = 8
144           OptCallOut = 16
145      $)