home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / mumps / user.doc < prev    next >
Text File  |  1989-03-06  |  53KB  |  1,386 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.                             MICROMUMPS
  13.  
  14.  
  15.  
  16.                            USER MANUAL
  17.  
  18.  
  19.  
  20.  
  21.  
  22.                             Version 5
  23.  
  24.  
  25.  
  26.  
  27.  
  28.                   Division of Computer Science
  29.                     University of California
  30.                         Davis, CA  95616
  31.  
  32.  
  33.  
  34.  
  35.  
  36.                          William Yaksick
  37.                        Richard F. Walters
  38.  
  39.  
  40.  
  41.                          December, 1986
  42.  
  43.  
  44.                        (updated March 1989)
  45.                           (version 5.2 )
  46.                           (marked '***')
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.                           Introduction
  70.  
  71. A single user version of Standard MUMPS has been  implemented  on
  72. 8086/88  and  compatible microcomputers operating under the PCDOS
  73. (MSDOS) Operating system.  This research has  been  supported  in
  74. part  by the Veterans Administration, the MUMPS Systems Laborato-
  75. ry, Nagoya, Japan, Shared Medical Systems, the  Lister  Hill  Na-
  76. tional  Center  for Biomedical Communications of the National Li-
  77. brary of Medicine, IBM Corporation, Cornell  University  and  the
  78. University  of California. It is distributed by the University of
  79. California, Davis, and by the  MUMPS  Users  Groups  of  England,
  80. Japan and Brazil.
  81.  
  82. In its current version, MicroMUMPS includes all commands  of  the
  83. ANSI  Standard  applicable  to single user versions.  This manual
  84. describes extensions to the MUMPS language that are  included  in
  85. MicroMUMPS.   In  general, direct I/O extensions conform to those
  86. of DSM and ISM implementations.  Some special capabilities avail-
  87. able at the micro-computer level are also described in this manu-
  88. al.
  89.  
  90.  
  91.  
  92.                       Initiating MicroMUMPS
  93.  
  94. To enter the MUMPS interpreter, begin by turning on  the  machine
  95. and  initiating  the  operating system.  Then type ``MUMPS'', and
  96. the interpreter will be loaded.   When  loaded,  the  interpreter
  97. will  give  an initial message identifying the Version number and
  98. then display a prompt ``>'', which is repeated each time the  in-
  99. terpreter  is awaiting further input from the user.  If MUMPS has
  100. been configured for auto execute mode using the SETMUMPS utility,
  101. then  the  command line entered during setup will be executed in-
  102. stead of the initial prompt.  See the SETMUMPS utility documenta-
  103. tion for more information on auto execute mode.
  104.  
  105. To exit MUMPS, type HALT or H, and the monitor  will  once  again
  106. assume control of the system.  ALWAYS EXIT USING THE HALT command
  107. to allow the system to rewrite all modified global  files  before
  108. returning  control  to the operating system. Failure to do so may
  109. result in loss of data in the global files.
  110.  
  111.  
  112.  
  113.                  Special Features of MicroMUMPS
  114.  
  115. MicroMUMPS now includes all the features added to Standard  MUMPS
  116. for inclusion in the ANS 1984 standard.  These features are:
  117.  
  118.  
  119.    SET $PIECE  The syntax SET $PIECE(X,delim,n)=``NEW VALUE'' es-
  120.    tablishes NEW VALUE as the nth piece of variable X.
  121.  
  122.    $ASCII(expr1,intexpr2) returns  the  $ASCII  function  on  the
  123.    intexpr2th character of expr1
  124.  
  125.    $EXTRACT(expr) returns the first character  of  the  value  of
  126.    expr.
  127.  
  128.  
  129.  
  130.                              - 1 -
  131.  
  132.  
  133.  
  134.    $JUSTIFY now includes a leading zero in front of decimal frac-
  135.    tions between -1 and 1.
  136.  
  137.    $LENGTH (exprl,expr2) gives the number of non-overlapping times 
  138.    expr2 occurs in expr1.
  139.  
  140.    $TEXT(+0) returns the name of the routine.
  141.  
  142.    Pattern match:  alternating forms permitted (see newsletter)
  143.  
  144.    READ A#n reads up to n characters, terminating at n.
  145.  
  146. In addition to permitting string subscripts,  decimal  subscripts
  147. are  also  allowed  in MicroMUMPS.  Note that the collating order
  148. specified by the MUMPS Development Committee  treats  ``canonical
  149. numbers''  as  special  cases, separating them from other numbers
  150. and alphanumeric strings.  See the section on Language Extensions
  151. for further details on this topic.
  152.  
  153.  
  154.  
  155.    Adherence to Portability Requirements of the MUMPS Standard
  156.  
  157. This version of Standard MUMPS adheres to or exceeds  all  provi-
  158. sions  specified  in part III of the ANSI Standard X11.1.  String
  159. variables may be up to 255 characters in length,  numeric  preci-
  160. sion  is  maintained to a minimum of nine significant digits, ex-
  161. tensible to 14. Numbers up to 10 raised to the 25th power can  be
  162. represented,  subscripts  may  be up to 63 characters, etc.  Some
  163. versions (distributed in Japan and China) permit use of  the  8th
  164. bit  in  character representation and permit manipulation of two-
  165. byte characters.
  166.  
  167.  
  168.  
  169.          Implementation-Specific Features of MicroMUMPS
  170.  
  171. ANSI X11.1 1984 reserves for the implementor a number of language
  172. elements.   This  section  describes  briefly the manner in which
  173. some of those features have been treated in MicroMUMPS
  174.  
  175. 1.  Direct entry of routine lines
  176.  
  177. MUMPS can be executed by direct commands, processed  as  soon  as
  178. they  are typed, or by executing stored routines.  Provision must
  179. be made for the entry of command lines that can be stored as rou-
  180. tines.   In  MicroMUMPS,  the  TAB character (control - I on some
  181. keyboards) is used to signal the start of a command line that  is
  182. to  be  stored  in  the workspace.  The Tab character echoes as a
  183. space (a change from earlier versions). Multiple Tabs are permit-
  184. ted  for  indentation  purposes. Multiple spaces between commands
  185. are also allowed.
  186.  
  187. When inserting new command lines into text, they are  placed  im-
  188. mediately  IN FRONT of the current text pointer which is then up-
  189. dated to point after the inserted line.  Extensions  that  permit
  190. manipulation  of  the  current  text pointer are described in the
  191. section on language extensions.
  192.  
  193. When a routine is entered from an editor, the linestart character
  194. may be any combination of one or more tabs or spaces.
  195.  
  196.                              - 2 -
  197.                              
  198.  
  199.  
  200. 2.  Control Character Functions
  201.  
  202. A number of special characters are interpreted by  MicroMUMPS  to
  203. provide  specific  actions  similar  to  those encountered in the
  204. operating system.  These characters are:
  205.  
  206.  
  207.      Control-A information typed to next carriage return is  not
  208.      echoed.
  209.  
  210.      Control-C execution interrupt.  Return to direct mode.  The
  211.      system can be configured to ignore Ctrl-C using the SETMUMPS
  212.      utility or BREAK 0 (see below).
  213.  
  214.      Control-G talk-through mode.  Everything typed until the next
  215.      Ctl-G is transmitted directly to output port, and  all infor-
  216.      mation received from port is echoed to screen.  This  feature
  217.      can  be  disabled,  and  MicroMUMPS  is  delivered  with  the
  218.      feature inactive, since it will cause a system to hang if  an
  219.      external port is not connected.
  220.  
  221.      Control-H backspace and delete character.
  222.  
  223.      Control-P echo to printer.
  224.  
  225.      Control-S pause output.  Resume by typing  any  char.  (See
  226.      special note in introduction for PCDOS.)
  227.  
  228.      Control-X remove line, erasing it from screen.
  229.  
  230.      Rubout     backspace and delete character.
  231.  
  232. 3.  BREAK and ZGO Commands
  233.  
  234. The ANSI Standard does not completely specify the BREAK  command.
  235. In this version, BREAK may be used in several ways.
  236.  
  237.         BREAK 0        disables control-C interrupt         
  238.     BREAK 1        enables control-C interrupt         
  239.     BREAK (arg)    halts execution and types out argument         
  240.     BREAK (var)    halts and types the value of variable
  241.  
  242. Return to execution following interruption by a BREAK command  is
  243. accomplished by the ZGO command, which picks up routine execution
  244. at the point at which it was suspended.  In addition, ZGO may  be
  245. used with Control-C, when used in indirect mode, as shown below.
  246.  
  247.         ZGO (no args)  returns to normal execution         
  248.     ZGO  1 executes   a   single   command   then  returns  
  249.         to  BREAK  mode.
  250.         ZGO 2 completes execution of the  current  line  and  the
  251.                 first command on the following line.
  252.  
  253. 4.  READ * and WRITE *;  READ A#n
  254.  
  255. The READ * syntax of Standard MUMPS permits  user  definition  of
  256. the  interpretation  of this special command.  In MicroMUMPS, the
  257. suggestion contained in the MUMPS Programmer's  Reference  Manual
  258. is  followed,  and READ * is used to implement a single character
  259. READ for use in those programs where single character input is an
  260. important  requirement  of  certain applications.  When MUMPS en-
  261.  
  262.                              - 3 -
  263.  
  264.  
  265.  
  266. counters the READ command followed by an asterisk, it  returns  a
  267. single  character which is the ASCII code equivalent of the char-
  268. acter entered from the keyboard.  Note that the  READ  *  command
  269. does not echo the character typed to the screen.
  270.  
  271. READ A#n, where n is the number of characters to  be  read,  will
  272. cause  the  READ  to  be terminated either when n characters have
  273. been typed or when a carriage return is typed.  This form of  the
  274. READ command is a new feature of 1984 ANS MUMPS.
  275.  
  276. 5.  $STORAGE
  277.  
  278. The special variables $STORAGE returns a number equivalent to the
  279. number   of  unused  bytes  of  storage  remaining  in  the  user
  280. workspace.  This value is only minimally affected by creation  of
  281. new  variables  (two  bytes are used to store an address for each
  282. variable). The remainder of the space is  used  for  storing  the
  283. current active Routine.
  284.  
  285. 6.  VIEW Command
  286.  
  287. VIEW is implemented with a single  argument  that  may  have  the
  288. values  0  through  5.  The meaning of these values is defined as
  289. follows:
  290.  
  291.         0       returns a list of local variable names and values
  292.         1       returns  local  variable  names,  subscripts  and
  293.            values of local    subscripted    variables
  294.         2       returns a list Global Variable Names
  295.         3       returns a list of MUMPS routines in routine  file
  296.         4       returns a directory of all files available to
  297.            that user on default I/O drive
  298.     5       returns a directory of *.MMP ASCII files  on disk
  299.  
  300. With Version 5.2, VIEW 3 has been changed to include zcallable       ***
  301. assembly language routines (.OBJ).  At the end of the list of MUMPS  ***
  302. routines, starting on a new line, the words 'assembly language' will ***
  303. appear.  The Assembly language OBJ routines will follow.             ***
  304.  
  305. 7.  HANG and Timeout Functions
  306.  
  307. The HANG command permits a pause of specified number of  seconds.
  308. Likewise,  various  commands  such as READ allow for a timeout in
  309. the same units.  Because of difference in processing speeds,  the
  310. exact time may vary.
  311.  
  312. 8.  OPEN #:  (parameters)
  313.  
  314. OPEN allows assignment of different  I/O  and  disk  devices  and
  315. files.  The device assignments currently available in OPEN, CLOSE
  316. and USE are:
  317.  
  318.         0       the primary input device (console/keyboard)
  319.         1       printer (listing device)          
  320.     2       disk file           
  321.     3       disk file           
  322.     4       disk file
  323.         5       Serial Port
  324.  
  325. Open 0 is ignored, since the primary input device is automatical-
  326. ly  opened when MUMPS is invoked.  If OPEN is invoked with either
  327. 1 or 5 as the device specification, parameters are ignored.
  328.  
  329.                              - 4 -
  330.  
  331.  
  332.  
  333. An OPEN command specifying one of the  disk  files  requires  the
  334. syntax (DRIVE:PATHNAME).  Failure to specify parameters will gen-    ***
  335. erate an error.  These two parameters may be string variables  or
  336. quoted constants.  For example,
  337.  
  338.         OPEN 3:("A":"\SOURCE\TEST.ASM")                              ***
  339.  
  340. will assign to device number 3 the ASCII file TEST.ASM which is      ***
  341. in the subdirectory 'SOURCE' on drive A.    The subdirectory         ***
  342. 'SOURCE' must exsit in the drive A before initializing MUMPS.        ***
  343. Note the necessity  for both  quotation  marks  and  parentheses
  344. in this specification. If variables have been previously set,  
  345. they  may also  be  used.  For example, if X="A" and 
  346. Y="\SOURCE\TEST.ASM",  then the command                              ***
  347.  
  348.         OPEN 3:(X:Y)
  349.  
  350. is a valid syntax for this command.
  351.  
  352. MicroMUMPS also permits addition of a record at the end of an ex-
  353. isting  file.   The syntax for this variation of the OPEN command
  354. is:
  355.  
  356.         OPEN 3:("A":"FILE.EXT":"END")
  357.  
  358. Thereafter, any records written to that file  are  added  at  the
  359. end.    See  the  description  of  the  USE  command  for  random
  360. read/write of files.  See also your operating systems manual  for
  361. specification of random file I/O.
  362.  
  363. 9.  CLOSE #: options
  364.  
  365. CLOSE refers to the same files and devices specified in OPEN  and
  366. USE, described above.  The two options available are 0 (close and
  367. lock file), and 1 (purge file and close it).  For example,
  368.  
  369.         CLOSE 3:0 (closes and saves the file specified as device 3)
  370.  
  371.         CLOSE 2:1 (erases the file referred to as device 2)
  372.  
  373. The default value (if no number appears after the  colon)  is  to
  374. leave the file in the status it was in when MUMPS use of the file
  375. started (a new file is deleted, an old file retained).
  376.  
  377. NOTE: When exiting MUMPS, it is essental to close files prior  to
  378. typing HALT, so as to avoid loss of data in existing buffers.
  379.  
  380. 10.  USE #
  381.  
  382. USE instructs the interface to  direct  I/O  to  the  device/file
  383. specified.  USE 1 directs output to the printer, USE 2 references
  384. read and write commands to the file specified, etc.
  385.  
  386. The USE command has several variations that can be used with dev-
  387. ices 2, 3 and 4 to  permit appending data at the end of a sequen-
  388. tial file and accessing directly records in a random file.  For a
  389. sequential file,
  390.  
  391.         USE 2:``END'' will move the file pointer to  the  end  of
  392. the  current file and add data at that point.  This option should
  393. only be used when a pre-existing file has been opened.
  394.  
  395.                              - 5 -
  396.  
  397.  
  398.  
  399. Random files must first be declared outside MUMPS using  standard
  400. operating  system  procedures.   Individuals who are not familiar
  401. with these procedures should not attempt  to  use  this  feature.
  402. When a random file exists, the syntax
  403.  
  404.         USE 2:n     where n is the sector number to be read, 
  405.  
  406. will move the pointer to that location so that the next READ or 
  407. WRITE is of the desired sector. 
  408.  
  409. 11.  SET $X and SET $Y
  410.  
  411. Frequently, it is desirable, in screen format-dependent routines,  
  412. to redefine the $X and $Y special variables to conform to new lo-
  413. cations of the cursor after terminal-specific write sequences  
  414. have been executed.  MicroMUMPS uses the same convention that has 
  415. been adopted by several commercial versions of Standard MUMPS.
  416. $X and $Y may be set by the user, who must write special routines
  417. to accomplish this function.  MicroMUMPS now supports this feature.
  418.  
  419. 12.  WRITE (without arguments)
  420.  
  421. Several commercial MUMPS systems (DSM, ISM, etc.) use WRITE without
  422. arguments as a way to view local variables.  In order to make use 
  423. of MicroMUMPS as convenient as possible for individuals who use 
  424. these versions, we have implemented WRITE with no arguments to 
  425. perform exactly the same function as VIEW 0.  The list of variables
  426. is displayed, but subscripted values are not displayed.
  427.  
  428.  
  429.                      MSDOS Specific Features
  430.  
  431. 1. Terminal I/O
  432.  
  433. The IBM PC does not allow for single character form feed control.
  434. Version  2.0  and subsequent releases permit escape sequence con-
  435. trols for various screen functions.  Refer to your operating sys-
  436. tem  manual to determine if these functions are available on your
  437. system.  Use WRITE  *nn where nn is the decimal value of  an  ap-
  438. propriate ASCII code to accomplish these functions.
  439.  
  440. 2.  Serial Port I/O
  441.  
  442. Input and output of data on a serial line other than  the  system
  443. console is supported in this version of MicroMUMPS.  The facility
  444. is provided using standard calls for auxiliary input/output ports
  445. devices as described in the MSDOS documentation.  It is necessary
  446. to set the speed and character length outside MUMPS.   Note  that
  447. at higher baud rates it is possible to lose characters, since in-
  448. terrupt handling and buffering is not provided in MSDOS calls.
  449.  
  450. 3.  Sequential File I/O
  451.  
  452. As described above, MicroMUMPS provides features that allow read-
  453. ing  and  writing of sequential ASCII files.  The OPEN, USE, READ
  454. and WRITE commands operate like the SDP files provided by DSM-11.
  455. A CNTRL/Z is returned to the MUMPS routine when an End-of-File is 
  456. detected on reads.  This facility is useful for writing MUMPS  
  457. routines  or  globals  to backup data and for interface to other 
  458. languages or word processors.  These features may also be used in
  459. conjunction with external MSDOS ports to transfer files between systems.
  460.  
  461.                              - 6 -
  462.  
  463.  
  464.  
  465.                       Z-Command Extensions
  466.  
  467. The ANS MUMPS Standard provides a means to extend the language to
  468. take  care  of  I/O and other features not fully specified in the
  469. standard.  In most cases, syntax of the  MicroMUMPS  Z-extensions
  470. are  similar or identical to DSM and ISM comparable commands.  In
  471. one or two instances,, minor differences exist.   Users  familiar
  472. with DSM, ISM, or with earlier versions of MicroMUMPS should note
  473. these language features carefully to avoid potential confusion or
  474. misuse.
  475.  
  476. ZCALL is a complex function allowing  users  to  invoke  assembly
  477.      language   routines  from  within  MUMPS.  This  feature  is
  478.      described separately at the end of the User Manual.
  479.  
  480. $ZC[OUNT]  returns  the number  of free blocks available in  the 
  481.      global file.  It can  be used in program mode  to avert any  
  482.      problems of overflowing the allocated global area. 
  483.  
  484. ZD[ELETE] <fname> will delete a routine file  from  the  Routines
  485.      file.  This command is different from the DSM and ISM method
  486.      of deleting  disk  copies  of  routines.  ZDELETE  can  take
  487.      several forms.
  488.  
  489.      ZD[ELETE] "<name>" will delete the MUMPS routine named <name>
  490.      which MUST be enclosed in quotes.  For example:
  491.            ZD "lower" will delete a MUMPS routine named lower
  492.  
  493.      ZD[ELETE] <var> will delete a MUMPS routine whose name is 
  494.      the value of the variable var.  For example:
  495.            SET VAR="lower" ZD VAR will delete the routine lower.
  496.   
  497.      ZD[ELETE] ("<name>":"<n>") where the parameter <n> may either be
  498.      the character 'M' (or 'm'), denoting a MUMPS routine, or the
  499.      character 'Z' (or 'z'), denoting an assembly routine.  As with 
  500.      first example, "<name>" and/or "<n>" may be replaced by a 
  501.      variable.  For example: 
  502.          ZD ("lower":"M") deletes the MUMPS routine lower.
  503.          ZD ("ASMB":"z")  deletes the assembly routine ASMB.
  504.  
  505. ZE[RROR]  When an error is encountered in a routine and $ZERROR has
  506.      been set previously, control will pass to the label^routine 
  507.      in $ZERROR.  The Z-command ZE can be used to force an error.
  508.      $ZERROR will be updated with: 
  509.   
  510.           <n> ; <label^routine> ; <char>
  511.  
  512.      where <n> is the error number (as found in ERRORS.DAT)
  513.            <label^routine> is the line where the error was found
  514.            <char> is the number of the character in the line where
  515.                   the error was discovered.
  516.  
  517. ZF[ETCH] is used to fetch one or more ASCII-formatted routine files
  518.      located in a DOS directory and place it in the current library 
  519.      file.  Care must be taken to make sure that the files are rou-
  520.      tines, since ZFETCH will load a  null routine if they are not. 
  521.      Several forms are available:
  522.  
  523.      ZF[ETCH] <pathname> assumes that the file(s) pointed to by
  524.      <pathname> are MSDOS MUMPS files.
  525.  
  526.                              - 7 -
  527.  
  528.  
  529.  
  530.      ZF[ETCH] (<pathname>:<n>), where <n> may take the value 'M' 
  531.      (or 'm') to refer to MUMPS routines, and 'Z' (or 'z') to 
  532.      refer to assembly routines.  In either case, the  file is 
  533.      loaded into the current routine library file.
  534.  
  535.      The parameter <pathname> MUST include the filename and three
  536.      character extension and MAY include wildcard characters (e.g.,
  537.      the '*').  It MAY also include the disk drive designation and
  538.      any DOS directory path.  The parameter <pathname> may be a 
  539.      character string enclosed in quotation marks, or it may be a 
  540.      variable designating the file.  When in command (direct) mode,
  541.      the ZFETCH command will report all fully expanded filenames as
  542.      they are loaded.  For example, to load all the MUMPS routines 
  543.      of the VA File Manager from a distribution disk:
  544.  
  545.              ZFETCH "A:\FMGR\DI*.MMP"
  546.  
  547.      will load and report the name of all MUMPS routines starting
  548.      with DI.MMP  in the FMGR subdirectory of the floppy disk on 
  549.      Drive A.
  550.  
  551.      It is permitted to have MUMPS routines  and  assembler  .OBJ
  552.      routines with the same name, since they are accessed in dif-
  553.      ferent ways within MUMPS (assembly routines are only invoked
  554.      via the ZCALL command).
  555.  
  556. $ZG[LOBAL] returns the drive name on which globals are currently 
  557.      located. It is useful in program mode to manage files when 
  558.      multiple disks are used.
  559.  
  560. $ZGPATH  returns the pathname used to access the Globals currently   ***
  561.      active.  The path name may be changed using ZOPTION.  Note      ***
  562.      that there is no abbreviation for this.                         ***
  563.  
  564. ZI[NSERT] <string>:<label[+n]> inserts the <string> BEFORE  the
  565.      specified  line.  Moves the line pointer just past the newly
  566.      inserted line.  The format of <string> may be as follows:
  567.  
  568.              " label  (space)  command-line"
  569.              " (space) command-line"
  570.              VAR   (where VAR is a previously defined string con-
  571.                     forming to one of the options listed above.)
  572.  
  573.      Note that the quotation marks are required if the string  is
  574.      entered directly.
  575.  
  576. ZL[OAD] <name> retrieves the named routine from the  Routine  Li-
  577.      brary  and  places it in the workspace.  The line pointer is
  578.      set at the end of the routine loaded.  ZLOAD does not require
  579.      quotation marks.
  580.  
  581. ZM[OVE] [arg] moves the routine line pointer to the location 
  582.      specified in the optional argument.  There are several forms.
  583.  
  584.      ZM[OVE] (without arguments) moves pointer to top of routine
  585.  
  586.      ZM <label>[+n] moves pointer to <label> and, if present,
  587.      advances +n lines, where n is an integer.
  588.  
  589.      ZM : moves to end of routine.
  590.  
  591.  
  592.                              - 8 -
  593.  
  594.  
  595.  
  596. $ZM[ATH](n,var) returns mathematical functions of var depending on
  597.      the value of n:
  598.  
  599.      $ZM(1,var)  returns the square root of var 
  600.      $ZM(2,var)  returns the log base e of var
  601.      $ZM(3,var)  returns the value of e to the power var
  602.  
  603. $ZN[AME] returns name of current routine
  604.  
  605. ZO[PTION] (without  arguments)  displays  three  parameters: 1) the
  606.      current  routine  drive name; 2) the drive and pathname of the  ***  
  607.      global file; and 3) the pathname of the routine library file.   ***
  608.      The special variable $ZR[OUTINE] retains routine drive and the
  609.      the special variable $ZG[LOBAL] retains global drive.  The 
  610.      special variable $ZP[ATH] retains the value of the pathname to
  611.      the routine library file.  The special variable $ZGPATH retains ***
  612.      the value of the pathname to the global file.                   ***
  613.  
  614. ZO[PTION] (<arg1>:<arg2>:<arg3>) allows the user to change the  
  615.      routine and global environment temporarily within the current
  616.      MUMPS session.  Before the environment is changed, any data
  617.      in the buffers will be saved in the old environment.  The 
  618.      arguments are positional and refer to the routines drive, 
  619.      the global drive and pathname, and the routines pathname 
  620.      respectively.  Each argument is optional, but all preceding 
  621.      colons (':') are required to denote the position. 
  622.  
  623.      ZO "A"  sets the routine drive to A, ($ZR[OUTINE] set to A).
  624.      Note that the quotation marks are required.
  625.  
  626.      ZO ("A":"B")  sets the routine drive to A, the global drive 
  627.      to B. $ZR[OUTINE] is set to A, $ZG[LOBAL] is set to drive B.
  628.      $ZGPATH is set to drive B while the pathway and global file     ***
  629.      name remain unchanged.                                          ***
  630.  
  631.      ZO ("A":"C:\MUMPS\USERGLOB") sets the routine drive to A, the   ***
  632.      global drive to B, and the pathway and global filename to       ***
  633.      C:\MUMPS\USERGLOB.  ($ZR is set to A, $ZG is set to B and       ***
  634.      $ZGPATH is set to C:\MUMPS\USERGLOB.)                           ***
  635.  
  636.      ZO ("":"":"C:\SUB1\LIB.DAT") leaves $ZR, $ZG and $ZGPATH        ***
  637.      unchanged, but sets the path and name of the routine library     
  638.      to \SUB1\LIB.DAT ($ZPATH).  Note that this also could be 
  639.      written as ZO (::"C:\SUB1\LIB.DAT")
  640.      
  641.      ZO ($ZR:$ZG) is a pseudo-change, in that it leaves the routines
  642.      drive and the globals drive exactly as is.  It has the effect
  643.      of dumping (or saving) the buffers. This option should be  
  644.      invoked  whenever the user wishes to make sure that the disk 
  645.      is updated with the latest changes to routines file and the
  646.      global data.
  647.  
  648. $ZO[RDER](args) returns the next full global subscript reference
  649.      after the argument specified.
  650.  
  651.      Example:  assume that ^A(2),^A(2,1),^A(2,3,1,1),  and  ^A(3)
  652.      are defined.  The MUMPS command line:
  653.  
  654.      SET X="^A("""")" FOR I=1:1 SET X=$ZO(@X) Q:X="" W X,!
  655.  
  656.      would write:    ^A(2) ^A(2,1) ^A(2,3,1,1) ^A(3)
  657.  
  658.                              - 9 -
  659.  
  660.  
  661.  
  662. ZP[RINT] prints all or part of the routine currently in the MUMPS
  663.      workspace.  (P may be used instead of ZP, as in DSM and ISM.)
  664.      
  665.      ZP[RINT] (without arguments) prints the entire routine
  666.  
  667.      ZP[RINT] * prints the current line
  668.     
  669.      ZP[RINT] <label>[+n] prints the line specified by <label>,  
  670.      optionally offset by +n lines
  671.     
  672.      ZP[RINT] <label1>[+n1]:<label2>[+n2] prints all lines between 
  673.      and including the lines referenced by <label1> and <label2>
  674.      as modified by n1 and n2
  675.  
  676.      ZP[RINT] <label>[+n]: lists all lines from the referenced 
  677.      <label> to the end of the routine in the work space.
  678.  
  679.      Note that ZPRINT does not affect the position  of  the  line
  680.      pointer.
  681.  
  682.      Note also that use of Control-S while in print mode halts the
  683.      listing.  Typing a Control-C while halted terminates printing
  684.      and returns to direct mode.
  685.  
  686. $ZP(ATH) returns the pathname used to access the routine library
  687.      currently active.  This path may be changed using ZOPTION.
  688.  
  689. ZR[EMOVE] deletes all or part of the routine that currently resides
  690.      in the MUMPS workspace.  It does not effect routines residing
  691.      in the routines library.
  692.  
  693.      ZR(EMOVE)  (without  arguments) deletes the entire routine 
  694.      from the workspace (but not from the Routine Library).
  695.      
  696.      ZR[EMOVE] * deletes the current line
  697.  
  698.      ZR[EMOVE] <label>[+n] deletes the line specified by <label> as
  699.      optionally modified by +n.
  700.  
  701.      ZR[EMOVE] <label1>[+n]:<label2>[+n] deletes all lines between  
  702.      and including label1 and label2 as modified by their optional
  703.      offsets.
  704.  
  705.      ZR[EMOVE <label>[+n]: deletes all lines from the specified 
  706.      <label> and offset to the end of the routine.
  707.  
  708. ZS[AVE] saves the routine currently residing in the workspace to
  709.      the current routines library.
  710.  
  711.      ZS[AVE] <name> saves the routine with <name> assigned.  This  
  712.      form must be used the first time a routine is saved. Thereafter,
  713.      it is not necessary to use the name in saving a modified routine,
  714.      unless the user wishes to change the name and save multiple copies
  715.  
  716.      ZS[AVE]  (without arguments) saves the routine in the workspace 
  717.      with the name stored in $ZNAME.  If $ZNAME is undefined, an error
  718.      message will occur.  
  719.  
  720. ZW[RITE] "<name>" outputs a MUMPS routine to a MSDOS ASCII file with 
  721.      the name <name>.MMP.  Since MSDOS files are always stored in 
  722.      upper case, it is not possible to store separately two routines
  723.      with the same name where one is in upper case and the other is
  724.      in lower case.
  725.                              - 10 -   
  726.  
  727.  
  728.  
  729.                           Global Files
  730.  
  731. The global file structure  for  MicroMUMPS  is  a  balanced  tree
  732. structure with pointers in the B-Tree and subscripts plus data at
  733. the bottom level. This structure is efficient for handling  large
  734. files,  and  it also permits variable length subscripts and vari-
  735. able length keys.
  736.  
  737. Several cautionary remarks should be made with respect to the use
  738. of globals.  In order to increase execution speed by reducing the
  739. number of disk seeks (a major delay on floppy disk systems),  in-
  740. memory  buffers are used.  The number of buffers routinely set up
  741. in the distribution disk is six.  This number can be modified  to
  742. increase  global  performance using the SETMUMPS utility.  A disk
  743. directory bit map is retained in memory, and  updated  each  time
  744. globals are added or KILLed.  This bit map is an essential key to
  745. the global files.  If a system failure occurs before the bit  map
  746. directory  has been written to memory, serious degradation of the
  747. global files may occur, usually resulting in the loss of  one  or
  748. more  variables previously set.  For this reason, it is important
  749. to minimize the potential effect of this loss by following one or
  750. more of the suggestions given below.
  751.  
  752. One way to update files online is to use the ZOPTION  command  in
  753. either  direct  or indirect mode.  Invoking ZOPTION with the same
  754. parameters that are currently in effect will force update of  the
  755. disk.  As  noted  in  the  ZOPTION documentation above, typing ZO
  756. ($ZR:$ZG) will also force buffers to be emptied, and will have no
  757. other effect on the status of the system.
  758.  
  759. NOTE: It is dangerous to remove disks  from  the  computer  while
  760. MUMPS  is  running.  Some information stored in memory relates to
  761. the files on a given disk, and  replacing  disks  may  result  in
  762. serious file destruction.
  763.  
  764. Backup files of transactions, or  other  software  mechanisms  to
  765. protect  against  power  failures  may be used as in all systems.
  766. Occasional use of the global dumper  utilities  (see  section  on
  767. utility  programs) will also provide checkpoint backup for sensi-
  768. tive file.
  769.  
  770. To maximize data base performance, the globals file should be        
  771. created  at  the  beginning  of  an empty disk.  This avoids file
  772. fragmentation and positions the file near the start of the disk's
  773. directory.
  774.  
  775. Another way that appears to offer promise for  improving  perfor-
  776. mance  of  MicroMUMPS is to use ``solid state disk'' options. See
  777. current literature for techniques of designating solid disk areas
  778. in  expanded  memory. Remember, however, that this version of Mi-
  779. croMUMPS makes use of available memory for Routine buffering,  so
  780. that  solid  state disk usage is less important than was the case
  781. with earlier releases.
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.                              - 11 -
  791.  
  792.  
  793.  
  794.  
  795.                       UCD ZCALL MicroMUMPS
  796.  
  797.  
  798. This document describes an extension to UCD MicroMUMPS that permits
  799. executing assembly language routines while in MUMPS. It should be
  800. useful for many activities such as screen manipulation and exter-
  801. nal file management. ZCALL  provides  the  mechanism  to  execute
  802. user-generated assembly language routines.
  803.  
  804.      The syntax is:
  805.  
  806.      ZC[ALL] ^rtn[,^rtn]...
  807.  
  808.      where  ^rtn has the form:  ^rtn_name[([parameter_list])]
  809.  
  810.                                   |   ,  | |  ,  |
  811.      where parameter_list is:|      |[|     |]...
  812.                                   | expr | |,expr|
  813.  
  814.      and expr may be: a global or local variable name
  815.                       a literal string
  816.                       a settable function (except $PIECE)
  817.  
  818.      ^rtn-name references an assembly routine contained in
  819.                    a file with the file extension '.OBJ'.
  820.  
  821.           - the ZCALL command may be post-conditionalized
  822.  
  823.           - ^rtn may be post-conditionalized if no
  824.                    parenthesized expression is present.
  825.  
  826.           - indirection:
  827.  
  828.               ^rtn may be specified by indirection if no parenthesized
  829.                 expression is present.
  830.  
  831.                parameters may be specified by indirection if ^rtn is
  832.                 not indirect.
  833.  
  834. ZCALLing an assembly routine is much like DOing a standard  MUMPS
  835. routine,  except  that  a label reference (alternate entry point)
  836. may not preceed the caret (^) in the command  arguemnt.   ZCALLed
  837. assembly  routines are dynamically buffered just as standard rou-
  838. tines. All routines, standard MUMPS and  assembly,  constitute  a
  839. single  set  that is subject to the current `least recently used'
  840. buffering  algorithm.   ZCALL  executes  the   assembly   routine
  841. `rtn_name.OBJ'.   There is no conflict if an assembly routine and
  842. a MUMPS routine  share  a  common  primary  filename.   That  is,
  843. ABC.MMP and ABC.OBJ may both exist.
  844.  
  845. Example:
  846.  
  847.      assume MUMPS program ABC.MMP contains the code segment
  848.  
  849.           ... ZC ^ABC ...
  850.  
  851.      then the following MUMPS code segment is valid
  852.  
  853.           ... DO ^ABC ...
  854.  
  855.  
  856.                              - 12 -
  857.  
  858.  
  859.  
  860. Unlike MUMPS routines that are first  loaded  from  disk  to  the
  861. MUMPS partition (thus limiting their size to the partition size),
  862. assembly language routines are loaded directly from disk  to  the
  863. routine  buffer area.  This eliminates any size restriction on an
  864. assembly routine.  The Zedit commands (ZLOAD, ZREMOVE, etc.) have
  865. no  effect  on  assembly  routines.  That is, ZLOAD ABC will load
  866. ABC.MMP (if it exists) independently of the existence of ABC.OBJ.
  867. Parameters  are  passed by value, i.e. after evaluation. There is
  868. no explicit limit on the number of parameters.  An implicit limit
  869. is  the 255 character MUMPS line length limit, before evaluation.
  870. Evaluated parameters are passed to a buffer area.  The length  of
  871. of  this  buffer  is defined by the user.  No limit exists on the
  872. length of  this  user  buffer  (and  therefore  on  the  combined
  873. evaluated  length  of all parameters).  Notice that the parameter
  874. syntax allows null parameters to be passed to the  assembly  rou-
  875. tine.
  876.  
  877.      ZC ^RTN                  passes no parameters
  878.      ZC ^RTN()                passes (1) null parameter
  879.      ZC ^RTN(,)               passes (2) null parameters
  880.      ZC ^RTN(var1,,^var2,)    passes (4) parameters:
  881.                               1. the value of local var1
  882.                               2. a null parameter
  883.                               3. the  value of global ^var2
  884.                               4. a null parameter
  885.  
  886. ZCALLable  assembly routines may optionally take advantage of the
  887. `call  back' facility.  This facility allows the assembly routine
  888. to `call back' to MUMPS to have the following services performed.
  889.  
  890.    func#       function
  891.  
  892.      0.   set a local or global variable or settable function.
  893.           exception: $PIECE
  894.      1.   fetch a global/local variable or dollar function.
  895.           exception: $PIECE
  896.      2.   kill a global or local variable.
  897.      3.   convert unsigned byte in AL register to ASCII string.
  898.      4.   store a word variable within MUMPS.
  899.      5.   get the word variable previously stored.
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.                    WRITING ASSEMBLY ROUTINES
  907.  
  908. This section explains the minimum assembly source  file  required
  909. to generate a ZCALLable routine.  It presents a skeleton that may
  910. be used to construct actual routine source files with a  line-by-
  911. line  explanation.  A skeleton file (SKELETON.ASM) is included on
  912. the distribution disk.  Label names may be changed  to  suit  the
  913. user.  If this is done, take care to replace any duplicate refer-
  914. ences of the changed  label  name.   No  source  line  may  exist
  915. preceding  line 1 that would generate byte(s) in the object file.
  916. The form and order of the lines must be preserved.
  917.  
  918.  
  919.  
  920.  
  921.  
  922.                              - 13 -
  923.  
  924.  
  925.  
  926.      1:   CODE SEGMENT   BYTE PUBLIC 'CODE'
  927.      2:        ASSUME    CS:CODE, DS:CODE, ES:CODE
  928.  
  929.      3:             jmp  my_code        ;jump to executable code
  930.      4:   call_back dd   0              ;call_back vector
  931.      5:   bfsiz     dw   offset stk_siz-$-5  ;'buf' size
  932.      6:   t_len     dw   0              ;total parameter length
  933.      7:   p_count   db   0              ;parameter count
  934.      8:   buf       rs   80H            ;communications buffer
  935.      9:   stk_siz   dw   0              ;MUMPS stack free space
  936.      A:   user_data dw   ??
  937.           :
  938.           :
  939.      M:   more_user db   ??
  940.      N:   my_code:                      ;start of user code
  941.           :
  942.           :
  943.      P:   retf                          ;return to MUMPS
  944.  
  945.  
  946.      1:   cseg
  947.         1:  CODE SEGMENT   BYTE PUBLIC 'CODE'
  948.  
  949. Line 1.  The required assembler directive. Notice that the  'pub-
  950. lic'  attribute  allows  you to have several source files (or li-
  951. brary routines) that will link together to generate  a  zcallable
  952. module.
  953.  
  954.         2: ASSUME     CS:CODE, DS:CODE, ES:CODE
  955.  
  956. Line 2. CS=DS=ES constitutes the Intel `small model.' Notice  the
  957. absence of an SS register declaration.
  958.  
  959.         3:          jmp  my_code        ;jump to executable code
  960.  
  961. Line 3. must be a `JMP  label'  instruction  where  `label'  must
  962. match  the  label  of  line  `N'.  This jump must be the standard
  963. length jump instruction (3 bytes) and not a short or a far jump.
  964.  
  965.         4:   call_back dd   0           ;call_back vector
  966.  
  967. Line 4. must appear exactly as shown.  This line  generates  room
  968. for  a  four byte far-call vector that is used to access the call
  969. back services described below. This line must exist even  if  the
  970. routine  will not perform a call-back.  The value is filled in by
  971. MUMPS.
  972.  
  973.         5:   bfsiz          dw   offset stk_siz-$-5  ;'buf' size
  974.  
  975. Line  5.  generates a word variable that holds the length of  the
  976. buffer generated by line 7.
  977.  
  978.         6:   t_len          dw   0        ;total parameter length
  979.  
  980. Line  6.  generates a word variable which has the meaning  'total
  981. passed  parameter  length'.  On entry, MUMPS fills this word with
  982. the combined length of all  passed  parameters  existing  in  the
  983. buffer  'buf'.  It does not count itself or the byte count of the
  984. number of passed parameters.
  985.  
  986.  
  987.  
  988.                              - 14 -
  989.  
  990.  
  991.  
  992.         7:   p_count   db   0           ;parameter count
  993.  
  994. Line  7.  generates a byte variable.  On ZCALL, MUMPS fills  this
  995. byte with the count of passed parameters.
  996.  
  997.         8:   buf            rs    80H             ;communications
  998. buffer
  999.  
  1000. Line  8.  establishes the communications buffer.  It is  used  to
  1001. accept passed parameters on entry as well as call-back communica-
  1002. tions (see below). The length of the buffer is specified  by  the
  1003. user  and  should  be  large  enough to accept all communications
  1004. data. As MUMPS loads the buffer, it checks `bfsiz' and  will  not
  1005. overflow  the  buffer.   A new MUMPS error `ASSEMBLY BUFFER OVER-
  1006. FLOW' is reported if all passed parameters cannot be loaded  into
  1007. 'buf' on entry.
  1008.  
  1009. On entry, 'buf' holds the passed parameters. The format is:
  1010.  
  1011.                     parameter
  1012.                          length     parameter
  1013.                     [|---------------|--------------|]...
  1014.                          1 byte       n bytes
  1015. Parameter length is the actual parameter length not counting  the
  1016. length  byte.  `p_count' is the number of occurences of this data
  1017. structure.
  1018.  
  1019.         An example using DEBUG
  1020.  
  1021.         DB9  (display memory by bytes starting @ byte 9, i.e. t_len)
  1022.  
  1023.         BBBB:0009 0A 00 03 03 65 66 67 00 04 65 66 67 68 . . . .
  1024.  
  1025.         t_len:    0A 00                         10 valid bytes in 'buf'
  1026.         p_count:        03                      3 parameters in 'buf'
  1027.         buf:               03                   3 byte length
  1028.                               65 66 67          param value 'ABC'
  1029.                                        00       a null param
  1030.                                           04    4 byte length
  1031.                                              65 66 67 68  'ABCD'
  1032.  
  1033.  
  1034.       9:   stk_siz   dw   0              ;MUMPS stack free space
  1035.  
  1036. Line  9.  generates a word value that holds the free room on  the
  1037. MUMPS  stack  on  entry.   See the section `STACK CONSIDERATIONS'
  1038. below.
  1039.  
  1040.       A:   user_data dw   ??
  1041.            :
  1042.       M:   more_user db   ??
  1043.  
  1044. Lines A. thru M. (inclusive) constitute  an  optional  user  data
  1045. area.   Consistent  with  the Intel ``small model'', user data is
  1046. not restricted to this area but may  be  interspersed  throughout
  1047. the code.
  1048.  
  1049.       N:   my_code:                      ;start of user code
  1050.  
  1051. Line  N.  The first line of executable code.  The label  must  be
  1052. referenced in line 2 jump instruction.
  1053.  
  1054.                              - 15 -
  1055.  
  1056.  
  1057.  
  1058.      P:   retf                          ;return to MUMPS
  1059.  
  1060. Line P. To return to MUMPS, simply execute a far return. If  your
  1061. assembler does not offer a mnemonic that generates the 1-byte far
  1062. return 0CBH, the following code will provide that mnemonic:
  1063.  
  1064.         retf    macro
  1065.                 db 0CBH
  1066.                 endm
  1067.  
  1068. Three files are included on the distribution disk that provide an
  1069. example of writing and using ZCALLable assembly routines:
  1070.  
  1071.    SKELETON.ASM  - this file provides a starting point for  writ-
  1072.    ing  an assembly routine.  It contains the required lines dis-
  1073.    cussed above.  Actual user  data  items  replace  the  example
  1074.    lines "user_data" through "more_user".  User code should start
  1075.    at label "my_code".
  1076.  
  1077.    Two files, ZCTEST.ASM and ZCTEST.OBJ, are the source code  and
  1078.    object  code  respectively  for  the example ZCALLable routine
  1079.    "ZCTEST". Refer to the section  "ASSEMBLING  ROUTINES"  below:
  1080.    the file ZCTEST.OBJ is NOT the direct output of an 8086 assem-
  1081.    bler.
  1082.  
  1083. ZCTEST is a ZCALLable assembly routine initially written  at  UCD
  1084. to  debug the development of the ZCALL command and is included to
  1085. aid the assembly programmer in writing  zcall  routines  and  ex-
  1086. ercising some of the zcall functions.
  1087.  
  1088. An example of using ZCTEST from within MUMPS:
  1089.      First set the following MUMPS variables:
  1090.  
  1091.      SET A="A LOCAL VARIABLE",B=2,C=3,^GVN="A GLOBAL VARIABLE"
  1092.  
  1093.      The MUMPS command   ZCALL ^ZCTEST(,A,B+C,,^GVN)   yields:
  1094.  
  1095.      o  the ZCTEST signon message
  1096.      o  a report of passed parameters:
  1097.  
  1098.           passed parameters:
  1099.           null parameter
  1100.           A LOCAL VARIABLE
  1101.           5
  1102.           null parameter
  1103.           A GLOBAL VARIABLE
  1104.  
  1105.           note: parameters passed by value, i.e. after evaluation
  1106.           note: if no parameters are passed, "none" is reported
  1107.  
  1108.      o  the ZCTEST menu:
  1109.  
  1110.           Call-Back Options:       <ESC> to quit
  1111.                                    <0> set glvn or settable function
  1112.                                    <1) fetch glvn or dollar function
  1113.                                    <2> kill glvn
  1114.  
  1115.                                    choice ?
  1116. A single keystoke reponse to "choice ?" will cause a request  for
  1117. the appropriate variable name and/or values.
  1118.  
  1119.  
  1120.                              - 16 -
  1121.  
  1122.  
  1123.  
  1124.  
  1125.                       STACK CONSIDERATIONS
  1126.  
  1127. As stated above, a seperate stack segment is not allowed.  Howev-
  1128. er,  two  options  are available: Option 1: Not too surprisingly,
  1129. the user may set-up his own stack within the single code segmnet.
  1130. This is the old 8080 way of doing things.  The only consideration
  1131. is that stack segment (SS) and stack pointer  (SP)  must  be  re-
  1132. stored to the entry state whenever a `call-back' is made, as well
  1133. as return to MUMPS.  Option 2: The user may elect to 'share'  the
  1134. MUMPS  stack, but must do so with care.  Since the MUMPS hardware
  1135. stack shares a memory area with the execution  stack  (with  each
  1136. growing  toward  the  other),  no statement can be made as to the
  1137. maximum stack space that will be available.  However,  on  entry,
  1138. the  word  variable  user  is  left  to test and consider if this
  1139. available room  will  be  sufficient  for  the  assembly  routine
  1140. without  overflow.   MUMPS  has  no  way of detecting an overflow
  1141. caused by the assembly routine.  Further,  if  a  'call-back'  is
  1142. made,   MUMPS  will need (AND USE) as much as twice the length of
  1143. all communications data (i.e. the length of  a  passed  variable,
  1144. after  evaluation).  However, since MUMPS is in control on 'call-
  1145. back', any overflow will be reported.  The absolute maximum  free
  1146. space  possible is in the order of 2010 bytes but is reduced from
  1147. this amount depending on 1. how deeply the users  MUMPS  routines
  1148. are  nested (stacked) and 2. The combined length of all arguments
  1149. referenced in the nested routines.
  1150.  
  1151.  
  1152.                      REGISTER CONSIDERATIONS
  1153.  
  1154. The user module is paragraph aligned.  On entry, the code segment
  1155. register  (CS),  data segment register (DS) and extra segment re-
  1156. gister (ES) are set to the base of the user module  and  the  in-
  1157. struction  pointer  (IP)  is  zeroed  such that CS:IP & DS:0 both
  1158. point to the 1st byte of the user module (The `jmp  my_code'  in-
  1159. struction).  The  stack resister SS & SP are the MUMPS stack. All
  1160. other registers should be considered  uninitialized.   On  return
  1161. from  call-back, MUMPS will restore the user's DS & ES registers:
  1162. all others not containing return data are destroyed.   On  return
  1163. to  MUMPS  (the `retf' far return), the user need not restore any
  1164. registers except for the stack pointer  (SP)  and  stack  segment
  1165. (SS) as discussed above.
  1166.  
  1167.  
  1168.                        CALL BACK SERVICES
  1169.  
  1170. To enhance the usefulness of assembly routines executing on (far)
  1171. call from MUMPS, a list of call-back services is provided.
  1172.  
  1173. The list, in function number order, is currently:
  1174.  
  1175.      0. Set a global or local variable or settable function except $PIECE.
  1176.  
  1177.      1. Fetch a MUMPS global/local variable or dollar function except $PIECE.
  1178.  
  1179.      2. Kill a MUMPS global/local variable.
  1180.  
  1181.      3. Convert 8-bit number to ASCII string.
  1182.  
  1183.      4. Store a word value for later retrieval.
  1184.  
  1185.      5. Recall a previously stored word variable.
  1186.  
  1187.                              - 17 -
  1188.  
  1189.  
  1190. The calling convention for making a call-back is as close as
  1191. possible to the calling convention used to make operating system
  1192. calls. Register CL is loaded with a call-back function number, DX
  1193. is set to the address of the calling string and a far call is
  1194. made to the call-back vector `call_back'. Returned string data is
  1195. placed in the communications buffer `buf'.  Register AL contains
  1196. an error flag.
  1197. All communications are in the form: one byte containing the
  1198. string length (this byte does not count itself), followed by
  1199. an ASCII string with no terminator.
  1200.  
  1201.      FUNCTION 0     SET LOCAL OR GLOBAL VARIABLE
  1202.                     SET A SETTABLE DOLLAR FUNCTION EXCEPT $PIECE
  1203.  
  1204.           entry: cl = 0                 exit: al = 0  successful
  1205.                  dx = name address            al = 0feh invalid name
  1206.                  bx = value address
  1207.  
  1208.      On entry, dx & bx point to the length byte of their respective strings.
  1209.  
  1210.           example:
  1211.                     :
  1212.                     set_name       db   15,'^ADDRESS("WJY")'
  1213.                     set_value      db   12,'123 MAIN ST.'
  1214.                     :
  1215.                     :
  1216.                     mov       cl, 0          ;'set' function number
  1217.                     lea       dx, set_name
  1218.                     lea       bx, set_value
  1219.                     callf     call_back      ;go do it
  1220.  
  1221.           result: variable ^ADDRESS("WJY") with be set to 123 MAIN ST.
  1222.  
  1223.      Notice that, as a consequence of communicating with strings, if the
  1224.      MUMPS variable NAME has the value "WJY", the following example 
  1225.      produces the same results as above.
  1226.  
  1227.                     set_name       db   14,'^ADDRESS(NAME)'
  1228.                     set_value      db   12,'123 MAIN ST.'
  1229.                     :
  1230.                     :
  1231.                     mov       cl, 0          ;'set' function number
  1232.                     lea       dx, set_name
  1233.                     lea       bx, set_value
  1234.                     callf     call_back      ;go do it
  1235.  
  1236.      FUNCTION 1     FETCH LOCAL OR GLOBAL VARIABLE
  1237.                     FETCH A DOLLAR FUNCTION EXCEPT $PIECE
  1238.  
  1239.           entry: cl = 0                 exit: al = 0  successful
  1240.                  dx = name address            al = 0ffh not found
  1241.                                               al = 0feh invalid name
  1242.           example:
  1243.                     :
  1244.                     fetch_name       db   15,'^ADDRESS("WJY")'
  1245.                     :
  1246.                     :
  1247.                     mov       cl, 1          ;'fetch' function number
  1248.                     lea       dx, fetch_name
  1249.                     callf     call_back      ;go do it
  1250.                
  1251.                  result: 'buf' contains bytes 0Ch,'123 MAIN ST.'
  1252.                              - 18 -
  1253.  
  1254.  
  1255.      FUNCTION 2     KILL LOCAL OR GLOBAL VARIABLE
  1256.  
  1257.           entry: cl = 2                 exit: al = 0  successful
  1258.                  dx = name address
  1259.                                               al = 0feh invalid name
  1260.           example:
  1261.                     :
  1262.                     kill_name       db   8,'^ADDRESS'
  1263.                     :
  1264.                     :
  1265.                     mov       cl, 2          ;'kill' function number
  1266.                     lea       dx, kill_name
  1267.                     callf     call_back      ;go do it
  1268.  
  1269.           result:   Complete file ^ADDRESS deleted.
  1270.  
  1271.      FUNCTION 3     CONVERT 8-bit UNSIGNED INTEGER TO ASCII STRING
  1272.  
  1273.           entry: cl = 3                        exit: al = 0  successful
  1274.                  al = unsigned interger
  1275.  
  1276.           result: integer valued ASCII string in 'buf'
  1277.  
  1278. The following two functions provide a (developmental) mechanism to
  1279. allow inter-routine communications.  They provide a means to pass a
  1280. word value between assembly routines. The meaning of the word is 
  1281. entirely defined by the assembly programmer.  Among other uses, it 
  1282. could represent the base address of an extra segment of memory 
  1283. obtained directly from the operating system.
  1284.  
  1285.      FUNCTION 4     STORE A WORD
  1286.  
  1287.           entry: cl = 4                 exit: al = 0  successful
  1288.                  dx = word to be stored
  1289.  
  1290.      FUNCTION 5     RECALL A WORD (previous stored by func 4)
  1291.  
  1292.           entry: cl = 5                 exit: al = 0  successful
  1293.                  bx = retrieved word
  1294.  
  1295.      FUNCTION 6     READ CHARCTER FROM KEYBOARD
  1296.  
  1297.           entry: cl = 6
  1298.  
  1299.           result: al=char code
  1300.  
  1301.      Notice that the entry and return registers parallel operating
  1302.      system calling conventions.
  1303.  
  1304.                          SPECIAL CAUTION
  1305.  
  1306. Assembly routines that read or write to disk files require special
  1307. handling. Assembly routines are loaded into the MUMPS data segment 
  1308. and are executed in that location.  On entry to an assembly routine, 
  1309. the DTA base address is set to the base of the MUMPS data segment. 
  1310. It is therefore necessary to:
  1311.    1. Get the DTA base address (via function 2FH) and store it.
  1312.    2. Set the DTA base address to the  base  of  the  assembly routine:
  1313.          Set DTA base to user CS register value via function 1AH.
  1314.    3. Perform disk file operations
  1315.    4. Recall stored entry DTA value and reset DTA base before exiting 
  1316.          to MUMPS.
  1317.  
  1318.                              - 19 -
  1319.  
  1320.  
  1321.  
  1322.  
  1323.                        ASSEMBLING ROUTINES
  1324.  
  1325. ZCALL  ^rtn will execute ROUTINE_NAME.OBJ that  was  obtained  as
  1326. follows:
  1327.  
  1328.      - create source code file RTN.ASM with intermixed  code  and
  1329. data  segment.   That  is, code, data, and extra segments sharing
  1330. the same base address. See the section  ``Stack  Considerations''
  1331. for  more details concerning the SS register. This approach simu-
  1332. lates the Intel "small model".
  1333.  
  1334.      - assemble the source.
  1335.  
  1336.      - link the resulting .OBJ file.  Note that requesting unini-
  1337. tialized memory is not allowed.
  1338.  
  1339.      - rename RTN.EXE to RTN.OBJ.
  1340.  
  1341. *** Should you inadvertently forget to rename the  .EXE  file  to
  1342. .OBJ, you will get the new MUMPS error `ASSEMBLY BUFFER OVERFLOW'
  1343. when you attempt to ZCALL this routine.
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.                              - 20 -
  1385.  
  1386.