home *** CD-ROM | disk | FTP | other *** search
/ Phoenix CD 2.0 / Phoenix_CD.cdr / 01e / msk230s1.zip / MSSSET.ASM < prev   
Assembly Source File  |  1988-02-12  |  100KB  |  2,381 lines

  1.         NAME    mssset
  2. ; File MSSSET.ASM
  3. ; Set command module
  4. ; edit history:
  5. ; Last edit: 4 Jan 1988
  6. ; 1 Jan 1988 version 2.30
  7. ; 4 Jan 1988 Check current disk on every Status display. [jrd]
  8. ; 3 Nov 1987 Fix parsing of Set Display with trailing spaces. [jrd]
  9. ; 19 Oct 1987 Cleanup, rewrite num0, allow \### in Set Escape-char. [jrd]
  10. ; 27 Aug 1987 Suppress Set Translate msgs if in quiet Take file. [jrd]
  11. ; 18 Aug 1987 Change ESC to escape for MASM 4.5+ [jrd]
  12. ; 31 July 1987 Increase Macro name space to 50 average names. [jrd]
  13. ; 7 July 1987 Change Show Macro to do cr/lf expansion internally. [jrd]
  14. ; 31 June 1987 Modify DEFINE Macro command to not parse backslash numbers
  15. ;  to binary; instead convert only commas to binary cr and simply store
  16. ;  everything else literally for the end user to parse. [jrd]
  17. ; 22 June 1987 Fix Set Remote On/Off display bits. [jrd]
  18. ; 13 June 1987 Rewrite Define/Do/Show Macro procedures to do automatic
  19. ;  deletion of macro space. A macro can be removed by saying Def mac-name <cr>
  20. ;  Permit backslash format binary numbers in defintions. Use base 10.
  21. ;  Many numerical parsing routines removed to file msster.asm so this file
  22. ;  will assemble under MASM 1.25. [jrd]
  23. ; 24 May 1987 Add SET DELAY seconds command. [jrd]
  24. ; 10 May 1987 Add keywords ON/OFF to Set Trans Input. Default is Off.
  25. ;  On/off condition is byte rxtable[256] (0=off, else on). [jrd]
  26. ; 24 March 1987 Add path to default disk status display.
  27. ;  Revise LOG Command to be LOG PACKETS | SESSION filespec [jrd]
  28. ; 21 March 1987 Add Set Translation and Show Translation commands to convert
  29. ;  incoming serial port bytes while in Connect mode.
  30. ; Add full number parsing code (cnvlin, katio, decout, valout) here too. [jrd]
  31. ; 4 Jan 1987 Add jump to keyboard translator when invoking Set Key if global
  32. ;  word stkadr (stored here) is non-zero; else use regular Set Key. Stkadr
  33. ;  would hold the offset address of the replacement Set Key routine. [jrd]
  34. ; 19 Nov 1986 Update trans.(pad and padch) to use the Users preset values
  35. ;  for I and S packets. [jrd]
  36. ; 1 Oct 1986 Version 2.29a
  37. ; 18 Sept 1986 Add 7-bit vs 8-bit flag to flags.remflg to control width
  38. ;  of characters being displayed. Part of Set Display command. [jrd]
  39. ; 13 Sept 1986 Add \ooo octal # notation to Set Prompt command. [jrd]
  40. ; 4 Sept 1986 Add Bob Goeke's change to move comms port table to a system
  41. ;  dependent module (typ msx---) to allow 3+ ports and localized idents. [jrd]
  42. ; 14 August 1986 Introduce Set Send/Receive End-of-Line [jrd]
  43. ; 17 July 1986 Replace Status display proc with better code. [jrd]
  44. ; 14 July 1986 Add Long packet support for Set send/rec packet length. [jrd]
  45. ; Add Script support, Set Input, from James Sturdevant. [jrd]
  46. ; 26 June 1986 Update trans.seol in Set End-of-line so S packets use preferred
  47. ;  (user specified) packet terminator. [jrd]
  48. ; 26 May 1986 Revise code to permit serial display. DISPLAY command now
  49. ;  accepts Quiet, Regular, or Serial arguments. [jrd]
  50. ; [2.29] code frozen on 6 May 1986 [jrd]
  51.  
  52.         public setcom, status, baudprt, prmptr, dodef, stat0
  53.         public setcpt, docom, shomac, dmpname, widmsk, stkadr
  54.         public setrx, shorx, rxtable
  55.         include mssdef.h
  56.  
  57. macmax  equ     50              ; max # of macros
  58.  
  59. maketab MACRO                   ; Assembler Macro to make rxtable [jrd]
  60. cnt = 0
  61.         rept 256
  62.         db      cnt             ; initialize table to 0 .. 255
  63. cnt = cnt + 1
  64.         endm
  65.         db      0               ; table off (0) or on (1) indicator
  66. ENDM
  67.  
  68. datas   segment public 'datas'
  69.         extrn   comand:byte, intake:byte, flags:byte, trans:byte, cptio:byte
  70.         extrn   takadr:word, taklev:byte, inichk:byte, portval:word
  71.         extrn   curdsk:byte, setktab:byte, setkhlp:byte, dtrans:byte
  72.         extrn   spause:byte, filtst:byte, maxtry:byte, imxtry:byte
  73.         extrn   indfto:word, inactv:byte, incasv:byte, inecho:byte
  74.         extrn   comptab:byte, termtb:byte
  75.  
  76. kerm    db      'Kermit-MS>$'
  77. crlf    db       cr,lf,'$'
  78. crlfsp  db      cr,lf,' ',' ','$'       ; crlf space space
  79. eqs     db      ' = $'
  80. ermes1  db      cr,lf,'?Too many macro names$'
  81. ermes2  db      cr,lf,'?No room for macro definition$'
  82. ermes3  db      cr,lf,'?Not confirmed$'
  83. ermes4  db      cr,lf,'?No room in Take stack to expand macro$'
  84. ermes5  db      cr,lf,'?Not implemented$'
  85. errcap  db      cr,lf,'?Unable to open that file$'
  86. filhlp  db      cr,lf,' Output filename for the log (def: Kermit.Log)$'
  87. dishlp  db      cr,lf,' Quiet (no screen writing), Regular (normal),'
  88.         db      ' Serial (non-formatted screen)'
  89.         db      cr,lf,' and/or 7-BIT (default) or 8-BIT wide characters.$'
  90. remhlp  db      cr,lf,' OFF to show file transfer statistics,'
  91.         db      ' ON for quiet screen$'
  92. macmsg  db      ' Specify macro name followed by body of macro, on same line$'
  93. shmmsg  db      ' Confirm with carriage return $'
  94. prmmsg  db      cr,lf
  95.         db    ' Enter new prompt string or nothing to regain regular prompt.'
  96.         db      cr,lf,' Use \123 notation for special chars (Escape is \27)$'
  97.  
  98. srxhlp1 db      cr,lf,' Enter   code for received byte   code for'
  99.         db      ' local byte ',cr,lf,' use ascii characters themselves or'
  100.         db      cr,lf,' numerical equivalents of  \nnn  decimal'
  101.         db      ' or \Onnn  octal or \Xnnn  hexadecimal',cr,lf
  102.         db      ' or keywords  ON  or  OFF  (translation is initially off)'
  103.         db      cr,lf,'$'
  104. badrx   db      cr,lf,' Bad byte code$'
  105. shormsg db      cr,lf,' Translation table of received byte codes while'
  106.         db      ' in CONNECT mode'
  107.         db      cr,lf,' Format: [received byte (decimal) -> local byte'
  108.         db      ' (decimal)]',cr,lf,'$'
  109. shopm1  db      ' [\$'                  ; Show Translation material
  110. shopm2  db      ' -> \$'
  111. shopm3  db      '] $'
  112. rxoffmsg db     cr,lf,' Input Translation is off.$'
  113. rxonmsg db      cr,lf,' Input Translation is on.$'
  114. rxtable equ THIS BYTE           ; build 256 byte Translation Input table
  115.         maketab                 ; table rxtable is used by Connect mode.
  116. stkadr  dw      0       ; non-zero if replacement keyboard xlator present
  117. prterr  db      '?Unrecognized value$'
  118. defpmp  db      'Definition string: $'
  119. nonmsg  db      'none$'
  120. delmsg  db      'delete$'
  121. onmsg   db      'on'
  122. offmsg  db      'off'
  123. defcpt  db      'KERMIT.LOG',0          ; default capture filename [jrd]
  124. dmpdefnam db    'KERMIT.SCN',0          ; asciiz default screen dump filename
  125.  
  126. widmsk  db      7FH                     ; non-pkt display width, def=7 bits
  127. tmp     db      ?,'$'
  128. min     dw      0
  129. max     dw      0
  130. numerr  dw      0
  131. numhlp  dw      0
  132. stflg   db      0               ; Says if setting SEND or RECEIVE parameter.
  133. temp    dw      0
  134. temp1   dw      ?                       ; Temporary storage.
  135. temp2   dw      ?                       ; Temporary storage.
  136.  
  137. modst   db      'Mode line: $'
  138. locst   db      'Local echo: $'
  139. belon   db      'Ring bell after transfer$'
  140. beloff  db      'No bell after transfer$'
  141. vtemst  db      'Terminal emulation: $'         ; terminal emulator [jrd]
  142. portst  db      'Communications port: $'
  143. capmsg  db      'Logging: $'
  144. dmpmsg  db      'Dump screen file: $'
  145. eofmsg  db      'EOF mode: $'
  146. flost   db      'No flow control used$'
  147. floxmsg db      'Flow control: xon/xoff $'
  148. handst  db      'Handshake used: $'
  149. destst  db      'File destination: $'
  150. diskst  db      'Path: $'
  151. blokst  db      'Block check used: $'
  152. ;;ebyst db      '8-bit quoting done only on request$'
  153. ;;ebvst db      '8-bit quoting will be done with: $'
  154. sqcst   db      'Send control char prefix: $'
  155. rqcst   db      'Receive control char prefix: $'
  156. debon   db      'Debug mode: $'
  157. flwon   db      'Warning (filename change): $'
  158. parmsg  db      'Parity: $'
  159. abfdst  db      'Discard incomplete file$'
  160. abfkst  db      'Keep incomplete file$'
  161. sndmsg  db      'Send Delay: $'
  162. sndmsg2 db      ' sec, Pause: $'
  163. sndmsg3 db      ' ms$'
  164. ssohst  db      'Send start-of-packet char: $'
  165. rsohst  db      'Receive start-of-packet char: $'
  166. meolst  db      'End-of-Line char  S: ',5eh,'$'
  167. mseol2  db      '  R: ',5eh,'$'
  168. stimst  db      'Send timeout (seconds): $'
  169. rtimst  db      'Receive timeout (seconds): $'
  170. spakst  db      'Send packet size: $'
  171. rpakst  db      'Receive packet size: $'
  172. snpdst  db      '# of send padding chars: $'
  173. rnpdst  db      '# of receive padding chars: $'
  174. retrymsg db     'Retry send/receive packet limit: $'
  175. dispst  db      'Display (vs Remote):$'
  176. remost  db      'Remote (vs Display) $'
  177. timmsg  db      'Timer: $'
  178. escmes  db      'Escape character: $'
  179. scpmsg  db      'Scripts(Input):$'
  180. scpmsne db      ' echo:off, $'
  181. scpmse  db      ' echo:on, $'
  182. casmsi  db      'case:ignore, $'
  183. casmso  db      'case:observe, $'
  184. scptms  db      'def-tmo: $'
  185. scpmsp  db      ' sec, tmo-action:proceed$'
  186. scpmsq  db      ' sec, tmo-action:quit$'
  187. baudrt  db      'Baud rate is $'
  188. unrec   db      'unknown$'
  189.  
  190. nummsg1 db      cr,lf,'?Use a number between $'
  191. nummsg2 db      ' and $'
  192. dmphlp  db      'Enter name of disk file to hold screen dumps$'
  193. eolhlp  db      cr,lf,'Decimal number between 0 and 31$'
  194. timhlp  db      cr,lf,'Decimal number between 0 and 94$'
  195. quohlp  db      cr,lf,'Decimal number between 33 and 126$'
  196. pakerr  db      cr,lf,'Illegal packet length. Choose a decimal number '
  197.         db      cr,lf,'from 20 to 94 (normal) or to 1000 (long)$'
  198. pakhlp  db      cr,lf,'Decimal number between 20 and 94 (normal) or '
  199.         db      '1000 (long)$'
  200. npdhlp  db      cr,lf,'Decimal number between 0 and 99$'
  201. paderr  db      cr,lf,'Illegal pad character$'
  202. padhlp  db      cr,lf,'Decimal number between 0 and 31 or 127$'
  203. pauhlp  db      cr,lf,'Decimal number between 0 and 127$'
  204. retryhlp db     cr,lf,'Decimal number between 1 and 63$'
  205. delyhlp db      cr,lf,'Delay seconds before sending file (0-63)$'
  206. eschlp  db      cr,lf,'Press literal control code (ex: Cntrl ]) or'
  207.         db      ' enter numerical value in \### form$'
  208. escerr  db      cr,lf,'?Not a control code$'
  209. dskhlp  db      cr,lf,'Default disk drive to use, such as A:$'
  210. dskerr  db      cr,lf,'Invalid drive specification$'
  211. hnd1hlp db      cr,lf,'xon (17), xoff (19), cr (13), lf (10), bell (7),'
  212.         db      ' esc (27), none (0)'
  213.         db      cr,lf,' or "code" followed by decimal number$'
  214. hnd2hlp db      cr,lf,'Decimal number between 0 and 31$'
  215. intoms  db      'number of seconds to wait before timeout',cr,lf,'$'
  216. loghlp  db      cr,lf,' PACKETS - during file transfers'
  217.         db      cr,lf,' SESSION - during Connect mode'
  218.         db      cr,lf,' followed by optional filename (default is KERMIT.LOG)$'
  219. debhlp  db      cr,lf,' PACKETS - during file transfers'
  220.         db      cr,lf,' SESSION - during Connect mode'
  221.         db      cr,lf,' ON - both packets and sessions'
  222.         db      cr,lf,' OFF - turns off all debugging$'
  223.  
  224. sethlp  db      cr,lf,lf
  225.         db      '  Baud or Speed     many speeds      '
  226.         db      '  Key         key-ident   definition '
  227.         db      cr,lf
  228.         db      '  Bell    on/off    at end of xfers  '
  229.         db      '  Local-echo        on/off'
  230.         db      cr,lf
  231.         db      '  Block-check-type  checksum/CRC     '
  232.         db      '  Mode-line         on/off'
  233.         db      cr,lf
  234.         db      '  Debug   on/off    display packets  '
  235.         db      '  Parity    even/odd/mark/space/none'
  236.         db      cr,lf
  237.         db      '  Default-disk                       '
  238.         db      '  Port for i/o      1/2/COM1/COM2'
  239.         db      cr,lf
  240.         db      '  Delay   secs  before Sending file  '
  241.         db      '  Prompt  string    (new Kermit prompt)'
  242.         db      cr,lf
  243.         db      '  Destination   Disk/Screen/Printer  '
  244.         db      '  Receive parameter  many things'
  245.         db      cr,lf
  246.         db      '  Display quiet/reg/serial show cnts?'
  247.         db      '  Remote    on/off  show xfer counts?'
  248.         db      cr,lf
  249.         db      '  Dump filespec     screen to disk   '
  250.         db      '  Retry limit for packet send/receive'
  251.         db      cr,lf
  252.         db      '  End-of-line char  cr or whatever   '
  253.         db      '  Send parameter    many things'
  254.         db      cr,lf
  255.         db      '  EOF Ctrl-Z/NoCtrl-Z  ^Z ends file? '
  256.         db      '  Take-echo on/off  display commands?'
  257.         db      cr,lf
  258.         db      '  Escape char  ^]   or whatever      '
  259.         db      '  Terminal  none, Heath-19, VT52, VT102,'
  260.         db      cr,lf
  261.         db      '  Flow-control      xon-xoff or none '
  262.         db      '     and many terminal setup parameters'
  263.         db      cr,lf
  264.         db      '  Handshake xon/xoff/cr/lf/bell/esc..'
  265.         db      '  Timer     on/off  time packet waiting'
  266.         db      cr,lf
  267.         db      '  Incomplete file   keep/discard     '
  268.         db      '  Translation IN  Connect mode rcv',27h,'d char'
  269.         db      cr,lf
  270.         db      '  Input timeout, etc   (for scripts) '
  271.         db      '  Warning   on/off  if file renamed'
  272.         db      cr,lf,'$'
  273.  
  274. settab   db     32
  275.         mkeyw   'Baud',baudst
  276.         mkeyw   'Bell',bellst
  277.         mkeyw   'Block-check-type',blkset
  278.         mkeyw   'Debug',debst
  279.         mkeyw   'Default-disk',dskset
  280.         mkeyw   'Delay',setdely
  281.         mkeyw   'Destination',desset
  282.         mkeyw   'Display',disply
  283.         mkeyw   'Dump',setdmp
  284.         mkeyw   'End-of-Line',eolset
  285.         mkeyw   'EOF',seteof
  286.         mkeyw   'Escape',escset
  287.         mkeyw   'Flow-control',floset
  288.         mkeyw   'Handshake',hndset
  289.         mkeyw   'Incomplete',abfset
  290.         mkeyw   'Input',inpset
  291.         mkeyw   'Key',setkey
  292.         mkeyw   'Local-echo',lcal
  293.         mkeyw   'Mode-line',modl
  294.         mkeyw   'Parity',setpar
  295.         mkeyw   'Port',coms
  296.         mkeyw   'Prompt',promset
  297.         mkeyw   'Receive',recset
  298.         mkeyw   'Remote',remset
  299.         mkeyw   'Retry',retryset
  300.         mkeyw   'Send',sendset
  301.         mkeyw   'Speed',baudst
  302.         mkeyw   'Take-echo',takset
  303.         mkeyw   'Terminal',vts
  304.         mkeyw   'Timer',timset
  305.         mkeyw   'Translation',setrx
  306.         mkeyw   'Warning',filwar
  307.  
  308.  
  309. seoftab db      2
  310.         mkeyw   'Ctrl-Z',1
  311.         mkeyw   'NoCtrl-Z',0
  312.  
  313. stsrtb  db      8                               ; Number of options.
  314.         mkeyw   'End-of-Line',sreol
  315.         mkeyw   'Packet-length',srpack
  316.         mkeyw   'Padchar',srpad
  317.         mkeyw   'Padding',srnpd
  318.         mkeyw   'Pause',srpaus
  319.         mkeyw   'Quote',srquo
  320.         mkeyw   'Start-of-packet',srsoh
  321.         mkeyw   'Timeout',srtim
  322.  
  323. ontab   db      2
  324.         mkeyw   'off',0
  325.         mkeyw   'on',1
  326.  
  327.  
  328. destab  db      3                       ; Three choices
  329.         mkeyw   'Disk',1
  330.         mkeyw   'Printer',0
  331.         mkeyw   'Screen',2
  332.  
  333. distab  db      5                       ; Set Display mode [jrd]
  334.         mkeyw   '7-bit',7               ; controls bit d8bit in flags.remflg
  335.         mkeyw   '8-bit',8               ; sets d8bit
  336.         mkeyw   'Quiet',dquiet          ; values defined in header file
  337.         mkeyw   'Regular',dregular
  338.         mkeyw   'Serial',dserial
  339.  
  340. dissta  db      6                       ; Status of Display mode [jrd]
  341.         mkeyw   'Quiet, 7-bit',dquiet
  342.         mkeyw   'Regular, 7-bit',dregular
  343.         mkeyw   'Serial, 7-bit',dserial
  344.         mkeyw   'Quiet, 8-bit',dquiet+d8bit
  345.         mkeyw   'Regular, 8-bit',dregular+d8bit
  346.         mkeyw   'Serial, 8-bit',dserial+d8bit
  347.  
  348. ; What type of block check to use.
  349. blktab  db      3
  350.         mkeyw   '1-character-checksum',1
  351.         mkeyw   '2-character-checksum',2
  352.         mkeyw   '3-character-CRC-CCITT',3
  353.  
  354. ; If abort when receiving files, can keep what we have or discard
  355.  
  356. abftab  db      2                       ; Only two options.
  357.         mkeyw   'Discard',1
  358.         mkeyw   'Keep',0
  359.  
  360. partab  db      5                       ; Five entries
  361.         mkeyw   'even',PAREVN
  362.         mkeyw   'mark',PARMRK
  363.         mkeyw   'none',PARNON
  364.         mkeyw   'odd',PARODD
  365.         mkeyw   'space',PARSPC
  366.  
  367. flotab  db      2
  368.         mkeyw   'none',flonon
  369.         mkeyw   'xon/xoff',floxon
  370.  
  371. hndtab  db      8
  372.         mkeyw   'bell',bell
  373.         mkeyw   'code',0ffh             ; allow general numerial code [jrd]
  374.         mkeyw   'cr',cr
  375.         mkeyw   'esc',escape
  376.         mkeyw   'lf',lf
  377.         mkeyw   'none',0
  378.         mkeyw   'xoff',xoff
  379.         mkeyw   'xon',xon
  380.  
  381. inptab  db      4                               ; Scripts. Set Input
  382.         mkeyw   'Case',inpcas                   ;[jrs]
  383.         mkeyw   'Default-timeout',inptmo        ;[jrs]
  384.         mkeyw   'Echo',inpeco                   ;[jrs]
  385.         mkeyw   'Timeout-action',inpact         ;[jrs]
  386.  
  387. inactb  db      2                               ; Set Input Timeout Action
  388.         mkeyw   'Proceed',0                     ;[jrs]
  389.         mkeyw   'Quit',1                        ;[jrs]
  390.  
  391. incstb  db      2                               ;[jrs] Set Input Case
  392.         mkeyw   'Ignore',0dfh                   ;[jrs]
  393.         mkeyw   'Observe',0ffh                  ;[jrs]
  394.  
  395.  
  396. bdtab   db      18                      ; 18 entries
  397.         mkeyw   '110',b0110
  398.         mkeyw   '115200',b115200
  399.         mkeyw   '1200',b1200
  400.         mkeyw   '134.5',b01345
  401.         mkeyw   '150',b0150
  402.         mkeyw   '1800',b1800
  403.         mkeyw   '19200',b19200
  404.         mkeyw   '2000',b2000
  405.         mkeyw   '2400',b2400
  406.         mkeyw   '300',b0300
  407.         mkeyw   '38400',b38400
  408.         mkeyw   '45.5',b00455
  409.         mkeyw   '4800',b4800
  410.         mkeyw   '50',b0050
  411.         mkeyw   '57600',b57600
  412.         mkeyw   '600',b0600
  413.         mkeyw   '75',b0075
  414.         mkeyw   '9600',b9600
  415.  
  416. debtab  db      4                       ; Set Debug command
  417.         mkeyw   'Off',0
  418.         mkeyw   'On',logpkt+logses
  419.         mkeyw   'Packets',logpkt
  420.         mkeyw   'Session',logses
  421.  
  422. logtab  db      2                       ; LOG command
  423.         mkeyw   'Packets',logpkt
  424.         mkeyw   'Session',logses
  425.  
  426. logsta  db      4                       ; Log Status table
  427.         mkeyw   'off',logoff            ; suspended or no logging
  428.         mkeyw   'Packets',logpkt
  429.         mkeyw   'Session',logses
  430.         mkeyw   'Packet+Session',logpkt+logses
  431.  
  432. trnstab db      1                       ; Set Translation table
  433.         mkeyw   'Input',1
  434.  
  435. prmptr  dw      kerm                    ; pointer to prompt
  436. prm     db      80 dup (?)              ; Buffer for new prompt.
  437. dmpname db      'KERMIT.SCN',54 dup (0) ; file name for screen dumps [jrd]
  438.  
  439. rdbuf   db      128 dup (?)             ; work space; room for macro def too
  440.                                         ;  and for Status display line
  441.  
  442. mcctab  db      1                       ; macro name table, one initially
  443.         mkeyw   'IBM',ibmmac            ; offset of definition string (7 bytes)
  444.         db      (macmax*10 - 7) dup (?) ; room for rest of macro names
  445. mcclen  equ     $-mcctab                ; length of mcctab
  446. mccptr  dw      mcctab + 8              ; ptr to first free byte in mcctab
  447.  
  448. macbuf  equ     this byte               ; buffer of macro strings
  449. ibmmac  db      imlen                   ; startup IBM macro definition
  450.         db      'set timer on',cr,'set parity mark',cr
  451.         db      'set local-echo on',cr,'set handshake xon',cr
  452.         db      'set flow none',cr
  453. imlen   equ     $-ibmmac-1
  454.         db      (macmax*60 -imlen-1) dup (?); space for additonal macro defs
  455. maclen  equ     $ - macbuf              ; length of macbuf
  456. macptr  dw      macbuf+imlen+1          ; ptr to first free byte in macbuf
  457.  
  458. shom9a  db      cr,lf,' Free space (bytes) for names: $'
  459. shom9c  db      ', for definitions: $'
  460.  
  461.  
  462. ; structure for status information table sttab.
  463. stent   struc
  464. sttyp   dw      ?               ; type (actually routine to call)
  465. msg     dw      ?               ; message to print
  466. val2    dw      ?               ; needed value: another message, or tbl addr
  467. tstcel  dw      ?               ; address of cell to test, in data segment
  468. basval  dw      0               ; base value, if non-zero
  469. stent   ends
  470.  
  471. sttab   stent   <baudprt>
  472.         stent   <srchkw,vtemst,termtb,flags.vtflg>      ; terminal emulator
  473.         stent   <srchkw,portst,comptab,flags.comflg>
  474.         stent   <onoff,modst,,flags.modflg>
  475.         stent   <srchkw,parmsg,partab,parflg,portval>
  476.         stent   <prsnd, sndmsg>
  477.         stent   <onoff,locst,,ecoflg,portval>
  478.         stent   <stnum,stimst,,dtrans.stime>
  479.         stent   <msg2,flost,floxmsg,floflg,portval>
  480.         stent   <onechr,ssohst,,trans.ssoh>
  481.         stent   <prhnd>
  482.         stent   <stlnum,spakst,,trans.slongp>
  483.         stent   <drnum,diskst,,curdsk>
  484.         stent   <stnum,snpdst,,dtrans.spad>
  485.         stent   <srchkw,destst,destab,flags.destflg>
  486.         stent   <onechr,sqcst,,trans.rquote>
  487.         stent   <onoff,flwon,,flags.flwflg>
  488.         stent   <stnum,rtimst,,trans.rtime>
  489.         stent   <msg2,abfkst,abfdst,flags.abfflg>
  490.         stent   <onechr,rsohst,,trans.rsoh>
  491.         stent   <srchkw,eofmsg,seoftab,flags.eofcz>
  492.         stent   <stlnum,rpakst,,trans.rlongp>
  493.         stent   <msg2,beloff,belon,flags.belflg>
  494.         stent   <stnum,rnpdst,,trans.rpad>
  495.         stent   <srchkw,capmsg,logsta,flags.capflg>
  496.         stent   <onechr,rqcst,,dtrans.squote>
  497.         stent   <onoff,timmsg,,flags.timflg>
  498.         stent   <preol,meolst>
  499.         stent   <srchkw,debon,logsta,flags.debug>
  500.         stent   <stnum,retrymsg,,maxtry>
  501.         stent   <onechr,escmes,,trans.escchr>
  502.         stent   <srchkw,blokst,blktab,trans.chklen>
  503.         stent   <srchkw,dispst,dissta,flags.remflg>
  504.         stent   <dmpstat,dmpmsg>
  505.         stent   <scpprt,scpmsg>
  506.         stent   <vtstat>                        ; Terminal status, in MSX
  507.         dw      0                               ; end of table
  508.  
  509. datas   ends
  510.  
  511. code    segment public 'code'
  512.         extrn prserr:near, comnd:near, dobaud:near, cmblnk:near, locate:near
  513.         extrn cmgtch:near, repars:near, coms:near, defkey:near
  514.         extrn inicpt:near, prompt:near, prtscr:near
  515.         extrn getbaud:near, isfile:near, strlen:near
  516.         extrn strcpy:near, cnvlin:near, katoi:near, decout:near, atoi:near
  517.         extrn vts:near, vtstat:near
  518.         assume  cs:code, ds:datas, es:nothing
  519.  
  520. ; DO defined macro command
  521.  
  522. DOCOM   PROC    NEAR
  523.         mov     dx,offset mcctab
  524.         mov     bx,0
  525.         mov     ah,cmkey
  526.         call    comnd
  527.          jmp    r
  528.         mov     temp,bx
  529.         mov     ah,cmcfm
  530.         call    comnd
  531.          jmp    r
  532.          nop
  533.         mov     bx,temp
  534.         cmp     taklev,maxtak           ; room in take level?
  535.         jl      docom2                  ; yes, continue
  536.         mov     dx,offset ermes4        ; else complain
  537.         jmp     reterr
  538. docom2: inc     taklev                  ; increment take level (overflow)
  539.         add     takadr,size takinfo
  540.         mov     si,bx                   ; point to macro definition
  541.         mov     cl,[si]                 ; get size from initial byte
  542.         mov     ch,0
  543.         inc     si                      ; point to actual definition
  544.         mov     bx,takadr               ; point to current buffer
  545.         mov     [bx].taktyp,0ffh        ; flag as a macro
  546.         mov     [bx].takptr,si          ; point to beginning of def
  547.         mov     [bx].takchl,cl          ; # of chars left in buffer
  548.         mov     [bx].takcnt,cx          ; and in definition
  549.         mov     word ptr [bx].takcnt+2,0 ; zero high order...
  550.         jmp     rskp
  551. DOCOM   ENDP
  552.  
  553. ; DEFINE macro command
  554. ; Data structures comments. Macro name is stored in table mcctab as if we
  555. ; had used macro mkeyw, such as       mkeyw 'mymac',offset my_definition.
  556. ; In detail:    db      length of name
  557. ;               db      'name'
  558. ;               db      '$'
  559. ;               dw      offset of definition string
  560. ; Mcctab begins with a byte holding the number of macros in the table; one,
  561. ;  IBM, is established at assembly time. Mcctab is 10*macmax bytes long.
  562. ; Pointer mccptr holds the offset of the next free byte in mcctab.
  563. ; Definition strings are stored in table macbuf as
  564. ;               db      length of definition string below
  565. ;               db      'definition string'
  566. ; Pointer macptr holds the offset of the next free byte in macbuf. Macbuf
  567. ; is nominally 100*macmax bytes long.
  568. ; A new definition is read into buffer rdbuf+1, where byte rdbuf is reserved
  569. ;  to hold the length of the macro's name during intermediate processing.
  570. ; If the definition is absent then the macro is removed from the tables.
  571. ; Rewritten 13 June 1987 [jrd]
  572. DODEF   PROC    NEAR
  573.         mov     ah,cmtxt
  574.         mov     bx,offset rdbuf+1       ; buffer for keyword
  575.         mov     dx,offset macmsg
  576.         call    comnd
  577.          jmp    r
  578.          nop
  579.         xchg    ah,al
  580.         xor     ah,ah
  581.         mov     temp,ax                 ; save length of command line
  582.         cmp     ax,0                    ; is command line empty?
  583.         jne     dode1                   ; ne = no
  584.         ret                             ; return not confirmed
  585. dode1:  mov     ah,cmcfm                ; get a confirm
  586.         call    comnd
  587.          jmp    r
  588.          nop
  589.         push    ds                      ; address data segment
  590.         pop     es
  591.         cld                             ; strings go forward
  592.         mov     cx,temp                 ; cmd line len, cx = running counter
  593.         mov     rdbuf,0                 ; number of chars in keyword so far
  594.                                         ; uppercase the keyword, look for end
  595.         mov     si,offset rdbuf+1       ; point at macro name text
  596. dode2:  lodsb                           ; get a byte, dec cx
  597.         cmp     al,'a'                  ; map lower case to upper
  598.         jb      dode3
  599.         cmp     al,'z'
  600.         ja      dode3
  601.         sub     al,'a'-'A'
  602.         mov     [si-1],al               ; uppercase if necessary
  603. dode3:  inc     rdbuf                   ; increment char count of keyword
  604.         cmp     al,' '                  ; is this the break character?
  605.         loopne  dode2                   ; no, loop thru rest of word
  606.         jne     dode4                   ; ended with break char?
  607.         dec     rdbuf                   ; yes, don't count in length
  608. dode4:
  609.         call    remtab                  ; remove any duplicate keyword
  610.         jcxz    dode6                   ; cx = 0 means no keyword
  611.                                 ; check for free space for keyword and string
  612.         mov     al,rdbuf                ; keyword text length
  613.         add     al,4                    ; plus overhead bytes
  614.         xor     ah,ah
  615.         add     ax,mccptr               ; add to free space pointer
  616.         cmp     ax,offset mcctab+mcclen ; enough room?
  617.         jb      dode5                   ; b = yes
  618.         mov     dx,offset ermes1        ; too many macro names
  619.         jmp     reterr
  620. dode5:  mov     di,si                   ; scan after keyword name
  621.         mov     al,' '                  ; remove leading spaces in string
  622.         repe    scasb
  623.         je      dode6                   ; e = all spaces
  624.         inc     cx                      ; offset auto decrement of rep
  625.         dec     di                      ; offset auto increment of rep
  626.         mov     si,di                   ; point to start of string text
  627.         mov     dx,di                   ; source of definition text
  628.         call    strlen                  ; get length of string into cx
  629.         mov     ax,cx                   ; length of string
  630.         mov     temp,cx                 ; remember it here
  631.         inc     ax                      ; plus its count byte
  632.         add     ax,macptr               ; plus free space pointer
  633.         cmp     ax,offset macbuf+maclen ; enough room?
  634.         jb      dode7                   ; b = yes
  635.  
  636.         mov     dx,offset ermes2        ; no room for definition
  637.         jmp     reterr
  638. dode6:  jmp     rskp
  639.                                         ; install new keyword in mcctab
  640. dode7:  cmp     temp,0                  ; temp = length of definition
  641.         je      dode10                  ; e = no def, exit now
  642.         mov     bx,offset mcctab
  643.         mov     dx,offset rdbuf
  644.         call    addtab
  645.                         ; copy definition into buffer, changing commas to CRs
  646.         mov     di,macptr               ; free space in string buffer
  647.         mov     bx,di                   ; look at count byte
  648.         inc     di                      ; skip over count byte
  649.         mov     cx,temp                 ; length of string text
  650.         mov     byte ptr[bx],cl         ; store length of string
  651. dode8:  lodsb                           ; get a byte
  652.         cmp     al,','                  ; comma?
  653.         jne     dode9                   ; no, keep going
  654.         mov     al,cr                   ; else replace with cr
  655. dode9:  stosb
  656.         loop    dode8                   ; keep copying
  657.         mov     cx,temp
  658.         inc     cx                      ; number of bytes copied overall
  659.         add     macptr,cx               ; update free ptr
  660. dode10: jmp     rskp
  661. DODEF   ENDP
  662.  
  663. ; add an entry to a keyword table
  664. ; enter with bx = table address, dx = ptr to new entry, macptr = string offset,
  665. ; mccptr = offset of free bytes in table mcctab.
  666. ; no check is made to see if the entry fits in the table.
  667. addtab  proc    near
  668.         push    cx
  669.         push    si
  670.         push    es
  671.         cld
  672.         mov     ax,ds
  673.         mov     es,ax           ; address data segment
  674.         mov     bp,bx           ; remember where tbl starts
  675.         mov     cl,[bx]         ; pick up length of table
  676.         mov     ch,0
  677.         inc     bx              ; point to actual table...
  678.         jcxz    addta4          ; cx = 0 if table is presently empty
  679.  
  680. addta1: push    cx              ; preserve count
  681.         mov     si,dx           ; point to entry
  682.         lodsb                   ; get length of new entry
  683.         mov     cl,[bx]         ; and length of table entry...
  684.         mov     ah,0            ; assume they're the same size
  685.         cmp     al,cl           ; are they the same?
  686.         lahf                    ; remember result of comparison...
  687.         jae     addta2          ; is new smaller? no, use table length
  688.         mov     cl,al           ; else use length of new entry
  689. addta2: mov     ch,0
  690.         lea     di,[bx+1]       ; point to actual keyword
  691.         repe    cmpsb           ; compare strings
  692.         pop     cx              ; restore count
  693.         jb      addta4          ; below, insert before this one
  694.         jne     addta3          ; not below or same, keep going
  695.         sahf                    ; same. get back result of length comparison
  696.         jb      addta4          ; if new len is smaller, insert here
  697.         jne     addta3          ; if not same size, keep going
  698.         mov     si,bx           ; else this is where entry goes
  699.         jmp     short addta6    ; no insertion required...
  700. addta3: mov     al,[bx]
  701.         mov     ah,0
  702.         add     bx,ax           ; skip this entry
  703.         add     bx,4            ; len + $ + value...
  704.         loop    addta1          ; and keep looking
  705. addta4: mov     si,bx           ; this is first location to move
  706.         mov     di,bx
  707.         inc     ds:byte ptr [bp] ; remember we're adding one...
  708.         jcxz    addta6          ; no more entries, forget this stuff
  709.         mov     bh,0            ; this stays 0
  710. addta5: mov     bl,[di]         ; get length
  711.         lea     di,[bx+di+4]    ; end is origin + length + 4 for len, $, value
  712.         loop    addta5          ; loop thru remaining keywords
  713.         mov     cx,di
  714.         sub     cx,si           ; compute # of bytes to move
  715.         push    si              ; preserve loc for new entry
  716.         mov     si,di           ; first to move is last
  717.         dec     si              ; minus one
  718.         mov     di,dx           ; new entry
  719.         mov     bl,[di]         ; get length
  720.         lea     di,[bx+si+4]    ; dest is source + length of new + 4
  721.         std                     ; move backwards
  722.         rep     movsb           ; move the table down
  723.         cld                     ; put flag back
  724.         pop     si
  725. addta6: mov     di,si           ; this is where new entry goes
  726.         mov     si,dx           ; this is where it comes from
  727.         mov     cl,[si]         ; length
  728.         mov     ch,0
  729.         add     cx,1            ; count byte
  730.         add     mccptr,cx       ; update free space pointer: cnt+name
  731.         add     mccptr,3        ; plus '$' and pointer to string
  732.         rep     movsb           ; stick it in
  733.         mov     al,'$'          ; add printing terminator
  734.         stosb
  735.         mov     ax,macptr       ; and string offset
  736.         stosw
  737.         pop     es
  738.         pop     si
  739.         pop     cx
  740.         ret
  741. addtab  endp
  742.  
  743. ; If new keyword matches an existing one then remove existing keyword,
  744. ; its string definition, compress tables mcctab and macbuf, readjust string
  745. ; pointers for each macro name, reduce number of macro table entries by one.
  746. ; Otherwise, exit with no changes.  13 June 1987 [jrd]
  747. remtab  proc    near
  748.         push    ax
  749.         push    bx
  750.         push    cx
  751.         push    si
  752.         push    di
  753.         mov     si,offset rdbuf+1       ; point to new macro name
  754.         mov     bx,offset mcctab+1      ; table of macro keywords
  755.         mov     temp,0                  ; temp = current keyword
  756.         cmp     byte ptr mcctab,0       ; any macros defined?
  757.         jne     remta1                  ; ne = yes
  758.         jmp     remtax                  ; else exit now
  759. remta1:                                 ; match table keyword and text word
  760.         mov     cl,rdbuf                ; length of user's macro name
  761.         xor     ch,ch
  762.         cmp     cl,byte ptr [bx]        ; compare length vs table keyword
  763.         jne     remta4                  ; ne = not equal lengths, try another
  764.         push    si                      ; lengths match, how about spelling?
  765.         push    bx
  766.         inc     bx                      ; point at start of keyword
  767. remta2: mov     ah,byte ptr [bx]        ; keyword char
  768.         mov     al,byte ptr [si]        ; new text char
  769.         cmp     al,ah                   ; test characters
  770.         jne     remta3                  ; ne = no match
  771.         inc     si                      ; move to next char
  772.         inc     bx
  773.         loop    remta2                  ; loop through entire length
  774. remta3: pop     bx
  775.         pop     si
  776.         jcxz    remta6                  ; z: cx = 0, exit with match;
  777.                                         ;  else select next keyword
  778. remta4: inc     temp                    ; number of keyword to test next
  779.         mov     cx,temp
  780.         cmp     cl,mcctab               ; all done? Recall, temp starts at 0
  781.         jb      remta5                  ; b = not yet
  782.         jmp     remtax                  ; exhausted search, unsuccessfully
  783. remta5: mov     al,byte ptr [bx]        ; cnt (keyword length from macro)
  784.         xor     ah,ah
  785.         add     ax,4                    ; skip over '$' and two byte value
  786.         add     bx,ax                   ; bx = start of next keyword slot
  787.         jmp     remta1                  ; do another comparison
  788.                                         ; new name already present as a macro
  789. remta6: cld                             ; clear macro string and macro name
  790.         push    ds
  791.         pop     es                      ; set es to datas segment
  792.         mov     temp,bx                 ; save ptr to found keyword
  793.         mov     al,byte ptr [bx]        ; cnt (keyword length of macro)
  794.         xor     ah,ah
  795.         add     ax,2                    ; skip cnt and '$'
  796.         add     bx,ax                   ; point to string offset field
  797.         add     ax,2                    ; count offset field bytes
  798.         sub     mccptr,ax               ; readjust free space ptr for names
  799.         push    bx
  800.         mov     bx,[bx]
  801.         mov     temp1,bx                ; temp1 = offset of old string
  802.         mov     al,byte ptr[bx]         ; length of old string
  803.         xor     ah,ah
  804.         inc     ax                      ; plus its count byte
  805.         mov     temp2,ax                ; save here
  806.         pop     bx
  807.                                         ; clear keyword table mcctab
  808.         add     bx,2                    ; compute source = next keyword
  809.         mov     si,bx                   ; address of next keyword
  810.         mov     di,temp                 ; address of found keyword
  811.         mov     cx,offset mcctab+mcclen ; address of buffer end
  812.         sub     cx,si                   ; amount to move
  813.         jcxz    remtax                  ; cx = 0 means none
  814.         rep     movsb                   ; move down keywords (deletes current)
  815.                                         ; revise other string offsets
  816.         mov     si,offset mcctab        ; table of string offsets
  817.         inc     si                      ; skip count byte
  818.         mov     cl,mcctab               ; current number of table entries
  819.         xor     ch,ch
  820.         dec     mcctab                  ; one less keyword
  821.         mov     dx,temp1                ; address of old string
  822. remta7: mov     al,byte ptr[si]         ; cnt of first keyword
  823.         add     al,2                    ; plus cnt and '$'
  824.         xor     ah,ah
  825.         add     si,ax                   ; look at string offset
  826.         cmp     dx,[si]                 ; old address vs this string
  827.         ja      remta8                  ; a = address not affected
  828.         mov     ax,temp2                ; size of old string
  829.         sub     [si],ax                 ; adjust offset downward
  830. remta8: add     si,2                    ; point to next table entry
  831.         loop    remta7
  832.                                         ; remove old string
  833.         mov     di,temp1                ; address of old string = destination
  834.         mov     ax,temp2                ; size of old string field
  835.         mov     si,di
  836.         add     si,ax                   ; plus length: source = next string
  837.         sub     macptr,ax               ; readjust top of buf free string ptr
  838.         mov     cx,offset macbuf+maclen ; end of buffer
  839.         sub     cx,si                   ; number of bytes to move
  840.         jcxz    remtax                  ; cx = 0 means none
  841.         rep     movsb                   ; move down old strings
  842. remtax: pop     di
  843.         pop     si
  844.         pop     cx
  845.         pop     bx
  846.         pop     ax
  847.         ret
  848. remtab  endp
  849.  
  850.  
  851. ; This is the SET command.
  852.  
  853. SETCOM  PROC    NEAR
  854.         mov     dx,offset settab        ; Parse a keyword from the set table.
  855.         mov     bx,offset sethlp
  856.         mov     ah,cmkey
  857.         call    comnd
  858.          jmp    r
  859.         call    bx
  860.          jmp    short setco2
  861.          nop
  862. setco1: jmp     rskp
  863. setco2: cmp     comand.cmstat,cmcfm     ; is there a confirm at the end?
  864.         je      setco1                  ; e = yes, ok
  865.         ret                             ; return non-confirmed
  866. SETCOM  endp
  867.  
  868.  
  869. ;   SET BAUD or SET SPEED.
  870.  
  871. BAUDST  PROC    NEAR
  872.         mov     dx,offset bdtab
  873.         mov     bx,0
  874.         mov     ah,cmkey
  875.         call    comnd
  876.          jmp    r
  877.         mov     temp,bx
  878.         mov     ah,cmcfm
  879.         call    comnd                   ; Get a confirm.
  880.          jmp    r                       ; Didn't get one.
  881.          nop
  882.         mov     bx,temp
  883.         mov     si,portval
  884.         mov     ax,[si].baud            ; Remember original value
  885.         mov     [si].baud,bx            ; Set the baud rate.
  886.         call    dobaud                  ; Use common code
  887.         ret
  888. BAUDST  ENDP
  889.  
  890. ; SET BELL on or off
  891.  
  892. BELLST  PROC    NEAR
  893.         mov     dx,offset ontab
  894.         mov     bx,0
  895.         mov     ah,cmkey
  896.         call    comnd
  897.          jmp    r
  898.         mov     temp,bx
  899.         mov     ah,cmcfm
  900.         call    comnd
  901.          jmp    r
  902.          nop
  903.         mov     bx,temp
  904.         mov     flags.belflg,bl
  905.         ret
  906. BELLST  ENDP
  907.  
  908. ; SET BLOCK-CHECK
  909.  
  910. BLKSET  PROC    NEAR
  911.         mov     dx,offset blktab
  912.         mov     bx,0
  913.         mov     ah,cmkey
  914.         call    comnd
  915.          jmp    r
  916.         mov     temp,bx
  917.         mov     ah,cmcfm
  918.         call    comnd                   ; Get a confirm.
  919.          jmp    r                       ; Didn't get a confirm.
  920.          nop
  921.         mov     bx,temp
  922.         mov     trans.chklen,bl         ; Use this char as the handshake.
  923.         mov     inichk,bl               ; Save here too.
  924.         ret
  925. BLKSET  ENDP
  926.  
  927. ; SET DEBUG {OFF | ON | SESSSION | PACKETS}
  928.  
  929. DEBST   PROC       NEAR
  930.         mov     dx,offset debtab
  931.         mov     bx,offset debhlp
  932.         mov     ah,cmkey
  933.         call    comnd
  934.          jmp    r
  935.         mov     temp,bx
  936.         mov     ah,cmcfm
  937.         call    comnd                   ; Get a confirm.
  938.          jmp    r                       ; Didn't get a confirm.
  939.          nop
  940.         mov     bx,temp
  941.         or      flags.debug,bl          ; set the mode, except for Off.
  942.         cmp     bx,0                    ; OFF?
  943.         jne     deb0                    ; ne = no
  944.         mov     flags.debug,0           ; Set the DEBUG flags off.
  945. deb0:   ret
  946. DEBST   ENDP
  947.  
  948. ; SET DESTINATION   of incoming files.
  949.  
  950. DESSET  PROC    NEAR
  951.         mov     dx,offset destab
  952.         mov     bx,0
  953.         mov     ah,cmkey
  954.         call    comnd
  955.          jmp    r
  956.         mov     temp,bx
  957.         mov     ah,cmcfm
  958.         call    comnd                   ; Get a confirm.
  959.          jmp    r                       ; Didn't get a confirm.
  960.          nop
  961.         mov     bx,temp
  962.         mov     flags.destflg,bl        ; Set the destination flag.
  963.         cmp     bl,2                    ; Is dest the screen?
  964.         jne     desa                    ; No, then done
  965.         mov     flags.xflg,1            ; Remember it here
  966.         ret
  967. desa:   mov     flags.xflg,0            ; Don't write to screen
  968.         ret
  969. DESSET  ENDP
  970.  
  971. ; SET DEFAULT-DISK    for sending/receiving, etc.
  972.  
  973. DSKSET  PROC    NEAR
  974.         mov     ah,cmfile               ; Parse for drive specification. [jrd]
  975.         mov     dx,offset rdbuf         ; Read into handy buffer.
  976.         mov     bx,offset dskhlp        ; Text of help message.
  977.         call    comnd
  978.          jmp    r
  979.         mov     ah,cmcfm
  980.         call    comnd
  981.          jmp    r
  982.         mov     ah,rdbuf                ; Get the drive they said to use.
  983.         cmp     ah,0                    ; Did they type a bare CR?
  984.         je      dsk0                    ; Yes, complain.
  985.         cmp     ah,'a'                  ; alphabetic?
  986.         jl      dsk2
  987.         sub     ah,'a'-1                ; convert to 1 = a, 2 = b, etc
  988.         jmp     dsk3
  989. dsk2:   cmp     ah,'A'
  990.         jl      dsk0                    ; opps, a non-alpha
  991.         sub     ah,'A'-1                ; convert to numeric
  992. dsk3:   mov     curdsk,ah               ; And remember it.
  993.         dec     ah
  994.         mov     dl,ah
  995.         mov     ah,seldsk
  996.         int     dos
  997.         mov     ah,gcurdsk              ; succeeded? get current disk
  998.         int     dos
  999.         inc     al                      ; map to 1 = a, etc
  1000.         cmp     al,curdsk               ; same?
  1001.         jne     dsk4                    ; ne = no
  1002.         ret
  1003. dsk4:   mov     curdsk,al               ; get back actual current disk
  1004. dsk0:   mov     ah,prstr
  1005.         mov     dx,offset dskerr        ; Illegal drive specification.
  1006.         int     dos
  1007.         ret
  1008. DSKSET  ENDP
  1009.  
  1010. ; SET DELAY seconds   Used only for SEND command in local mode
  1011. SETDELY PROC    NEAR
  1012.         mov     min,0                   ; smallest acceptable value
  1013.         mov     max,63                  ; largest acceptable value
  1014.         mov     numhlp,offset delyhlp   ; help message
  1015.         mov     numerr,0                ; complaint message
  1016.         call    num0                    ; parse numerical input
  1017.         mov     trans.sdelay,al
  1018.         ret
  1019. SETDELY ENDP
  1020.  
  1021. ; SET DISPLAY Quiet/Regular/Serial/7-Bit/8-Bit (inverse of Set Remote on/off)
  1022. ; Accepts two keywords in one command.  [jrd]
  1023. disply  proc    near
  1024.         mov     ah,cmkey
  1025.         mov     dx,offset distab
  1026.         mov     bx,offset dishlp
  1027.         call    comnd
  1028.          jmp    r
  1029.         mov     temp1,bx                ; save parsed value
  1030.         mov     temp2,0ffh              ; assume no second keyword
  1031.         cmp     comand.cmsflg,0         ; first command ended with whitespace?
  1032.         je      displ1                  ; e = no, get a confirm
  1033.         mov     comand.cmcr,1           ; bare CR's are allowed
  1034.         mov     ah,cmkey                ; parse for second keyword
  1035.         mov     dx,offset distab
  1036.         mov     bx,offset dishlp
  1037.         call    comnd
  1038.          jmp    displ1                  ; no matching keyword
  1039.          nop
  1040.          nop
  1041.         mov     temp2,bx                ; get key value
  1042. displ1: mov     comand.cmcr,0           ; bare CR's are not allowed
  1043.         mov     ah,cmcfm
  1044.         call    comnd                   ; confirm
  1045.          jmp    r                       ; return on failure
  1046.          nop
  1047.         mov     bx,temp1                ; examine first key value
  1048.         cmp     bx,0                    ; check range
  1049.         jle     displ3                  ; le = not legal
  1050.         cmp     bx,7                    ; 7-8 bit value?
  1051.         jge     displ2                  ; ge = yes
  1052.         mov     flags.remflg,bl         ; set display mode
  1053.         jmp     displ3                  ; check next key value
  1054. displ2: cmp     bx,8                    ; set 8-bit wide display?
  1055.         ja      displ3                  ; a = bad value
  1056.         and     flags.remflg,not d8bit  ; assume want 7 bit mode
  1057.         cmp     bx,7                    ; really want 7 bit mode?
  1058.         je      displ3                  ; e = yes
  1059.         or      flags.remflg,d8bit      ; set 8 bit flag
  1060. displ3: mov     bx,temp2                ; examine second key value
  1061.         cmp     bx,0                    ; check range
  1062.         jle     displ5                  ; le = not legal
  1063.         cmp     bx,7                    ; 7-8 bit value?
  1064.         jge     displ4                  ; ge = yes
  1065.         mov     flags.remflg,bl         ; set display mode
  1066.         jmp     displ5                  ; all done
  1067. displ4: cmp     bx,8                    ; set 8-bit wide display?
  1068.         ja      displ5                  ; a = bad value
  1069.         and     flags.remflg,not d8bit  ; assume want 7 bit mode
  1070.         cmp     bx,7                    ; really want 7 bit mode?
  1071.         je      displ5                  ; e = yes
  1072.         or      flags.remflg,d8bit      ; set 8 bit flag
  1073. displ5: ret
  1074. disply  endp
  1075.  
  1076.  
  1077. ; Set Dump filename  for saving screen images on disk. [jrd]
  1078. ; Puts filename in global string dmpname.
  1079. setdmp  proc    near
  1080.         mov     dx,offset rdbuf         ; work area
  1081.         mov     byte ptr rdbuf,0        ; clear it
  1082.         mov     bx,offset dmphlp        ; help message
  1083.         mov     ah,cmfile               ; allow paths
  1084.         call    comnd
  1085.          jmp    r
  1086.         mov     ah,cmcfm
  1087.         call    comnd
  1088.          jmp    r
  1089.         mov     dx,offset rdbuf         ; assume we will use this text
  1090.         call    strlen                  ; filename given?
  1091.         mov     si,dx                   ; for strcpy
  1092.         cmp     cx,0                    ; length of user's filename
  1093.         jg      setdmp1                 ; g = filename is given
  1094.         mov     si,offset dmpdefnam     ; no name, use default instead.
  1095. setdmp1:mov     di,offset dmpname       ; copy to globally available loc.
  1096.         call    strcpy
  1097.         ret
  1098. setdmp  endp
  1099.  
  1100. ; SET EOF
  1101.  
  1102. seteof  proc    near
  1103.         mov     ah,cmkey
  1104.         mov     bx,0
  1105.         mov     dx,offset seoftab
  1106.         call    comnd
  1107.          jmp    r
  1108.         mov     temp,bx
  1109.         mov     ah,cmcfm
  1110.         call    comnd
  1111.          jmp    r                       ; error return...
  1112.          nop
  1113.         mov     bx,temp
  1114.         mov     flags.eofcz,bl          ; set value
  1115.         ret
  1116. seteof  endp
  1117.  
  1118. ; SET EOL char (for Sent packets)
  1119. ; Archic, here for downward compatibility
  1120. EOLSET  PROC    NEAR
  1121.         mov     stflg,'S'               ; set send/receive flag to Send
  1122.         jmp     sreol                   ; use Set Send/Rec routine do the work
  1123. EOLSET  ENDP
  1124.  
  1125. ; SET ESCAPE character.
  1126. ; Accept literal control codes and \### numbers. [jrd] 18 Oct 1987
  1127. ESCSET  PROC    NEAR
  1128.         mov     ah,cmfile
  1129.         mov     dx,offset rdbuf         ; work space
  1130.         mov     word ptr rdbuf,0        ; clear it
  1131.         mov     bx,offset eschlp        ; help
  1132.         call    comnd
  1133.          jmp    r
  1134.          nop
  1135.         cmp     ah,0                    ; anything given?
  1136.         jne     escse1                  ; ne = yes
  1137.          ret                            ; else  return unconfirmed
  1138. escse1: mov     ah,cmcfm                ; get a confirm
  1139.         call    comnd
  1140.          jmp    r
  1141.         nop
  1142.         mov     si,offset rdbuf         ; source of chars
  1143.         call    katoi                   ; convert escaped numbers to binary
  1144.         cmp     ax,spc                  ; is it a control code?
  1145.         jae     escse2                  ; ae = no, complain
  1146.         cmp     ax,0                    ; non-zero too?
  1147.         je      escse2                  ; e = zero
  1148.         mov     trans.escchr,al         ; Save new value.
  1149.         ret
  1150. escse2: mov dx,offset escerr
  1151.         jmp     reterr
  1152. ESCSET  ENDP
  1153.  
  1154. ; SET FILEWARNING
  1155.  
  1156. FILWAR  PROC    NEAR
  1157.         mov     dx,offset ontab
  1158.         mov     bx,0
  1159.         mov     ah,cmkey
  1160.         call    comnd
  1161.          jmp    r
  1162.         mov     temp,bx
  1163.         mov     ah,cmcfm
  1164.         call    comnd                   ; Get a confirm.
  1165.          jmp    r                       ; Didn't get a confirm.
  1166.          nop
  1167.         mov     bx,temp
  1168.         mov     flags.flwflg,bl         ; Set the filewarning flag.
  1169.         ret
  1170. FILWAR  ENDP
  1171.  
  1172. ; SET FLOW-CONTROL
  1173.  
  1174. FLOSET  PROC    NEAR
  1175.         mov     dx,offset flotab
  1176.         xor     bx,bx
  1177.         mov     ah,cmkey
  1178.         call    comnd
  1179.          jmp    r
  1180.         mov     temp,bx
  1181.         mov     ah,cmcfm
  1182.         call    comnd                   ; Get a confirm.
  1183.          jmp    r                       ; Didn't get a confirm.
  1184.          nop
  1185.         mov     bx,temp
  1186.         mov     si,portval
  1187.         mov     [si].flowc,bx           ; Flow control value.
  1188.         cmp     bx,0                    ; Turning it off?
  1189.         je      flo0                    ; Yes.
  1190.         mov     [si].floflg,1           ; Say we're doing flow control.
  1191.         ret
  1192. flo0:   mov     [si].floflg,bl          ; Say we're not doing flow control.
  1193.         ret
  1194. FLOSET  ENDP
  1195.  
  1196. ; SET HANDSHAKE
  1197. ; Add ability to accept general decimal code. [jrd]
  1198.  
  1199. HNDSET  PROC    NEAR
  1200.         mov     dx,offset hndtab        ; table to scan
  1201.         mov     bx,offset hnd1hlp       ; help message
  1202.         mov     ah,cmkey
  1203.         call    comnd
  1204.          jmp    r
  1205.         cmp     bl,0ffh                 ; want a general char code?
  1206.         jne     hnd1                    ; ne = no
  1207.         mov     min,0                   ; get decimal char code
  1208.         mov     max,31                  ; range is 0 to 31 decimal
  1209.         mov     numhlp,offset hnd2hlp   ; help message.
  1210.         mov     numerr,0                ; error message
  1211.         call    num0                    ; convert number, return it in ax
  1212.         mov     bx,ax                   ; recover numerical code
  1213. hnd1:   mov     temp,bx                 ; handshake type
  1214.         mov     ah,cmcfm
  1215.         call    comnd                   ; Get a confirm.
  1216.          jmp    r                       ; Didn't get a confirm.
  1217.          nop
  1218.         mov     bx,temp                 ; recover bx
  1219.         mov     si,portval
  1220.         cmp     bl,0                    ; Setting handshake off?
  1221.         je      hnd0                    ; Yes.
  1222.         mov     [si].hndflg,1           ; And turn on handshaking.
  1223.         mov     [si].hands,bl           ; Use this char as the handshake.
  1224.         ret
  1225. hnd0:   mov     [si].hndflg,0           ; No handshaking.
  1226.         ret
  1227. HNDSET  ENDP
  1228.  
  1229. ;   SET INCOMPLETE file disposition
  1230.  
  1231. ABFSET  PROC    NEAR
  1232.         mov     dx,offset abftab
  1233.         mov     bx,0
  1234.         mov     ah,cmkey
  1235.         call    comnd
  1236.          jmp    r
  1237.         mov     temp,bx
  1238.         mov     ah,cmcfm
  1239.         call    comnd                   ; Get a confirm.
  1240.          jmp    r                       ;  Didn't get a confirm.
  1241.          nop
  1242.         mov     bx,temp
  1243.         mov     flags.abfflg,bl         ; Set the aborted file flag.
  1244.         ret
  1245. ABFSET  ENDP
  1246. ;
  1247. ; Set Input commands (default-timeout, timeout-action, case, echo)
  1248. ; By Jim Strudevant [jrs].
  1249. INPSET  PROC    NEAR
  1250.         mov     ah,cmkey                ; key word
  1251.         mov     dx,offset inptab        ; from inputtable
  1252.         mov     bx,0                    ; no hints
  1253.         call    comnd                   ; get the word
  1254.          jmp    r                       ; they blew it
  1255.         call    bx                      ; call the sub command
  1256.          jmp    r                       ; bad return
  1257.         jmp     rskp                    ; good return
  1258. ;
  1259. ; Set Input Default-timeout in seconds
  1260. ;
  1261. inptmo: mov     ah,cmtxt                ; get a line of text
  1262.         mov     bx,offset rdbuf         ; put it here
  1263.         mov     dx,offset intoms        ; here's some help
  1264.         call    comnd                   ; get it
  1265.          jmp    r                       ; nothing typed
  1266.         mov     cl,ah                   ; get the length
  1267.         xor     ch,ch
  1268.         mov     si,offset rdbuf         ; set up
  1269.         call    atoi                    ; make it a number
  1270.          jmp    r                       ; bad number
  1271.         mov     indfto,ax               ; save it
  1272.         jmp     rskp                    ; good return
  1273.  
  1274. ;
  1275. ; Set Input Timeout action (proceed or quit)
  1276. ;
  1277. inpact: mov     ah,cmkey                ; get a keyword
  1278.         mov     dx,offset inactb        ; from this list
  1279.         mov     bx,0                    ; no hints
  1280.         call    comnd                   ; get it
  1281.          jmp    r                       ; bad input
  1282.         mov     inactv,bl               ; save the action
  1283.         jmp     rskp                    ; good return
  1284. ;
  1285. ; Set Input Echo on or off
  1286. ;
  1287. inpeco: mov     ah,cmkey                ; get a keyword
  1288.         mov     dx,offset ontab         ; from this list
  1289.         mov     bx,0                    ; no hints
  1290.         call    comnd                   ; get it
  1291.          jmp    r                       ; bad input
  1292.         mov     inecho,bl               ; save the action
  1293.         jmp     rskp                    ; good return
  1294. ;
  1295. ; Set Input Case observe or ignore
  1296. ;
  1297. inpcas: mov     ah,cmkey                ; get a keyword
  1298.         mov     dx,offset incstb        ; from this list
  1299.         mov     bx,0                    ; no hints
  1300.         call    comnd                   ; get it
  1301.          jmp    r                       ; bad input
  1302.         mov     incasv,bl               ; save the action
  1303.         jmp     rskp                    ; good return
  1304. INPSET  ENDP
  1305.  
  1306. ; SET KEY
  1307. ; Jumps to new Set Key routine
  1308. setkey  proc    near
  1309.         cmp     stkadr,0        ; keyboard translator present? [jrd]
  1310.         je      setk4           ; e = no, use this routine
  1311.         mov     bx,stkadr       ; yes, get offset of procedure
  1312.         jmp     bx              ; jump to keyboard translator [jrd]
  1313. setk4:  mov     dx,offset ermes5
  1314.         jmp     reterr          ; else print error message
  1315. setkey  endp
  1316.  
  1317. ; SET LOCAL-ECHO {ON | OFF}
  1318.  
  1319. LCAL    PROC    NEAR
  1320.         mov     dx,offset ontab
  1321.         mov     bx,0
  1322.         mov     ah,cmkey
  1323.         call    comnd
  1324.          jmp    r
  1325.         mov     temp,bx                 ; Save the parsed value.
  1326.         mov     ah,cmcfm
  1327.         call    comnd                   ; Get a confirm.
  1328.          jmp    r                       ; Didn't get a confirm.
  1329.          nop
  1330.         mov     bx,temp
  1331.         mov     si,portval
  1332.         mov     [si].ecoflg,bl          ; Set the local echo flag.
  1333.         ret
  1334. LCAL    ENDP
  1335.  
  1336. ; LOG  {PACKETS | SESSION} filename
  1337. ;   addition for capture of raw output
  1338. ; revised by [jrd] to use full DOS 2.0 path name
  1339.  
  1340. setcpt  proc    near
  1341.         mov     dx,offset logtab        ; kinds of logging
  1342.         mov     bx,offset loghlp        ; help on kind of logging
  1343.         mov     ah,cmkey                ; parse keyword
  1344.         call    comnd
  1345.          jmp    r
  1346.         mov     temp,bx                 ; Save the parsed value.
  1347.         mov     dx,offset cptio.string  ; holds the complete filename
  1348.         mov     bx,offset filhlp        ; ask for filename
  1349.         mov     ah,cmfile               ; allow paths
  1350.         call    comnd
  1351.          jmp    r
  1352.         mov     ah,cmcfm
  1353.         call    comnd                   ; Get a confirm.
  1354.          jmp    r                       ;  Didn't get a confirm.
  1355.         cmp     flags.capflg,0          ; is capturing active already?
  1356.         jne     setcp5                  ; ne = yes, just update kind
  1357.         mov     dx,offset cptio.string
  1358.         call    strlen                  ; filename given?
  1359.         cmp     cx,0                    ; length of user's filename
  1360.         jg      setcp4                  ; g = filename is given
  1361.         mov     dx,offset defcpt        ; use default name instead.
  1362. setcp4: mov     ax,dx                   ; place for filename for isfile.
  1363.         call    isfile                  ; does file exist already?
  1364.         jc      setcp3                  ; c = does not exist.
  1365.         test    byte ptr filtst.dta+21,1fh ; file attributes, ok to write?
  1366.         jnz     setcp2                  ; nz = no.
  1367.         mov     ah,open2                ; open existing file.
  1368.         mov     al,2                    ; opened for reading and writing
  1369.         int     dos                     ; do it
  1370.         jc      setcp2                  ; if carry bit set then error
  1371.         mov     cptio.handle,ax         ; save filehandle
  1372.         mov     bx,ax                   ; file handle for seeking
  1373.         mov     cx,0ffffh               ; high order displacement (-1 ext)
  1374.         mov     dx,-1                   ; low order part of displacement
  1375.         mov     ah,lseek                ; seek to EOF (to do appending)
  1376.         mov     al,2                    ; says to EOF
  1377.         int     dos
  1378.         call    inicpt                  ; init capture variables
  1379. setcp5: mov     ax,temp                 ; kind of Logging
  1380.         or      al,al                   ; is logging off?
  1381.         jne     setcp4a                 ; ne = no, add this type to the list
  1382.         mov     flags.capflg,al         ; say capture routine is inactive
  1383. setcp4a:or      flags.capflg,al         ; accumulate kinds of logging
  1384.         jmp     rskp                    ; and return
  1385.  
  1386. setcp3: test    filtst.fstat,80h        ; access problem?
  1387.         jnz     setcp2                  ; nz = yes, stop here
  1388.         mov     ah,creat2               ; function is create, v 2.0
  1389.         mov     cl,20H                  ; turn on archive bit
  1390.         mov     ch,0
  1391.         int     dos                     ; create the file, DOS 2.0
  1392.         jc      setcp2                  ; if carry bit set then error
  1393.         mov     cptio.handle,ax         ; save filehandle
  1394.         call    inicpt                  ; init capture variables
  1395.         mov     ax,temp                 ; kind of logging
  1396.         or      al,al                   ; is logging off?
  1397.         jne     setcp3a                 ; ne = no, add this type to the list
  1398.         mov     flags.capflg,al         ; say capture routine is inactive
  1399. setcp3a:or      flags.capflg,al         ; accumulate kinds of logging
  1400.         jmp     rskp                    ; and return
  1401.  
  1402. setcp2: mov     dx,offset errcap        ; give error message
  1403.         jmp     reterr                  ; and display it
  1404.  
  1405. setcpt  endp
  1406.  
  1407. ; SET MODE LINE
  1408.  
  1409. MODL    PROC    NEAR
  1410.         mov     dx,offset ontab         ; parse an on or off
  1411.         mov     bx,0                    ; no special help...
  1412.         mov     ah,cmkey
  1413.         call    comnd
  1414.          jmp    r
  1415.         mov     temp,bx                 ; save value
  1416.         mov     ah,cmcfm
  1417.         call    comnd
  1418.          jmp    r
  1419.          nop
  1420.         mov     bx,temp
  1421.         mov     flags.modflg,bl         ; set flag appropriately
  1422.         ret
  1423. MODL    ENDP
  1424.  
  1425. ; SET PARITY
  1426.  
  1427. SETPAR  PROC    NEAR
  1428.         mov     dx,offset partab
  1429.         mov     bx,0
  1430.         mov     ah,cmkey
  1431.         call    comnd
  1432.          jmp    r
  1433.         mov     temp,bx
  1434.         mov     ah,cmcfm
  1435.         call    comnd                   ; Get a confirm.
  1436.          jmp    r                       ;  Didn't get a confirm.
  1437.          nop
  1438.         mov     bx,temp
  1439.         mov     si,portval
  1440.         mov     [si].parflg,bl          ; Set the parity flag.
  1441.         cmp     bl,parnon               ; Resetting parity to none?
  1442.         je      setp0                   ; Yes, reset 8 bit quote character.
  1443.         mov     trans.ebquot,dqbin      ; Else, do quoting
  1444.         ret                             ; That's it
  1445. setp0:  mov     trans.ebquot,'Y'        ; If none, say will quote upon request
  1446.         ret
  1447. SETPAR  ENDP
  1448.  
  1449. ; SET PROMPT      Allow user to change the "Kermit-MS>" prompt.
  1450. ; {string} and \number notation permitted to represent special chars. [jrd]
  1451.  
  1452. PROMSET PROC    NEAR
  1453.         mov     ah,cmtxt
  1454.         mov     bx,offset rdbuf         ; Read in the prompt.
  1455.         mov     word ptr [bx],0         ; clear buffer
  1456.         mov     dx,offset prmmsg
  1457.         call    comnd
  1458.          jmp    r
  1459.         mov     ah,cmcfm                ; get a confirm
  1460.         call    comnd
  1461.          jmp    r
  1462.         cmp     rdbuf,0                 ; Just a bare CR?
  1463.         jne     prom0                   ; ne = no
  1464.         mov     ax,offset kerm          ; yes, restore default prompt
  1465.         jmp     prom1
  1466. prom0:  push    si                      ; parse \### constants into
  1467.         push    di                      ;  1 byte binary numbers inline.
  1468.         mov     si,offset rdbuf         ; source = new prompt string
  1469.         mov     byte ptr [si-1+length rdbuf],0 ; plant null terminator
  1470.         mov     di,offset prm           ; destination
  1471.         call    cnvlin                  ; convert \### in string to binary
  1472.         pop     di
  1473.         pop     si
  1474.         mov     bx,cx                   ; get byte count
  1475.         add     bx,offset prm           ; point to null terminator
  1476.         mov     byte ptr [bx],'$'       ; End of string.
  1477.         mov     ax,offset prm
  1478. prom1:  mov     prmptr,ax               ; Remember it.
  1479.         ret
  1480. PROMSET ENDP
  1481.  
  1482. ; SET RETRY value. Changes the packet retry limit. [jrd]
  1483.  
  1484. RETRYSET PROC   NEAR
  1485.         mov     min,1                   ; smallest acceptable value
  1486.         mov     max,63                  ; largest acceptable value
  1487.         mov     numhlp,offset retryhlp  ; help message
  1488.         mov     numerr,0                ; complaint message
  1489.         call    num0                    ; parse numerical input
  1490.         mov     maxtry,al
  1491.         shl     al,1                    ; quick multiply by two or three
  1492.         mov     imxtry,al               ; keep that much
  1493.         add     al,maxtry               ; try three times
  1494.         js      retrys1                 ; s = sign bit set, too much
  1495.         mov     imxtry,al               ; I packets get 3 times as many tries.
  1496. retrys1:ret
  1497. RETRYSET ENDP
  1498.  
  1499. ; SET TAKE-ECHO  on or off.
  1500.  
  1501. TAKSET  PROC    NEAR
  1502.         mov     dx,offset ontab
  1503.         mov     bx,0
  1504.         mov     ah,cmkey
  1505.         call    comnd
  1506.          jmp    r
  1507.         mov     temp,bx
  1508.         mov     ah,cmcfm
  1509.         call    comnd
  1510.          jmp    r
  1511.          nop
  1512.         mov     bx,temp
  1513.         mov     flags.takflg,bl
  1514.         ret
  1515. TAKSET  ENDP
  1516.  
  1517. ; SET TIMER     on or off during file transfer.
  1518.  
  1519. TIMSET  PROC    NEAR
  1520.         mov     dx,offset ontab
  1521.         mov     bx,0
  1522.         mov     ah,cmkey
  1523.         call    comnd
  1524.          jmp    r
  1525.         mov     temp,bx
  1526.         mov     ah,cmcfm
  1527.         call    comnd
  1528.          jmp    r
  1529.          nop
  1530.         mov     bx,temp
  1531.         mov     flags.timflg,bl
  1532.         ret
  1533. TIMSET  ENDP
  1534.  
  1535. ; SET SEND parameters
  1536.  
  1537. SENDSET PROC    NEAR
  1538.         mov     stflg,'S'               ; Setting SEND parameter
  1539. sndst0: mov     dx,offset stsrtb        ; Parse a keyword.
  1540.         mov     bx,0                    ; no specific help
  1541.         mov     ah,cmkey
  1542.         call    comnd
  1543.          jmp    r                       ; bad user text
  1544.         call    bx                      ; call the action routine
  1545.          nop
  1546.          nop
  1547.          nop
  1548.         jmp     rskp
  1549. SENDSET ENDP
  1550.  
  1551. ; SET RECEIVE parameters
  1552.  
  1553. recset: mov     stflg,'R'               ; Setting RECEIVE paramter.
  1554.         jmp     sndst0
  1555.  
  1556. remset  proc    near                    ; Set REMOTE ON/OFF
  1557.         mov     ah,cmkey
  1558.         mov     dx,offset ontab
  1559.         mov     bx,offset remhlp
  1560.         call    comnd
  1561.          jmp    r
  1562.          nop
  1563.         mov     temp,bx                 ; save parsed value
  1564.         mov     ah,cmcfm
  1565.         call    comnd                   ; confirm
  1566.          jmp    r                       ; return on failure
  1567.          nop
  1568.         mov     bx,temp
  1569.         and     flags.remflg,not (dquiet+dserial+dregular) ; no display bits
  1570.         or      bl,bl                   ; want off state? (same as regular)
  1571.         jz      remset1                 ; z = yes
  1572.         or      flags.remflg,dquiet     ; else on = quiet display
  1573.         ret
  1574. remset1:or      flags.remflg,dregular   ; off = regular display
  1575.         ret
  1576. remset  endp
  1577.  
  1578.  
  1579. ; SET Send and Receive EOL char
  1580.  
  1581. sreol   PROC    NEAR
  1582.         mov     min,0                   ; lowest acceptable value
  1583.         mov     max,1FH                 ; largest acceptable value
  1584.         mov     numhlp,offset eolhlp    ; Reuse help message.
  1585.         mov     numerr,0                ; error message address
  1586.         call    num0                    ; get numerical input
  1587.         cmp     stflg,'S'               ; Setting SEND paramter?
  1588.         je      sreol1
  1589.         mov     trans.reol,al
  1590.         jmp     short sreol2
  1591. sreol1: mov     dtrans.seol,al
  1592. sreol2: mov     ah,dtrans.seol
  1593.         mov     trans.seol,ah
  1594.         ret
  1595. sreol   ENDP
  1596.  
  1597.  
  1598. ; SET SEND and RECEIVE start-of-header.
  1599.  
  1600. srsoh:  mov     min,0
  1601.         mov     max,1FH
  1602.         mov     numhlp,offset eolhlp    ; Reuse help message.
  1603.         mov     numerr,0                ; error message
  1604.         call    num0            ; Common routine for parsing numerical input.
  1605.         cmp     stflg,'S'               ; Setting SEND paramter?
  1606.         je      srsoh1
  1607.         mov     trans.rsoh,al           ; set Receive soh
  1608.         ret
  1609. srsoh1: mov     trans.ssoh,al           ; set Send soh
  1610.         ret
  1611.  
  1612. ; SET SEND and  RECEIVE TIMEOUT.
  1613.  
  1614. srtim:  mov     min,0
  1615.         mov     max,94
  1616.         mov     numhlp,offset timhlp    ; Reuse help message.
  1617.         mov     numerr,0                ; error message
  1618.         call    num0            ; Common routine for parsing numerical input.
  1619.         cmp     stflg,'S'               ; Setting SEND paramter?
  1620.         je      srtim1
  1621.         mov     trans.rtime,al
  1622.         jmp     short srtim2
  1623. srtim1: mov     dtrans.stime,al
  1624. srtim2: mov     ah,dtrans.stime
  1625.         mov     trans.stime,ah
  1626.         ret
  1627. ; SET SEND and RECEIVE PACKET LENGTH.
  1628. ; Upgraded for long packets. [jrd]
  1629.  
  1630. srpack: mov     min,20
  1631.         mov     max,maxpack
  1632.         mov     numhlp,offset pakhlp    ; help
  1633.         mov     numerr,offset pakerr    ; error message
  1634.         call    num0
  1635.         cmp     stflg,'S'               ; setting send value?
  1636.         jne     srpakr                  ; ne = receive
  1637.         mov     trans.slongp,ax         ; set send value
  1638.         mov     trans.slong,ax          ; and remember what we Set.
  1639.         cmp     ax,94                   ; within normal packet range?
  1640.         ja      srpak2                  ; a = no
  1641.         mov     trans.spsiz,al          ; yes. update regular pkt size too
  1642. srpak2: ret
  1643. srpakr: mov     trans.rlongp,ax         ; set receive value
  1644.         cmp     ax,94                   ; within normal packet range?
  1645.         ja      srpak4                  ; a = no
  1646.         mov     trans.rpsiz,al          ; yes. update regular pkt size too.
  1647. srpak4: ret
  1648.  
  1649.  
  1650. ; SET SEND and RECEIVE number of padding characters.
  1651.  
  1652. srnpd:  mov     min,0
  1653.         mov     max,99
  1654.         mov     numhlp,offset npdhlp    ; help message
  1655.         mov     numerr,0                ; error message
  1656.         call    num0                    ; Parse numerical input.
  1657.         cmp     stflg,'S'               ; Setting SEND paramter?
  1658.         je      srnpd1                  ; e = yes
  1659.         mov     trans.rpad,al           ; set Receive padding
  1660.         jmp     short srnpd2
  1661. srnpd1: mov     dtrans.spad,al          ; set default Send padding
  1662. srnpd2: mov     al,dtrans.spad
  1663.         mov     trans.spad,al    ; update active array for I and S pkts [jrd]
  1664.         ret
  1665.  
  1666. ; SET SEND and RECEIVE padding character.
  1667.  
  1668. srpad:  mov     min,0
  1669.         mov     max,127
  1670.         mov     numhlp,offset padhlp
  1671.         mov     numerr,offset paderr
  1672.         call    num0                    ; Parse numerical input.
  1673.         cmp     ah,127                  ; This is allowed.
  1674.         je      srpad1
  1675.         cmp     ah,32
  1676.         jb      srpad1                  ; Between 0 and 31 is OK too.
  1677.         mov     ah,prstr
  1678.         mov     dx,offset paderr
  1679.         int     dos
  1680.         ret
  1681. srpad1: cmp     stflg,'S'               ; Send?
  1682.         je      srpad2                  ; e = yes, else Receive
  1683.         mov     trans.rpadch,al         ; store receive pad char
  1684.         jmp     short srpad3
  1685. srpad2: mov     dtrans.spadch,al        ; store Send pad char
  1686. srpad3: mov     ah,dtrans.spadch
  1687.         mov     trans.spadch,ah  ; update active array for I and S pkts [jrd]
  1688.         ret
  1689.  
  1690. ; SET SEND and  RECEIVE control character prefix.
  1691.  
  1692. srquo:  mov     min,33
  1693.         mov     max,126
  1694.         mov     numhlp,offset quohlp    ; help message
  1695.         mov     numerr,0                ; error message
  1696.         call    num0                    ; Parse numerical input.
  1697.         cmp     stflg,'S'               ; Setting outgoing quote char?
  1698.         je      srquo1
  1699.         mov     trans.rquote,al         ; set Receive quote char
  1700.         jmp     short srquo2
  1701. srquo1: mov     dtrans.squote,al        ; set Send quote char
  1702. srquo2: mov     ah,dtrans.spadch
  1703.         mov     trans.spadch,ah   ; update active array for I and S pkts [jrd]
  1704.         ret
  1705.  
  1706. ; SET SEND Pause number of milliseconds         ; [jrd]
  1707.  
  1708. srpaus: mov     min,0
  1709.         mov     max,127
  1710.         mov     numhlp,offset pauhlp
  1711.         mov     numerr,0
  1712.         call    num0                    ; Parse numerical input.
  1713.         cmp     stflg,'S'               ; Setting SEND paramter?
  1714.         je      srpau0
  1715.         mov     dx,offset ermes5        ; "Not implemented" msg
  1716.         jmp     reterr                  ; print error message
  1717. srpau0: mov     spause,al               ; store value
  1718.         ret
  1719.  
  1720. ; SET TRANSLATION INPUT   Connect mode translate incoming characters.
  1721. ; SET TRANS IN {Original-byte New-byte | ON | OFF}
  1722.  
  1723. SETRX   PROC    NEAR                    ; translate incoming serial port char
  1724.         mov     ah,cmkey
  1725.         mov     dx,offset trnstab       ; direction table (just one entry)
  1726.         mov     bx,0                    ; no help
  1727.         call    comnd
  1728.          jmp    r
  1729.         mov     dx,offset rdbuf         ; our work space
  1730.         mov     word ptr rdbuf,0        ; insert terminator
  1731.         mov     bx,offset srxhlp1       ; first help message
  1732.         mov     ah,cmfile               ; parse a word
  1733.         call    comnd                   ; get incoming byte pattern
  1734.          jmp    r                       ; error if none
  1735.         or      ah,ah                   ; any text given?
  1736.         jz      setr6                   ; nz = no
  1737.         mov     temp,ax                 ; save byte count here
  1738.         mov     ax,word ptr rdbuf       ; get first two characters
  1739.         or      ax,2020h                ; convert upper to lower case
  1740.         cmp     ax,'fo'                 ; first part of word OFF?
  1741.         je      setr6                   ; e = yes, go analyze
  1742.         cmp     ax,'no'                 ; word ON?
  1743.         je      setr6                   ; e = yes, go do it
  1744.         mov     si,offset rdbuf         ; convert text to number
  1745.         call    katoi                   ; number converter procedure, to ax
  1746.         jnc     setr1                   ; nc = success
  1747.         cmp     byte ptr temp+1,1       ; just one character given?
  1748.         jne     setr6                   ; ne = no, so bad code
  1749. setr1:  mov     min,ax                  ; save byte code here
  1750.         mov     dx,offset rdbuf         ; our work space
  1751.         mov     word ptr rdbuf,0        ; insert terminator
  1752.         mov     bx,offset srxhlp1       ; first help message
  1753.         mov     ah,cmfile               ; parse a word
  1754.         call    comnd                   ; get incoming byte pattern
  1755.          jmp    r
  1756.         or      ah,ah                   ; any text given?
  1757.         jz      setr6                   ; z = no
  1758.         mov     temp,ax                 ; save byte count here
  1759.         mov     si,offset rdbuf         ; convert text to number
  1760.         call    katoi                   ; number converter procedure
  1761.         jnc     setr3                   ; nc = success
  1762.         cmp     byte ptr temp+1,1       ; just one character given?
  1763.         jne     setr6                   ; ne = no, so bad code or ON/OFF
  1764. setr3:  mov     max,ax                  ; save byte code here
  1765.         mov     ah,cmcfm                ; get a confirm
  1766.         call    comnd
  1767.          jmp    r                       ; no confirm
  1768.         mov     bx,min                  ; bl = incoming byte code
  1769.         xor     bh,bh
  1770.         mov     ax,max                  ; al = local (translated) byte code
  1771.         mov     rxtable [bx],al         ; store in rx translate table
  1772.         jmp     rskp
  1773.  
  1774. setr6:  mov     ah,cmcfm                ; get a confirm
  1775.         call    comnd
  1776.          jmp    r                       ; no confirm
  1777.         mov     dx,offset badrx         ; assume bad construction
  1778.         or      word ptr rdbuf,2020h    ; convert to lower case
  1779.         or      rdbuf+2,20h             ; first three chars
  1780.         cmp     word ptr rdbuf,'fo'     ; key word OFF?
  1781.         jne     setr8                   ; ne = no
  1782.         cmp     rdbuf+2,'f'             ; last letter of OFF?
  1783.         jne     setr8
  1784.         mov     rxtable+256,0           ; OFF is status byte = zero
  1785.         mov     dx,offset rxoffmsg      ; say translation is turned off
  1786.         jmp     setr9
  1787. setr8:  cmp     word ptr rdbuf,'no'     ; keyword ON?
  1788.         jne     setr9a                  ; ne = no, error
  1789.         mov     rxtable+256,1           ; ON is status byte non-zero
  1790.         mov     dx,offset rxonmsg       ; say translation is turned on
  1791. setr9:  cmp     intake,0                ; executing from a Take file?
  1792.         je      setr9a                  ; e = no
  1793.         cmp     flags.takflg,0          ; echo contents of Take file?
  1794.         je      setr10                  ; e = no
  1795. setr9a: mov     ah,prstr                ; bad number message
  1796.         int     dos
  1797. setr10: ret
  1798. SETRX   ENDP
  1799.  
  1800. ; SHOW TRANSLATE-RECEIVE
  1801. ; Display characters being changed for Connect mode serial receive translator.
  1802.  
  1803. SHORX   PROC    NEAR                    ; show translate table of incoming
  1804.                                         ; chars, only those changed
  1805.         mov     ah,cmcfm                ; get a confirm
  1806.         call    comnd
  1807.           jmp   r                       ; no confirm
  1808.         mov     ah,prstr
  1809.         mov     dx,offset rxoffmsg      ; assume translation is off
  1810.         cmp     rxtable+256,0           ; is translation off?
  1811.         je      shorx0                  ; e = yes
  1812.         mov     dx,offset rxonmsg       ; say translation is on
  1813. shorx0: int     dos
  1814.         mov     dx,offset shormsg       ; give title line
  1815.         int     dos
  1816.         xor     cx,cx                   ; formatted line counter
  1817.         xor     bx,bx                   ; entry subscript
  1818. shorx1: cmp     rxtable[bx],bl          ; entry same as normal?
  1819.         je      shorx2                  ; e = yes, skip it
  1820.         call    shoprt                  ; print the entry
  1821. shorx2: inc     bx                      ; next entry
  1822.         cmp     bx,255                  ; done all entries yet?
  1823.         jbe     shorx1                  ; be = not yet
  1824.         mov     ah,prstr
  1825.         mov     dx,offset crlf          ; end with cr/lf
  1826.         int     dos
  1827.         jmp     rskp
  1828.  
  1829. shoprt: cmp     cx,4                    ; done five entries for this line?
  1830.         jb      shopr1                  ; b = no
  1831.         mov     ah,prstr
  1832.         mov     dx,offset crlf          ; break line now
  1833.         int     dos
  1834.         xor     cx,cx
  1835. shopr1: mov     ah,prstr
  1836.         mov     dx,offset shopm1        ; start of display
  1837.         int     dos
  1838.         xor     ah,ah
  1839.         mov     al,bl                   ; original byte code
  1840.         call    decout                  ; display its value
  1841.         mov     ah,prstr
  1842.         mov     dx,offset shopm2        ; intermediate part of display
  1843.         int     dos
  1844.         xor     ah,ah
  1845.         mov     al,rxtable[bx]          ; new byte code
  1846.         call    decout                  ; display its value
  1847.         mov     ah,prstr
  1848.         mov     dx,offset shopm3        ; last part of display
  1849.         int     dos
  1850.         inc     cx                      ; count item displayed
  1851.         ret
  1852. SHORX   ENDP
  1853.  
  1854.  
  1855. ; SHOW defined macros.
  1856.  
  1857. SHOMAC  PROC    NEAR
  1858.         mov     ah,cmtxt
  1859.         mov     bx,offset rdbuf
  1860.         mov     dx,offset shmmsg
  1861.         call    comnd
  1862.          jmp    r
  1863.         cmp     ah,0                    ; Bare CR means show all macros.
  1864.         je      shom1                   ; e = show all macros
  1865.         jmp     shom6                   ; No, he wants specific macro expanded.
  1866. shom1:  mov     si,offset mcctab        ; Table of macro names.
  1867.         cld
  1868.         lodsb
  1869.         mov     cl,al                   ; Number of macro entries.
  1870.         mov     ch,0
  1871. shom2:  jcxz    shom5                   ; Done if none left to display.
  1872.         lodsb                           ; Length of macro name.
  1873.         push    ax                      ; Don't forget it.
  1874.         mov     ah,prstr
  1875.         mov     dx,offset crlfsp        ; Go to new line.
  1876.         int     dos
  1877.         mov     dx,si                   ; Print macro name.
  1878.         int     dos
  1879.         mov     dx,offset eqs           ; display equals sign
  1880.         int     dos
  1881.         pop     ax                      ; recover length of macro name
  1882.         mov     ah,0
  1883.         add     si,ax                   ; Skip over name.
  1884.         add     si,1                    ; skip '$' field
  1885.         push    cx                      ; save regs
  1886.         push    si
  1887.         mov     si,[si]                 ; si = offset of count + string
  1888.         mov     cl,byte ptr [si]        ; length of string
  1889.         xor     ch,ch
  1890.         inc     si                      ; si = offset of string text proper
  1891.         mov     ah,conout
  1892. shom3:  lodsb                           ; get a byte into al
  1893.         cmp     al,' '                  ; control char?
  1894.         jae     shom3a                  ; ae = no
  1895.         cmp     al,cr                   ; carriage return?
  1896.         je      shom3a                  ; e = yes, handle separately
  1897.         push    ax
  1898.         mov     dl,5eh                  ; caret
  1899.         int     dos
  1900.         pop     ax
  1901.         add     al,'A'-1                ; add offset to make printable letter
  1902. shom3a: mov     dl,al                   ; display it
  1903.         int     dos
  1904.         cmp     al,cr                   ; binary carriage return?
  1905.         jne     shom4                   ; ne = no
  1906.         mov     dl,lf                   ; binary carriage returns are expanded
  1907.         int     dos
  1908.         mov     dl,' '                  ; to cr/lf/space/space
  1909.         int     dos
  1910.         int     dos
  1911. shom4:  loop    shom3                   ; do whole string
  1912.         pop     si
  1913.         pop     cx
  1914.         dec     cx
  1915.         add     si,2                    ; Skip over string offset
  1916.         jmp     shom2                   ; And do the rest.
  1917. shom5:  mov     ah,prstr
  1918.         mov     dx,offset shom9a        ; free space: name entries
  1919.         int     dos
  1920.         mov     ax,offset mcctab+mcclen
  1921.         sub     ax,mccptr               ; compute # of free name bytes
  1922.         call    decout
  1923.         mov     ah,prstr
  1924.         mov     dx,offset shom9c        ; body characters
  1925.         int     dos
  1926.         mov     ax,offset macbuf+maclen
  1927.         sub     ax,macptr
  1928.         call    decout
  1929.         mov     ah,prstr
  1930.         mov     dx,offset crlf
  1931.         int     dos
  1932.         jmp     rskp
  1933. shom6:  mov     ah,prstr
  1934.         mov     dx,offset ermes3
  1935.         int     dos
  1936.         jmp     rskp
  1937. SHOMAC  ENDP
  1938.  
  1939.  
  1940. ; STATUS command. Revised by [jrd]
  1941.  
  1942. STATUS  PROC    NEAR
  1943.         mov     ah,cmcfm
  1944.         call    comnd                   ; Get a confirm.
  1945.          jmp    r                       ; Didn't get a confirm.
  1946.         mov     dx,offset crlf
  1947.         mov     ah,prstr
  1948.         int     dos                     ; print a crlf
  1949. STAT0:  call    cmblnk                  ; clear the screen
  1950.         call    locate                  ; home the cursor
  1951.         push    es                      ; STAT0 is an external ref (in mster)
  1952.         push    bx
  1953.         push    di
  1954.         mov     bx,ds
  1955.         mov     es,bx
  1956.         cld
  1957.         mov     bx,offset sttab         ; table to control printing
  1958.         xor     cx,cx                   ; column counter
  1959. stat1:  cmp     word ptr [bx],0         ; end of table?
  1960.         je      statx                   ; e = yes
  1961.         cld                             ; string direction is forward
  1962.         mov     di,offset rdbuf         ; point to destination buffer
  1963.         mov     byte ptr[di],spc        ; start with two spaces
  1964.         inc     di
  1965.         mov     byte ptr[di],spc
  1966.         inc     di
  1967.         push    cx                      ; save column number
  1968.         push    bx
  1969.         call    [bx].sttyp              ; call appropriate routine
  1970.         pop     bx
  1971.         pop     cx
  1972.         sub     di,offset rdbuf         ; number of bytes used
  1973.         add     cx,di                   ; new line col count
  1974.         push    cx                      ; save col number around print
  1975.         mov     cx,di                   ; how much to print now
  1976.         mov     di,offset rdbuf         ; source text
  1977.         call    prtscr                  ; print counted string
  1978.         pop     cx
  1979.         cmp     cx,38                   ; place for second display?
  1980.         jbe     stat2                   ; be = only half full
  1981.         mov     dx,offset crlf          ; over half full. send cr/lf
  1982.         mov     ah,prstr
  1983.         int     dos
  1984.         xor     cx,cx                   ; say line is empty now
  1985.         jmp     stat4
  1986. stat2:  mov     ax,cx
  1987.         mov     cx,38                   ; where we want to be next time
  1988.         sub     cx,ax                   ; compute number of filler spaces
  1989.         or      cx,cx
  1990.         jle     stat3a                  ; nothing to do
  1991.         mov     ah,conout
  1992.         mov     dl,' '
  1993. stat3:  int     dos                     ; fill with spaces
  1994.         loop    stat3                   ; do cx times
  1995. stat3a: mov     cx,38                   ; current column number
  1996. stat4:  add     bx,size stent           ; look at next entry
  1997.         jmp     stat1                   ; and do it
  1998. statx:  pop     di
  1999.         pop     bx
  2000.         pop     es
  2001.         jmp     rskp
  2002. STATUS  ENDP
  2003.  
  2004. ; handler routines for status
  2005. ; all are called with di/ destination buffer, bx/ stat ptr. They can change
  2006. ; any register except es:, must update di to the end of the buffer.
  2007.  
  2008. ; copy the message into the buffer
  2009. stmsg   proc    near
  2010.         push    ds
  2011.         pop     es              ; ensure es points to datas segment
  2012.         mov     si,[bx].msg     ; get message address
  2013. stms1:  lodsb                   ; get a byte
  2014.         stosb                   ; drop it off
  2015.         cmp     al,'$'          ; end of message?
  2016.         jne     stms1           ; no, keep going
  2017.         dec     di              ; else back up ptr
  2018.         ret
  2019. stmsg   endp
  2020.  
  2021. ; get address of test value in stent. Returns address in si
  2022. stval   proc    near
  2023.         mov     si,[bx].basval  ; get base value
  2024.         cmp     si,0            ; any there?
  2025.         je      stva1           ; no, keep going
  2026.         mov     si,[si]         ; yes, use as base address
  2027. stva1:  add     si,[bx].tstcel  ; add offset of test cell
  2028.         ret                     ; and return it
  2029. stval   endp
  2030.  
  2031. ; print a single character
  2032. onechr  proc    near
  2033.         call    stmsg           ; copy message part first
  2034.         call    stval           ; pick up test value address
  2035.         mov     al,[si]         ; this is char to print
  2036.         cmp     al,' '          ; printable?
  2037.         jae     onech1          ; yes, keep going
  2038.         add     al,64           ; make printable.
  2039.         mov     byte ptr [di],5eh       ; caret
  2040.         inc     di              ; note ctrl char
  2041. onech1: stosb                   ; drop char off
  2042.         ret
  2043. onechr  endp
  2044.  
  2045. ; numeric field...
  2046. stnum   proc    near            ; for 8 bit numbers
  2047.         call    stmsg           ; copy message
  2048.         call    stval           ; pick up value address
  2049.         mov     al,[si]         ; get value
  2050.         mov     ah,0            ; high order is 0
  2051.         call    outnum          ; put number into buffer
  2052.         ret
  2053. stnum   endp
  2054.  
  2055. stlnum  proc    near            ; for 16 bit numbers [jrd]
  2056.         call    stmsg           ; copy message
  2057.         call    stval           ; pick up value address
  2058.         mov     ax,[si]         ; get value
  2059.         call    outnum          ; put number into buffer
  2060.         ret
  2061. stlnum  endp
  2062.  
  2063. ; Common routine for parsing numerical input.
  2064. ; Enter with numhlp = offset of help message, numerr = offset of optional
  2065. ;  error message, min, max = allowable range of values.
  2066. ; Returns value in ax, or does parse error return.
  2067. ; Changes ax,bx,dx,si.                  [jrd] 18 Oct 1987
  2068. num0:   mov     dx,offset rdbuf+1       ; were to put text
  2069.         mov     word ptr rdbuf,0        ; clear the buffer
  2070.         mov     bx,numhlp               ; help text
  2071.         mov     ah,cmfile               ; get a word
  2072.         call    comnd
  2073.          jmp    r
  2074.         mov     ah,cmcfm
  2075.         call    comnd                   ; Get a confirm.
  2076.          jmp    r                       ; Didn't get one.
  2077.          nop
  2078.         mov     si,offset rdbuf+1
  2079.         cmp     rdbuf+1,'\'             ; already quoted?
  2080.         je      num0a                   ; e = yes
  2081.         mov     rdbuf,'\'               ; add a numerical quote
  2082.         dec     si                      ; point to our escape char
  2083. num0a:  call    katoi                   ; convert number in rdbuf
  2084.         jc      num0er                  ; c = no number, error
  2085.         cmp     ax,max                  ; largest permitted value
  2086.         ja      num0er                  ; a = error
  2087.         cmp     ax,min                  ; smallest permitted value
  2088.         jb      num0er                  ; b = error
  2089.         ret                             ; return value in ax
  2090.  
  2091. num0er: mov     ah,prstr
  2092.         mov     dx,numerr               ; comand-specific error message, if any
  2093.         cmp     dx,0                    ; was any given?
  2094.         je      num0e1                  ; e = no, use generic msg
  2095.         int     dos                     ; show given error message
  2096.         jmp     short num0e2
  2097. num0e1: mov     dx,offset nummsg1       ; get address of numeric error message.
  2098.         int     dos
  2099.         mov     ax,min                  ; smallest permitted number
  2100.         call    decout                  ; display decimal number in ax
  2101.         mov     ah,prstr
  2102.         mov     dx,offset nummsg2       ; "and"
  2103.         int     dos
  2104.         mov     ax,max                  ; largest permitted number
  2105.         call    decout
  2106. num0e2: jmp     prserr                  ; parsing error
  2107.  
  2108. ; translate the number in ax...
  2109. outnum  proc    near
  2110.         cwd
  2111.         mov     bx,10
  2112.         div     bx              ; divide to get digit
  2113.         push    dx              ; save remainder digit
  2114.         or      ax,ax           ; test quotient
  2115.         jz      outnu1          ; zero, no more of number
  2116.         call    outnum          ; else call for rest of number
  2117. outnu1: pop     ax              ; get digit back
  2118.         add     al,'0'          ; make printable
  2119.         stosb                   ; drop it off
  2120.         ret
  2121. outnum  endp
  2122.  
  2123. ; on/off field
  2124. onoff   proc    near
  2125.         call    stmsg           ; copy message
  2126.         call    stval           ; get value cell
  2127.         mov     al,[si]
  2128.         mov     si,offset onmsg
  2129.         mov     cx,2            ; assume 2-byte 'ON' message
  2130.         or      al,al           ; test value
  2131.         jnz     onof1           ; on, have right msg
  2132.         mov     si,offset offmsg
  2133.         mov     cx,3
  2134. onof1:  rep     movsb           ; copy right message in
  2135.         ret
  2136. onoff   endp
  2137.  
  2138. ; print first message if false, second if true
  2139. msg2    proc    near
  2140.         call    stval           ; get value cell
  2141.         mov     al,[si]
  2142.         mov     si,[bx].msg     ; assume off
  2143.         or      al,al           ; is it?
  2144.         jz      msg21           ; yes, continue
  2145.         mov     si,[bx].val2    ; else use alternate message
  2146. msg21:  jmp     stms1           ; handle copy and return
  2147. msg2    endp
  2148.  
  2149. ; search a keyword table for a value, print that value
  2150. srchkw  proc    near
  2151.         call    stmsg           ; first print message
  2152.         call    stval
  2153.         mov     al,[si]         ; get value to hunt for
  2154.         mov     ah,0            ; high order is 0
  2155.         mov     bx,[bx].val2    ; this is table address
  2156.         jmp     prttab          ; and look in table.
  2157. srchkw  endp
  2158.  
  2159.  
  2160. ; Print the drive name.
  2161. drnum   proc    near
  2162.         call    stmsg           ; copy message part first
  2163.         call    stval           ; pick up test value address
  2164. ;;;     mov     al,[si]         ; this is char to print
  2165.         mov     ah,gcurdsk      ; Get current disk.
  2166.         int     dos
  2167.         inc     al              ; We want 1 == A (not zero).
  2168.         mov     curdsk,al
  2169.         add     al,'@'          ; Make it printable.
  2170.         cld
  2171.         stosb
  2172.         mov     byte ptr [di],':'
  2173.         inc     di
  2174.         mov     byte ptr [di],'\'
  2175.         inc     di              ; end with a colon and backslash
  2176.         mov     dl,0            ; get current drive
  2177.         mov     ah,gcd          ; get current directory
  2178.         mov     si,di           ; current working buffer position
  2179.         int     dos
  2180.         push    cx
  2181.         push    dx
  2182.         mov     dx,di           ; directory string
  2183.         call    strlen          ; length of path part to cx
  2184.         cmp     cx,26           ; too long to show the whole thing?
  2185.         jbe     drnum3          ; be = is ok, show the whole path
  2186.         push    di              ; scan backward for last backslash
  2187.         mov     al,'\'          ; thing to search for
  2188.         std                     ; backward
  2189.         mov     di,si           ; start of buffer
  2190.         add     di,cx           ; length of string
  2191.         repne   scasb           ; scan backward for a backslash
  2192.         jcxz    drnum2          ; should not happen, but then again ...
  2193.         repne   scasb           ; do again for second to last path part
  2194. drnum2: cld                     ; reset direction flag
  2195.         dec     di              ; move di two places preceding backslash
  2196.         mov     [di],'--'       ; insert a missing path indicator
  2197.         dec     di
  2198.         mov     byte ptr [di],'-'
  2199.         mov     si,di           ; we will show just this part
  2200.         pop     di              ; recover main status pointer
  2201. drnum3: pop     dx
  2202.         pop     cx
  2203.  
  2204. drnum4: lodsb                   ; copy until null terminator
  2205.         stosb
  2206.         cmp     al,0            ; end of string?
  2207.         je      drnum5          ; e = yes
  2208.         jmp     short drnum4    ; do all
  2209. drnum5: dec     di              ; offset inc of stosb
  2210.         ret
  2211. drnum   endp
  2212.  
  2213.  
  2214. ; Print the screen-dump filename [jrd]
  2215.  
  2216. dmpstat proc    near
  2217.         call    stmsg           ; copy message part
  2218.         mov     si,offset dmpname ; address of filename
  2219. dmpstat1:lodsb                  ; get a byte
  2220.         cmp     al,0            ; at end yet?
  2221.         je      dmpstat2        ; e = yes
  2222.         stosb                   ; store in buffer
  2223.         jmp     short dmpstat1  ; keep storing non-null chars
  2224. dmpstat2:ret
  2225. dmpstat endp
  2226.  
  2227. ; print the End-of-Line characters
  2228. preol   proc    near
  2229.         call    stmsg           ; display leadin part of message
  2230.         mov     al,dtrans.seol  ; send eol char
  2231.         add     al,40H          ; make it printable
  2232.         stosb
  2233.         mov     si,offset mseol2 ; second part of message
  2234.         call    stms1           ; add that
  2235.         mov     al,trans.reol   ; receive eol char
  2236.         add     al,40H          ; make it printable
  2237.         stosb
  2238.         ret
  2239. preol   endp
  2240.  
  2241. ; print Send Delay and Pause
  2242. prsnd   proc    near
  2243.         call    stmsg           ; display leadin part of msg
  2244.         mov     al,trans.sdelay ; Send Delay (sec)
  2245.         xor     ah,ah
  2246.         call    outnum
  2247.         mov     si,offset sndmsg2 ; second part of msg
  2248.         call    stms1           ; add that
  2249.         mov     al,spause       ; Send Pause (millisec)
  2250.         call    outnum
  2251.         mov     si,offset sndmsg3 ; last part of msg
  2252.         call    stms1           ; add it too
  2253.         ret
  2254. prsnd   endp
  2255.  
  2256. ; Print the handshake.
  2257. prhnd:  mov     si,offset handst        ; copy in initial message
  2258.         call    stms1
  2259.         mov     si,offset nonmsg        ; assume no handshake
  2260.         mov     bx,portval
  2261.         cmp     [bx].hndflg,0           ; Is handshaking in effect?
  2262.         jne     prh0                    ; Yes, print what we're using.
  2263.         jmp     stms1                   ; no, say so and return
  2264. prh0:   mov     al,5eh                  ; Doing handshaking with control char.
  2265.         stosb
  2266.         mov     al,[bx].hands
  2267.         add     al,40H                  ; Make printable.
  2268.         stosb                           ; put in buffer
  2269.         ret                             ; and return
  2270.  
  2271. ; Print the pad character in AL.
  2272. prpad:  cmp     al,127                  ; Are they using a delete?
  2273.         jne     prpad0
  2274.         mov     ah,prstr
  2275.         mov     dx,offset delmsg
  2276.         int     dos
  2277.         ret
  2278. prpad0: mov     dl,5eh                  ; caret
  2279.         mov     ah,conout
  2280.         push    ax
  2281.         int     dos
  2282.         pop     ax
  2283.         mov     dl,al
  2284.         add     dl,40H                  ; Make printable.
  2285.         int     dos
  2286.         ret
  2287.  
  2288. ; Print value from table.   BX/address of table, AL/value of variable.
  2289. prttab: mov     cl,[bx]                 ; Number of entries in our table.
  2290.         inc     bx                      ; Point to the data.
  2291. prtt0:  mov     dl,[bx]                 ; Length of keyword.
  2292.         inc     bx                      ; Point to keyword.
  2293.         mov     dh,0
  2294.         inc     dx                      ; Account for "$" in table.
  2295.         mov     si,dx                   ; Put to index register.
  2296.         cmp     ax,[bx+si]              ; Is this the one?
  2297.         je      prtt1
  2298.         add     bx,dx                   ; Go to end of keyword.
  2299.         add     bx,2                    ; Point to next keyword.
  2300.         dec     cl                      ; Any more keywords to check?
  2301.         jnz     prtt0                   ; Yes, go to it.
  2302.         mov     bx,offset prterr
  2303. prtt1:  mov     si,bx
  2304.         jmp     stms1                   ; copy in message
  2305.         ret                             ; and return
  2306.  
  2307. ; Print the baud rate
  2308.  
  2309. BAUDPRT PROC     NEAR
  2310.         mov     si,offset baudrt        ; "Baud rate is"
  2311.         call    stms1                   ; display that part
  2312.         call    getbaud                 ; read baud rate first
  2313.         mov     bx,portval
  2314.         mov     ax,[bx].baud
  2315.         cmp     al,byte ptr bdtab       ; number of table entries
  2316.         jb      bdprt5                  ; b = in table
  2317.         mov     si,offset unrec         ; say unrecognized value
  2318.         jmp     stms1                   ; display text and return
  2319. bdprt5: mov     bx,offset bdtab         ; show ascii rate from table
  2320.         call    prttab
  2321.         ret
  2322. BAUDPRT ENDP
  2323.                                         ; Scripts - Status
  2324. scpprt  proc    near                    ; display script settings on a line
  2325.         call    stmsg                   ; copy leading part of message
  2326.         mov     si,offset scpmsne       ; echo off
  2327.         cmp     inecho,0                ; echo state
  2328.         je      scppre                  ; e = off
  2329.         mov     si,offset scpmse        ; echo on
  2330. scppre: call    stms1                   ; add to buffer
  2331.         mov     si,offset casmsi        ; "ignore"
  2332.         cmp     incasv,0dfh             ; case state
  2333.         je      scpprc
  2334.         mov     si,offset casmso        ; "observe"
  2335. scpprc: call    stms1                   ; add to buffer
  2336.         mov     si,offset scptms        ; default timeout
  2337.         call    stms1                   ; add to buffer
  2338.         mov     ax,indfto               ; timeout value
  2339.         call    outnum                  ; add ascii rendition to buffer
  2340.         mov     si,offset scpmsp        ; "proceed"
  2341.         cmp     inactv,0                ; action on timeout, proceed?
  2342.         je      scppra                  ; e = yes
  2343.         mov     si,offset scpmsq        ; "quit"
  2344. scppra: call    stms1
  2345.         ret
  2346. scpprt  endp
  2347.  
  2348.  
  2349. ; Jumping to this location is like retskp.    It assumes the instruction
  2350. ;    after the call is a jmp addr.
  2351.  
  2352. RSKP    PROC    NEAR
  2353.         pop     bp
  2354.         add     bp,3
  2355.         push    bp
  2356.         ret
  2357. RSKP    ENDP
  2358.  
  2359. ; Jumping here is the same as a ret.
  2360.  
  2361. R       PROC    NEAR
  2362.         ret
  2363. R       ENDP
  2364.  
  2365. ; routine to print an error message, then retskp
  2366. ; expects message in dx
  2367. reterr  proc    near
  2368.         mov     ah,prstr
  2369.         int     dos
  2370.         jmp     rskp
  2371. reterr  endp
  2372.  
  2373. code    ends
  2374.  
  2375. if1
  2376.         %out [End of pass 1]
  2377. else
  2378.         %out [End of assembly]
  2379. endif
  2380.         end
  2381.