Jaap's Psion II Page

System services for the LZ


Part 1:
  Allocator cells and their system services.
    AL$FREE AL$GRAB AL$GROW AL$REPL

    AL$SHNK AL$SIZE AL$ZERO
  Hardware services
    BT$NMDN BT$NMEN BT$NOF BT$NON

    BT$PPRG BT$SWOF
  Sound services
    BZ$ALRM BZ$BELL BZ$TONE
  Display services
    DP$EMIT DP$PRNT DP$REST DP$SAVE
    DP$STAT DP$VIEW DP$WRDY
  Device services
    DV$BOOT DV$CLER DV$LKUP DV$LOAD DV$VECT
  Editor services
    ED$EDIT ED$EPOS ED$VIEW
  Error services
    ER$LKUP ER$MESS
  File services
    FL$BACK FL$BCAT FL$BDEL FL$BOPN
    FL$BSAV FL$CATL FL$COPY FL$CRET
    FL$DELN FL$ERAS FL$FFND FL$FIND
    FL$FREC FL$NEXT FL$OPEN FL$PARS
    FL$READ FL$RECT FL$RENM FL$RSET
    FL$SETP FL$SIZE FL$WRIT
  Complex Floating point services
    FN$ATAN FN$COS FN$EXP FN$LN
    FN$LOG FN$POWR FN$RND FN$SIN
    FN$SQRT FN$TAN

Part 2:
  Table interpreter services.
    IT$GVAL IT$RADD IT$STRT IT$TADD
  Keyboard services.
    KB$INIT KB$TEST KB$GETK KB$BREK
    KB$FLSH KB$UGET KB$STAT
  Language services.
    LG$RLED LG$NEWP LN$STRT
  Menu services.
    MN$DISP
  Floating point arithmetic services.
    MT$BTOF MT$FADD MT$FBDC MT$FBEX
    MT$FBGN MT$FBIN MT$FDIV MT$FMUL
    MT$FNGT MT$FSUB
  Pack services.
    PK$PKOF PK$QADD PK$RBYT PK$READ
    PK$RWRD PK$SADD PK$SAVE PK$SETP
    PK$SKIP
  Run services.
    RM$RUNP
  Top level services.
    TL$ADDI TL$CPYX TL$DELI TL$XXMD
    TL$RSTR TL$LSET
  Timing services.
    TM$DAYV TM$TGET TM$UPDT TM$WAIT
  Utility display services.
    UT$DDSP UT$DISP UT$CDSP
  Utility services.
    UT$CPYB UT$ENTR UT$FILL UT$ICPB
    UT$ISBF UT$LEAV UT$SDIV UT$SMUL
    UT$SPLT UT$UDIV UT$UMUL UT$UTOB
    UT$XCAT UT$XTOB UT$YSNO

LZ Services
  Hardware services
    BT$TOFF
  Display services
    DP$CPRN DP$CSET DP$MSET DP$PVEW
    DP$UDG XT$BAR
  Editor services
    TL$ZZMD
  Error services
    ER$PRNT
  File services
    FL$FDEL FL$GETX FL$NCAT FL$VALX
    FL$WCAT FL$WCPY FL$WDEL FL$WFND
    FL$WPAR XF$SORT XT$DIRM
  Complex Floating point services
    FN$ASIN FN$ACOS FN$MAX FN$MEAN
    FN$MIN FN$STD FN$SUM FN$VAR
  Keyboard services.
    KB$CONK
  Language services.
    LG$EDIT LG$ENTR LN$XSTT
  Menu services.
    MN$1DSP MN$TITL MN$XDSP
  Timing services.
    TM$DNAM TM$MNAM TM$NDYS TM$TSET
    TM$WEEK
  Top level services.
    AM$ENTR CA$ENTR DI$ENTR NT$ENTR
    TI$ENTR WL$ENTR XF$ENTR XT$ENTR
  Utility services.
    UT$CMPB UT$SORT UT$WILD


Hardware services

129 81 BT$TOFF
INPUT: D=Number of seconds to be switched off (must be 2-1800 secs for system clock to function correctly)
OUTPUT: None.
Switch off for D seconds.

Display services

132 84 DP$CPRN
INPUT: A=zero to update only flashing colon, non-zero for whole clock.
OUTPUT: None.
UTW_Sx=preserved
Redefines the clock UDG's. Preserves the screen status. This service is called by the keyboard interrupt routine every half second when the clock is enabled.

131 83 DP$CSET
INPUT: B=Position of screen clock. Bit 7 set to disable clock.
OUTPUT: B=previous clock status.
Sets the status of the UDG clock. Note that if enabled, the clock is only displayed once when this service is called. It is updated by only changing the UDG's on keyboard interrupt, not by printing to the screen. The cursor position and status is preserved.

Note that the clock uses the UDG's 3 to 7 to display hh:mm. If in 12 hour mode this is followed by UDG 1 which is used for 'a' or 'p'. In 24 hour mode UDG 1 is unchanged and the clock is preceded by UDG 2, which is not redefined and is assumed to show an underline.

130 82 DP$MSET
INPUT: A=0 for 2-line mode, 1 for 4-line mode. If bit 7 also set then udg clock unaffected, else switched off.
OUTPUT: A=Previous display mode
B,X=preserved
Sets 2 or 4 line display mode.

163 A3 DP$PVEW
INPUT: X=Address of string to view, 0 for previous string.
A=bit 7 set to disallow changing the scroll direction.
B=Length of string to view.
UTW_S0=Initial pause before scrolling (in 20th of a sec)
OUTPUT: B=Key pressed
Works exactly like DP$VIEW, except that the string is viewed at the current cursor position, and that anything on the current line to the left of the cursor will not be disturbed. The string is only displayed on the right side of the line. This service is used in CALC for example. See DP$VIEW for full details.

133 85 DP$UDG
INPUT: A=Bit 7 set for reading udg, clear to define udg. Bit 0 set for five byte pattern (defining only), clear for 8 byte.
B=Udg number (0-7)
X=Address of 5/8 byte udg buffer to read from or write to.
OUTPUT: X=8 byte pattern read/write: the next byte after the buffer 5 byte pattern write: preserved
Reads or writes a UDG pattern. Note that reading a UDG in 5 byte format is not allowed. Interrupts are temporarily disabled by this service.

UDG's consist of an 8x5 pattern of pixels. The 8 byte format is the same as used in the OPL command UDG. Thus the 8 bytes contain the horizontal lines from top to bottom, and the five pixels are contained in the lowest 5 bits. The three highest bits are ignored. The 5 byte format contains vertical lines instead, from left to right. Now all 8 bits are used, with the highest bit denoting the top pixel and the lowest bit the bottom one.

162 A2 XT$BAR
INPUT: A=Percentage of black bar on left of graph
B=Percentage of grey bar on right of graph
OUTPUT: RTT_BF=String of the bar graph (20 chars long)
Defines the UDG's for displaying a bar graph like in the INFO option in utils. Note that A+B should not be more than 100%. All 8 UDG's are re-defined by this service, but UDG 5 is not used in the resulting string. The UDG's 1, 3 and 6 show the start, middle and end of the black bar. The grey bar similarly uses UDG's 2, 4 and 7. UDG 0 is the underline between the bars.

Editor services

155 9B TL$ZZMD
INPUT: A=Flags:
  Bit 0 set for multi-line editing, clear for single-line.
  Bit 1 set for up/down to exit editor in single-line editing. LZ only.
  Bit 7 clear for MODE to exit editor, set if MODE to be ignored.
B=Maximum input length (possibly 0)
X=Address of prompt to display (lbc string, e.g. 'FIND' shows 'FIND A:')
TLB_CPAK=Initial pack
RTT_BUF=String to be edited
UTW_S0l=Line on which to display prompt (0-3)
OUTPUT:
TLB_CPAK=Chosen pack
Carry=set if ON/Clear used to exit.
Works exactly like TL$XXMD, except that the screen is not cleared beforehand. UTW_S0l contains the line where the prompt is to be displayed (0-3). See TL$XXMD for further details.

Error services

169 A9 ER$PRNT
INPUT: X=message to display as an error (lbc string, no longer than current screen width)
OUTPUT: None.
Displays a string as if it were an error message.

File services

176 B0 FL$FDEL
INPUT: D=Number of first record to delete
X=Number of records to delete, $FFFF to delete till end.
OUTPUT: None.
Deletes X records starting from record D, of the current record type.

152 98 FL$GETX
INPUT: A=file type ($81-8F, 0 for '.*', $FF for empty string)
X=Address to store extension at.
UTW_S0l=0,1,2 for .OPL/.OPO/.OPT if type is $83.
OUTPUT: B=Length of extension
Converts a file type into an extension. File type 0 will return '.*' and $FF returns an empty string. The exact opposite of FL$VALX.

157 9D FL$NCAT
INPUT: A=1 on initial call, 0 for subsequent calls (and then only X needs to be given). If bit 7 set then returns further info about file sizes found.
B=pack to search (0-3)
X=Address to store the filename found.
UTW_S0l=Length of string to match filenames, bit 7 set to match file type in UTW_S0h.
UTW_S0h=File type to match, ignored if bit 7 of UTW_S0l clear.
UTW_S1=Address of string to match filenames
UTW_S2=The number of the match to search for.
OUTPUT: A=File type found
B=1 or 2 if .OPO/.OPT was given, zero otherwise
UTW_S0=Length of data of block file or number of records in file. Only available if requested by setting bit 7 of A.
Same as FL$WCAT but gets the n'th match. See FL$WCAT for further details.

153 99 FL$VALX
INPUT: B=Length of extension string
X=Address of extension string
OUTPUT: A=File type (0 for '.*', $FF for empty string)
UTW_S0l=0,1,2 for .OPL/.OPO/.OPT if type is $83.
Converts a file extension to a file type. The exact opposite of FL$GETX. May cause error 236 'bad file name'.

144 90 FL$WCAT
INPUT: A=1 on initial call, 0 for subsequent calls (and then only X needs to be given). If bit 7 set then returns further info about file sizes found.
B=pack to search (0-3)
X=Address to store the filename found.
UTW_S0l=Length of string to match filenames, bit 7 set to match file type in UTW_S0h.
UTW_S0h=File type to match, ignored if bit 7 of UTW_S0l clear.
UTW_S1=Address of string to match filenames
OUTPUT: A=File type found
B=1 or 2 if .OPO/.OPT was given, zero otherwise
UTW_S0=Length of data of block file or number of records in file. Only available if requested by setting bit 7 of A.
Works very much like FL$BCAT and FL$CATL except that the filenames that are returned must match a given string. The string may contain wildcards '*' and '+', and may also have an extension. Note that the file extensions '.OPL', '.OPO' and '.OPT' are considered to be equivalent by this service and that if no extension is given then extension '.*' is assumed which matches all file types. Returns error 238 'end of file' is no more matching files were found. See also FL$NCAT. The following errors can be generated:
238 end of file (normal exit)
236 bad file name
243 bad device name
245 write pack error
246 no pack

145 91 FL$WCPY
INPUT: D=address of source filename (lbc string of form 'D:NAME' or 'D:')
X=address of target filename (lbc string of form 'D:NAME' or 'D:')
UTW_S0=Address of user routine to call with each file copied, 0 if no routine supplied (the routine will be given address of filename in X, file type in A)
OUTPUT: None.
Wild file copy, works somewhat like FL$COPY. This service copies files (both block files and ordinary files) with a name matching the first string to a file/pack given in second string. The files can only be copied from one device to another, not to the same device. The target name may be different, but if no target name is given the original filename is kept. The source name may contain wild cards, and if this is the case then the target name must consist of no more than the device name only. The source name may also have an extension, the target name may not. A user routine can be supplied which is called for each file copied, which allows you to display the progress of the copy. The following errors can be generated:
194 battery too low
200 read pack error
232 pak not copyable
233 directory full
234 file not found
236 bad file name
238 end of file
239 pack full
240 unknown pack
241 pack not blank
242 pak changed
243 bad device name
244 read only pack
245 write pack error
246 no pack

146 92 FL$WDEL
INPUT: X=Wildcard filename to match (lbc string, 'D:NAME.EXT')
UTW_S0=Address of user routine to call with each file deleted, 0 if no routine supplied (the routine will be given address of filename in X, file type in A)
OUTPUT: None.
Wild file delete, works somewhat like FL$DELN and FL$BDEL. This service deletes all files (block and ordinary files) matching a given string. The string must include a device name and an extension (though '.*' is allowed). A user routine can be supplied which is called for each file deleted, which allows you to display the progress of the deletion. The following errors can be generated:
194 battery too low
200 read pack error
234 file not found
236 bad file name
240 unknown pack
241 pack not blank
243 bad device name
244 read only pack
245 write pack error
246 no pack

147 93 FL$WFND
INPUT: D=address of lbc string to search for
X=address to store record found, as lbc string
OUTPUT: A=current record type
Wild find. Works like FL$FIND, except that the wild cards '*' and '+' are allowed. This therefore works exactly like the OPL function FINDW. See FL$FIND for details.

143 8F FL$WPAR
INPUT: B=Length of filename
X=Address of filename
OUTPUT: A=File type ($81-8F), 0 for extension .*, $FF if no extension.
B=Length of body of filename (excl extension)
UTW_S0l=0,1,2 for .OPL/.OPO/.OPT extension (and then type is $83)
Checks whether a wildcard filename is legal. The filename may include wildcards, and an extension. If the filename is not legal, then error 236 'bad filename' is returned.

174 AE XF$SORT
INPUT: X=Name of file to sort (lbc string, 'A:NAME')
D=Address of user routine, 0 if no routine supplied
OUTPUT: None.
Sorts an ordinary file using the Quick Sort algorithm. The files should be on pack A:. A use routine can be supplied which is called during the sort, usually to print information to the screen. When the user routine is called, the A register contains 1-3 depending on which pass is being performed, and the X register contains the record number during pass 1 and 3, or the number of comparisons (divided by 10) on pass 2. The first pass generates a list of tags for the file records. This is sorted on pass 2 with the Quick Sort algorithm. Pass 3 then constructs a sorted file from the tag list. If there is not enough memory to sort the file, then the file will be left unchanged. The following errors can be generated:
234 File not found
254 out of memory
Any other file error in exceptional circumstances.

156 9C XT$DIRM
INPUT: A=File type ($81-8F, or 0 for all files)
B=Maximum length of filename
X=Address prompt (lbc string)
UTW_S0h=Line number for prompt (must be 0-1, bottom of screen not allowed)
UTW_S0l=Flags for the directory display (0 for no directory):
  Bit 0 - show the filenames
  Bit 1 - show the sizes of files on right
  Bit 2 - show the file types on left
  Bit 3 - include <*> as first directory entry
  Bit 4 - show file type after prompt, (e.g. "Dir of All A:")
  Bit 5 - Disable EXE key (used by DIR)
  Bit 6 - Disable MODE key (used by SORT).
RTT_BUF=Default filename to be offered
TLB_CPAK=Default device to be offered
OUTPUT: A=file type of chosen file (only if flags were non-zero)
RTT_BUF=Filename chosen
TLB_CPAK=Device chosen
carry=set if ON/Clear pressed
Allows the user to get a directory of files. Produces a directory of files with a prompt like EDIT in PROG etc. If EXE is used to select a file, the filename will be printed after the prompt and the lower 2 or 3 lines of the screen will be cleared when the routine exits.

Complex floating point services

172 AC FN$ASIN
INPUT: None.
OUTPUT: None.
Replaces the floating point number on the top of the run-time stack with its arcsine. Error 247 'Function argument error' may be returned.

173 AD FN$ACOS
INPUT: None.
OUTPUT: None.
Replaces the floating point number on the top of the run-time stack with its arccosine. Error 247 'Function argument error' may be returned.

142 8D FN$MAX
INPUT: None.
OUTPUT: None.
Returns the maximum of a list of floating point numbers. Before this service is called, push the word containing the number of floats in the list and then the address of the list on the run-time stack. This service pushes the result on the run-time stack without removing the two parameters. Error 249 'stack overflow' can be generated.

138 8A FN$MEAN
INPUT: None.
OUTPUT: None.
Returns the mean of a list of floating point numbers. Before this service is called, push the word containing the number of floats in the list and then the address of the list on the run-time stack. This service pushes the result on the run-time stack without removing the two parameters. The following errors can be generated:
253 exponent range
249 stack overflow

141 8D FN$MIN
INPUT: None.
OUTPUT: None.
Returns the minimum of a list of floating point numbers. Before this service is called, push the word containing the number of floats in the list and then the address of the list on the run-time stack. This service pushes the result on the run-time stack without removing the two parameters. Error 249 'stack overflow' can be generated.

140 8C FN$STD
INPUT: None.
OUTPUT: None.
Returns the standard deviation of a list of floating point numbers. Before this service is called, push the word containing the number of floats in the list and then the address of the list on the run-time stack. This service pushes the result on the run-time stack without removing the two parameters. The following errors can be generated:
253 exponent range
249 stack overflow

137 89 FN$SUM
INPUT: None.
OUTPUT: None.
Returns the sum of a list of floating point numbers. Before this service is called, push the word containing the number of floats in the list and then the address of the list on the run-time stack. This service pushes the result on the run-time stack without removing the two parameters. The following errors can be generated:
253 exponent range
249 stack overflow

139 8B FN$VAR
INPUT: None.
OUTPUT: None.
Returns the sample variance of a list of floating point numbers. Before this service is called, push the word containing the number of floats in the list and then the address of the list on the run-time stack. This service pushes the result on the run-time stack without removing the two parameters. The following errors can be generated:
253 exponent range
249 stack overflow

Keyboard services

177 B1 KB$CONK
INPUT: None.
OUTPUT: B=Key pressed.
The cursor is switched on, and then the organiser waits until a key is pressed (just like KB$GETK). Afterwards the cursor is switched off, and the ASCII value of the keypress is returned.

Language services

171 AB LG$EDIT
INPUT: B=language editor function to be carried out.
OUTPUT: A=the editor flags. See below.
B=position in the current line
X=the current line number
Calls the language editor routine. It allows the editing of text in an allocator cell, but does not handle files. Which of the 9 functions to be carried out is in register B. Note that UDG 0 is assumed to already contain an icon.

Function 0: Initialise parameters. Register A should contain the block file type and byte UTW_S0h the low byte of the tag of allocator cell to use. The cell must exist before calling this service, though it may be zeroed.
Function 1: New. Register X points to the name string of the new file, which will be inserted at the start of the cell.
Function 2: Edit existing cell. Register X contains the current line (0 for first line), and A the offset into the current line. UTW_S0 contains the following flags:
  bit 7 - set if numbered
  bit 2 - set if prompt is to be capitalized
  bit 1 - set if no title is required
  bit 0 - set if changed
The cell must contain a name which ends in a colon at the start. Lines are terminated by a zero byte. The editor is exited by pressing MODE.
Function 3: Find
Function 4: Zap
Function 5: Top
Function 6: Bottom
Function 7: Print
Function 8: Restore editor status for OPL editing. Must be called when finished editing.

175 AF LG$ENTR
INPUT: B=language editor function to be carried out.
Calls the program routine. The function to be carried out depends on register B.

Function 0: Unused
Function 1: Calls prog as if the top level menu option was chosen.
Function 2: Search all block files of type LGB_LANT ($23E0) for the string given in the buffer RTT_FF ($22C9). The carry is set if the search was completed normally. If the carry is clear then B contains 1 if MODE was pressed after a match was found, or 0 if the search was aborted by an error or by pressing ON/CLEAR. Used by the utils-search menu option.

154 9A LN$XSTT
INPUT: A=0 for 2-line translate, 1 for LZ translate.
B=function (0=tran proc, 1=tran calc, 2=locate error in calc, 3=loc err in proc)
X=offset in Q-code where error occurred (error-locating only, else ignored. Must be in range)
OUTPUT: B=error code if there is one.
X=offset in textcell where error occurred if there is one.
Qcode-cell=translated output if translating
Exactly like LN$STRT, except that A contains 0 when translating for 2-line machines and 1 for 4-line machines. See LN$STRT for details.

Menu services

135 87 MN$1DSP
INPUT: X=Address of menu string.
D=Bit mask of keys that exit the menu (bit n set if char n+1 exits).
OUTPUT: B=keypress used to exit menu (gives Exe if a letter key was used)
A=non-zero
  X=Address of menu item in the menu string.
  UTW_S0=number of the chosen item (0=first item)
A=zero
  X=Associated address of menu item
  UTW_S0=Address of menu item in the menu string.
Exactly the same as MN$DISP except that the menu is displayed only on the current cursor line, leaving the other lines undisturbed. This is exactly like the OPL function MENUN(1,..). See MN$DISP for details. The control characters 24 and 25 are useful in preparation to this service, as they display a dotted line (using UDG 2) to separate the top or bottom line from the rest of the screen, and put the cursor in the correct position.

136 88 MN$TITL
INPUT: X=Address of menu string.
D=Bit mask of keys that exit the menu (bit n set if char n+1 exits).
OUTPUT: B=keypress used to exit menu (gives Exe if a letter key was used)
A=non-zero
  X=Address of menu item in the menu string.
  UTW_S0=number of the chosen item (0=first item)
A=zero
  X=Associated address of menu item
  UTW_S0=Address of menu item in the menu string.
Exactly the same as MN$DISP except that the top line will show an icon (UDG 0) and the clock in the same way as the top level menu. UDG 0 is not affected and is assumed to already contain the icon to be used. See MN$DISP for details.

134 86 MN$XDSP
INPUT: X=Address of menu string.
D=Bit mask of keys that exit the menu (bit n set if char n+1 exits).
OUTPUT: B=keypress used to exit menu (gives Exe if a letter key was used)
A=non-zero
  X=Address of menu item in the menu string.
  UTW_S0=number of the chosen item (0=first item)
A=zero
  X=Associated address of menu item
  UTW_S0=Address of menu item in the menu string.
Exactly the same as MN$DISP except that the menu is displayed only on the lines below the current cursor position, leaving the other lines undisturbed. If the cursor is already on the bottom line, then menu overwrites that line. This is exactly like the OPL function MENUN(2,..). See MN$DISP for details.

Timing services

151 97 TM$DNAM
INPUT: B=Day of week (0-6, 0=Monday)
OUTPUT: X=Address of three character string with day name in caps (e.g. 'MON')
Converts number of the day of the week to a day name.

170 AA TM$MNAM
INPUT: B=Month of year (0-11)
OUTPUT: X=Address of three character string with month name in caps (e.g. 'JAN')
Converts number of the month of the year to a month name.

149 95 TM$NDYS
INPUT: X=Address of 3 byte date (Year 0-255, Month 0-11, Day 0-30)
OUTPUT: A=preserved
B=High byte of days since 1/1/1900
X=low bytes of days since 1/1/1900
Returns the number of days difference between 1/1/1900 and the given date. If the given date is invalid, then the carry flag is set but no error code is in B. The A register is preserved.

179 B3 TM$TSET
INPUT: X=Address of 6-byte time/date (Y/M/D/H/M/S)
OUTPUT: None.
Sets the system time. This service makes sure that the system time is not being updated at the time of copying.

150 96 TM$WEEK
INPUT: X=Address of 3 byte date (Year 0-255, Month 0-11, Day 0-30)
OUTPUT: A=preserved
B=Week number (0-52)
X=preserved
Returns the week number of the given date. The first monday of the year starts week 0, and the days just before that are the final week of the previous year. If the given date is invalid, then the carry flag is set but no error code is in B. The main applications like the diary convert the weeknumber from 0-52 to 1-53.

Top level services

158 9E AM$ENTR
INPUT: B=Alarm function to be carried out (0-6)
Calls the alarm routine. Which of the 7 functions to be carried out is in register B.
Function 0: Initialise alarms, as on a cold boot. Clears all alarms and sets AMB_EI thus enabling alarm checking.
Function 1: Top level alarm entry. Calls alarm as if the top level menu option was chosen. The screen will be used in 4-line mode, though the display mode is preserved on exit.
Function 2: Check for alarms due within 2048 seconds. If any alarm (incl. diary alarms) is due immediately, it will go off. If there is an alarm due, the service exits with D containing the number of seconds before the next alarm (2<=D<2048), and the carry flag set. Otherwise, the carry flag is clear. This function is disabled if AMB_EI ($2335) is clear.
Function 3: Checks for alarms due immediately. If any alarm (incl. diary alarms) is due immediately, it will go off. This function is disabled if AMB_EI ($2335) is clear.
Function 4: Checks for unacknowledged diary alarms. If any diary alarms have gone off that haven't been acknowledged by pressing ON/CLEAR then the 'Review missed alarms' screen will be shown. Note that DP$SAVE/DP$REST is used to preserve the screen contents. This function is disabled if AMB_EI ($2335) is clear.
Function 5: Disable alarms. This function copies AMB_EI to AMB_SEI and clears AMB_EI. This disables functions 2-4. Note that if called again, it will overwrite AMB_SEI, thus losing the previous alarm flag.
Function 6: Restores alarm flag. The reverse of function 5. This function copies AMB_SEI back to AMB_EI.

160 A0 CA$ENTR
INPUT: None
OUTPUT: None
Enters the calculator exactly as if the top level menu option were chosen. Note that it can only be called from OPL if all the system variables that the OPL language uses are preserved.

167 A7 DI$ENTR
INPUT: B=Diary function to be carried out.
Calls the diary routine. Which of the 4 functions to be carried out is in register B. Note that all options redefine the UDG's.
Function 0: Initialise diary, as on a cold boot.
Function 1: Calls the diary as if the top level menu option was chosen.
Function 2: Search current diary for given string. The string to search for is in RTT_FF ($22C9). If found, the matching diary entry is shown on the bottom two lines after which a key press is expected. EXE continues the search, ON/CLEAR aborts it, and MODE enters the diary at the entry found. On exit, the carry flag is set if the whole diary was searched. If clear, B contains 0 if ON was used to abort the search and 1 if MODE was pressed and the diary exited. Used by the utils-search menu option.
Function 3: Calls the diary as if the 'Month' option was chosen in the top level menu.

159 9F NT$ENTR
INPUT: B=Notepad function to be carried out.
Calls the notepad routine. Which of the 5 functions to be carried out is in register B. Note that all functions clear the diary paste buffer (which is used for the find string), and temporarily set the block file type and the cell type for notepad editing.
Function 0: Initialise notepad, as on a cold boot. Clears the current notepad cell.
Function 1: Top level Notepad entry. Calls Notepad as if the top level menu option was chosen.
Function 2: Search. Searches current notepad and non-encrypted notepad files for given string. The string to search for is in RTT_FF ($22C9). If found, the matching file is shown on the bottom two lines after which a key press is expected. EXE continues the search, ON/CLEAR aborts it, and MODE enters the notepad with the file found. On exit, the carry flag is set if the end of the search was reached. If clear, B contains 0 if ON was used to abort the search and 1 if MODE was pressed and the notepad exited. Used by the utils-search menu option.
Function 3: Enter named notepad. Calls the notepad as if an inserted notepad name in the top level menu was chosen. UTW_S0 points to the filename. Any error is displayed rather than returned.
Function 4: Check if encrypted. Checks whether a notepad file has a password. UTW_S0 points to the filename. On exit, B=0 if not password protected, non-zero otherwise. Register A will contain the notepad flags.

164 A4 TI$ENTR
INPUT: B=Time function to be carried out.
Calls the time routine. Which of the 2 functions to be carried out is in register B.
Function 0: Initialise time, as on a cold boot. Actually, this option doesn't need to do anything!
Function 1: Calls the time routine as if the top level menu option was chosen.

166 A6 WL$ENTR
INPUT: B=World function to be carried out.
Calls the world routine. Which of the 3 functions to be carried out is in register B.
Function 0: Initialise world, as on a cold boot. Sets the home and current city.
Function 1: Calls world as if the top level menu option was chosen.
Function 2: Returns the name of the base city and country. The city is stored at RTT_BF+100 and the country at RTT_BF+120, both as lbc strings. If the current base is set to a country (so no city is set) then the country is put at RTT_BF+100 and RTT_BF+120 is empty.

168 A8 XF$ENTR
INPUT: B=xfiles function to be carried out.
Calls the xfiles routine. Which of the 6 functions to be carried out is in register B.
Function 0: Initialise xfiles, as on a cold boot. This only sets the current file to be MAIN.
Function 1: Calls xfiles as if the top level menu option was chosen.
Function 2: Searches all ordinary files on all devices for the string given in the buffer RTT_FF ($22C9). The carry is set if the search was completed normally. If the carry is clear then B contains 1 if MODE was pressed after a match was found, or 0 if the search was aborted by an error or by pressing ON/CLEAR. Used by the utils-search menu option.
Function 3: Search all packs for a file, and if found it is made the current file in xfiles. The filename is given by the lbc string at UTW_S0. This option is used when a filename in the top-level menu is chosen.
Function 4: Calls the top-level FIND function.
Function 5: Calls the top-level SAVE function.

161 A1 XT$ENTR
INPUT: B=Utility function to be carried out.
Calls the Utils routine. Which of the 12 functions to be carried out is in register B.
Function 0: Initialise system password notepad, as on a cold boot. Clears the current system password.
Function 1: Calls utils as if the top level menu option was chosen.
Function 2: Calls SEARCH as if the utils level menu option was chosen.
Function 3: Calls INFO as if the utils level menu option was chosen.
Function 4: Calls PASSW as if the utils level menu option was chosen.
Function 5: Calls LANG as if the utils level menu option was chosen. Register A must contain 0 to disable the ON/CLEAR key, 1 otherwise. In fact A contains the low byte of the key mask used in the menu services.
Function 6: Checks the system password if it is active. Used on warm boot.
Function 7: Reset the machine. Used by the menu option RESET.
Function 8: Format a rampak. Register A contains 1 for pack B:, and 2 for pack C:.
Function 9: Calls DIR as if the utils level menu option was chosen.
Function 10: Calls COPY as if the utils level menu option was chosen.
Function 11: Calls DELETE as if the utils level menu option was chosen.

Utility services

178 B2 UT$CMPB
INPUT: A=Length of first string
B=Length of second string
X=Address of first string
UTW_S0=Address of second string
OUTPUT: B=0 if equal, negative if <, positive if >.
X=preserved
Two ASCII strings are compared, case dependent. Works exactly like UT$ICPB except that it is case dependent. See UT$ICPB for parameters.

165 A5 UT$SORT
INPUT: D=Number of items to sort
X=User interface routine
OUTPUT: None.
Sort utility. This routine provides the Quick Sort algorithm to sort any list. The user is expected to supply an interface routine for accessing and comparing the items. This allows any type of item to be sorted. The user routine is called with B containing the number of the pass (0,1,2).

During the first pass (B=0), the number of the item is given in X (0 means first item), and the user routine should return an identifying tag, for example the address in memory of that item. During the second pass (B=1), X and UTW_S0 contain the tags of the items to be compared. The user routine should return the condition flags as if the instruction CMP (item X),(item UTW_S0) had been carried out. During the final pass (B=2), X will contain the tag for the each item in sorted order, allowing the user routine to build up a sorted list.

Note that the user routine must not use the run-time buffer RTT_BF. This service may return error 254 (out of memory).

148 94 UT$WILD
INPUT: A=Length of major string
B=Length of minor string
X=Address of major string
UTW_S0=Address of minor string
OUTPUT: B=Offset within major string where minor string is found (0 if at start), length of major string if not found.
Finds the location of one string inside another, and allows wild cards. Works exactly like UT$ISBF except that the wild characters '*' and '+' are allowed.