home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / asm / MSKERMIT.ZIP / MSSET.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-05-17  |  38.1 KB  |  1,630 lines

  1.     public setcom, status, stat0, baudprt, escprt, prmptr, dodef
  2.     public setcpt, docom, shomac, atoi
  3.     include msdefs.h
  4.  
  5. setextra  equ    100
  6. macmax    equ    20            ; max # of macros
  7.  
  8. datas    segment public 'datas'
  9.     extrn    comand:byte, flags:byte, trans:byte, cptfcb:byte, takadr:word
  10.     extrn    taklev:byte, inichk:byte, portval:word, curdsk:byte
  11.     extrn    setktab:byte, setkhlp:byte
  12.  
  13. kerm    db    'Kermit-MS>$'
  14. crlf    db    cr,lf,'$'
  15. crlfsp    db    cr,lf,' '       ; crlf space
  16.     db    '$'
  17. eqs    db    ' = $'
  18. ermes1    db    cr,lf,'?Too many macros$'
  19. ermes2    db    cr,lf,'?No room in table for macro$'
  20. ermes3    db    cr,lf,'?Not confirmed$'
  21. ermes4    db    cr,lf,'?No room in take stack to expand macro$'
  22. ermes5    db    cr,lf,'?Not implemented$'
  23. erms23    db    cr,lf,'?0 or null scan code not allowed$' ;[jd]
  24. erms24    db    cr,lf,'?Capture file already open (use close command)$' ;[jd]
  25. filhlp    db    ' Input file specification for session logging$'
  26. macmsg    db    ' Specify macro name followed by body of macro $'
  27. shmmsg    db    ' Confirm with carriage return $'
  28. prmmsg    db    ' Enter new prompt string $'
  29. sk1msg    db    ' Decimal scan code for key $'
  30. sk2msg    db    ' Redefinition string for key $'
  31. prterr    db    '?Unrecognized value$'
  32. unrec    db    'Baud rate is unknown$'
  33. defpmp    db    'Definition string: $'
  34. esctl    db    'Control-$'         ; [6]
  35. nonmsg    db    'none$'
  36. delmsg    db    'delete$'
  37. onmsg    db    'On'
  38. offmsg    db    'Off'
  39. tmp    db    ?,'$'
  40. sum    db    0
  41. min    db    0
  42. max    db    0
  43. desta    dw    0
  44. numerr    dw    0
  45. numhlp    dw    0
  46. stflg    db    0        ; Says if setting SEND or RECEIVE parameter.
  47. srtmp    db    0
  48. savsp    dw    0
  49. temp    dw    0
  50. temp1    dw    ?        ; Temporary storage.
  51. temp2    dw    ?        ; Temporary storage.
  52.  
  53. locst    db    'Local echo $'
  54. belon    db    'Ring bell after transfer$'
  55. beloff    db    'No bell after transfer$'
  56. vtemst    db    'HEATH-19 emulation $'
  57. cm1st    db    'Communications port: 1$'
  58. cm2st    db    'Communications port: 2$'
  59. capmsg    db    'Session logging $'
  60. eofmsg    db    'EOF mode: $'
  61. flost    db    'No flow control used$'
  62. floxmsg db    'Flow control: XON/XOFF $'
  63. handst    db    'Handshake used: $'
  64. destst    db    'File destination: $'
  65. diskst    db    'Default disk: $'
  66. blokst    db    'Block check used: $'
  67. ebyst    db    '8-bit quoting done only on request$'
  68. ebvst    db    '8-bit quoting will be done with: $'
  69. sqcst    db    'Send cntrl char prefix: $'
  70. rqcst    db    'Receive cntrl char prefix: $'
  71. debon    db    'Debug mode $'
  72. flwon    db    'Warning $'
  73. parmsg    db    'Parity $'
  74. abfdst    db    'Discard incomplete file$'
  75. abfkst    db    'Keep incomplete file$'
  76. eolst    db    'End-of-line character: $'
  77. ssohst    db    'Send start-of-packet char: $'
  78. rsohst    db    'Receive start-of-packet char: $'
  79. stimst    db    'Send timeout (seconds): $'
  80. rtimst    db    'Receive timeout (seconds): $'
  81. spakst    db    'Send packet size: $'
  82. rpakst    db    'Receive packet size: $'
  83. snpdst    db    '# of send pad chars: $'
  84. rnpdst    db    '# of receive pad chars: $'
  85. timmsg    db    'Timer $'
  86. escmes    db    'Escape character: $'
  87. b03st    db    'Baud rate is 300$'
  88. b12st    db    'Baud rate is 1200$'
  89. b18st    db    'Baud rate is 1800$'
  90. b24st    db    'Baud rate is 2400$'
  91. b48st    db    'Baud rate is 4800$'
  92. b96st    db    'Baud rate is 9600$'
  93. b04st    db    'Baud rate is 45.5$'
  94. b05st    db    'Baud rate is 50$'
  95. b07st    db    'Baud rate is 75$'
  96. b11st    db    'Baud rate is 110$'
  97. b13st    db    'Baud rate is 134.5$'
  98. b15st    db    'Baud rate is 150$'
  99. b06st    db    'Baud rate is 600$'
  100. b20st    db    'Baud rate is 2000$'
  101. b19st    db    'Baud rate is 19200$'
  102. b38st    db    'Baud rate is 38400$'
  103.  
  104. eolhlp    db    cr,lf,'Decimal number between 0 and 31$'
  105. eolerr    db    cr,lf,'Illegal end-of-line character$'
  106. timerr    db    cr,lf,'Illegal timeout value$'
  107. timhlp    db    cr,lf,'Decimal number between 0 and 94$'
  108. soherr    db    cr,lf,'Illegal start-of-packet character$'
  109. quohlp    db    cr,lf,'Decimal number between 33 and 126$'
  110. quoerr    db    cr,lf,'Illegal control character prefix$'
  111. pakerr    db    cr,lf,'Illegal packet length$'
  112. pakhlp    db    cr,lf,'Decimal number between 20 and 94$'
  113. npderr    db    cr,lf,'Illegal number of pad characters$'
  114. npdhlp    db    cr,lf,'Decimal number between 0 and 99$'
  115. paderr    db    cr,lf,'Illegal pad character$'
  116. padhlp    db    cr,lf,'Decimal number between 0 and 31 or 127$'
  117. eschlp    db    cr,lf,'Enter literal value (ex: Cntrl ])  $'
  118. desterr db    cr,lf,'Illegal destination device$'
  119. dskhlp    db    cr,lf,'Default disk drive to use, such as A:$'
  120. dskerr    db    cr,lf,'Invalid drive specification$'
  121.  
  122. sethlp    db    cr,lf,'BAUD rate'
  123.     db    cr,lf,'BELL'
  124.     db    cr,lf,'BLOCK-CHECK-TYPE'
  125.     db    cr,lf,'DEBUG'
  126.     db    cr,lf,'DEFAULT-DISK'
  127.     db    cr,lf,'DESTINATION'
  128.     db    cr,lf,'END-OF-LINE character'
  129.     db    cr,lf,'EOF CTRL-Z or NOCTRL-Z'
  130.     db    cr,lf,'ESCAPE character change'
  131.     db    cr,lf,'FLOW-CONTROL'
  132.     db    cr,lf,'HANDSHAKE'
  133.     db    cr,lf,'HEATH-19'
  134.     db    cr,lf,'INCOMPLETE file'
  135.     db    cr,lf,'KEY'
  136.     db    cr,lf,'LOCAL-ECHO echoing (half-duplex)'
  137.     db    cr,lf,'PARITY type'
  138.     db    cr,lf,'PORT for communication'
  139.     db    cr,lf,'PROMPT'
  140.     db    cr,lf,'RECEIVE parameter'
  141.     db    cr,lf,'REMOTE on/off'
  142.     db    cr,lf,'SEND parameter'
  143.     db    cr,lf,'TAKE-ECHO'
  144.     db    cr,lf,'TIMER'
  145.     db    cr,lf,'WARNING'
  146.     db    '$'
  147.  
  148. settab    db    24
  149.     mkeyw    'BAUD',baudst
  150.     mkeyw    'BELL',bellst
  151.     mkeyw    'BLOCK-CHECK-TYPE',blkset
  152.     mkeyw    'DEBUG',debst
  153.     mkeyw    'DEFAULT-DISK',dskset
  154.     mkeyw    'DESTINATION',desset
  155.     mkeyw    'END-OF-LINE',eolset
  156.     mkeyw    'EOF',seteof
  157.     mkeyw    'ESCAPE',escape
  158.     mkeyw    'FLOW-CONTROL',floset
  159.     mkeyw    'HANDSHAKE',hndset
  160.     mkeyw    'HEATH19-EMULATION',vt52em
  161.     mkeyw    'INCOMPLETE',abfset
  162.     mkeyw    'KEY',setkey
  163.     mkeyw    'LOCAL-ECHO',lcal
  164.     mkeyw    'PARITY',setpar
  165.     mkeyw    'PORT',comset
  166.     mkeyw    'PROMPT',promset
  167.     mkeyw    'RECEIVE',recset
  168.     mkeyw    'REMOTE',remset
  169.     mkeyw    'SEND',sendset
  170.     mkeyw    'TAKE-ECHO',takset
  171.     mkeyw    'TIMER',timset
  172.     mkeyw    'WARNING',filwar
  173.  
  174.  
  175. seoftab db    2
  176.     mkeyw    'CTRL-Z',1
  177.     mkeyw    'NOCTRL-Z',0
  178.  
  179. stsrtb    db    06        ; Number of options.
  180.     mkeyw    'PACKET-LENGTH',srpack
  181.     mkeyw    'PADCHAR',srpad
  182.     mkeyw    'PADDING',srnpd
  183.     mkeyw    'QUOTE',srquo
  184.     mkeyw    'START-OF-PACKET',srsoh
  185.     mkeyw    'TIMEOUT',srtim
  186.  
  187. ontab    db    02H        ; Two entries.
  188.     mkeyw    'OFF',00H
  189.     mkeyw    'ON',01H
  190.  
  191. destab    db    02H        ; Two choices.
  192.     mkeyw    'DISK',01H
  193.     mkeyw    'PRINTER',00H
  194.  
  195. ; What type of block check to use.
  196. blktab    db    03H
  197.     mkeyw    '1-CHARACTER-CHECKSUM',1
  198.     mkeyw    '2-CHARACTER-CHECKSUM',2
  199.     mkeyw    '3-CHARACTER-CRC-CCITT',3
  200.  
  201. ; If abort when receiving files, can keep what we have or discard. [20d]
  202.  
  203. abftab    db    02H        ; Only two options.
  204.     mkeyw    'DISCARD',01H
  205.     mkeyw    'KEEP',00H
  206.  
  207. partab    db    05H        ; Five entries.         [10 start]
  208.     mkeyw    'EVEN',PAREVN
  209.     mkeyw    'MARK',PARMRK
  210.     mkeyw    'NONE',PARNON
  211.     mkeyw    'ODD',PARODD
  212.     mkeyw    'SPACE',PARSPC
  213.  
  214. flotab    db    2
  215.     mkeyw    'NONE',flonon
  216.     mkeyw    'XON/XOFF',floxon
  217.  
  218. hndtab    db    7
  219.     mkeyw    'BELL',bell
  220.     mkeyw    'CR',cr
  221.     mkeyw    'ESC',esc
  222.     mkeyw    'LF',lf
  223.     mkeyw    'NONE',0
  224.     mkeyw    'XOFF',xoff
  225.     mkeyw    'XON',xon
  226.  
  227. BStab    db    02H            ;Two entries [19c start]
  228.     mkeyw    'BACKSPACE',00H
  229.     mkeyw    'DELETE',01H
  230.  
  231. bdtab    db    010H        ; 16 entries
  232.     mkeyw    '110',b0110
  233.     mkeyw    '1200',b1200
  234.     mkeyw    '134.5',b01345
  235.     mkeyw    '150',b0150
  236.     mkeyw    '1800',b1800
  237.     mkeyw    '19200',b19200
  238.     mkeyw    '2000',b2000
  239.     mkeyw    '2400',b2400
  240.     mkeyw    '300',b0300
  241.     mkeyw    '38400',b38400
  242.     mkeyw    '45.5',b00455
  243.     mkeyw    '4800',b4800
  244.     mkeyw    '50',b0050
  245.     mkeyw    '600',b0600
  246.     mkeyw    '75',b0075
  247.     mkeyw    '9600',b9600
  248.  
  249. ten    dw    10            ; multiplier for setatoi
  250. rdbuf    db    80H DUP(?)
  251. prm    db    30 dup(0)        ; Buffer for new prompt.
  252. prmptr    dw    kerm            ; pointer to prompt
  253. defkw    db    100 dup (?)
  254. macnum    dw    0            ; one macro yet
  255. mactab    dw    ibmmac            ; default ibm mac is macro 0
  256.     dw    macmax dup (?)        ; empty macro table
  257. defptr    dw    macbuf
  258. macbuf    db    macmax*100 dup (?)    ; buffer for macro defs
  259. rmlft    db    setextra        ; space left in set table
  260. mcctab    db    1            ; macro cmd table, one initially
  261.     mkeyw    'IBM',0                 ; macro # 0
  262.     db    setextra dup (?)    ; room for more.
  263.  
  264. ibmmac    db    imlen-1
  265.     db    'set timer on',cr,'set parity mark',cr
  266.     db    'set local-echo on',cr,'set handshake xon',cr
  267.     db    'set flow none',cr
  268. imlen    equ    $-ibmmac
  269.  
  270. ; structure for status information
  271. stent    struc
  272. sttyp    dw    ?        ; type (actually routine to call)
  273. msg    dw    ?        ; message to print
  274. val2    dw    ?        ; needed value: another message, or tbl addr
  275. tstcel    dw    ?        ; address of cell to test, in data segment
  276. basval    dw    0        ; base value, if non-zero
  277. stent    ends
  278.  
  279. sttab    stent    <onoff,vtemst,,flags.vtflg>
  280.     stent    <onoff,locst,,ecoflg,portval>
  281.     stent    <baudprt>
  282.     stent    <srchkw,parmsg,partab,parflg,portval>
  283.     stent    <onechr,escmes,,trans.escchr>
  284.     stent    <onoff,capmsg,,flags.capflg>
  285.     stent    <msg2,flost,floxmsg,floflg,portval>
  286.     stent    <prhnd>
  287.     stent    <srchkw,destst,destab,flags.destflg>
  288.     stent    <drnum,diskst,,curdsk>
  289.     stent    <onoff,flwon,,flags.flwflg>
  290.     stent    <msg2,beloff,belon,flags.belflg>
  291.     stent    <msg2,abfkst,abfdst,flags.abfflg>
  292.     stent    <srchkw,eofmsg,seoftab,flags.eofcz>
  293.     stent    <onechr,sqcst,,trans.rquote>
  294.     stent    <onechr,rqcst,,trans.squote>
  295.     stent    <onechr,rsohst,,trans.rsoh>
  296.     stent    <onechr,ssohst,,trans.ssoh>
  297.     stent    <stnum,rtimst,,trans.rtime>
  298.     stent    <stnum,stimst,,trans.stime>
  299.     stent    <stnum,rpakst,,trans.rpsiz>
  300.     stent    <stnum,spakst,,trans.spsiz>
  301.     stent    <stnum,snpdst,,trans.spad>
  302.     stent    <stnum,rnpdst,,trans.rpad>
  303.     stent    <onoff,timmsg,,flags.timflg>
  304.     stent    <pr8bit>
  305.     stent    <onechr,eolst,,trans.seol>
  306.     stent    <srchkw,blokst,blktab,trans.chklen>
  307.     stent    <msg2,cm2st,cm1st,flags.comflg>
  308.     stent    <onoff,debon,,flags.debug>
  309.     dw    0        ; end of table
  310. sttbuf    db    2000 dup (?)    ; big buffer for status msg.
  311. datas    ends
  312.  
  313. code    segment public
  314.     extrn cmcfrm:near, prserr:near, comnd:near, dobaud:near
  315.     extrn cmgtch:near, repars:near, coms:near, vts:near, defkey:near
  316.     extrn inicpt:near, prompt:near, nout:near, prtscr:near
  317.     extrn prkey:near
  318.     assume    cs:code,ds:datas
  319.  
  320. ; This is the SET command.
  321.  
  322. SETCOM    PROC    NEAR
  323.     mov dx,offset settab    ; Parse a keyword from the set table.
  324.     mov bx,offset sethlp
  325.     mov ah,cmkey
  326.     call comnd
  327.      jmp r
  328.     call bx
  329.      nop
  330.      nop
  331.      nop
  332.     jmp rskp
  333. SETCOM    endp
  334.  
  335. docom    proc    near
  336.     mov    dx,offset mcctab
  337.     mov    bx,0
  338.     mov    ah,cmkey
  339.     call    comnd
  340.      jmp    r
  341.     push    bx
  342.     mov    ah,cmcfm
  343.     call    comnd
  344.      pop    bx
  345.      ret
  346.      nop
  347.     pop    bx
  348.     cmp    taklev,maxtak        ; room in take level?
  349.     jl    docom2            ; yes, continue
  350.     mov    dx,offset ermes4    ; else complain
  351.     jmp    reterr
  352. docom2: inc    taklev            ; increment take level (overflow)
  353.     add    takadr,size takinfo
  354.     shl    bx,1
  355.     mov    si,mactab[bx]        ; point to macro
  356.     mov    cl,[si]         ; get size from macro
  357.     mov    ch,0
  358.     inc    si            ; point to actual definition
  359.     mov    bx,takadr        ; point to current buffer
  360.     mov    [bx].takfcb,0ffh    ; flag as a macro
  361.     mov    [bx].takptr,si        ; point to beginning of def
  362.     mov    [bx].takchl,cl        ; # of chars left in buffer
  363.     mov    [bx].takcnt,cx        ; and in definition
  364.     mov    word ptr [bx].takcnt+2,0 ; zero high order...
  365.     jmp    rskp
  366. docom    endp
  367.  
  368. ; the define command
  369. dodef    proc    near
  370.     cmp    macnum,macmax        ; get current macro count
  371.     jl    dode1            ; no, go on
  372.     mov    dx,offset ermes1    ; else complain
  373.     jmp    reterr            ; and return
  374.  
  375. dode1:    mov    ah,cmtxt
  376.     mov    bx,offset defkw+1    ; buffer for keyword
  377.     mov    dx,offset macmsg
  378.     call    comnd
  379.      ret
  380.      nop
  381.      nop
  382.     cmp    ah,0
  383.     jne    dode2
  384.     ret
  385. dode2:    push    es
  386.     mov    bx,ds
  387.     mov    es,bx
  388.     cld
  389.     mov    cl,ah
  390.     mov    ch,0            ; length
  391.     mov    si,offset defkw+1    ; pointer to keyword
  392.     mov    ah,0            ; # of chars in keyword
  393. ; uppercase keyword, look for end
  394. dode3:    lodsb                ; get a byte
  395.     cmp    al,'a'
  396.     jb    dode4
  397.     cmp    al,'z'
  398.     ja    dode4
  399.     sub    al,'a'-'A'
  400.     mov    [si-1],al        ; uppercase if necessary
  401. dode4:    inc    ah            ; increment word count
  402.     cmp    al,' '                  ; is it the break character?
  403.     loopne    dode3            ; no, loop thru rest of word
  404. dode5:    jne    dode6            ; ended with break char?
  405.     dec    ah            ; yes, don't count in length
  406. dode6:    mov    defkw,ah        ; store length in front of it
  407.     add    ah,4            ; add keyword overhead length
  408.     cmp    ah,rmlft        ; will it fit in buffer
  409.     jb    dode7            ; yes, keep going
  410.     mov    dx,offset ermes2    ; else complain
  411.     jmp    reterr
  412.  
  413. dode7:    sub    rmlft,ah        ; subtract space used in tbl
  414.     mov    di,defptr        ; pointer to free space
  415.     inc    macnum            ; count the macro
  416.     mov    bx,macnum
  417.     shl    bx,1            ; double for word idx!!!
  418.     mov    mactab[bx],di        ; install into table
  419.     mov    [di],cl         ; store length
  420.     inc    di
  421.     jcxz    dode10            ; no copy if 0 length
  422.  
  423. ; copy definition into buffer, changing commas to crs
  424. dode8:    lodsb                ; get a byte
  425.     cmp    al,','                  ; comma?
  426.     jne    dode9            ; no, keep going
  427.     mov    al,cr            ; else replace with cr
  428. dode9:    stosb
  429.     loop    dode8            ; keep copying
  430.  
  431. dode10: mov    defptr,di        ; update free ptr
  432.     mov    bl,defkw
  433.     mov    bh,0
  434.     lea    di,defkw+1[bx]        ; end of keyword
  435.     mov    al,'$'
  436.     stosb
  437.     mov    ax,macnum
  438.     stosb                ; low-order
  439.     mov    al,0            ; high-order is always 0.
  440.     stosb
  441.  
  442. ; now install into table
  443.     pop    es
  444.     mov    bx,offset mcctab
  445.     mov    dx,offset defkw
  446.     call    addtab
  447.     jmp    rskp
  448. dodef    endp
  449.  
  450. ; add an entry to a keyword table
  451. ; enter with bx/ table address, dx/ ptr to new entry
  452. ; no check is made to see if the entry fits in the table.
  453. addtab    PROC    NEAR
  454.     push    es
  455.     cld
  456.     mov    ax,ds
  457.     mov    es,ax        ; address data segment
  458.     mov    bp,bx        ; remember where tbl starts
  459.     mov    cl,[bx]     ; pick up length of table
  460.     mov    ch,0
  461.     inc    bx        ; point to actual table...
  462. addta1: push    cx        ; preserve count
  463.     mov    si,dx        ; point to entry
  464.     lodsb            ; get length of new entry
  465.     mov    cl,[bx]     ; and length of table entry...
  466.     mov    ah,0        ; assume they're the same size
  467.     cmp    al,cl        ; are they the same?
  468.     lahf            ; remember result of comparison...
  469.     jae    addta2        ; is new smaller? no, use table length
  470.     mov    cl,al        ; else use length of new entry
  471. addta2: mov    ch,0
  472.     lea    di,[bx+1]    ; point to actual keyword
  473.     repe    cmpsb        ; compare strings
  474.     pop    cx        ; restore count
  475.     jb    addta4        ; below, insert before this one
  476.     jne    addta3        ; not below or same, keep going
  477.     sahf            ; same. get back result of length comparison
  478.     jb    addta4        ; if new len is smaller, insert here
  479.     jne    addta3        ; if not same size, keep going
  480.     mov    si,bx        ; else this is where entry goes
  481.     jmp    short addta6    ; no insertion required...
  482. addta3: mov    al,[bx]
  483.     mov    ah,0
  484.     add    bx,ax        ; skip this entry
  485.     add    bx,4        ; len + $ + value...
  486.     loop    addta1        ; and keep looking
  487. addta4: mov    si,bx        ; this is first location to move
  488.     mov    di,bx
  489.     inc    ds:byte ptr [bp] ; remember we're adding one...
  490.     jcxz    addta6        ; no more entries, forget this stuff
  491.     mov    bh,0        ; this stays 0
  492. addta5: mov    bl,[di]     ; get length
  493.     lea    di,[bx+di+4]    ; end is origin + length + 4 for len, $, value
  494.     loop    addta5        ; loop thru remaining keywords
  495.     mov    cx,di
  496.     sub    cx,si        ; compute # of bytes to move
  497.     push    si        ; preserve loc for new entry
  498.     mov    si,di        ; first to move is last
  499.     dec    si        ; minus one
  500.     mov    di,dx        ; new entry
  501.     mov    bl,[di]     ; get length
  502.     lea    di,[bx+si+4]    ; dest is source + length of new + 4
  503.     std            ; move backwards
  504.     rep    movsb        ; move the table down
  505.     cld            ; put flag back
  506.     pop    si
  507. addta6: mov    di,si        ; this is where new entry goes
  508.     mov    si,dx        ; this is where it comes from
  509.     mov    cl,[si]     ; length
  510.     mov    ch,0
  511.     add    cx,4        ; overhead bytes
  512.     rep    movsb        ; stick it in
  513.     pop    es
  514.     ret            ; and return
  515. addtab    endp
  516.  
  517. ; Show defined macros.
  518. SHOMAC    PROC    NEAR
  519.     mov ah,cmtxt
  520.     mov bx,offset rdbuf
  521.     mov dx,offset shmmsg
  522.     call comnd
  523.      jmp r
  524.     cmp ah,0        ; Bare CR means show all macros.
  525.     jne shom2        ; No, he wants specific macro expanded.
  526.     mov si,offset mcctab    ; Table of macro names.
  527.     lodsb
  528.     mov cl,al        ; Number of macro entries.
  529.     mov ch,0
  530. shom0:    jcxz shom1        ; Done if none left to display.
  531.     lodsb            ; Length of macro name.
  532.     push ax         ; Don't forget it.
  533.     mov ah,prstr
  534.     mov dx,offset crlfsp    ; Go to new line.
  535.     int dos
  536.     mov dx,si        ; Print macro name.
  537.     int dos
  538.     mov dx,offset eqs
  539.     int dos
  540.     pop ax
  541.     mov ah,0
  542.     add si,ax        ; Skip over name.
  543.     inc si            ; Get to macro number.
  544.     mov bx,[si]        ; Pick it up.
  545.     call expmac        ; Expand the macro.
  546.     dec cx
  547.     add si,2        ; Skip over macro number.
  548.     jmp shom0        ; And do the rest.
  549. shom1:    mov ah,prstr
  550.     mov dx,offset crlf
  551.     int dos
  552.     jmp rskp
  553. shom2:    mov ah,prstr
  554.     mov dx,offset ermes3
  555.     int dos
  556.     jmp rskp
  557. SHOMAC    ENDP
  558.  
  559. ; Expand the macro, called with BX/macro number.
  560. expmac: push si
  561.     push cx
  562.     mov si,offset mactab    ; Table of address expansions.
  563.     shl bx,1        ; Double and use as index into table.
  564.     mov si,[si+bx]        ; Get address of expansion in question.
  565.     mov ax,si        ; Address of string.
  566.     inc ax            ; Don't print length.
  567.     mov cl,[si]        ; Length of string.
  568.     mov ch,0
  569.     call prkey        ; Print it.
  570.     pop cx
  571.     pop si
  572.     ret
  573.  
  574. seteof    proc    near
  575.     mov ah,cmkey
  576.     mov bx,0
  577.     mov dx,offset seoftab
  578.     call comnd
  579.      jmp r
  580.     push bx
  581.     mov ah,cmcfm
  582.     call comnd
  583.      jmp seteo1        ; error return...
  584.      nop
  585.     pop bx
  586.     mov flags.eofcz,bl    ; set value
  587.     jmp rskp        ; and return
  588. seteo1: pop bx
  589.     ret
  590. seteof    endp
  591.  
  592. ;    This is the ESCAPE character SET subcommand.     [6 start]
  593.  
  594. ESCAPE    PROC    NEAR
  595.     call cmgtch        ; Get a char.
  596.     cmp ah,0
  597.     jns es1         ; Terminator or no?
  598.     and ah,7FH        ; Turn off minus bit.
  599.     cmp ah,'?'
  600.     jne es0
  601.     mov dx,offset eschlp
  602.     mov ah,prstr
  603.     int dos
  604.     mov dx,offset crlf
  605.     int dos
  606.     mov dx,comand.cmprmp
  607.     int dos
  608.     mov bx,comand.cmdptr
  609.     mov al,'$'
  610.     mov [bx],al
  611.     mov dx,offset comand.cmdbuf
  612.     int dos
  613.     dec comand.cmcptr        ; Ignore dollar sign.
  614.     dec comand.cmccnt
  615.     mov comand.cmaflg,0
  616.     jmp repars
  617. es0:    mov ah,prstr
  618.     mov dx,offset ermes3
  619.     int dos
  620.     ret
  621. es1:    mov temp,ax
  622.     call cmcfrm
  623.      jmp es0
  624.      nop            ; Take up 3 bytes.
  625.     mov ax,temp
  626.     mov trans.escchr,ah    ; Save new value.
  627.     ret
  628. ESCAPE    ENDP            ; [6 end]
  629.  
  630. ;    This is the End-of-line character SET subcommand.
  631.  
  632. EOLSET    PROC    NEAR
  633.     mov min,0
  634.     mov max,1FH
  635.     mov sum,0
  636.     mov tmp,10
  637.     mov temp1,0
  638.     mov desta,offset trans.seol
  639.     mov numhlp,offset eolhlp
  640.     mov numerr,offset eolerr
  641.     jmp num0        ; Common routine for parsing numerical input.
  642. EOLSET    ENDP
  643.  
  644. num0:    call cmgtch        ; Get the first char into AH.
  645.     cmp ah,0
  646.     js num1
  647.     cmp ah,'0'
  648.     jl num1
  649.     cmp ah,'9'
  650.     ja num1
  651.     mov temp1,1
  652.     sub ah,30H
  653.     mov dl,ah
  654.     mov al,sum
  655.     mul tmp
  656.     add al,dl
  657.     mov sum,al
  658.     jmp num0
  659. num1:    and ah,7FH
  660.     cmp ah,CR
  661.     jne num2
  662.     cmp temp1,0
  663.     je num21
  664.     mov al,sum
  665.     cmp al,min
  666.     jl num3
  667.     cmp al,max
  668.     jg num3
  669.     mov bx,desta
  670.     mov [bx],al
  671.     ret
  672. num2:    cmp ah,03FH        ; Question mark?
  673.     je num4
  674. num21:    mov ah,prstr
  675.     mov dx,offset ermes3
  676.     int dos
  677.     jmp prserr
  678. num3:    mov ah,prstr
  679.     mov dx,numerr
  680.     int dos
  681.     jmp prserr
  682. num4:    mov ah,prstr
  683.     mov dx,numhlp
  684.     int dos
  685.     mov dx,offset crlf
  686.     int dos
  687.     mov dx,comand.cmprmp
  688.     int dos
  689.     mov bx,comand.cmdptr
  690.     mov al,'$'
  691.     mov [bx],al
  692.     mov dx,offset comand.cmdbuf
  693.     int dos
  694.     dec comand.cmcptr        ; Don't count the dollar sign.
  695.     dec comand.cmccnt        ; Or the question mark.
  696.     mov comand.cmaflg,0        ; Check for more input.
  697.     jmp repars
  698.  
  699. ;    This is the LOCAL echo SET subcommand.
  700.  
  701. LCAL    PROC    NEAR
  702.     mov dx,offset ontab
  703.     mov bx,0
  704.     mov ah,cmkey
  705.     call comnd
  706.      jmp r
  707.     push bx         ; Save the parsed value.
  708.     mov ah,cmcfm
  709.     call comnd        ; Get a confirm.
  710.      jmp lcl0        ;  Didn't get a confirm.
  711.      nop
  712.     pop bx
  713.     mov si,portval
  714.     mov [si].ecoflg,bl     ; Set the local echo flag.
  715.     mov [si].hndflg,bl    ; This goes on/off with local echo.
  716.     xor bl,01        ; Toggle this.
  717.     mov [si].floflg,bl    ; This is the opposite.
  718.     ret
  719. lcl0:    pop bx
  720.     ret
  721. LCAL    ENDP
  722.  
  723. ;    This is the VT52 emulation SET subcommand.
  724.  
  725. VT52EM    PROC    NEAR
  726.     call vts
  727.     ret
  728. VT52EM    ENDP
  729.  
  730. ; This is the SET subcommand to choose between COM1 and COM2. [19b]
  731.  
  732. COMSET    PROC    NEAR
  733.     call coms
  734.     ret
  735. COMSET    ENDP
  736.  
  737. FILWAR    PROC    NEAR
  738.     mov dx,offset ontab
  739.     mov bx,0
  740.     mov ah,cmkey
  741.     call comnd
  742.      jmp r
  743.     push bx
  744.     mov ah,cmcfm
  745.     call comnd        ; Get a confirm.
  746.      jmp fil0        ; Didn't get a confirm.
  747.      nop
  748.     pop bx
  749.     mov flags.flwflg,bl    ; Set the filewarning flag.
  750.     ret
  751. fil0:    pop bx
  752.     ret
  753. FILWAR    ENDP
  754.  
  755. ;    This is the SET aborted-file command.  [20d]
  756.  
  757. ABFSET    PROC    NEAR
  758.     mov dx,offset abftab
  759.     mov bx,0
  760.     mov ah,cmkey
  761.     call comnd
  762.      jmp r
  763.     push bx
  764.     mov ah,cmcfm
  765.     call comnd        ; Get a confirm.
  766.      jmp abf0        ;  Didn't get a confirm.
  767.      nop
  768.     pop bx
  769.     mov flags.abfflg,bl    ; Set the aborted file flag.
  770.     ret
  771. abf0:    pop bx
  772.     ret
  773. ABFSET    ENDP
  774.  
  775. ;    This is the SET Parity command.             [10 start]
  776.  
  777. SETPAR    PROC    NEAR
  778.     mov dx,offset partab
  779.     mov bx,0
  780.     mov ah,cmkey
  781.     call comnd
  782.      jmp r
  783.     push bx
  784.     mov ah,cmcfm
  785.     call comnd        ; Get a confirm.
  786.      jmp par0        ;  Didn't get a confirm.
  787.      nop
  788.     pop bx
  789.     mov si,portval
  790.     mov [si].parflg,bl    ; Set the parity flag.
  791.     cmp bl,parnon        ; Resetting parity to none? [21b]
  792.     je setp0        ; Yes, reset 8 bit quote character. [21b]
  793.     mov trans.ebquot,dqbin    ; Else, do quoting.  [21b]
  794.     ret            ; That's it.  [21b]
  795. setp0:    mov trans.ebquot,'Y'    ; If none, say will quote upon request. [21b]
  796.     ret
  797. par0:    pop bx
  798.     ret
  799. SETPAR    ENDP                            ; [10 end]
  800.  
  801. ; Sets debugging mode on and off.
  802.  
  803. DEBST    PROC    NEAR
  804.     mov dx,offset ontab
  805.     mov bx,0
  806.     mov ah,cmkey
  807.     call comnd
  808.      jmp r
  809.     push bx
  810.     mov ah,cmcfm
  811.     call comnd        ; Get a confirm.
  812.      jmp deb0        ; Didn't get a confirm.
  813.      nop
  814.     pop bx
  815.     mov flags.debug,bl    ; Set the DEBUG flag.
  816.     ret
  817. deb0:    pop bx
  818.     ret
  819. DEBST    ENDP
  820.  
  821. ; Turn bell on or off.      [17a start]
  822.  
  823. BELLST    PROC    NEAR
  824.     mov dx,offset ontab
  825.     mov bx,0
  826.     mov ah,cmkey
  827.     call comnd
  828.      jmp r
  829.     push bx
  830.     mov ah,cmcfm
  831.     call comnd
  832.      jmp bel0
  833.      nop
  834.     pop bx
  835.     mov flags.belflg,bl
  836.     ret
  837. bel0:    pop bx
  838.     ret
  839. BELLST    ENDP              ;  [17a end]
  840.  
  841. ; Toggle echo'ing of TAKE file to be either ON or OFF.
  842. TAKSET    PROC    NEAR
  843.     mov dx,offset ontab
  844.     mov bx,0
  845.     mov ah,cmkey
  846.     call comnd
  847.      jmp r
  848.     push bx
  849.     mov ah,cmcfm
  850.     call comnd
  851.      jmp tak0
  852.      nop
  853.     pop bx
  854.     mov flags.takflg,bl
  855.     ret
  856. tak0:    pop bx
  857.     ret
  858. TAKSET    ENDP              ;  [17a end]
  859.  
  860. ; Set timer ON/OFF during file transfer.
  861. TIMSET    PROC    NEAR
  862.     mov dx,offset ontab
  863.     mov bx,0
  864.     mov ah,cmkey
  865.     call comnd
  866.      jmp r
  867.     push bx
  868.     mov ah,cmcfm
  869.     call comnd
  870.      jmp tim0
  871.      nop
  872.     pop bx
  873.     mov flags.timflg,bl
  874.     ret
  875. tim0:    pop bx
  876.     ret
  877. TIMSET    ENDP              ;  [17a end]
  878.  
  879. ; Allow user to change the "Kermit-MS>" prompt.
  880. PROMSET PROC    NEAR
  881.     mov ah,cmtxt
  882.     mov bx,offset prm        ; Read in the prompt.
  883.     mov dx,offset prmmsg
  884.     call comnd
  885.      jmp r
  886.     cmp ah,0            ; Just a bare CR?
  887.     jne prom0
  888.     mov ax,offset kerm
  889.     jmp prom1
  890. prom0:    mov byte ptr [bx],'$'           ; End of string.
  891.     mov ax,offset prm
  892. prom1:    mov prmptr,ax            ; Remember it.
  893.     jmp rskp
  894. PROMSET ENDP
  895.  
  896. ; Set Flow-Control subcommand.
  897. FLOSET    PROC    NEAR
  898.     mov dx,offset flotab
  899.     xor bx,bx
  900.     mov ah,cmkey
  901.     call comnd
  902.      jmp r
  903.     push bx
  904.     mov ah,cmcfm
  905.     call comnd        ; Get a confirm.
  906.      jmp flox        ; Didn't get a confirm.
  907.      nop
  908.     pop bx
  909.     mov si,portval
  910.     mov [si].flowc,bx    ; Flow control value.
  911.     cmp bx,0        ; Turning it off?
  912.     je flo0         ; Yes.
  913.     mov [si].floflg,1    ; Say we're doing flow control.
  914.     mov [si].hndflg,0    ; So don't do handshaking.
  915.     ret
  916. flo0:    mov [si].floflg,bl    ; Say we're not doing flow control.
  917.     ret
  918. flox:    pop bx
  919.     ret
  920. FLOSET    ENDP
  921.  
  922. ; Set Handshake subcommand.
  923. HNDSET    PROC    NEAR
  924.     mov dx,offset hndtab
  925.     mov bx,0
  926.     mov ah,cmkey
  927.     call comnd
  928.      jmp r
  929.     push bx
  930.     mov ah,cmcfm
  931.     call comnd        ; Get a confirm.
  932.      jmp hndx        ; Didn't get a confirm.
  933.      nop
  934.     pop bx
  935.     mov si,portval
  936.     cmp bl,0        ; Setting handshake off?
  937.     je hnd0         ; Yes.
  938.     mov [si].floflg,0    ; Else, turn flow control off.
  939.     mov [si].hndflg,1    ; And turn on handshaking.
  940.     mov [si].hands,bl    ; Use this char as the handshake.
  941.     ret
  942. hnd0:    mov [si].hndflg,0    ; No handshaking.
  943.     mov [si].floflg,1    ; If one is off, the other is on.
  944.     ret
  945. hndx:    pop bx
  946.     ret
  947. HNDSET    ENDP
  948.  
  949. ; Set block check type sub-command.
  950. BLKSET    PROC    NEAR
  951.     mov dx,offset blktab
  952.     mov bx,0
  953.     mov ah,cmkey
  954.     call comnd
  955.      jmp r
  956.     push bx
  957.     mov ah,cmcfm
  958.     call comnd        ; Get a confirm.
  959.      jmp blk0        ; Didn't get a confirm.
  960.      nop
  961.     pop bx
  962.     mov trans.chklen,bl    ; Use this char as the handshake.
  963.     mov inichk,bl        ; Save here too.
  964.     ret
  965. blk0:    pop bx
  966.     ret
  967. BLKSET    ENDP
  968.  
  969. ; Set destination for incoming file.
  970. DESSET    PROC    NEAR
  971.     mov dx,offset destab
  972.     mov bx,0
  973.     mov ah,cmkey
  974.     call comnd
  975.      jmp r
  976.     push bx
  977.     mov ah,cmcfm
  978.     call comnd        ; Get a confirm.
  979.      jmp des0        ; Didn't get a confirm.
  980.      nop
  981.     pop bx
  982.     mov flags.destflg,bl    ; Set the destination flag.
  983.     ret
  984. des0:    pop bx
  985.     ret
  986. DESSET    ENDP
  987.  
  988. ; Set default disk for sending/receiving, etc.
  989. DSKSET    PROC    NEAR
  990.     mov comand.cmcr,1    ; Don't want filename specified.
  991.     mov ah,cmifi        ; Parse for drive specification.
  992.     mov dx,offset rdbuf    ; Read into handy buffer.
  993.     mov bx,offset dskhlp    ; Text of help message.
  994.     call comnd
  995.      jmp r
  996.     mov ah,cmcfm
  997.     call comnd
  998.      jmp r
  999.     cmp flags.nmoflg,0    ; Fail if specified file name.
  1000.     je dsk1
  1001. dsk0:    mov ah,prstr
  1002.     mov dx,offset dskerr    ; Illegal drive specification.
  1003.     int dos
  1004.     ret
  1005. dsk1:    mov bx,offset rdbuf
  1006.     mov ah,[bx]        ; Get the drive they said to use.
  1007.     cmp ah,0        ; Did they type a bare CR?
  1008.     je dsk0         ; Yes, complain.
  1009.     mov curdsk,ah        ; And remember it.
  1010.     dec ah
  1011.     mov dl,ah
  1012.     mov ah,seldsk
  1013.     int dos
  1014.     ret
  1015. DSKSET    ENDP
  1016.  
  1017. ;  This function sets the baud rate.
  1018.  
  1019. BAUDST    PROC    NEAR
  1020.     mov dx,offset bdtab
  1021.     mov bx,0
  1022.     mov ah,cmkey
  1023.     call comnd
  1024.      jmp r
  1025.     push bx
  1026.     mov ah,cmcfm
  1027.     call comnd        ; Get a confirm.
  1028.      jmp bau0        ; Didn't get one.
  1029.      nop
  1030.     pop bx
  1031.     mov si,portval
  1032.     mov ax,[si].baud    ; Remember original value. [25]
  1033.     mov [si].baud,bx    ; Set the baud rate.
  1034.     call dobaud        ; Use common code. [19a]
  1035.     ret
  1036. bau0:    pop bx
  1037.     ret
  1038. BAUDST    ENDP
  1039.  
  1040. SENDSET PROC    NEAR
  1041.     mov stflg,'S'           ; Setting SEND parameter
  1042. sndst0: mov dx,offset stsrtb    ; Parse a keyword.
  1043.     mov bx,0
  1044.     mov ah,cmkey
  1045.     call comnd
  1046.      jmp r
  1047.     call bx
  1048.      nop
  1049.      nop
  1050.      nop
  1051.     jmp rskp
  1052. SENDSET ENDP
  1053.  
  1054. recset: mov stflg,'R'           ; Setting RECEIVE paramter.
  1055.     jmp sndst0
  1056.  
  1057. remset    proc    near
  1058.     mov    ah,cmkey
  1059.     mov    dx,offset ontab
  1060.     mov    bx,0
  1061.     call    comnd
  1062.      jmp    r
  1063.     push    bx        ; save parsed value
  1064.     mov    ah,cmcfm
  1065.     call    comnd        ; confirm
  1066.      pop    bx
  1067.      ret            ; return on failure
  1068.      nop
  1069.     pop    bx
  1070.     mov    flags.remflg,bl ; set remote setting
  1071.     jmp    rskp        ; and return
  1072. remset    endp
  1073.  
  1074. ; Set send/receive start-of-header.
  1075. srsoh:    mov min,0
  1076.     mov max,1FH
  1077.     mov sum,0
  1078.     mov tmp,10
  1079.     mov desta,offset trans.ssoh    ; Assume SEND.
  1080.     cmp stflg,'S'                   ; Setting SEND paramter?
  1081.     je srsoh0
  1082.     mov desta,offset trans.rsoh
  1083. srsoh0: mov numhlp,offset eolhlp    ; Reuse help message.
  1084.     mov numerr,offset soherr
  1085.     mov temp1,0
  1086.     jmp num0        ; Common routine for parsing numerical input.
  1087.  
  1088. ; Set send/receive timeout.
  1089. srtim:    mov min,0
  1090.     mov max,94
  1091.     mov sum,0
  1092.     mov tmp,10
  1093.     mov desta,offset trans.stime    ; Assume SEND.
  1094.     cmp stflg,'S'                   ; Setting SEND paramter?
  1095.     je srtim0
  1096.     mov desta,offset trans.rtime
  1097. srtim0: mov numhlp,offset timhlp    ; Reuse help message.
  1098.     mov numerr,offset timerr
  1099.     mov temp1,0
  1100.     jmp num0        ; Common routine for parsing numerical input.
  1101.  
  1102. ; Set send/receive packet length.
  1103. srpack: mov min,20
  1104.     mov max,94
  1105.     mov sum,0
  1106.     mov tmp,10
  1107.     mov desta,offset trans.spsiz
  1108.     cmp stflg,'S'           ; Setting SEND paramter?
  1109.     je srpak0
  1110.     mov desta,offset trans.rpsiz
  1111. srpak0: mov numhlp,offset pakhlp
  1112.     mov numerr,offset pakerr
  1113.     mov temp1,0
  1114.     jmp num0        ; Parse numerical input.
  1115.  
  1116. ; Set send/receive number of padding characters.
  1117. srnpd:    mov min,0
  1118.     mov max,99
  1119.     mov sum,0
  1120.     mov tmp,10
  1121.     mov desta,offset trans.spad
  1122.     cmp stflg,'S'           ; Setting SEND paramter?
  1123.     je srnpd0
  1124.     mov desta,offset trans.rpad
  1125. srnpd0: mov numhlp,offset npdhlp
  1126.     mov numerr,offset npderr
  1127.     mov temp1,0
  1128.     jmp num0        ; Parse numerical input.
  1129.  
  1130. ; Set send/receive padding character.
  1131. srpad:    mov min,0
  1132.     mov max,127
  1133.     mov sum,0
  1134.     mov tmp,10
  1135.     mov srtmp,0FFH        ; Haven't seen anything yet.
  1136.     mov desta,offset srtmp
  1137.     mov numhlp,offset padhlp
  1138.     mov numerr,offset paderr
  1139.     mov temp1,0
  1140.     mov savsp,sp
  1141.     call num0        ; Parse numerical input.
  1142.     mov sp,savsp
  1143.     mov temp,offset trans.spadch
  1144.     cmp stflg,'S'
  1145.     je srpad1
  1146.     mov temp,offset trans.rpadch
  1147. srpad1: mov bx,offset srtmp
  1148.     mov ah,[bx]
  1149.     cmp ah,0FFH        ; Did they end up not doing the command?
  1150.     je srpad3
  1151.     cmp ah,127        ; This is allowed.
  1152.     je srpad2
  1153.     cmp ah,32
  1154.     jb srpad2        ; Between 0 and 31 is OK too.
  1155.     mov ah,prstr
  1156.     mov dx,offset paderr
  1157.     int dos
  1158.     ret
  1159. srpad2: mov bx,temp        ; Set the real pad char.
  1160.     mov [bx],ah
  1161. srpad3: ret
  1162.  
  1163. ; Set send/receive control character prefix.
  1164. srquo:    mov min,33
  1165.     mov max,126
  1166.     mov sum,0
  1167.     mov tmp,10
  1168.     mov desta,offset trans.rquote    ; Used for outgoing packets.
  1169.     cmp stflg,'S'                   ; Setting outgoing quote char?
  1170.     je srquo0
  1171.     mov desta,offset trans.squote    ; For incoming quote char.
  1172. srquo0: mov numhlp,offset quohlp
  1173.     mov numerr,offset quoerr
  1174.     mov temp1,0
  1175.     jmp num0            ; Parse numerical input.
  1176.  
  1177. ;    This is the STATUS command.
  1178.  
  1179. STATUS    PROC    NEAR
  1180.     mov ah,cmcfm
  1181.     call comnd        ; Get a confirm.
  1182.      jmp r            ;  Didn't get a confirm.
  1183.     mov dx,offset crlf
  1184.     mov ah,prstr
  1185.     int dos         ; initial crlf
  1186.     call stat0
  1187.     mov cx,di        ; End of buffer
  1188.     sub cx,ax        ; Get length of buffer.
  1189.     dec cx            ; Account for null.
  1190.     mov di,ax        ; Buffer pointer.
  1191.     call prtscr        ; Put data onto the screen.
  1192.     jmp rskp
  1193. STATUS    ENDP
  1194.  
  1195. ; Return a pointer to status message in AX, ptr to end in DI.
  1196.  
  1197. STAT0    PROC    NEAR
  1198.     push    es
  1199.     mov    ax,ds
  1200.     mov    es,ax        ; address data segment
  1201.     cld            ; make sure strings go the right way
  1202.     mov    di,offset sttbuf ; point to destination buffer
  1203.     mov    bx,offset sttab ; table to control printing
  1204.     mov    al,' '          ; start with a space
  1205.     stosb            ; in the buffer
  1206.     mov    ax,0        ; need-new-line flag
  1207. stat01: cmp    word ptr [bx],0 ; end of table?
  1208.     je    stat02        ; yes, exit routine
  1209.     push    bx
  1210.     push    di        ; remember important values
  1211.     push    ax
  1212.     call    [bx].sttyp    ; call the appropriate routine
  1213.     pop    ax
  1214.     pop    cx        ; return buffer value
  1215.     pop    bx        ; and ptr
  1216.     or    ax,ax        ; do we need a newline?
  1217.     jne    stat03        ; yes, go put one in
  1218.     sub    cx,di        ; else see how many columns they used
  1219.     add    cx,40        ; this is where we'd like to be
  1220. ; if cx is negative here, we have a problem...
  1221.     mov    al,' '
  1222.     rep    stosb        ; add right # of spaces
  1223.     mov    ax,1        ; note we need a newline next time
  1224.     jmp    short stat04    ; and keep looping around
  1225. stat03: mov    cx,3
  1226.     mov    si,offset crlfsp
  1227.     rep    movsb        ; append crlf to string
  1228.     xor    ax,ax        ; reset newline flag
  1229. stat04: add    bx,size stent    ; advance to next one
  1230.     jmp    stat01
  1231. stat02: mov    al,0        ; end buffer
  1232.     stosb
  1233.     mov    ax,offset sttbuf
  1234.     pop    es        ; restore this
  1235.     ret            ; and return
  1236. STAT0    ENDP
  1237.  
  1238. ; handler routines for status
  1239. ; all are called with di/ destination buffer, bx/ stat ptr.  They
  1240. ; can change any register but the segment registers, must update
  1241. ; di to the end of the buffer.
  1242.  
  1243. ; copy the message into the buffer
  1244. stmsg    proc    near
  1245.     mov    si,[bx].msg    ; get message address
  1246. stms1:    lodsb            ; get a byte
  1247.     stosb            ; drop it off
  1248.     cmp    al,'$'          ; end of message?
  1249.     jne    stms1        ; no, keep going
  1250.     dec    di        ; else back up ptr
  1251.     ret            ; and return
  1252. stmsg    endp
  1253.  
  1254. ; get address of test value in stent.  Returns address in si
  1255. stval    proc    near
  1256.     mov    si,[bx].basval    ; get base value
  1257.     cmp    si,0        ; any there?
  1258.     je    stva1        ; no, keep going
  1259.     mov    si,[si]     ; yes, use as base address
  1260. stva1:    add    si,[bx].tstcel    ; add offset of test cell
  1261.     ret            ; and return it
  1262. stval    endp
  1263.  
  1264. ; print a single character
  1265. onechr    proc    near
  1266.     call    stmsg        ; copy message part first
  1267.     call    stval        ; pick up test value address
  1268.     mov    al,[si]     ; this is char to print
  1269.     cmp    al,' '          ; printable?
  1270.     jae    onech1        ; yes, keep going
  1271.     add    al,64        ; make printable.
  1272.     mov    byte ptr [di],'^'
  1273.     inc    di        ; note ctrl char
  1274. onech1: stosb            ; drop char off
  1275.     ret            ; and return
  1276. onechr    endp
  1277.  
  1278. ; numeric field...
  1279. stnum    proc    near
  1280.     call    stmsg        ; copy message
  1281.     call    stval        ; pick up value address
  1282.     mov    al,[si]     ; get value
  1283.     mov    ah,0        ; high order is 0
  1284.     call    outnum        ; put number into buffer
  1285.     ret            ; and return
  1286. stnum    endp
  1287.  
  1288. ; translate the number in ax...
  1289. outnum    proc    near
  1290.     cwd
  1291.     mov    bx,10
  1292.     div    bx        ; divide to get digit
  1293.     push    dx        ; save remainder digit
  1294.     or    ax,ax        ; test quotient
  1295.     jz    outnu1        ; zero, no more of number
  1296.     call    outnum        ; else call for rest of number
  1297. outnu1: pop    ax        ; get digit back
  1298.     add    al,'0'          ; make printable
  1299.     stosb            ; drop it off
  1300.     ret            ; and return
  1301. outnum    endp
  1302.  
  1303. ; on/off field
  1304. onoff    proc    near
  1305.     call    stmsg        ; copy message
  1306.     call    stval        ; get value cell
  1307.     mov    al,[si]
  1308.     mov    si,offset onmsg
  1309.     mov    cx,2        ; assume 2-byte 'ON' message
  1310.     or    al,al        ; test value
  1311.     jnz    onof1        ; on, have right msg
  1312.     mov    si,offset offmsg
  1313.     mov    cx,3
  1314. onof1:    rep    movsb        ; copy right message in
  1315.     ret            ; and return
  1316. onoff    endp
  1317.  
  1318. ; print first message if false, second if true
  1319. msg2    proc    near
  1320.     call    stval        ; get value cell
  1321.     mov    al,[si]
  1322.     mov    si,[bx].msg    ; assume off
  1323.     or    al,al        ; is it?
  1324.     jz    msg21        ; yes, continue
  1325.     mov    si,[bx].val2    ; else use alternate message
  1326. msg21:    jmp    stms1        ; handle copy and return
  1327. msg2    endp
  1328.  
  1329. ; search a keyword table for a value, print that value
  1330. srchkw    proc    near
  1331.     call    stmsg        ; first print message
  1332.     call    stval
  1333.     mov    al,[si]     ; get value to hunt for
  1334.     mov    ah,0        ; high order is 0
  1335.     mov    bx,[bx].val2    ; this is table address
  1336.     jmp    prttab        ; and look in table.
  1337. srchkw    endp
  1338.  
  1339. ; Print the drive name.
  1340. drnum    proc    near
  1341.     call    stmsg        ; copy message part first
  1342.     call    stval        ; pick up test value address
  1343.     mov    al,[si]     ; this is char to print
  1344.     add    al,'@'          ; Make it printable.
  1345.     stosb
  1346.     mov    byte ptr [di],':'
  1347.     inc    di        ; end with a colon
  1348.     ret            ; and return
  1349. drnum    endp
  1350.  
  1351. ; print 8-bit quoting
  1352. pr8bit    proc    near
  1353.     mov    bl,trans.ebquot ; get quote char
  1354.     mov    si,offset ebyst ; assume no 8-bit quoting
  1355.     cmp    bl,'Y'          ; on request only?
  1356.     je    pr8bi1        ; yes, continue
  1357.     mov    si,offset ebvst ; else variable
  1358. pr8bi1: call    stms1        ; copy message in
  1359.     cmp    bl,'Y'          ; not doing it?
  1360.     je    pr8bi2        ; no, forget this part
  1361.     mov    [di],bl     ; else drop off char too
  1362.     inc    di
  1363. pr8bi2: ret            ; and return
  1364. pr8bit    endp
  1365.  
  1366. ; Print the handshake.
  1367. prhnd:    mov si,offset handst    ; copy in initial message
  1368.     call stms1
  1369.     mov si,offset nonmsg    ; assume no handshake
  1370.     mov bx,portval
  1371.     cmp [bx].hndflg,0    ; Is handshaking in effect?
  1372.     jne prh0        ; Yes, print what we're using.
  1373.     jmp stms1        ; no, say so and return
  1374. prh0:    mov al,'^'              ; Doing handshaking with control char.
  1375.     stosb
  1376.     mov al,[bx].hands
  1377.     add al,40H        ; Make printable.
  1378.     stosb            ; put in buffer
  1379.     ret            ; and return
  1380.  
  1381. ; Print the pad character in AL.
  1382. prpad:    cmp al,127        ; Are they using a delete?
  1383.     jne prpad0
  1384.     mov ah,prstr
  1385.     mov dx,offset delmsg
  1386.     int dos
  1387.     ret
  1388. prpad0: mov dl,'^'
  1389.     mov ah,conout
  1390.     push ax
  1391.     int dos
  1392.     pop ax
  1393.     mov dl,al
  1394.     add dl,40H        ; Make printable.
  1395.     int dos
  1396.     ret
  1397.  
  1398. ; Print value from table.  BX/address of table, AL/value of variable.
  1399. prttab: mov cl,[bx]        ; Number of entries in our table.
  1400.     inc bx            ; Point to the data.
  1401. prtt0:    mov dl,[bx]        ; Length of keyword.
  1402.     inc bx            ; Point to keyword.
  1403.     mov dh,0
  1404.     inc dx            ; Account for "$" in table.
  1405.     mov si,dx        ; Put to index register.
  1406.     cmp ax,[bx+si]        ; Is this the one?
  1407.     je prtt1
  1408.     add bx,dx        ; Go to end of keyword.
  1409.     add bx,2        ; Point to next keyword.
  1410.     dec cl            ; Any more keywords to check?
  1411.     jnz prtt0        ; Yes, go to it.
  1412.     mov bx,offset prterr
  1413. prtt1:    mov si,bx
  1414. prtt2:    jmp stms1        ; copy in message
  1415.     ret            ; and return
  1416.  
  1417. ;    This routine prints out the escape character in readable format.
  1418.  
  1419. ESCPRT    PROC    NEAR        ; [6 start]
  1420.     mov dl,trans.escchr
  1421.     cmp dl,' '
  1422.     jge escpr2
  1423.     push dx
  1424.     mov ah,prstr
  1425.     mov dx,offset esctl
  1426.     int dos
  1427.     pop dx
  1428.     add dl,040H        ; Make it printable.
  1429. escpr2: mov ah,conout
  1430.     int dos
  1431.     ret
  1432. ESCPRT    ENDP            ; [6 end]
  1433.  
  1434. ; Print information on the baud rate. [19a]
  1435.  
  1436. BAUDPRT PROC     NEAR
  1437.     mov si,portval
  1438.     mov ax,[si].baud
  1439.     mov dx,offset b48st    ; Assume 4800 baud.
  1440.     cmp ax,B4800
  1441.     jnz bdprt0
  1442.     jmp bdprt2
  1443. bdprt0: mov dx,offset b12st
  1444.     cmp ax,B1200
  1445.     jnz bdprt1
  1446.     jmp bdprt2
  1447. bdprt1: mov dx,offset b18st
  1448.     cmp ax,B1800
  1449.     jz bdprt2
  1450.     mov dx,offset b24st
  1451.     cmp ax,B2400
  1452.     jz bdprt2
  1453.     mov dx,offset b96st
  1454.     cmp ax,B9600
  1455.     jz bdprt2
  1456.     mov dx,offset b03st
  1457.     cmp ax,B0300
  1458.     jz bdprt2
  1459.     mov dx,offset b04st
  1460.     cmp ax,B00455
  1461.     jz bdprt2
  1462.     mov dx,offset b05st
  1463.     cmp ax,B0050
  1464.     jz bdprt2
  1465.     mov dx,offset b07st
  1466.     cmp ax,b0075
  1467.     jz bdprt2
  1468.     mov dx,offset b11st
  1469.     cmp ax,B0110
  1470.     jz bdprt2
  1471.     mov dx,offset b13st
  1472.     cmp ax,B01345
  1473.     jz bdprt2
  1474.     mov dx,offset b15st
  1475.     cmp ax,B0150
  1476.     jz bdprt2
  1477.     mov dx,offset b06st
  1478.     cmp ax,B0600
  1479.     je bdprt2
  1480.     mov dx,offset b20st
  1481.     cmp ax,B2000
  1482.     jz bdprt2
  1483.     mov dx,offset b19st
  1484.     cmp ax,B19200
  1485.     jz bdprt2
  1486.     mov dx,offset b38st
  1487.     cmp ax,B38400
  1488.     jz bdprt2
  1489.     mov dx,offset unrec    ; Unrecognized baud rate.
  1490. bdprt2: mov si,dx        ; this is baud rate
  1491. bdprt3: jmp stms1        ; go copy it and return
  1492. BAUDPRT ENDP
  1493.  
  1494. setkey    proc    near
  1495.     cmp    setktab,0    ; any table?
  1496.     jne    setk0        ; yes, use it
  1497.     mov    dx,offset ermes5
  1498.     jmp    reterr        ; else print error message
  1499. setk0:    mov    dx,offset setktab    ; set key options
  1500.     mov    bx,offset setkhlp
  1501.     mov    ah,cmkey
  1502.     call    comnd
  1503.      jmp    r
  1504.     cmp    bx,-1        ;[jd] do we have scan code?
  1505.     jne    setk1        ;[jd] yes, skip this part
  1506.  
  1507.     mov    ah,cmtxt
  1508.     mov    bx,offset rdbuf ; handy buffer
  1509.     mov    dx,offset sk1msg
  1510.     call    comnd
  1511.      jmp    r        ; fail return
  1512.     mov    si,offset rdbuf ; this is parsed number
  1513.     call    atoi        ; Convert input to real number.
  1514.      jmp    reterr        ; No good.
  1515.     mov    bx,ax        ; put accumulation into bl
  1516. setat3: cmp    bx,0        ; is scan code 0?
  1517.     jne    setk2        ; no, have scan code, look for def
  1518.  
  1519. setk1:    push    bx        ; save our scan code
  1520.     mov    ah,cmcfm
  1521.     call    comnd
  1522.      jmp    short setkx    ; no good, pop bx and return
  1523.     nop            ; waste a byte
  1524.     pop    bx
  1525. ; scan code is in bl, ask for string part
  1526. setk2:    push    bx
  1527.     mov    dx,offset defpmp
  1528.     call    prompt
  1529.     mov    ah,cmtxt
  1530.     mov    bx,offset rdbuf
  1531.     mov    dx,offset sk2msg
  1532.     call    comnd        ; read the definition
  1533.      jmp    short setkx    ; pop bx and fail return
  1534.      nop
  1535.     mov    cl,ah
  1536.     mov    ch,0        ; set up length of definition
  1537.     pop    ax        ; get scan code back
  1538.     mov    si,offset rdbuf ; point to definition
  1539.     call    defkey        ; go define the key
  1540.     ret            ; use ret for now...
  1541.     jmp    rskp        ; and return
  1542. setkx:    pop    bx        ; pop junk off stack
  1543.     ret            ; and return
  1544. setkey    endp
  1545.  
  1546. ; Convert input in buffer pointed to by SI to real number which is returned
  1547. ; in AX.  Return on failure, return skip on success.
  1548. ATOI    PROC    NEAR
  1549.     mov    cl,ah        ; Number of chars of input.
  1550.     mov    ch,0        ; size of string
  1551.     jcxz    atoi4        ; Fail on no input.
  1552.     mov    ax,0        ; init sum
  1553.     mov    bh,0        ; high order of this stays 0.
  1554. atoi0:    xchg    al,bl        ; save current sum
  1555.     lodsb            ; grab a byte
  1556.     cmp    al,' '          ; leading space?
  1557.     jne    atoi1        ; no, continue
  1558.     xchg    al,bl        ; put sum back
  1559.     jmp    short atoi2    ; and continue loop
  1560. atoi1:    cmp    al,'9'
  1561.     ja    atoi3        ; out of range, done
  1562.     cmp    al,'0'
  1563.     jb    atoi3
  1564.     xchg    al,bl        ; put sum back into al
  1565.     mul    ten        ; shift one digit
  1566.     sub    bl,'0'          ; convert to binary
  1567.     add    ax,bx        ; add to sum
  1568. atoi2:    loop    atoi0        ; loop thru all chars
  1569. atoi3:    jmp    rskp
  1570. atoi4:    mov    dx,offset erms23    ; complain and return
  1571.     ret
  1572. ATOI    ENDP
  1573.  
  1574. ;  addition for capture of raw output
  1575.  
  1576. setcpt    proc    near
  1577.     test    flags.capflg,0FFH
  1578.     jz    setcp1            ; no capture file, keep going
  1579.     mov    dx,offset erms24
  1580.     jmp    reterr
  1581. setcp1: mov    comand.cmcr,0        ; Filename must be specified.
  1582.     mov    ah,cmifi
  1583.     mov    dx,offset cptfcb
  1584.     mov    bx,offset filhlp
  1585.     call    comnd
  1586.      jmp    r
  1587.     mov    ah,cmcfm
  1588.     call    comnd            ; confirm with carriage return
  1589.      jmp    r
  1590.     mov    ah,delf
  1591.     mov    dx,offset cptfcb
  1592.     int    dos            ; open up file
  1593.     mov    ah,makef
  1594.     mov    dx,offset cptfcb
  1595.     int    dos
  1596.     mov    cptfcb+32,0
  1597.  
  1598.     call    inicpt            ; init capture variables
  1599.     mov    flags.capflg,0FFH    ; know we have capture routine
  1600.     jmp    rskp        ; and return
  1601.  
  1602. setcpt    endp
  1603.  
  1604. ; Jumping to this location is like retskp.  It assumes the instruction
  1605. ;   after the call is a jmp addr.
  1606.  
  1607. RSKP    PROC    NEAR
  1608.     pop bp
  1609.     add bp,3
  1610.     push bp
  1611.     ret
  1612. RSKP    ENDP
  1613.  
  1614. ; Jumping here is the same as a ret.
  1615.  
  1616. R    PROC    NEAR
  1617.     ret
  1618. R    ENDP
  1619.  
  1620. ; routine to print an error message, then retskp
  1621. ; expects message in dx
  1622. reterr    proc    near
  1623.     mov    ah,prstr
  1624.     int    dos
  1625.     jmp    rskp
  1626. reterr    endp
  1627.  
  1628. code    ends
  1629.     end
  1630.