home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ccdos / ccsset.asm < prev    next >
Assembly Source File  |  2020-01-01  |  109KB  |  2,701 lines

  1.      NAME    ccsset
  2. ; File CCSSET.ASM
  3.  
  4. ;CHINESE1
  5. ifdef   MSDOS
  6.         include mssset1.dat
  7. else
  8.         include ccsset1.dat
  9. endif
  10.  
  11. code    segment public 'code'
  12.         extrn prserr:near, comnd:near, dobaud:near, cmblnk:near, locate:near
  13.         extrn prompt:near, coms:near, defkey:near, cwdir:near
  14.         extrn prtscr:near, getbaud:near, isfile:near, strlen:near
  15.         extrn strcpy:near, cnvlin:near, katoi:near, decout:near
  16.         extrn vts:near, vtstat:near, shomodem:near, setalrm:near
  17.  
  18.         assume  cs:code, ds:datas, es:nothing
  19.  
  20. ; DO defined macro command
  21. ; DO macname variable variable   also defines variables \%1, \%2, ...\%9
  22. DOCOM   PROC    NEAR
  23.         mov     dx,offset mcctab        ; table of macro defs
  24.         mov     bx,0                    ; help is table
  25.         mov     ah,cmkey                ; get key word (macro name)
  26.         call    comnd                   ; get pointer to keyword structure
  27.          ret
  28.          nop
  29.          nop
  30.         mov     comand.cmquiet,0        ; permit command echoing
  31.         mov     domacptr,bx             ; address of definition string
  32. ; note: remtab updates domacptr because substitutions many modify the table
  33.         mov     bx,offset decbuf        ; point to borrowed work buffer
  34.         mov     word ptr[bx],0          ; clear buffer
  35. ;        mov     dx,offset dohlp         ; help
  36.         mcmsg   dohlp,cdohlp
  37.         mov     comand.cmblen,length rdbuf ; length of analysis buffer
  38.         mov     ah,cmtxt                ; get line of text, if any
  39.         call    comnd
  40.          ret
  41.          nop
  42.          nop
  43.         mov     al,ah
  44.         mov     ah,0
  45.         mov     deftemp,ax              ; save byte count of command args
  46.         cmp     al,0                    ; anything given?
  47.         je      docom9                  ; e = no, just do the macro
  48.         mov     word ptr rdbuf+3,' 1'   ; number of first variable
  49. docom8: mov     rdbuf,0                 ; clear length field, install \%x name
  50.         mov     word ptr rdbuf+1,'%\'   ; start with '\%1 '
  51.         mov     word ptr rdbuf+5,0      ; clear text field
  52.         mov     tempptr,offset rdbuf+5  ; pointer to location of found word
  53.         mov     ch,0                    ; make cx = 1 - 9
  54.         mov     cl,rdbuf+3              ; cx = word # of interest, for getwrd
  55.         sub     cl,'0'                  ; remove ascii bias
  56.         mov     si,offset decbuf        ; source = work buffer (borrowed)
  57.         call    getwrd                  ; get CX-th word from  work buf (1-9)
  58.         cmp     deftemp,0               ; length of word, was it found?
  59.         je      docom9                  ; e = no, end variable definition part
  60.         add     deftemp,4               ; count '\%n ' in command line length
  61.         call    dodecom                 ; add keyword+def using DEF MAC below
  62.          nop
  63.          nop
  64.          nop
  65.         inc     rdbuf+3                 ; inc number of variable in '\%n '
  66.         cmp     rdbuf+3,'9'
  67.         jbe     docom8                  ; do '1' through '9', if available
  68.  
  69.                                         ; DO the macro itself
  70. docom9: cmp     taklev,maxtak           ; room in take level?
  71.         jl      docom2                  ; l = yes, continue
  72. ;        mov     dx,offset ermes4        ; else complain
  73.         mcmsg   ermes4,cermes4
  74.        jmp     reterr
  75. docom2: inc     taklev                  ; increment take level
  76.         add     takadr,size takinfo
  77.         mov     bx,takadr               ; point to current buffer
  78.         mov     si,domacptr             ; address of macro definition string
  79.         mov     [bx].takbuf,si          ; remember in Take structure
  80.         mov     cl,[si]                 ; length of definition
  81.         mov     ch,0
  82.         inc     si                      ; point to actual definition
  83.         mov     [bx].taktyp,0ffh        ; flag as a macro
  84.         mov     [bx].takptr,si          ; point to beginning of def
  85.         mov     [bx].takcnt,cx          ; # of chars in buffer
  86.         jmp     rskp
  87. DOCOM   ENDP
  88.  
  89. ; Extract CX-th word (cx = 1-9) from buffer (DI). Enter with si = source
  90. ; string and tempptr pointing at destination. Returns deftemp (count) of
  91. ; transferred characters. Allow string in curly braces to exist as a word.
  92. ; Adjacent curly braced strings are separate "words":
  93. ;    {this is word-one}{this is word-two}word-three.
  94. ; All registers preserved.
  95. getwrd  proc    near
  96.         push    ax
  97.         push    cx
  98.         push    dx
  99.         push    si
  100.         push    di
  101.         push    es
  102.         push    ds
  103.         pop     es                      ; set es to datas segment
  104. getwr1: push    cx                      ; save word counter (1-9)
  105.         mov     deftemp,0               ; no bytes transferred yet
  106.         mov     di,tempptr              ; where to store word/string
  107.         mov     byte ptr [di],0         ; clear destination
  108.         mov     dx,si                   ; start looking here in work buf
  109.         call    strlen                  ; cx = remaining length of work buf
  110.         jcxz    getwr6                  ; z = nothing there, quit
  111. getwr2: lodsb
  112.         cmp     al,' '                  ; skip leading whitespace
  113.         loope   getwr2
  114.         dec     si                      ; return to break char
  115.                                         ; Parse curly brace delimited string
  116.                                         ; end with si after closing brace
  117.         mov     dl,0                    ; assume "opening brace" is a null
  118.         mov     dh,' '                  ; assume "closing brace" is a space
  119.         mov     cx,1                    ; we are at brace level 1
  120.         cmp     byte ptr [si],braceop   ; starting with a real opening brace?
  121.         jne     getwr3                  ; ne = no
  122.         inc     si                      ; skip opening brace
  123.         mov     dl,braceop              ; opening brace (we count them up)
  124.         mov     dh,bracecl              ; closing brace (we count them down)
  125. getwr3: cld                             ; search forward
  126.         lodsb                           ; read a char
  127.         stosb                           ; store in output buffer
  128.         cmp     al,0                    ; at end of text?
  129.         jne     getwr3a                 ; ne = no
  130.         dec     si                      ; stay at null terminator
  131.         dec     di
  132.         jmp     short getwr6            ; we are done with this "word"
  133. getwr3a:inc     deftemp                 ; count copied char
  134.         cmp     al,dl                   ; an opening brace?
  135.         jne     getwr4                  ; ne = no
  136.         inc     cx                      ; yes, increment brace level
  137.         jmp     short getwr3            ;  and continue scanning
  138.  
  139. getwr4: cmp     al,dh                   ; closing brace?
  140.         jne     getwr3                  ; ne = no, continue scanning
  141.         dec     cx                      ; yes, decrement brace level
  142.         cmp     byte ptr [si],0         ; have we just read the last char?
  143.         jne     getwr5                  ; no, continue scanning
  144.         mov     cx,0                    ; yes, this is the closing brace
  145. getwr5: cmp     cx,0                    ; at level 0?
  146.         jne     getwr3                  ; ne = no, #opening <> #closing braces
  147.         mov     byte ptr [di-1],0       ; plant terminator on closing brace
  148.         dec     deftemp                 ; do not count closing brace
  149.  
  150. getwr6: pop     cx                      ; recover word counter
  151.         mov     byte ptr [di],0
  152.         jcxz    getwrx                  ; just in case
  153.         loop    getwr1                  ; do until desired word is copied
  154. getwrx: pop     es
  155.         pop     di
  156.         pop     si
  157.         pop     dx
  158.         pop     cx
  159.         pop     ax
  160.         ret
  161. getwrd  endp
  162.  
  163. ; DEFINE and ASSIGN macro commands
  164. ; Data structures comments. Macro name is stored in table mcctab as if we
  165. ; had used macro mkeyw, such as       mkeyw 'mymac',offset my_definition.
  166. ; In detail:    db      length of name
  167. ;               db      'name'
  168. ;               db      '$'
  169. ;               dw      offset of definition string
  170. ; Mcctab begins with a byte holding the number of macros in the table; one,
  171. ;  IBM, is established at assembly time. Mcctab is 10*macmax bytes long.
  172. ; Pointer mccptr holds the offset of the next free byte in mcctab.
  173. ; Definition strings are stored in table macbuf as
  174. ;               db      length of definition string below
  175. ;               db      'definition string'
  176. ; Pointer macptr holds the offset of the next free byte in macbuf. Macbuf
  177. ; is nominally 100*macmax bytes long.
  178. ; A new definition is read into buffer rdbuf+1, where byte rdbuf is reserved
  179. ;  to hold the length of the macro's name during intermediate processing.
  180. ; If the definition is absent then the macro is removed from the tables.
  181. ; Rewritten 13 June 1987 [jrd]
  182. ;
  183. ; ASSIGN is equivalent to DEFINE, except in the definition string substitution
  184. ; variable names are expanded to their definitions. This becomes a copy cmd.
  185. ; DEFINE does not expand substitution variables.
  186.  
  187. ASSIGN  PROC    NEAR
  188.         mov     temp,0                  ; flag command as ASSIGN, vs DEFINE
  189.         jmp     dodefcom                ; common code
  190. ASSIGN  ENDP
  191.  
  192. DODEF   PROC    NEAR
  193.         mov     temp,1                  ; flag command as DEFINE, vs ASSIGN
  194. DODEFCOM:
  195.         mov     comand.cmper,1          ; do not react to '\%' in macro name
  196.         mov     ah,cmfile
  197.         mov     dx,offset rdbuf+1       ; buffer for macro name
  198.         mov     word ptr rdbuf,0
  199. ;        mov     bx,offset macmsg
  200.          mcmsgb   macmsg,cmacmsg
  201.         call    comnd                   ; get macro name
  202.          ret
  203.          nop
  204.          nop
  205.         cmp     ah,0                    ; null entry?
  206.         jne     dodef1                  ; ne = no
  207. ;        mov     dx,offset ermes6        ; more parameters needed
  208.          mcmsg   ermes6,cermes6
  209.         jmp     reterr
  210.  
  211. dodef1: mov     bx,dx                   ; updated pointer
  212.         mov     byte ptr [bx-1],' '     ; replace null with space separator
  213.         mov     word ptr [bx],0         ; terminator, in case no command
  214.         mov     ax,temp                 ; get ASSIGN/DEFINE flag
  215.         mov     comand.cmper,al         ; react (DEF) to '\%' in definition
  216.         mov     ah,cmtxt                ; get a line of text
  217. ;        mov     dx,offset macmsg
  218.          mcmsg   macmsg,cmacmsg
  219.         mov     comand.cmblen,length rdbuf ; our buffer length
  220.         sub     comand.cmblen,al        ; minus part used
  221.         dec     comand.cmblen           ; space separator
  222.         call    comnd                   ; get macro name
  223.          ret
  224.          nop
  225.          nop
  226.         sub     bx,offset rdbuf         ; length of command line
  227.         dec     bx                      ; minus count byte
  228.         mov     deftemp,bx              ; save length of command line
  229. ;;      jmp     dodecom                 ; common code below
  230. DODEF   ENDP
  231.                                         ; DODECOM called by DO mac above
  232. ; accepts rdbuf+1 et seq = <macro name><spaces><arg><spaces><arg> ...
  233. ; byte rdbuf computed here as length of keyword
  234. DODECOM PROC    NEAR
  235.         push    si                      ; macro name in rdbuf+1 et seq
  236.         push    di                      ; cmd line length in deftemp
  237.         push    es
  238.         push    ds                      ; address data segment
  239.         pop     es
  240.         mov     cx,deftemp              ; cmd line len, cx = running counter
  241.         mov     rdbuf,0                 ; number of chars in keyword so far
  242.                                         ; uppercase the keyword, look for end
  243.         mov     si,offset rdbuf+1       ; point at macro name text
  244.         cld                             ; strings go forward
  245. dode2:  lodsb                           ; get a byte, dec cx
  246.         cmp     al,'a'                  ; map lower case to upper
  247.         jb      dode3
  248.         cmp     al,'z'
  249.         ja      dode3
  250.         sub     al,'a'-'A'
  251.         mov     [si-1],al               ; uppercase if necessary
  252. dode3:  inc     rdbuf                   ; increment char count of keyword
  253.         cmp     al,' '                  ; is this the break character?
  254.         loopne  dode2                   ; no, loop thru rest of word
  255.         jne     dode4                   ; ne = did not end with break char
  256.         dec     rdbuf                   ; yes, don't count in length
  257. dode4:  push    di
  258.         mov     di,offset rdbuf         ; point at mac name length byte
  259.         call    remtab                  ; remove any duplicate keyword
  260.         pop     di
  261.         jcxz    dode6                   ; cx = 0 means no keyword
  262.                                 ; check for free space for keyword and string
  263.         mov     al,rdbuf                ; keyword text length
  264.         add     al,4                    ; plus overhead bytes
  265.         xor     ah,ah
  266.         add     ax,mccptr               ; add to free space pointer
  267.         cmp     ax,offset mcctab+mcclen ; enough room for name?
  268.         jb      dode5                   ; b = yes
  269. ;        mov     dx,offset ermes1        ; too many macro names
  270.         mcmsg   ermes1,cermes1
  271.         pop     es
  272.         pop     di
  273.         pop     si
  274.         jmp     reterr
  275. dode5:
  276.         mov     di,si                   ; si = source address
  277.         add     di,cx                   ; length of string
  278.         dec     di                      ; omit null terminator
  279.         std
  280.         mov     al,' '                  ; scan off trailing spaces
  281.         repe    scasb
  282.         add     di,2                    ; backup to terminator slot
  283.         cld
  284.         mov     byte ptr [di],0         ; plant new terminator
  285.         mov     dx,si
  286.         call    strlen                  ; get new length into cx
  287.  
  288.         mov     di,si                   ; scan after keyword name
  289.         mov     al,' '                  ; remove leading spaces in string
  290.         repe    scasb
  291.         je      dode6                   ; e = all spaces
  292.         inc     cx                      ; offset auto decrement of rep
  293.         dec     di                      ; offset auto increment of rep
  294.  
  295.         mov     si,di                   ; point to start of string text
  296.         mov     dx,di                   ; source of definition text
  297.         call    strlen                  ; get length of string into cx
  298.         mov     ax,cx                   ; length of string
  299.         mov     deftemp,cx              ; remember it here
  300.         inc     ax                      ; plus its count byte
  301.         add     ax,macptr               ; plus free space pointer
  302.         cmp     ax,offset macbuf+maclen ; enough room for definition string?
  303.         jb      dode7                   ; b = yes
  304.         pop     es
  305.         pop     di
  306.         pop     si
  307. ;        mov     dx,offset ermes2        ; no room for definition
  308.         mcmsg   ermes2,cermes2
  309.         jmp     reterr
  310. dode6:  pop     es
  311.         pop     di
  312.         pop     si
  313.         jmp     rskp
  314.                                         ; install new keyword in mcctab
  315. dode7:  cmp     deftemp,0               ; deftemp = length of definition
  316.         je      dode10                  ; e = no def, exit now
  317.         mov     bx,offset mcctab
  318.         mov     dx,offset rdbuf         ; count byte + name string
  319.         call    addtab
  320.                         ; copy definition into buffer, changing commas to CRs
  321.         mov     di,macptr               ; free space in string buffer
  322.         mov     cx,deftemp              ; length of definition string
  323.         mov     byte ptr[di],cl         ; store length of string
  324.         inc     di                      ; skip over count byte
  325. dode8:  lodsb                           ; get a byte
  326.         cmp     al,','                  ; comma?
  327.         jne     dode9                   ; no, keep going
  328.         mov     al,cr                   ; else replace with cr
  329. dode9:  stosb
  330.         loop    dode8                   ; keep copying
  331.         mov     macptr,di               ; update free ptr
  332. dode10: pop     es
  333.         pop     di
  334.         pop     si
  335.         jmp     rskp
  336. DODECOM ENDP
  337.  
  338. ; ASK <variable or macro name> <prompt string>
  339. ; Defines indicated variable/macro with text from user at keyboard or pipe
  340. ; (but not from a Take/macro). Prompt string is required.       [jrd]
  341. ASK     PROC    NEAR
  342.         mov     dx,offset rdbuf+1       ; point to work buffer
  343.         mov     word ptr rdbuf,0
  344. ;        mov     bx,offset askhlp1       ; help
  345.          mcmsgb   askhlp1,caskhlp1
  346.         mov     comand.cmper,1          ; do not expand variable name
  347.         mov     ah,cmfile               ; get variable name
  348.         call    comnd
  349.          jmp    r
  350.          nop
  351.         cmp     ah,0                    ; anything given?
  352.         jne     ask2                    ; ne = yes
  353. ;        mov     dx,offset ermes6        ; more parameters needed
  354.          mcmsg   ermes6,cermes6
  355.         jmp     reterr
  356.  
  357. ask2:   xchg    ah,al
  358.         mov     ah,0
  359.         mov     bx,offset rdbuf+1       ; start of name
  360.         add     bx,ax                   ; plus length of variable name
  361.         mov     byte ptr [bx],' '       ; put space separator after name
  362.         inc     ax                      ; count space
  363.         mov     temp,ax                 ; remember length here
  364.                                         ; get ASK command prompt string
  365.         inc     bx                      ; put prompt string here
  366.         mov     byte ptr [bx],0         ; safety terminator
  367. ;        mov     dx,offset askhlp2
  368.          mcmsg   askhlp2,caskhlp2
  369.         mov     comand.cmblen,127       ; our buffer length
  370.         sub     comand.cmblen,al        ;  minus part used above
  371.         mov     ah,cmtxt                ; get prompt string
  372.         call    comnd
  373.          jmp    r
  374.          nop
  375.         cmp     ah,0                    ; anything given?
  376.         jne     ask4                    ; ne = yes
  377. ;        mov     dx,offset ermes6        ; more parameters needed
  378.          mcmsg   ermes6,cermes6
  379.         jmp     reterr
  380.  
  381. ask4:   mov     ax,takadr               ; we could be in a macro or Take file
  382.         mov     temp2,ax                ; save Take address
  383.         mov     al,taklev
  384.         mov     ah,0
  385.         mov     temp1,ax                ; and Take level
  386.         mov     dx,size takinfo         ; bytes for each current Take
  387.         mul     dx                      ; times number of active Take/macros
  388.         sub     takadr,ax               ; clear Take address as if no
  389.         mov     taklev,0                ;  Take/macro were active so that
  390.                                         ;  user input is from kbd or pipe
  391.         mov     word ptr [bx],'$ '      ; printing terminator for prompt
  392.         mov     dx,offset rdbuf+1
  393.         add     dx,temp                 ; prompt for input string
  394.         mov     si,dx
  395.         mov     di,offset rdbuf+129     ; temporary destination
  396.         push    dx                      ; save source
  397.         call    cnvlin                  ; parse backslash numbers etc
  398.         pop     dx                      ; destination is old source location
  399.         mov     si,di                   ; copy back to lower part of rdbuf
  400.         add     di,cx                   ; go to null terminator
  401.         mov     word ptr [di],'$ '      ; dollar sign/space for DOS printing
  402.         mov     byte ptr [di+2],0
  403.         mov     di,dx
  404.         call    strcpy
  405.         call    prompt                  ; buf = <var name>< ><prompt string>
  406.         mov     bx,offset rdbuf+129     ; use this buffer for raw user input
  407.         mov     word ptr [bx],0         ; insert terminator
  408. ;        mov     dx,offset askhlp3       ; help for user input
  409.          mcmsg   askhlp3,caskhlp3
  410.         mov     ah,cmtxt                ; read user's input string
  411.         call    comnd
  412.          jmp    ask9                    ; exit now on ^C from user
  413.          nop
  414.         mov     cl,ah                   ; length of entry
  415.         mov     ch,0
  416.         jcxz    ask8                    ; z = empty
  417.         mov     si,offset rdbuf+129     ; source string
  418.         mov     di,offset rdbuf+1       ; start of variable name
  419.         add     di,temp                 ; di points to final user string
  420.         push    es                      ; save es
  421.         push    ds
  422.         pop     es                      ; set es to datas segment
  423.         cld
  424. ask6:   lodsb                           ; read original user string char
  425.         cmp     al,','                  ; literal comma?
  426.         jne     ask7                    ; ne = no
  427.         mov     ax,'{\'                 ; yes. Replace literal comma
  428.         stosw                           ;  with numerical equivalent \{44}
  429.         mov     ax,'44'                 ;  to permit commas in macro def
  430.         stosw
  431.         add     temp,4
  432.         mov     al,'}'
  433. ask7:   stosb                           ; store string character
  434.         inc     temp                    ; length of <variable>< ><user string>
  435.         loop    ask6
  436.         pop     es
  437. ask8:   mov     ax,temp                 ; length of <variable>< ><user string>
  438.         mov     deftemp,ax              ; put here for dodecom usage
  439.         mov     ax,temp2
  440.         mov     takadr,ax               ; restore Take address
  441.         mov     ax,temp1
  442.         mov     taklev,al               ; restore Take level
  443.         jmp     DODECOM                 ; define the macro/variable and exit
  444.  
  445. ask9:   mov     ax,temp2                ; failure path
  446.         mov     takadr,ax               ; restore Take address
  447.         mov     ax,temp1
  448.         mov     taklev,al               ; restore Take level
  449.         ret                             ; return command failure
  450. ASK     ENDP
  451.  
  452. ; Open a disk based Take file buffer. Define macro named "<null>T<'taklev'>",
  453. ; allocate 128 byte uninitiated buffer in mcctab for disk i/o. Leading null
  454. ; is to prevent user from employing the same name accidentally. Return offset
  455. ; of buffer in [takadr].takbuf and set [takadr].takptr pointing to it.
  456. ; Return carry clear for success, carry set for failure.
  457.  
  458. TAKOPEN PROC    NEAR
  459.         push    ax
  460.         push    bx
  461.         push    dx
  462.         push    di
  463. ;        mov     dx,offset ermes2        ; says no room for defintions
  464.         mcmsg   ermes2,cermes2
  465.         mov     ax,dmasiz+1             ; count byte plus length of buffer
  466.         add     ax,macptr               ; plus free space pointer
  467.         cmp     ax,offset macbuf+maclen ; enough room for definition string?
  468.         jae     takopen1                ; ae = no, complain
  469.         cmp     taklev,maxtak           ; room in take level?
  470.         jl      takopen2                ; l = yes, continue
  471. ;        mov     dx,offset ermes4        ; say too many Take files
  472.          mcmsg   ermes4,cermes4
  473. takopen1:mov    ah,prstr
  474.         int     dos
  475.         pop     di
  476.         pop     dx
  477.         pop     bx
  478.         pop     ax
  479.         stc                             ; set carry for failure
  480.         ret
  481.  
  482. takopen2:inc    taklev                  ; next Take
  483.         add     takadr,size takinfo     ; pointer to Take structure
  484.         mov     rdbuf,3                 ; length of name, 3 bytes <null>Tn
  485.         mov     rdbuf+1,0
  486.         mov     rdbuf+2,'T'             ; name of <null>Tn
  487.         mov     al,taklev               ; Take level digit
  488.         add     al,'0'                  ; add ascii bias
  489.         mov     rdbuf+3,al              ; last of the name
  490.         mov     di,offset rdbuf         ; pointer for remtab
  491.         call    remtab                  ; remove possible old macro
  492.         mov     bx,offset mcctab        ; table to use
  493.         mov     dx,offset rdbuf         ; count and mac name to enter
  494.         call    addtab                  ; returns string pointer in macptr
  495.         mov     di,macptr
  496.         add     macptr,dmasiz+1         ; set new free byte into pointer
  497.         mov     byte ptr [di],dmasiz    ; string length (128 bytes)
  498.         mov     bx,takadr               ; pointer to Take structure
  499.         mov     [bx].takbuf,di          ; offset of Take buffer
  500.         inc     di                      ; skip count byte in takbuf
  501.         mov     [bx].takptr,di          ; init pointer to definition itself
  502.         pop     di
  503.         pop     dx
  504.         pop     bx
  505.         pop     ax
  506.         clc                             ; carry clear for success
  507.         ret
  508. TAKOPEN ENDP
  509.  
  510. ; Close Take file. Enter at Take level to be closed. Removes pseudo macro
  511. ; name <null>Tn and its buffer, closes disk file, pops Take level.
  512.  
  513. TAKCLOS PROC    NEAR
  514.         cmp     taklev,0                ; anything to close?
  515.         jle     takclo2                 ; le = no
  516.         push    ax
  517.         push    bx
  518.         mov     bx,takadr               ; point to Take structure
  519.         cmp     [bx].taktyp,0feh        ; disk file (vs macro)?
  520.         jne     takclo1                 ; ne = no, no buffer to deallocate
  521.         mov     rdbuf,3                 ; length of name
  522.         mov     rdbuf+1,0
  523.         mov     rdbuf+2,'T'             ; name of <null>Tn
  524.         mov     al,taklev               ; Take level digit
  525.         add     al,'0'                  ; add ascii bias
  526.         mov     rdbuf+3,al              ; last of the name
  527.         push    di
  528.         mov     di,offset rdbuf         ; pointer for remtab
  529.         call    remtab                  ; remove possible old macro
  530.         pop     di
  531.         mov     bx,[bx].takhnd          ; get file handle
  532.         mov     ah,close2               ; close file
  533.         int     dos
  534.                                         ; both disk and macro Takes
  535. takclo1:dec     taklev                  ; pop Take level
  536.         mov     ah,taklev               ; get current Take level
  537.         mov     intake,ah               ; remember here for later callers
  538.         sub     takadr,size takinfo     ; get previous Take's address
  539.         pop     bx
  540.         pop     ax
  541. takclo2:ret
  542. TAKCLOS ENDP
  543.  
  544. ; add an entry to a keyword table
  545. ; enter with bx = table address, dx = ptr to new entry, macptr = string offset,
  546. ; mccptr = offset of free bytes in table mcctab.
  547. ; no check is made to see if the entry fits in the table.
  548. addtab  proc    near
  549.         push    cx
  550.         push    si
  551.         push    es
  552.         cld
  553.         mov     ax,ds
  554.         mov     es,ax           ; address data segment
  555.         mov     bp,bx           ; remember where tbl starts
  556.         mov     cl,[bx]         ; pick up length of table
  557.         mov     ch,0
  558.         inc     bx              ; point to actual table
  559.         jcxz    addta4          ; cx = 0 if table is presently empty
  560.  
  561. addta1: push    cx              ; preserve count
  562.         mov     si,dx           ; point to entry
  563.         lodsb                   ; get length of new entry
  564.         mov     cl,[bx]         ; and length of table entry
  565.         mov     ah,0            ; assume they're the same size
  566.         cmp     al,cl           ; are they the same?
  567.         lahf                    ; remember result of comparison
  568.         jae     addta2          ; is new smaller? no, use table length
  569.         mov     cl,al           ; else use length of new entry
  570. addta2: mov     ch,0
  571.         lea     di,[bx+1]       ; point to actual keyword
  572.         repe    cmpsb           ; compare strings
  573.         pop     cx              ; restore count
  574.         jb      addta4          ; below, insert before this one
  575.         jne     addta3          ; not below or same, keep going
  576.         sahf                    ; same. get back result of length comparison
  577.         jb      addta4          ; if new len is smaller, insert here
  578.         jne     addta3          ; if not same size, keep going
  579.         mov     si,bx           ; else this is where entry goes
  580.         jmp     short addta6    ; no insertion required
  581. addta3: mov     al,[bx]
  582.         mov     ah,0
  583.         add     bx,ax           ; skip this entry
  584.         add     bx,4            ; len + $ + value
  585.         loop    addta1          ; and keep looking
  586. addta4: mov     si,bx           ; this is first location to move
  587.         mov     di,bx
  588.         inc     ds:byte ptr [bp] ; remember we're adding one
  589.         jcxz    addta6          ; no more entries, forget this stuff
  590.         mov     bh,0            ; this stays 0
  591. addta5: mov     bl,[di]         ; get length
  592.         lea     di,[bx+di+4]    ; end is origin + length + 4 for len, $, value
  593.         loop    addta5          ; loop thru remaining keywords
  594.         mov     cx,di
  595.         sub     cx,si           ; compute # of bytes to move
  596.         push    si              ; preserve loc for new entry
  597.         mov     si,di           ; first to move is last
  598.         dec     si              ; minus one
  599.         mov     di,dx           ; new entry
  600.         mov     bl,[di]         ; get length
  601.         lea     di,[bx+si+4]    ; dest is source + length of new + 4
  602.         std                     ; move backward
  603.         rep     movsb           ; move the table down (compress it)
  604.         cld                     ; put flag back
  605.         pop     si
  606. addta6: mov     di,si           ; this is where new entry goes
  607.         mov     si,dx           ; this is where it comes from
  608.         mov     cl,[si]         ; length
  609.         mov     ch,0
  610.         add     cx,1            ; include count byte
  611.         add     mccptr,cx       ; update free space pointer: cnt+name
  612.         add     mccptr,3        ; plus '$' and pointer to string
  613.         rep     movsb           ; stick it in
  614.         mov     al,'$'          ; add printing terminator
  615.         stosb
  616.         mov     ax,macptr       ; and string offset
  617.         stosw
  618.         pop     es
  619.         pop     si
  620.         pop     cx
  621.         ret
  622. addtab  endp
  623.  
  624. ; If new keyword matches an existing one then remove existing keyword,
  625. ; its string definition, compress tables mcctab and macbuf, readjust string
  626. ; pointers for each macro name, reduce number of macro table entries by one.
  627. ; DO MAC pointer (domacptr) is adjusted to follow deletion.
  628. ; Enter with DI pointing at length byte of mac name (followed by mac name).
  629. ; Otherwise, exit with no changes.  13 June 1987 [jrd]
  630. remtab  proc    near
  631.         push    ax
  632.         push    bx
  633.         push    cx
  634.         push    si
  635.         push    di
  636.         mov     bx,offset mcctab+1      ; table of macro keywords
  637.         mov     temp,0                  ; temp = current keyword
  638.         cmp     byte ptr mcctab,0       ; any macros defined?
  639.         jne     remta1                  ; ne = yes
  640.         jmp     remtax                  ; else exit now
  641. remta1:                                 ; match table keyword and text word
  642.         mov     si,di                   ; pointer to user's cnt+name
  643.         mov     cl,[si]                 ; length of user's macro name
  644.         xor     ch,ch
  645.         inc     si                      ; point to new macro name
  646.         cmp     cl,[bx]                 ; compare length vs table keyword
  647.         jne     remta4                  ; ne = not equal lengths, try another
  648.         push    si                      ; lengths match, how about spelling?
  649.         push    bx
  650.         inc     bx                      ; point at start of keyword
  651. remta2: mov     ah,[bx]                 ; keyword char
  652.         mov     al,[si]                 ; new text char
  653.         cmp     al,ah                   ; test characters
  654.         jne     remta3                  ; ne = no match
  655.         inc     si                      ; move to next char
  656.         inc     bx
  657.         loop    remta2                  ; loop through entire length
  658. remta3: pop     bx
  659.         pop     si
  660.         jcxz    remta6                  ; z: cx = 0, exit with match;
  661.                                         ;  else select next keyword
  662. remta4: inc     temp                    ; number of keyword to test next
  663.         mov     cx,temp
  664.         cmp     cl,mcctab               ; all done? Recall, temp starts at 0
  665.         jb      remta5                  ; b = not yet
  666.         jmp     remtax                  ; exhausted search, unsuccessfully
  667. remta5: mov     al,[bx]                 ; cnt (keyword length from macro)
  668.         xor     ah,ah
  669.         add     ax,4                    ; skip over '$' and two byte value
  670.         add     bx,ax                   ; bx = start of next keyword slot
  671.         jmp     remta1                  ; do another comparison
  672.                                         ; new name already present as a macro
  673. remta6: cld                             ; clear macro string and macro name
  674.         push    ds
  675.         pop     es                      ; set es to datas segment
  676.         mov     temp,bx                 ; save ptr to found keyword
  677.         mov     al,[bx]                 ; cnt (keyword length of macro)
  678.         xor     ah,ah
  679.         add     ax,2                    ; skip cnt and '$'
  680.         add     bx,ax                   ; point to string offset field
  681.         add     ax,2                    ; count offset field bytes
  682.         sub     mccptr,ax               ; readjust free space ptr for names
  683.         push    bx
  684.         mov     bx,[bx]
  685.         mov     temp1,bx                ; temp1 = offset of old string
  686.         mov     al,[bx]                 ; length of old string
  687.         xor     ah,ah
  688.         inc     ax                      ; plus its count byte
  689.         mov     temp2,ax                ; save here
  690.         pop     bx
  691.                                         ; clear keyword table mcctab
  692.         add     bx,2                    ; compute source = next keyword
  693.         mov     si,bx                   ; address of next keyword
  694.         mov     di,temp                 ; address of found keyword
  695.         mov     cx,offset mcctab+mcclen ; address of buffer end
  696.         sub     cx,si                   ; amount to move
  697.         jcxz    remtax                  ; cx = 0 means none
  698.         rep     movsb                   ; move down keywords (deletes current)
  699.                                         ; revise other string offsets
  700.         mov     si,offset mcctab        ; table of string offsets
  701.         inc     si                      ; skip count byte
  702.         mov     cl,mcctab               ; current number of table entries
  703.         xor     ch,ch
  704.         dec     mcctab                  ; one less keyword
  705.         mov     dx,temp1                ; address of old string
  706. remta7: mov     al,[si]                 ; cnt of first keyword
  707.         add     al,2                    ; plus cnt and '$'
  708.         xor     ah,ah
  709.         add     si,ax                   ; look at string offset
  710.         cmp     dx,[si]                 ; old address vs this string
  711.         ja      remta8                  ; a = address not affected
  712.         mov     ax,temp2                ; size of old string
  713.         sub     [si],ax                 ; adjust offset downward
  714. remta8: add     si,2                    ; point to next table entry
  715.         loop    remta7
  716.         cmp     dx,domacptr             ; DO <macro> definition affected?
  717.         ja      remta8a                 ; a = no (occurs before removal)
  718.         mov     ax,temp2                ; get length being removed from table
  719.         sub     domacptr,ax             ; revise pointer downward also
  720. remta8a:mov     cl,taklev               ; consider all Take files
  721.         mov     ch,0
  722.         jcxz    remta9                  ; z = no active Take file
  723.                                         ; revise Take file def pointers
  724.         mov     bx,takadr               ; Take structure
  725. remta8b:mov     ax,[bx].takbuf          ; pointer to definition
  726.         cmp     dx,ax                   ; is this structure affected?
  727.         ja      remta8d                 ; a = no
  728.         mov     ax,temp2                ; length being removed from table
  729.         sub     [bx].takbuf,ax          ; adjust string structure downward
  730.         sub     [bx].takptr,ax          ; ditto for active read pointer
  731. remta8d:sub     bx,size takinfo         ; preceeding Take file
  732.         loop    remta8b
  733.                                         ; remove old string
  734. remta9: mov     di,temp1                ; address of old string = destination
  735.         mov     ax,temp2                ; size of old string field
  736.         mov     si,di
  737.         add     si,ax                   ; plus length: source = next string
  738.         sub     macptr,ax               ; readjust top of buf free string ptr
  739.         mov     cx,offset macbuf+maclen ; end of buffer
  740.         sub     cx,si                   ; number of bytes to move
  741.         jcxz    remtax                  ; cx = 0 means none
  742.         rep     movsb                   ; move old strings (garbage collect)
  743. remtax: pop     di
  744.         pop     si
  745.         pop     cx
  746.         pop     bx
  747.         pop     ax
  748.         ret
  749. remtab  endp
  750.  
  751. ; Common Get keyword + Get Confirm sequence. Call with dx = keyword table,
  752. ; bx = help message offset. Returns result in BX. Modifies AX, BX and temp.
  753. ; Returns rskp if sucessful or ret if failure. Used in many places below.
  754. keyend  proc    near
  755.         mov     ah,cmkey
  756.         call    comnd
  757.          ret
  758.          nop
  759.          nop
  760.         mov     temp,bx
  761.         mov     ah,cmcfm
  762.         call    comnd
  763.          ret
  764.          nop
  765.          nop
  766.         mov     bx,temp
  767.         jmp     rskp
  768. keyend  endp
  769.  
  770. srvdsa  proc    near                    ; DISABLE Server commands
  771.         mov     dx,offset srvdetab
  772. ;        mov     bx,offset sdshlp
  773.         mcmsgb  sdshlp,csdshlp
  774.         call    keyend
  775.          ret
  776.          nop
  777.          nop
  778.         or      denyflg,bx              ; turn on bit (deny) for that item
  779.         jmp     rskp                    ; return successfully
  780. srvdsa  endp
  781.  
  782. srvena  proc    near                    ; ENABLE Server commands
  783.         mov     dx,offset srvdetab      ; keyword table
  784. ;        mov     bx,offset sdshlp        ; help on keywords
  785.         mcmsgb  sdshlp,csdshlp
  786.         call    keyend
  787.          ret
  788.          nop
  789.          nop
  790.         not     bx                      ; invert bits
  791.         and     denyflg,bx              ; turn off (enable) selected item
  792.         jmp     rskp
  793. srvena  endp
  794.  
  795.  
  796. ; This is the SET command
  797. ; Called analyzers return rskp for success, else ret for failure
  798. SETCOM  PROC    NEAR                    ; Dispatch all SET commands from here
  799.         mov     kstatus,0               ; global status, success
  800.         mov     dx,offset settab        ; Parse a keyword from the set table
  801. ;        mov     bx,offset sethlp
  802.         mcmsgb  sethlp,csethlp
  803.         mov     ah,cmkey
  804.         call    comnd
  805.          ret
  806.          nop
  807.          nop
  808.         jmp     bx                      ; execute analyzer routine
  809.                                         ; returns rskp for success, else ret
  810. SETCOM  endp
  811.  
  812. ;   SET BAUD or SET SPEED
  813.  
  814. BAUDST  PROC    NEAR
  815.         mov     dx,offset bdtab
  816.         mov     bx,0
  817.         call    keyend
  818.          ret
  819.          nop
  820.          nop
  821.         mov     si,portval
  822.         mov     ax,[si].baud            ; Remember original value
  823.         mov     [si].baud,bx            ; Set the baud rate
  824.         call    dobaud                  ; Use common code
  825.         jmp     rskp
  826. BAUDST  ENDP
  827.  
  828. ; SET BELL on or off
  829.  
  830. BELLST  PROC    NEAR
  831.         mov     dx,offset ontab
  832.         mov     bx,0
  833.         call    keyend
  834.          ret
  835.          nop
  836.          nop
  837.         mov     flags.belflg,bl
  838.         jmp     rskp
  839. BELLST  ENDP
  840.  
  841. ; SET BLOCK-CHECK
  842.  
  843. BLKSET  PROC    NEAR
  844.         mov     dx,offset blktab
  845.         mov     bx,0
  846.         call    keyend
  847.          ret
  848.          nop
  849.          nop
  850.         mov     trans.chklen,bl         ; Use this char as the handshake
  851.         mov     inichk,bl               ; Save here too
  852.         jmp     rskp
  853. BLKSET  ENDP
  854.  
  855. ; SET COUNTER number    for script IF COUNTER number <command>
  856. TAKECTR PROC    NEAR
  857.         mov     min,0                   ; get decimal char code
  858.         mov     max,65535               ; range is 0 to 65535 decimal
  859.         mov     numhlp,offset takchlp   ; help message
  860. ;-------------- Sept.12,1990 [zqf]
  861.         cmp     isccdos,0               ; if in CCDOS ?
  862.         je      takect1                 ; e = no. in MSDOS
  863.         mov     numhlp,offset ctakchlp   ; help message
  864. takect1:
  865. ;-------------- 
  866.         mov     numerr,0                ; error message
  867.         call    num0                    ; convert number, return it in ax
  868.         jc      takect2                 ; c = error
  869.         mov     temp,ax                 ; recover numerical code
  870.         mov     ah,cmcfm
  871.         call    comnd                   ; Get a confirm
  872.          ret                            ; Didn't get a confirm
  873.          nop
  874.          nop
  875.         mov     ax,temp                 ; recover bx
  876.         cmp     taklev,0                ; in a Take file?
  877.         je      takect4                 ; e = no
  878.         push    bx
  879.         mov     bx,takadr
  880.         mov     [bx].takctr,ax          ; set COUNT value
  881.         pop     bx
  882. takect2:jmp     rskp
  883. takect4:
  884. ;        mov     dx,offset takcerr       ; say must be in Take file
  885.         mcmsg   takcerr,ctakcerr
  886.         jmp     reterr                  ; display msg and jmp rskp
  887. TAKECTR ENDP
  888.  
  889. ; SET DEBUG {OFF | ON | SESSSION | PACKETS}
  890.  
  891. DEBST   PROC       NEAR
  892.         mov     dx,offset debtab
  893. ;        mov     bx,offset debhlp
  894.         mcmsgb  debhlp,cdebhlp
  895.         call    keyend
  896.          ret
  897.          nop
  898.          nop
  899.         or      flags.debug,bl          ; set the mode, except for Off
  900.         cmp     bx,0                    ; OFF?
  901.         jne     deb0                    ; ne = no
  902.         mov     flags.debug,0           ; Set the DEBUG flags off
  903. deb0:   jmp     rskp
  904. DEBST   ENDP
  905.  
  906. ; SET DESTINATION   of incoming files
  907.  
  908. DESSET  PROC    NEAR
  909.         mov     dx,offset destab
  910.         mov     bx,0
  911.         call    keyend
  912.          ret
  913.          nop
  914.          nop
  915.         mov     flags.destflg,bl        ; Set the destination flag
  916.         cmp     bl,2                    ; Is dest the screen?
  917.         jne     desa                    ; No, then done
  918.         mov     flags.xflg,1            ; Remember it here
  919.         jmp     rskp
  920. desa:   mov     flags.xflg,0            ; Don't write to screen
  921.         jmp     rskp
  922. DESSET  ENDP
  923.  
  924. ; SET DEFAULT-DISK    for sending/receiving, etc
  925. ; See cwdir in file mssker
  926.  
  927. ; SET DELAY seconds   Used only for SEND command in local mode
  928. SETDELY PROC    NEAR
  929.         mov     min,0                   ; smallest acceptable value
  930.         mov     max,63                  ; largest acceptable value
  931.         mov     numhlp,offset delyhlp   ; help message
  932. ;-------------- Sept.12,1990 [zqf]
  933.         cmp     isccdos,0               ; if in CCDOS ?
  934.         je      setdly2                 ; e = no. in MSDOS
  935.         mov     numhlp,offset cdelyhlp   ; help message
  936. setdly2:
  937. ;-------------- 
  938.         mov     numerr,0                ; complaint message
  939.         call    num0                    ; parse numerical input
  940.         jc      setdly1                 ; c = error
  941.         mov     trans.sdelay,al
  942. setdly1:jmp     rskp                    ; success or failure
  943. SETDELY ENDP
  944.  
  945. ; SET DISPLAY Quiet/Regular/Serial/7-Bit/8-Bit (inverse of Set Remote on/off)
  946. ; Accepts two keywords in one command
  947. disply  proc    near
  948.         mov     ah,cmkey
  949.         mov     dx,offset distab
  950. ;        mov     bx,offset dishlp
  951.          mcmsgb   dishlp,cdishlp
  952.         call    comnd
  953.          ret
  954.          nop
  955.          nop
  956.         mov     temp1,bx                ; save parsed value
  957.         mov     temp2,0ffffh            ; assume no second keyword
  958.         mov     comand.cmcr,1           ; bare CR's are allowed
  959.         mov     ah,cmkey                ; parse for second keyword
  960.         mov     dx,offset distab
  961. ;        mov     bx,offset dishlp
  962.          mcmsgb   dishlp,cdishlp
  963.         call    comnd
  964.          jmp    short displ1            ; no keyword
  965.          nop
  966.         mov     temp2,bx                ; get key value
  967. displ1: mov     comand.cmcr,0           ; bare CR's are not allowed
  968.         mov     ah,cmcfm
  969.         call    comnd                   ; confirm
  970.          ret                            ; return on failure
  971.          nop
  972.          nop
  973.         mov     ax,temp1                ; examine first key value
  974.         call    dispcom                 ; do common code
  975.         mov     ax,temp2                ; examine second key value
  976.         call    dispcom
  977.         jmp     rskp
  978.  
  979. dispcom:cmp     ax,0                    ; check range
  980.         jle     displ3                  ; le = not legal, ignore
  981.         cmp     al,7                    ; 7-8 bit value?
  982.         jge     displ2                  ; ge = yes
  983.         and     flags.remflg,not(dquiet+dregular+dserial)
  984.         or      flags.remflg,al         ; set display mode
  985.         ret                             ; check next key value
  986. displ2: cmp     al,8                    ; set 8-bit wide display?
  987.         ja      displ3                  ; a = bad value
  988.         and     flags.remflg,not d8bit  ; assume want 7 bit mode
  989.         cmp     al,7                    ; really want 7 bit mode?
  990.         je      displ3                  ; e = yes
  991.         or      flags.remflg,d8bit      ; set 8 bit flag
  992. displ3: ret                             ; end of display common code
  993. disply  endp
  994.  
  995.  
  996. ; Set Dump filename  for saving screen images on disk. [jrd]
  997. ; Puts filename in global string dmpname
  998. setdmp  proc    near
  999.         mov     dx,offset rdbuf         ; work area
  1000.         mov     rdbuf,0                 ; clear it
  1001. ;        mov     bx,offset dmphlp        ; help message
  1002.         mcmsgb  dmphlp,cdmphlp
  1003.         mov     ah,cmfile               ; allow paths
  1004.         call    comnd
  1005.          ret
  1006.          nop
  1007.          nop
  1008.         mov     ah,cmcfm
  1009.         call    comnd
  1010.          ret
  1011.          nop
  1012.          nop
  1013.         mov     dx,offset rdbuf         ; assume we will use this text
  1014.         call    strlen                  ; filename given?
  1015.         mov     si,dx                   ; for strcpy
  1016.         cmp     cx,0                    ; length of user's filename
  1017.         jg      setdmp1                 ; g = filename is given
  1018.         mov     si,offset dmpdefnam     ; no name, use default instead
  1019. setdmp1:mov     di,offset dmpname       ; copy to globally available loc
  1020.         call    strcpy
  1021.         jmp     rskp
  1022. setdmp  endp
  1023.  
  1024. ; SET EOF
  1025.  
  1026. SETEOF  PROC    NEAR
  1027.         mov     bx,0
  1028.         mov     dx,offset seoftab
  1029.         call    keyend
  1030.          ret
  1031.          nop
  1032.          nop
  1033.         mov     flags.eofcz,bl          ; set value
  1034.         jmp     rskp
  1035. SETEOF  ENDP
  1036.  
  1037. ; SET EOL char (for Sent packets)
  1038. ; Archic, here for downward compatibility
  1039. EOLSET  PROC    NEAR
  1040.         mov     stflg,'S'               ; set send/receive flag to Send
  1041.         jmp     sreol                   ; use Set Send/Rec routine do the work
  1042. EOLSET  ENDP
  1043.  
  1044. ; SET ERRORLEVEL number
  1045. SETERL  PROC    NEAR
  1046.         mov     numhlp,offset erlhlp    ; help
  1047. ;-------------- Sept.12,1990 [zqf]
  1048.         cmp     isccdos,0               ; if in CCDOS ?
  1049.         je      seterl2                 ; e = no. in MSDOS
  1050.         mov     numhlp,offset cerlhlp   ; help message
  1051. seterl2:
  1052. ;-------------- 
  1053.         mov     numerr,0                ; error message
  1054.         mov     min,0                   ; smallest number
  1055.         mov     max,255                 ; largest magnitude
  1056.         call    num0                    ; parse numerical input
  1057.         jc      seterl1                 ; c = error
  1058.         mov     errlev,al               ; store result
  1059. seterl1:jmp     rskp                    ; success or failure
  1060. SETERL  ENDP
  1061.  
  1062. ; SET ESCAPE character.
  1063. ; Accept literal control codes and \### numbers. [jrd] 18 Oct 1987
  1064. ESCSET  PROC    NEAR
  1065.         mov     ah,cmfile
  1066.         mov     dx,offset rdbuf         ; work space
  1067.         mov     word ptr rdbuf,0        ; clear it
  1068. ;        mov     bx,offset eschlp        ; help
  1069.         mcmsgb  eschlp,ceschlp
  1070.         call    comnd
  1071.          ret
  1072.          nop
  1073.          nop
  1074.         cmp     ah,0                    ; anything given?
  1075.         jne     escse1                  ; ne = yes
  1076. ;        mov     dx,offset ermes6        ; more parameters needed
  1077.          mcmsg   ermes6,cermes6
  1078.         jmp     reterr
  1079. escse1: mov     ah,cmcfm                ; get a confirm
  1080.         call    comnd
  1081.          ret
  1082.          nop
  1083.          nop
  1084.         mov     si,offset rdbuf         ; source of chars
  1085.         call    katoi                   ; convert escaped numbers to binary
  1086.         cmp     ax,spc                  ; is it a control code?
  1087.         jae     escse2                  ; ae = no, complain
  1088.         cmp     ax,0                    ; non-zero too?
  1089.         je      escse2                  ; e = zero
  1090.         mov     trans.escchr,al         ; Save new value.
  1091.         jmp     rskp
  1092. escse2: 
  1093. ;       mov     dx,offset escerr
  1094.         mcmsg  escerr,cescerr
  1095.         jmp     reterr
  1096. ESCSET  ENDP
  1097.  
  1098. SETATT  PROC    NEAR                    ; Set attributes on | off
  1099.         mov     dx,offset ontab
  1100.         mov     bx,0
  1101.         call    keyend
  1102.          ret
  1103.          nop
  1104.          nop
  1105.         mov     flags.attflg,bl
  1106.         jmp     rskp
  1107. SETATT  ENDP
  1108.  
  1109. ; SET FILEWARNING
  1110.  
  1111. FILWAR  PROC    NEAR
  1112.         mov     dx,offset ontab
  1113.         mov     bx,0
  1114.         call    keyend
  1115.          ret
  1116.          nop
  1117.          nop
  1118.         mov     flags.flwflg,bl         ; Set the filewarning flag
  1119.         jmp     rskp
  1120. FILWAR  ENDP
  1121.  
  1122. ; SET FLOW-CONTROL
  1123.  
  1124. FLOSET  PROC    NEAR
  1125.         mov     dx,offset flotab
  1126.         xor     bx,bx
  1127.         call    keyend
  1128.          ret
  1129.          nop
  1130.          nop
  1131.         mov     si,portval
  1132.         mov     [si].flowc,bx           ; Flow control value
  1133.         mov     [si].floflg,bl          ; Say if doing flow control
  1134.         jmp     rskp
  1135. FLOSET  ENDP
  1136.  
  1137. ; SET HANDSHAKE
  1138. ; Add ability to accept general decimal code. [jrd]
  1139.  
  1140. HNDSET  PROC    NEAR
  1141.         mov     dx,offset hndtab        ; table to scan
  1142. ;        mov     bx,offset hnd1hlp       ; help message
  1143.         mcmsgb  hnd1hlp,chnd1hlp
  1144.         mov     ah,cmkey
  1145.         call    comnd
  1146.          ret
  1147.          nop
  1148.          nop
  1149.         cmp     bl,0ffh                 ; want a general char code?
  1150.         jne     hnd1                    ; ne = no
  1151.         mov     min,0                   ; get decimal char code
  1152.         mov     max,31                  ; range is 0 to 31 decimal
  1153.         mov     numhlp,offset ctlhlp    ; help message
  1154. ;-------------- Sept.12,1990 [zqf]
  1155.         cmp     isccdos,0               ; if in CCDOS ?
  1156.         je      hnd3                 ; e = no. in MSDOS
  1157.         mov     numhlp,offset cctlhlp   ; help message
  1158. hnd3:
  1159. ;-------------- 
  1160.         mov     numerr,0                ; error message
  1161.         call    num0                    ; convert number, return it in ax
  1162.         jc      hnd2                    ; c = error
  1163.         mov     bx,ax                   ; recover numerical code
  1164. hnd1:
  1165.         mov     temp,bx                 ; handshake type
  1166.         mov     ah,cmcfm
  1167.         call    comnd                   ; Get a confirm
  1168.          ret                            ; Didn't get a confirm
  1169.          nop
  1170.          nop
  1171.         mov     bx,temp                 ; recover bx
  1172.         mov     si,portval
  1173.         cmp     bl,0                    ; Setting handshake off?
  1174.         je      hnd0                    ; Yes
  1175.         mov     [si].hndflg,1           ; And turn on handshaking
  1176.         mov     [si].hands,bl           ; Use this char as the handshake
  1177.         jmp     rskp
  1178. hnd0:   mov     [si].hndflg,0           ; No handshaking
  1179. hnd2:   jmp     rskp
  1180. HNDSET  ENDP
  1181.  
  1182. ;   SET INCOMPLETE file disposition
  1183.  
  1184. ABFSET  PROC    NEAR
  1185.         mov     dx,offset abftab
  1186.         mov     bx,0
  1187.         call    keyend
  1188.          ret
  1189.          nop
  1190.          nop
  1191.         mov     flags.abfflg,bl         ; Set the aborted file flag
  1192.         jmp     rskp
  1193. ABFSET  ENDP
  1194. ;
  1195. ; Set Input commands (default-timeout, timeout-action, case, echo)
  1196. ; By Jim Strudevant [jrs]
  1197. INPSET  PROC    NEAR
  1198.         mov     ah,cmkey                ; key word
  1199.         mov     dx,offset inptab        ; from inputtable
  1200.         mov     bx,0                    ; no hints
  1201.         call    comnd                   ; get the word
  1202.          ret                            ; they blew it
  1203.          nop
  1204.          nop
  1205.         jmp     bx                      ; do the sub command
  1206. ;
  1207. ; Set Input Default-timeout in seconds
  1208. ;
  1209. inptmo: mov     numhlp,offset intoms    ; help
  1210. ;-------------- Sept.12,1990 [zqf]
  1211.         cmp     isccdos,0               ; if in CCDOS ?
  1212.         je      inptmo2                 ; e = no. in MSDOS
  1213.         mov     numhlp,offset cintoms   ; help message
  1214. inptmo2:
  1215. ;-------------- 
  1216.         mov     numerr,0                ; error message
  1217.         mov     min,0                   ; smallest number
  1218.         mov     max,-1                  ; largest magnitude
  1219.         call    num0                    ; parse numerical input
  1220.         jc      inptmo1                 ; c = error
  1221.         mov     script.indfto,ax        ; store result
  1222. inptmo1:jmp     rskp                    ; success or failure
  1223. ;
  1224. ; Set Input Timeout action (proceed or quit)
  1225. ;
  1226. inpact: mov     dx,offset inactb        ; from this list
  1227.         mov     bx,0                    ; no hints
  1228.         call    keyend                  ; get it
  1229.          ret                            ; bad input
  1230.          nop
  1231.          nop
  1232.         mov     script.inactv,bl        ; save the action
  1233.         jmp     rskp                    ; good return
  1234. ;
  1235. ; Set Input Echo on or off
  1236. ;
  1237. inpeco: mov     dx,offset ontab         ; from this list
  1238.         mov     bx,0                    ; no hints
  1239.         call    keyend                  ; get it
  1240.          ret                            ; bad input
  1241.          nop
  1242.          nop
  1243.         mov     script.inecho,bl        ; save the action
  1244.         jmp     rskp                    ; good return
  1245. ;
  1246. ; Set Input Case observe or ignore
  1247. ;
  1248. inpcas: mov     dx,offset incstb        ; from this list
  1249.         mov     bx,0                    ; no hints
  1250.         call    keyend                  ; get it
  1251.          ret                            ; bad input
  1252.          nop
  1253.          nop
  1254.         mov     script.incasv,bl        ; save the action
  1255.         jmp     rskp                    ; good return
  1256. INPSET  ENDP
  1257.  
  1258. ; SET KEY
  1259. ; Jumps to new Set Key routine
  1260. setkey  proc    near
  1261.         cmp     stkadr,0        ; keyboard translator present?
  1262.         je      setk4           ; e = no, use this routine
  1263.         mov     bx,stkadr       ; yes, get offset of procedure
  1264.         jmp     bx              ; jump to keyboard translator
  1265. setk4:  
  1266. ;        mov     dx,offset ermes5
  1267.          mcmsg   ermes5,cermes5
  1268.         jmp     reterr          ; else print error message
  1269. setkey  endp
  1270.  
  1271. ; SET LOCAL-ECHO {ON | OFF}
  1272.  
  1273. LCAL    PROC    NEAR
  1274.         mov     dx,offset ontab
  1275.         mov     bx,0
  1276.         call    keyend
  1277.          ret
  1278.          nop
  1279.          nop
  1280.         mov     si,portval
  1281.         mov     [si].ecoflg,bl          ; Set the local echo flag
  1282.         jmp     rskp
  1283. LCAL    ENDP
  1284.  
  1285. ; LOG  {PACKETS | SESSION | TRANSACTION} filename
  1286.  
  1287. setcpt  proc    near
  1288.         mov     dx,offset logtab        ; kinds of logging
  1289. ;        mov     bx,offset loghlp        ; help on kind of logging
  1290.         mcmsgb  loghlp,cloghlp
  1291.         mov     ah,cmkey                ; parse keyword
  1292.         call    comnd
  1293.          ret
  1294.          nop
  1295.          nop
  1296.         mov     temp,bx                 ; Save the parsed value
  1297.         mov     dx,offset rdbuf         ; holds the complete filename
  1298.         mov     rdbuf,0                 ; clear buffer
  1299. ;        mov     bx,offset filhlp        ; ask for filename
  1300.          mcmsgb   filhlp,cfilhlp
  1301.         mov     ah,cmfile               ; allow paths
  1302.         call    comnd
  1303.          ret
  1304.          nop
  1305.          nop
  1306.         mov     ah,cmcfm
  1307.         call    comnd                   ; Get a confirm
  1308.          ret                            ;  Didn't get a confirm
  1309.          nop
  1310.          nop
  1311.         mov     bx,temp                 ; recover kind of logging
  1312.         mov     dx,offset rdbuf         ; length of filename to cx
  1313.         call    strlen                  ; length of given filename
  1314.  
  1315.         test    bl,logpkt               ; packet logging?
  1316.         jz      setcp2                  ; z = no, try others
  1317.         mov     dx,offset lpktnam       ; filename
  1318.         jcxz    setcp1                  ; z = no filename given
  1319.         mov     si,offset rdbuf         ; get new name
  1320.         mov     di,dx                   ; destination
  1321.         call    strcpy                  ; replace old name
  1322. setcp1: cmp     ploghnd,-1              ; packet log file already open?
  1323.         je      setcp6                  ; e = no, open it
  1324.         jmp     setcp16                 ; say file is open already
  1325.  
  1326. setcp2: test    bl,logses               ; session logging?
  1327.         jz      setcp4                  ; z = no, try others
  1328.         mov     dx,offset lsesnam       ; use default name
  1329.         jcxz    setcp3                  ; z = no filename given
  1330.         mov     si,offset rdbuf         ; get new name
  1331.         mov     di,dx                   ; destination
  1332.         call    strcpy                  ; replace old name
  1333. setcp3: cmp     sloghnd,-1              ; transaction file already open?
  1334.         je      setcp6                  ; e = no, open it
  1335.         jmp     setcp16                 ; say file is open already
  1336.  
  1337. setcp4: test    bl,logtrn               ; transaction logging?
  1338.         jz      setcp14                 ; z = no, error
  1339.         mov     dx,offset ltranam       ; use default name
  1340.         jcxz    setcp5                  ; z = no filename given
  1341.         mov     si,offset rdbuf         ; get new name
  1342.         mov     di,dx                   ; destination
  1343.         call    strcpy                  ; replace old name
  1344. setcp5: cmp     tloghnd,-1              ; transaction file already open?
  1345.         je      setcp6                  ; e = no, open it
  1346.         jmp     setcp16                 ; say file is open already
  1347.  
  1348. setcp6: mov     ax,dx                   ; place for filename for isfile
  1349.         call    isfile                  ; does file exist already?
  1350.         jc      setcp7                  ; c = does not exist so use create
  1351.         test    byte ptr filtst.dta+21,1fh ; file attributes, ok to write?
  1352.         jnz     setcp14                 ; nz = no, use error exit
  1353.         mov     ah,open2                ; open existing file
  1354.         mov     al,1+1                  ;  for writing and reading
  1355.         int     dos
  1356.         jc      setcp14                 ; if carry then error
  1357.         mov     bx,ax                   ; file handle for seeking
  1358.         mov     cx,0                    ; high order displacement
  1359.         mov     dx,0                    ; low order part of displacement
  1360.         mov     ah,lseek                ; seek to EOF (to do appending)
  1361.         mov     al,2                    ; says to EOF
  1362.         int     dos
  1363.         jmp     short setcp8
  1364.  
  1365. setcp7: test    filtst.fstat,80h        ; access problem?
  1366.         jnz     setcp14                 ; nz = yes, stop here
  1367.         mov     ah,creat2               ; function is create
  1368.         mov     cl,20H                  ; turn on archive bit
  1369.         mov     ch,0
  1370.         int     dos                     ; create the file, DOS 2.0
  1371.         jc      setcp14                 ; if carry bit set then error
  1372.         mov     bx,ax                   ; file handle
  1373.  
  1374. setcp8: cmp     temp,logpkt             ; packet logging?
  1375.         jne     setcp9                  ; ne = no
  1376.         mov     ploghnd,bx              ; save transaction log handle here
  1377.         jmp     short setcp12
  1378. setcp9: cmp     temp,logses             ; session logging?
  1379.         jne     setcp10                 ; ne = no
  1380.         mov     sloghnd,bx              ; save session log handle here
  1381.         jmp     short setcp12
  1382. setcp10:mov     tloghnd,bx              ; save transaction log handle here
  1383.  
  1384. setcp12:mov     ax,temp                 ; kind of Logging
  1385.         or      flags.capflg,al         ; accumulate kinds of logging
  1386.         jmp     rskp                    ; and return
  1387.  
  1388. setcp14:
  1389. ;       mov     dx,offset errcap        ; give error message
  1390.          mcmsg   errcap,cerrcap
  1391.         jmp     reterr                  ; and display it
  1392.  
  1393. setcp16:mov     ah,prstr                ; file already open
  1394. ;        mov     dx,offset erropn
  1395.          mcmsg   erropn,cerropn
  1396.         int     dos
  1397.         jmp     rskp                    ; return success
  1398. setcpt  endp
  1399.  
  1400. ; SET MODE LINE
  1401.  
  1402. MODL    PROC    NEAR
  1403.         mov     dx,offset ontab         ; parse an on or off
  1404.         mov     bx,0                    ; no special help
  1405.         call    keyend
  1406.          ret
  1407.          nop
  1408.          nop
  1409.         mov     flags.modflg,bl         ; set flag appropriately
  1410.         jmp     rskp
  1411. MODL    ENDP
  1412.  
  1413. ; SET PARITY
  1414.  
  1415. SETPAR  PROC    NEAR
  1416.         mov     dx,offset partab
  1417.         mov     bx,0
  1418.         call    keyend
  1419.          ret
  1420.          nop
  1421.          nop
  1422.         mov     si,portval
  1423.         mov     [si].parflg,bl          ; Set the parity flag
  1424.         cmp     bl,parnon               ; Resetting parity to none?
  1425.         je      setp0                   ; e = yes, reset 8 bit quote character
  1426.         mov     trans.ebquot,dqbin      ; we want quoting, active
  1427.         mov     dtrans.ebquot,dqbin     ; we want quoting, our default
  1428.         jmp     short setp1
  1429. setp0:  mov     trans.ebquot,'Y'        ; say will quote upon request
  1430.         mov     dtrans.ebquot,'Y'       ; and our default
  1431.         setp1:  jmp     rskp
  1432. SETPAR  ENDP
  1433.  
  1434. ; SET PROMPT  Allow user to change the "Kermit-MS>" prompt
  1435. ; {string} and \number notation permitted to represent special chars. [jrd]
  1436.  
  1437. PROMSET PROC    NEAR
  1438.         mov     ah,cmtxt
  1439.         mov     bx,offset rdbuf         ; Read in the prompt
  1440.         mov     word ptr [bx],0         ; clear buffer
  1441. ;        mov     dx,offset prmmsg
  1442.          mcmsg   prmmsg,cprmmsg
  1443.         call    comnd
  1444.          ret
  1445.          nop
  1446.          nop
  1447.         cmp     rdbuf,0                 ; Just a bare CR?
  1448.         jne     prom0                   ; ne = no
  1449.         mov     ax,offset kerm          ; yes, restore default prompt
  1450.         jmp     prom1
  1451. prom0:  push    si                      ; parse \### constants into
  1452.         push    di                      ;  1 byte binary numbers inline
  1453.         mov     si,offset rdbuf         ; source = new prompt string
  1454.         mov     byte ptr [si-1+length rdbuf],0 ; plant null terminator
  1455.         mov     di,offset prm           ; destination
  1456.         call    cnvlin                  ; convert \### in string to binary
  1457.         pop     di
  1458.         pop     si
  1459.         mov     bx,cx                   ; get byte count
  1460.         add     bx,offset prm           ; point to null terminator
  1461.         mov     byte ptr [bx],'$'       ; End of string
  1462.         mov     ax,offset prm
  1463. prom1:  mov     prmptr,ax               ; Remember it
  1464.         jmp     rskp
  1465. PROMSET ENDP
  1466.  
  1467. ; SET SERVER TIMEOUT
  1468.  
  1469. SETSRV  PROC    NEAR
  1470.         mov     dx,offset srvtab        ; set server table
  1471.         mov     bx,0                    ; use table for help
  1472.         mov     ah,cmkey                ; get keyword
  1473.         call    comnd
  1474.          ret
  1475.          nop
  1476.          nop
  1477.         mov     min,0                   ; smallest acceptable value
  1478.         mov     max,255                 ; largest acceptable value, one byte
  1479.         mov     numhlp,offset srvthlp   ; help message
  1480. ;-------------- Sept.12,1990 [zqf]
  1481.         cmp     isccdos,0               ; if in CCDOS ?
  1482.         je      setsrv2                 ; e = no. in MSDOS
  1483.         mov     numhlp,offset csrvthlp   ; help message
  1484. setsrv2:
  1485. ;-------------- 
  1486.         mov     numerr,0                ; complaint message
  1487.         call    num0                    ; parse numerical input
  1488.         jc      setsrv1                 ; c = error
  1489.         mov     srvtmo,al               ; store timeout value
  1490. setsrv1:jmp     rskp
  1491. SETSRV  ENDP
  1492.  
  1493. ; SET RETRY value. Changes the packet retry limit. [jrd]
  1494.  
  1495. RETRYSET PROC   NEAR
  1496.         mov     min,1                   ; smallest acceptable value
  1497.         mov     max,63                  ; largest acceptable value
  1498.         mov     numhlp,offset retryhlp  ; help message
  1499. ;-------------- Sept.12,1990 [zqf]
  1500.         cmp     isccdos,0               ; if in CCDOS ?
  1501.         je      retrys2                 ; e = no. in MSDOS
  1502.         mov     numhlp,offset cretryhlp ; help message
  1503. retrys2:
  1504. ;-------------- 
  1505.         mov     numerr,0                ; complaint message
  1506.         call    num0                    ; parse numerical input
  1507.         jc      retrys1                 ; c = error
  1508.         mov     maxtry,al
  1509.         shl     al,1                    ; quick multiply by two or three
  1510.         mov     imxtry,al               ; keep that much
  1511.         add     al,maxtry               ; try three times
  1512.         js      retrys1                 ; s = sign bit set, too much
  1513.         mov     imxtry,al               ; I packets get 3 times as many tries
  1514. retrys1:jmp     rskp
  1515. RETRYSET ENDP
  1516.  
  1517. ; SET TAKE-ECHO  on or off
  1518.  
  1519. TAKSET  PROC    NEAR
  1520.         mov     dx,offset ontab
  1521.         mov     bx,0
  1522.         call    keyend
  1523.          ret
  1524.          nop
  1525.          nop
  1526.         mov     flags.takflg,bl
  1527.         jmp     rskp
  1528. TAKSET  ENDP
  1529.  
  1530. ; SET TIMER     on or off during file transfer
  1531.  
  1532. TIMSET  PROC    NEAR
  1533.         mov     dx,offset ontab
  1534.         mov     bx,0
  1535.         call    keyend
  1536.          ret
  1537.          nop
  1538.          nop
  1539.         mov     flags.timflg,bl
  1540.         jmp     rskp
  1541. TIMSET  ENDP
  1542.  
  1543. ; SET SEND parameters
  1544.  
  1545. SENDSET PROC    NEAR
  1546.         mov     stflg,'S'               ; Setting SEND parameter
  1547. sndst0: mov     dx,offset stsrtb        ; Parse a keyword
  1548.         mov     bx,0                    ; no specific help
  1549.         mov     ah,cmkey
  1550.         call    comnd
  1551.          ret                            ; bad user text
  1552.          nop
  1553.          nop
  1554.         jmp     bx                      ; do the action routine
  1555. SENDSET ENDP
  1556.  
  1557. ; SET RECEIVE parameters
  1558.  
  1559. recset: mov     stflg,'R'               ; Setting RECEIVE paramter
  1560.         jmp     sndst0
  1561.  
  1562. remset  proc    near                    ; Set REMOTE ON/OFF
  1563.         mov     dx,offset ontab
  1564. ;        mov     bx,offset remhlp
  1565.          mcmsgb   remhlp,cremhlp
  1566.         call    keyend
  1567.          ret
  1568.          nop
  1569.          nop
  1570.         and     flags.remflg,not (dquiet+dserial+dregular) ; no display bits
  1571.         or      bl,bl                   ; want off state? (same as regular)
  1572.         jz      remset1                 ; z = yes
  1573.         or      flags.remflg,dquiet     ; else on = quiet display
  1574.         jmp     short remset2
  1575. remset1:or      flags.remflg,dregular   ; off = regular display
  1576. remset2:jmp     rskp
  1577. remset  endp
  1578.  
  1579.  
  1580. ; SET Send and Receive EOL char
  1581.  
  1582. sreol   PROC    NEAR
  1583.         mov     min,0                   ; lowest acceptable value
  1584.         mov     max,1FH                 ; largest acceptable value
  1585.         mov     numhlp,offset ctlhlp    ; Reuse help message
  1586. ;-------------- Sept.12,1990 [zqf]
  1587.         cmp     isccdos,0               ; if in CCDOS ?
  1588.         je      sreol4                 ; e = no. in MSDOS
  1589.         mov     numhlp,offset cctlhlp   ; help message
  1590. sreol4:
  1591. ;-------------- 
  1592.         mov     numerr,0                ; error message address
  1593.         call    num0                    ; get numerical input
  1594.         jc      sreol3                  ; c = error
  1595.         cmp     stflg,'S'               ; Setting SEND paramter?
  1596.         je      sreol1
  1597.         mov     trans.reol,al
  1598.         jmp     short sreol2
  1599. sreol1: mov     dtrans.seol,al
  1600. sreol2: mov     ah,dtrans.seol
  1601.         mov     trans.seol,ah
  1602. sreol3: jmp     rskp
  1603. sreol   ENDP
  1604.  
  1605.  
  1606. ; SET SEND and RECEIVE start-of-header
  1607.  
  1608. srsoh:  mov     min,0
  1609.         mov     max,1FH
  1610.         mov     numhlp,offset ctlhlp    ; Reuse help message
  1611. ;-------------- Sept.12,1990 [zqf]
  1612.         cmp     isccdos,0               ; if in CCDOS ?
  1613.         je      srsoh3                 ; e = no. in MSDOS
  1614.         mov     numhlp,offset cctlhlp   ; help message
  1615. srsoh3:
  1616. ;-------------- 
  1617.         mov     numerr,0                ; error message
  1618.         call    num0            ; Common routine for parsing numerical input
  1619.         jc      srsoh2                  ; c = error
  1620.         cmp     stflg,'S'               ; Setting SEND paramter?
  1621.         je      srsoh1
  1622.         mov     trans.rsoh,al           ; set Receive soh
  1623.         jmp     short srsoh2
  1624. srsoh1: mov     trans.ssoh,al           ; set Send soh
  1625. srsoh2: jmp     rskp                    ; success or failure
  1626.  
  1627. ; SET SEND and  RECEIVE TIMEOUT
  1628.  
  1629. srtim:  mov     min,0
  1630.         mov     max,94
  1631.         mov     numhlp,offset timhlp    ; Reuse help message
  1632. ;-------------- Sept.12,1990 [zqf]
  1633.         cmp     isccdos,0               ; if in CCDOS ?
  1634.         je      srtim4                 ; e = no. in MSDOS
  1635.         mov     numhlp,offset ctimhlp   ; help message
  1636. srtim4:
  1637. ;-------------- 
  1638.         mov     numerr,0                ; error message
  1639.         call    num0            ; Common routine for parsing numerical input
  1640.         jc      srtim3                  ; c = error
  1641.         cmp     stflg,'S'               ; Setting SEND paramter?
  1642.         je      srtim1
  1643.         mov     trans.rtime,al
  1644.         jmp     short srtim2
  1645. srtim1: mov     dtrans.stime,al
  1646. srtim2: mov     ah,dtrans.stime
  1647.         mov     trans.stime,ah
  1648. srtim3: jmp     rskp
  1649.  
  1650. ; SET SEND and RECEIVE PACKET LENGTH
  1651.  
  1652. srpack: mov     min,20
  1653.         mov     max,maxpack
  1654.         mov     numhlp,offset pakhlp    ; help
  1655. ;-------------- Sept.12,1990 [zqf]
  1656.         cmp     isccdos,0               ; if in CCDOS ?
  1657.         je      srpak5                 ; e = no. in MSDOS
  1658.         mov     numhlp,offset cpakhlp   ; help message
  1659. srpak5:
  1660. ;-------------- 
  1661.         mov     numerr,offset pakerr    ; error message
  1662. ;-------------- Sept.12,1990 [zqf]
  1663.         cmp     isccdos,0               ; if in CCDOS ?
  1664.         je      srpak6                 ; e = no. in MSDOS
  1665.         mov     numerr,offset cpakerr   ; help message
  1666. srpak6:
  1667. ;-------------- 
  1668.         call    num0
  1669.         jc      srpak2                  ; c = error
  1670.         cmp     stflg,'S'               ; setting send value?
  1671.         jne     srpakr                  ; ne = receive
  1672.         mov     trans.slongp,ax         ; set send value
  1673.         mov     trans.slong,ax          ; and remember what we Set
  1674.         cmp     ax,94                   ; within normal packet range?
  1675.         ja      srpak2                  ; a = no
  1676.         mov     trans.spsiz,al          ; yes. update regular pkt size too
  1677. srpak2: jmp     rskp                    ; success or failure
  1678. srpakr: mov     trans.rlongp,ax         ; set receive value
  1679.         cmp     ax,94                   ; within normal packet range?
  1680.         ja      srpak4                  ; a = no
  1681.         mov     trans.rpsiz,al          ; yes. update regular pkt size too
  1682. srpak4: jmp     rskp
  1683.  
  1684.  
  1685. ; SET SEND and RECEIVE number of padding characters
  1686.  
  1687. srnpd:  mov     min,0
  1688.         mov     max,99
  1689.         mov     numhlp,offset padhlp    ; help message
  1690. ;-------------- Sept.12,1990 [zqf]
  1691.         cmp     isccdos,0               ; if in CCDOS ?
  1692.         je      srnpd4                 ; e = no. in MSDOS
  1693.         mov     numhlp,offset cpadhlp   ; help message
  1694. srnpd4:
  1695. ;-------------- 
  1696.         mov     numerr,0                ; error message
  1697.         call    num0                    ; Parse numerical input
  1698.         jc      srnpd3                  ; c = error
  1699.         cmp     stflg,'S'               ; Setting SEND paramter?
  1700.         je      srnpd1                  ; e = yes
  1701.         mov     trans.rpad,al           ; set Receive padding
  1702.         jmp     short srnpd2
  1703. srnpd1: mov     dtrans.spad,al          ; set default Send padding
  1704. srnpd2: mov     al,dtrans.spad
  1705.         mov     trans.spad,al           ; update active array for I and S pkts
  1706. srnpd3: jmp     rskp                    ; success or failure
  1707.  
  1708. ; SET SEND and RECEIVE padding character
  1709.  
  1710. srpad:  mov     min,0
  1711.         mov     max,127
  1712.         mov     numhlp,offset padhlp
  1713. ;-------------- Sept.12,1990 [zqf]
  1714.         cmp     isccdos,0               ; if in CCDOS ?
  1715.         je      srpad5                 ; e = no. in MSDOS
  1716.         mov     numhlp,offset cpadhlp   ; help message
  1717. srpad5:
  1718. ;-------------- 
  1719.         mov     numerr,offset padhlp
  1720. ;-------------- Sept.12,1990 [zqf]
  1721.         cmp     isccdos,0               ; if in CCDOS ?
  1722.         je      srpad6                 ; e = no. in MSDOS
  1723.         mov     numerr,offset cpadhlp   ; help message
  1724. srpad6:
  1725. ;-------------- 
  1726.         call    num0                    ; Parse numerical input
  1727.         jc      srpad4                  ; c = error
  1728.         cmp     ah,127                  ; This is allowed
  1729.         je      srpad1
  1730.         cmp     ah,32
  1731.         jb      srpad1                  ; Between 0 and 31 is OK too
  1732.         mov     ah,prstr
  1733. ;        mov     dx,offset padhlp
  1734.         mcmsg   padhlp,cpadhlp
  1735.         int     dos
  1736. srpad1: cmp     stflg,'S'               ; Send?
  1737.         je      srpad2                  ; e = yes, else Receive
  1738.         mov     trans.rpadch,al         ; store receive pad char
  1739.         jmp     short srpad3
  1740. srpad2: mov     dtrans.spadch,al        ; store Send pad char
  1741. srpad3: mov     ah,dtrans.spadch
  1742.         mov     trans.spadch,ah         ; update active array for I and S pkts
  1743. srpad4: jmp     rskp
  1744.  
  1745. ; SET SEND and  RECEIVE control character prefix
  1746.  
  1747. srquo:  mov     min,33
  1748.         mov     max,126
  1749.         mov     numhlp,offset quohlp    ; help message
  1750. ;-------------- Sept.12,1990 [zqf]
  1751.         cmp     isccdos,0               ; if in CCDOS ?
  1752.         je      srquo4                 ; e = no. in MSDOS
  1753.         mov     numhlp,offset cquohlp   ; help message
  1754. srquo4:
  1755. ;-------------- 
  1756.         mov     numerr,0                ; error message
  1757.         call    num0                    ; Parse numerical input
  1758.         jc      srquo3                  ; c = error
  1759.         cmp     stflg,'S'               ; Setting outgoing quote char?
  1760.         je      srquo1
  1761.         mov     trans.rquote,al         ; set Receive quote char
  1762.         jmp     short srquo2
  1763. srquo1: mov     dtrans.squote,al        ; set Send quote char
  1764. srquo2: mov     ah,dtrans.spadch
  1765.         mov     trans.spadch,ah         ; update active array for I and S pkts
  1766. srquo3: jmp     rskp
  1767.  
  1768. ; SET SEND Pause number of milliseconds
  1769.  
  1770. srpaus: mov     min,0
  1771.         mov     max,127
  1772.         mov     numhlp,offset pauhlp    ; help
  1773. ;-------------- Sept.12,1990 [zqf]
  1774.         cmp     isccdos,0               ; if in CCDOS ?
  1775.         je      srpau4                 ; e = no. in MSDOS
  1776.         mov     numhlp,offset cpauhlp   ; help message
  1777. srpau4:
  1778. ;-------------- 
  1779.         mov     numerr,0
  1780.         call    num0                    ; Parse numerical input
  1781.         pushf                           ; save carry for error state
  1782.         cmp     stflg,'S'               ; Setting SEND paramter?
  1783.         je      srpau0
  1784.         popf
  1785. ;        mov     dx,offset ermes5        ; "Not implemented" msg
  1786.          mcmsg   ermes5,cermes5
  1787.         jmp     reterr                  ; print error message
  1788. srpau0: popf
  1789.         jc      srpau1                  ; c = error
  1790.         mov     spause,al               ; store value
  1791. srpau1: jmp     rskp
  1792.  
  1793. ; SET TRANSLATION INPUT   Connect mode translate incoming characters
  1794. ; SET TRANS IN {Original-byte New-byte | ON | OFF}
  1795.  
  1796. SETRX   PROC    NEAR                    ; translate incoming serial port char
  1797.         mov     ah,cmkey
  1798.         mov     dx,offset trnstab       ; direction table (just one entry)
  1799.         mov     bx,0                    ; no help
  1800.         call    comnd
  1801.          ret
  1802.          nop
  1803.          nop
  1804.         mov     dx,offset rdbuf         ; our work space
  1805.         mov     word ptr rdbuf,0        ; insert terminator
  1806. ;        mov     bx,offset srxhlp1       ; first help message
  1807.          mcmsgb   srxhlp1,csrxhlp1
  1808.         mov     ah,cmfile               ; parse a word
  1809.         call    comnd                   ; get incoming byte pattern
  1810.          ret                            ; error if none
  1811.          nop
  1812.          nop
  1813.         or      ah,ah                   ; any text given?
  1814.         jz      setr6                   ; nz = no
  1815.         mov     temp,ax                 ; save byte count here
  1816.         mov     ax,word ptr rdbuf       ; get first two characters
  1817.         or      ax,2020h                ; convert upper to lower case
  1818.         cmp     ax,'fo'                 ; first part of word OFF?
  1819.         je      setr6                   ; e = yes, go analyze
  1820.         cmp     ax,'no'                 ; word ON?
  1821.         je      setr6                   ; e = yes, go do it
  1822.         mov     si,offset rdbuf         ; convert text to number
  1823.         call    katoi                   ; number converter procedure, to ax
  1824.         jnc     setr1                   ; nc = success
  1825.         cmp     byte ptr temp+1,1       ; just one character given?
  1826.         jne     setr6                   ; ne = no, so bad code
  1827. setr1:  mov     min,ax                  ; save byte code here
  1828.         mov     dx,offset rdbuf         ; our work space
  1829.         mov     word ptr rdbuf,0        ; insert terminator
  1830. ;        mov     bx,offset srxhlp1       ; first help message
  1831.          mcmsgb   srxhlp1,csrxhlp1
  1832.         mov     ah,cmfile               ; parse a word
  1833.         call    comnd                   ; get incoming byte pattern
  1834.          ret
  1835.          nop
  1836.          nop
  1837.         or      ah,ah                   ; any text given?
  1838.         jz      setr6                   ; z = no
  1839.         mov     temp,ax                 ; save byte count here
  1840.         mov     si,offset rdbuf         ; convert text to number
  1841.         call    katoi                   ; number converter procedure
  1842.         jnc     setr3                   ; nc = success
  1843.         cmp     byte ptr temp+1,1       ; just one character given?
  1844.         jne     setr6                   ; ne = no, so bad code or ON/OFF
  1845. setr3:  mov     max,ax                  ; save byte code here
  1846.         mov     ah,cmcfm                ; get a confirm
  1847.         call    comnd
  1848.          ret                            ; no confirm
  1849.          nop
  1850.          nop
  1851.         mov     bx,min                  ; bl = incoming byte code
  1852.         xor     bh,bh
  1853.         mov     ax,max                  ; al = local (translated) byte code
  1854.         mov     rxtable [bx],al         ; store in rx translate table
  1855.         jmp     rskp
  1856.  
  1857. setr6:  mov     ah,cmcfm                ; get a confirm
  1858.         call    comnd
  1859.          ret
  1860.          nop
  1861.          nop
  1862. ;        mov     dx,offset badrx         ; assume bad construction
  1863.         mcmsg   badrx,cbadrx
  1864.         or      word ptr rdbuf,2020h    ; convert to lower case
  1865.         or      rdbuf+2,20h             ; first three chars
  1866.         cmp     word ptr rdbuf,'fo'     ; key word OFF?
  1867.         jne     setr8                   ; ne = no
  1868.         cmp     rdbuf+2,'f'             ; last letter of OFF?
  1869.         jne     setr8
  1870.         mov     rxtable+256,0           ; OFF is status byte = zero
  1871. ;        mov     dx,offset rxoffmsg      ; say translation is turned off
  1872.         mcmsg   rxoffmsg,crxoffmsg
  1873.         jmp     setr9
  1874. setr8:  cmp     word ptr rdbuf,'no'     ; keyword ON?
  1875.         jne     setr9a                  ; ne = no, error
  1876.         mov     rxtable+256,1           ; ON is status byte non-zero
  1877. ;        mov     dx,offset rxonmsg       ; say translation is turned on
  1878.         mcmsg   rxonmsg,crxonmsg
  1879. setr9:  cmp     intake,0                ; executing from a Take file?
  1880.         je      setr9a                  ; e = no
  1881.         cmp     flags.takflg,0          ; echo contents of Take file?
  1882.         je      setr10                  ; e = no
  1883. setr9a: mov     ah,prstr                ; bad number message
  1884.         int     dos
  1885. setr10: jmp     rskp
  1886. SETRX   ENDP
  1887.  
  1888. ; SHOW TRANSLATE-RECEIVE
  1889. ; Display characters being changed for Connect mode serial receive translator
  1890.  
  1891. SHORX   PROC    NEAR                    ; show translate table of incoming
  1892.                                         ; chars, only those changed
  1893.         mov     ah,cmcfm                ; get a confirm
  1894.         call    comnd
  1895.           ret                           ; no confirm
  1896.           nop
  1897.           nop
  1898.         mov     ah,prstr
  1899. ;        mov     dx,offset rxoffmsg      ; assume translation is off
  1900.         mcmsg   rxoffmsg,crxoffmsg
  1901.         cmp     rxtable+256,0           ; is translation off?
  1902.         je      shorx0                  ; e = yes
  1903. ;        mov     dx,offset rxonmsg       ; say translation is on
  1904.         mcmsg   rxonmsg,crxonmsg
  1905. shorx0: int     dos
  1906. ;        mov     dx,offset shormsg       ; give title line
  1907.          mcmsg   shormsg,cshormsg
  1908.         int     dos
  1909.         xor     cx,cx                   ; formatted line counter
  1910.         xor     bx,bx                   ; entry subscript
  1911. shorx1: cmp     rxtable[bx],bl          ; entry same as normal?
  1912.         je      shorx2                  ; e = yes, skip it
  1913.         call    shoprt                  ; print the entry
  1914. shorx2: inc     bx                      ; next entry
  1915.         cmp     bx,255                  ; done all entries yet?
  1916.         jbe     shorx1                  ; be = not yet
  1917.         mov     ah,prstr
  1918.         mov     dx,offset crlf          ; end with cr/lf
  1919.         int     dos
  1920.         jmp     rskp
  1921.  
  1922. shoprt: cmp     cx,4                    ; done five entries for this line?
  1923.         jb      shopr1                  ; b = no
  1924.         mov     ah,prstr
  1925.         mov     dx,offset crlf          ; break line now
  1926.         int     dos
  1927.         xor     cx,cx
  1928. shopr1: mov     ah,prstr
  1929.         mov     dx,offset shopm1        ; start of display
  1930.         int     dos
  1931.         xor     ah,ah
  1932.         mov     al,bl                   ; original byte code
  1933.         call    decout                  ; display its value
  1934.         mov     ah,prstr
  1935.         mov     dx,offset shopm2        ; intermediate part of display
  1936.         int     dos
  1937.         xor     ah,ah
  1938.         mov     al,rxtable[bx]          ; new byte code
  1939.         call    decout                  ; display its value
  1940.         mov     ah,prstr
  1941.         mov     dx,offset shopm3        ; last part of display
  1942.         int     dos
  1943.         inc     cx                      ; count item displayed
  1944.         ret
  1945. SHORX   ENDP
  1946.  
  1947. ; SHOW MACRO [macro name]
  1948.  
  1949. SHOMAC  PROC    NEAR
  1950.         mov     ah,cmfile
  1951.         mov     dx,offset rdbuf
  1952. ;        mov     bx,offset shmmsg
  1953.          mcmsgb   shmmsg,cshmmsg
  1954.         mov     comand.cmper,1          ; don't react to \%x variables
  1955.         call    comnd
  1956.          ret
  1957.          nop
  1958.          nop
  1959.         mov     al,ah
  1960.         mov     ah,0
  1961.         mov     shmcnt,ax               ; save length of user spec
  1962.         mov     ah,cmcfm
  1963.         call    comnd
  1964.          ret
  1965.          nop
  1966.          nop
  1967.         mov     si,offset mcctab        ; table of macro names
  1968.         cld
  1969.         lodsb
  1970.         mov     cl,al                   ; number of macro entries
  1971.         mov     ch,0
  1972.         jcxz    shom6                   ; z = none
  1973.         mov     temp,0                  ; count of macros displayed
  1974. shom2:  push    cx                      ; save loop counter
  1975.         lodsb                           ; length of macro name
  1976.         mov     ah,0
  1977.         mov     cx,shmcnt               ; length of user's string
  1978.         jcxz    shom4                   ; show all names
  1979.         cmp     al,cl                   ; mac name shorter that user spec?
  1980.         jb      shom5                   ; b = yes, no match
  1981.         push    ax
  1982.         push    si                      ; save these around match test
  1983.         mov     di,offset rdbuf         ; user's string
  1984. shom3:  mov     ah,[di]
  1985.         inc     di
  1986.         lodsb                           ; al = mac name char, ah = user char
  1987.         and     ax,not 2020h            ; clear bits (uppercase chars)
  1988.         cmp     ah,al                   ; same?
  1989.         loope   shom3                   ; while equal, do more
  1990.         pop     si                      ; restore regs
  1991.         pop     ax
  1992.         jne     shom5                   ; ne = no match
  1993. shom4:  call    shom9                   ; show this name
  1994. shom5:  add     si,ax                   ; no match, skip name
  1995.         add     si,3                    ; and '$', and string pointer
  1996.         pop     cx                      ; recover loop counter
  1997.         loop    shom2                   ; one less macro to examine
  1998.  
  1999.         cmp     temp,0                  ; did we show any macros?
  2000.         jne     shom7                   ; ne = yes
  2001. shom6:  mov     ah,prstr
  2002. ;        mov     dx,offset shom9m3       ; no entries found
  2003.         mcmsg   shom9m3,cshom9m3
  2004.         int     dos
  2005. shom7:  mov     ah,prstr                ; Summary line
  2006. ;        mov     dx,offset shom9m1       ; free space: name entries
  2007.         mcmsg   shom9m1,cshom9m1
  2008.         int     dos
  2009.         mov     ax,offset mcctab+mcclen
  2010.         sub     ax,mccptr               ; compute # of free name bytes
  2011.         call    decout
  2012.         mov     ah,prstr
  2013. ;        mov     dx,offset shom9m2       ; body characters
  2014.         mcmsg   shom9m2,cshom9m2
  2015.         int     dos
  2016.         mov     ax,offset macbuf+maclen
  2017.         sub     ax,macptr
  2018.         call    decout
  2019.         mov     ah,prstr
  2020.         mov     dx,offset crlf
  2021.         int     dos
  2022.         jmp     rskp                    ; return successfully to caller
  2023.  
  2024.                                         ; worker, show mac name and def
  2025. shom9:  push    ax                      ; call with si pointing at macro
  2026.         push    si                      ; name, byte ptr [si-1] = length
  2027.         cmp     byte ptr[si],0          ; name starts with null char?
  2028.         je      shom9e                  ; yes, TAKE file, ignore
  2029.         mov     ah,prstr
  2030.         mov     dx,offset crlfsp        ; go to new line
  2031.         int     dos
  2032.         inc     temp                    ; count displayed macros
  2033.         mov     dx,si                   ; Print macro name
  2034.         int     dos
  2035.         mov     dx,offset eqs           ; display equals sign
  2036.         int     dos
  2037.         mov     al,[si-1]               ; length of macro name
  2038.         mov     ah,0
  2039.         add     si,ax                   ; skip over name
  2040.         add     si,1                    ; skip '$' field
  2041.         mov     si,[si]                 ; si = offset of count + string
  2042.         mov     cl,byte ptr [si]        ; length of string
  2043.         mov     ch,0
  2044.         inc     si                      ; si = offset of string text proper
  2045. shom9a: lodsb                           ; get a byte into al
  2046.         cmp     al,' '                  ; control char?
  2047.         jae     shom9c                  ; ae = no
  2048.         cmp     al,cr                   ; carriage return?
  2049.         jne     shom9b                  ; ne = no
  2050.         mov     ah,prstr
  2051.         mov     dx,offset shom9m4       ; show <cr>
  2052.         int     dos
  2053.         cmp     cx,1                    ; more to show?
  2054.         je      shom9d                  ; e = no
  2055.         mov     dx,offset crlfsp        ; show cr,lf,space,space
  2056.         int     dos
  2057.         cmp     byte ptr[si],lf         ; cr followed by linefeed?
  2058.         jne     short shom9d
  2059.         inc     si                      ; skip the leading lf
  2060.         dec     cx
  2061.         jmp     short shom9d
  2062. shom9b: push    ax
  2063.         mov     ah,conout
  2064.         mov     dl,5eh                  ; caret
  2065.         int     dos
  2066.         pop     ax
  2067.         add     al,'A'-1                ; add offset to make printable letter
  2068. shom9c: mov     ah,conout
  2069.         mov     dl,al                   ; display it
  2070.         int     dos
  2071. shom9d: loop    shom9a                  ; do whole string
  2072. shom9e: pop     si
  2073.         pop     ax
  2074.         ret
  2075. SHOMAC  ENDP
  2076.  
  2077. SHCOM   PROC    NEAR                    ; Show Modem
  2078.         mov     ah,cmcfm
  2079.         call    comnd                   ; Get a confirm
  2080.          ret                            ; Didn't get a confirm
  2081.          nop
  2082.          nop
  2083.         mov     dx,offset crlf
  2084.         mov     ah,prstr
  2085.         int     dos                     ; print a crlf
  2086. ;        mov     bx,offset stcom         ; table of items to be shown
  2087.         mcmsgb  stcom,cstcom
  2088.         call    statc                   ; finish in common code
  2089.          nop
  2090.          nop
  2091.          nop
  2092.         call    shomodem
  2093.          nop
  2094.          nop
  2095.          nop
  2096.         jmp     rskp
  2097. SHCOM   ENDP
  2098. SHFILE  PROC    NEAR                    ; Show File
  2099.         mov     ah,cmcfm
  2100.         call    comnd                   ; Get a confirm
  2101.          ret                            ; Didn't get a confirm
  2102.          nop
  2103.          nop
  2104.         mov     dx,offset crlf
  2105.         mov     ah,prstr
  2106.         int     dos                     ; print a crlf
  2107. ;        mov     bx,offset stfile        ; table of items to be shown
  2108.         mcmsgb  stfile,cstfile
  2109.         jmp     statc                   ; finish in common code
  2110. SHFILE  ENDP
  2111.  
  2112. SHLOG   PROC    NEAR                    ; Show Log
  2113.         mov     ah,cmcfm
  2114.         call    comnd                   ; Get a confirm
  2115.          ret
  2116.          nop
  2117.          nop
  2118.         mov     dx,offset crlf
  2119.         mov     ah,prstr
  2120.         int     dos                     ; print a crlf
  2121. ;        mov     bx,offset stlog         ; table of items to be shown
  2122.         mcmsgb  stlog,cstlog
  2123.         jmp     statc                   ; finish in common code
  2124. SHLOG   ENDP
  2125. SHPRO   PROC    NEAR                    ; Show Protocol
  2126.         mov     ah,cmcfm
  2127.         call    comnd                   ; Get a confirm
  2128.          ret
  2129.          nop
  2130.          nop
  2131.         mov     dx,offset crlf
  2132.         mov     ah,prstr
  2133.         int     dos                     ; print a crlf
  2134. ;        mov     bx,offset stpro         ; table of items to be shown
  2135.         mcmsgb  stpro,cstpro
  2136.         jmp     statc                   ; finish in common code
  2137. SHPRO   ENDP
  2138. SHSCPT  PROC    NEAR                    ; Show Script
  2139.         mov     ah,cmcfm
  2140.         call    comnd                   ; Get a confirm
  2141.          ret
  2142.          nop
  2143.          nop
  2144.         mov     dx,offset crlf
  2145.         mov     ah,prstr
  2146.         int     dos                     ; print a crlf
  2147. ;        mov     bx,offset stscpt        ; table of items to be shown
  2148.         mcmsgb  stscpt,cstscpt
  2149.         jmp     statc                   ; finish in common code
  2150. SHSCPT  ENDP
  2151. SHSERV  PROC    NEAR                    ; Show Server
  2152.         mov     ah,cmcfm
  2153.         call    comnd                   ; Get a confirm
  2154.          ret
  2155.          nop
  2156.          nop
  2157.         mov     dx,offset crlf
  2158.         mov     ah,prstr
  2159.         int     dos                     ; print a crlf
  2160. ;        mov     bx,offset stserv2       ; do heartbeak item
  2161.         mcmsgb  stserv2,cstserv2
  2162.         call    statc
  2163.          nop
  2164.          nop
  2165.          nop
  2166.         mov     dx,offset crlf
  2167.         mov     ah,prstr
  2168.         int     dos
  2169. ;        mov     bx,offset stserv        ; table of items to be shown
  2170.         mcmsgb  stserv,cstserv
  2171.         jmp     statc                   ; finish in common code
  2172. SHSERV  ENDP
  2173.  
  2174. SHTERM  PROC    NEAR                    ; Show Terminal
  2175.         mov     ah,cmcfm
  2176.         call    comnd                   ; Get a confirm
  2177.          ret
  2178.          nop
  2179.          nop
  2180.         mov     dx,offset crlf
  2181.         mov     ah,prstr
  2182.         int     dos                     ; print a crlf
  2183. ;        mov     bx,offset stterm        ; table of items to be shown
  2184.         mcmsgb  stterm,cstterm
  2185.         jmp     statc                   ; use common code
  2186. SHTERM  ENDP
  2187.  
  2188. ; STATUS command. Revised by [jrd]
  2189.  
  2190. STATUS  PROC    NEAR
  2191.         mov     ah,cmcfm
  2192.         call    comnd                   ; Get a confirm
  2193.          ret
  2194.          nop
  2195.          nop
  2196.         mov     dx,offset crlf
  2197.         mov     ah,prstr
  2198.         int     dos                     ; print a crlf
  2199. STAT0:  call    cmblnk                  ; clear the screen
  2200.         call    locate                  ; home the cursor
  2201. ;        mov     bx,offset sttab         ; table to control printing
  2202.         mcmsgb  sttab,csttab
  2203.  
  2204. STATC:  push    es                      ; STAT0 is an external ref (in mster)
  2205.         push    di
  2206.         mov     cx,ds
  2207.         mov     es,cx
  2208.         cld
  2209.         xor     cx,cx                   ; column counter
  2210. stat1:  cmp     word ptr [bx],0         ; end of table?
  2211.         je      statx                   ; e = yes
  2212.         cld                             ; string direction is forward
  2213.         mov     di,offset rdbuf         ; point to destination buffer
  2214.         mov     byte ptr[di],spc        ; start with two spaces
  2215.         inc     di
  2216.         mov     byte ptr[di],spc
  2217.         inc     di
  2218.         push    cx                      ; save column number
  2219.         push    bx
  2220.         call    [bx].sttyp              ; call appropriate routine
  2221.         pop     bx
  2222.         pop     cx
  2223.         sub     di,offset rdbuf         ; number of bytes used
  2224.         add     cx,di                   ; new line col count
  2225.         push    cx                      ; save col number around print
  2226.         mov     cx,di                   ; how much to print now
  2227.         mov     di,offset rdbuf         ; source text
  2228.         cmp     cx,2                    ; nothing besides our two spaces?
  2229.         jbe     stat5                   ; e = yes, forget it
  2230.         call    prtscr                  ; print counted string
  2231. stat5:  pop     cx
  2232.         add     bx,size stent           ; look at next entry
  2233.         cmp     word ptr [bx],0         ; at end of table?
  2234.         je      statx                   ; e = yes
  2235.         cmp     cx,38                   ; place for second display?
  2236.         jbe     stat2                   ; be = only half full
  2237.         mov     dx,offset crlf          ; over half full. send cr/lf
  2238.         mov     ah,prstr
  2239.         int     dos
  2240.         xor     cx,cx                   ; say line is empty now
  2241.         jmp     stat1
  2242. stat2:  mov     ax,cx
  2243.         mov     cx,38                   ; where we want to be next time
  2244.         sub     cx,ax                   ; compute number of filler spaces
  2245.         or      cx,cx
  2246.         jle     stat4                   ; nothing to do
  2247.         mov     ah,conout
  2248.         mov     dl,' '
  2249. stat3:  int     dos                     ; fill with spaces
  2250.         loop    stat3                   ; do cx times
  2251. stat4:  mov     cx,38                   ; current column number
  2252.         jmp     stat1                   ; and do it
  2253. statx:  pop     di
  2254.         pop     es
  2255.         jmp     rskp
  2256. STATUS  ENDP
  2257.  
  2258. ; handler routines for status
  2259. ; all are called with di/ destination buffer, bx/ stat ptr. They can change
  2260. ; any register except es:, must update di to the end of the buffer.
  2261.  
  2262. ; copy the message into the buffer
  2263. stmsg   proc    near
  2264.         push    ds
  2265.         pop     es              ; ensure es points to datas segment
  2266.         mov     si,[bx].msg     ; get message address
  2267. stms1:  lodsb                   ; get a byte
  2268.         stosb                   ; drop it off
  2269.         cmp     al,'$'          ; end of message?
  2270.         jne     stms1           ; no, keep going
  2271.         dec     di              ; else back up ptr
  2272.         ret
  2273. stmsg   endp
  2274.  
  2275. ; get address of test value in stent. Returns address in si
  2276. stval   proc    near
  2277.         mov     si,[bx].basval  ; get base value
  2278.         cmp     si,0            ; any there?
  2279.         je      stva1           ; no, keep going
  2280.         mov     si,[si]         ; yes, use as base address
  2281. stva1:  add     si,[bx].tstcel  ; add offset of test cell
  2282.         ret                     ; and return it
  2283. stval   endp
  2284.  
  2285. ; print a single character
  2286. onechr  proc    near
  2287.         call    stmsg           ; copy message part first
  2288.         call    stval           ; pick up test value address
  2289.         mov     al,[si]         ; this is char to print
  2290.         cmp     al,' '          ; printable?
  2291.         jae     onech1          ; yes, keep going
  2292.         add     al,64           ; make printable
  2293.         mov     byte ptr [di],5eh       ; caret
  2294.         inc     di              ; note ctrl char
  2295. onech1: stosb                   ; drop char off
  2296.         ret
  2297. onechr  endp
  2298.  
  2299. ; numeric field
  2300. stnum   proc    near            ; for 8 bit numbers
  2301.         call    stmsg           ; copy message
  2302.         call    stval           ; pick up value address
  2303.         mov     al,[si]         ; get value
  2304.         mov     ah,0            ; high order is 0
  2305.         call    outnum          ; put number into buffer
  2306.         ret
  2307. stnum   endp
  2308.  
  2309. stlnum  proc    near            ; for 16 bit numbers [jrd]
  2310.         call    stmsg           ; copy message
  2311.         call    stval           ; pick up value address
  2312.         mov     ax,[si]         ; get value
  2313.         call    outnum          ; put number into buffer
  2314.         ret
  2315. stlnum  endp
  2316.  
  2317. ; Common routine for parsing numerical input
  2318. ; Enter with numhlp = offset of help message, numerr = offset of optional
  2319. ;  error message, min, max = allowable range of values.
  2320. ; Returns value in ax, or does parse error return.
  2321. ; Changes ax,bx,dx,si.                  [jrd] 18 Oct 1987
  2322. num0:   mov     dx,offset rdbuf+1       ; were to put text
  2323.         mov     word ptr rdbuf,0        ; clear the buffer
  2324.         mov     bx,numhlp               ; help text
  2325.         mov     ah,cmfile               ; get a word
  2326.         call    comnd
  2327.          ret
  2328.          nop
  2329.          nop
  2330.         mov     ah,cmcfm
  2331.         call    comnd                   ; Get a confirm
  2332.          ret
  2333.          nop
  2334.          nop
  2335.         mov     si,offset rdbuf+1
  2336.         cmp     rdbuf+1,'\'             ; already quoted?
  2337.         je      num0a                   ; e = yes
  2338.         mov     rdbuf,'\'               ; add a numerical quote
  2339.         dec     si                      ; point to our escape char
  2340. num0a:  call    katoi                   ; convert number in rdbuf
  2341.         jc      num0er                  ; c = no number, error
  2342.         cmp     ax,max                  ; largest permitted value
  2343.         ja      num0er                  ; a = error
  2344.         cmp     ax,min                  ; smallest permitted value
  2345.         jb      num0er                  ; b = error
  2346.         clc
  2347.         ret                             ; return value in ax
  2348.  
  2349. num0er: mov     ah,prstr
  2350.         mov     dx,numerr               ; comand-specific error message, if any
  2351.         cmp     dx,0                    ; was any given?
  2352.         je      num0e1                  ; e = no, use generic msg
  2353.         int     dos                     ; show given error message
  2354.         jmp     short num0e2
  2355. num0e1: 
  2356. ;       mov     dx,offset nummsg1       ; get address of numeric error message
  2357.         mcmsg   nummsg1,cnummsg1
  2358.         int     dos
  2359.         mov     ax,min                  ; smallest permitted number
  2360.         call    decout                  ; display decimal number in ax
  2361.         mov     ah,prstr
  2362. ;        mov     dx,offset nummsg2       ; "and"
  2363.         mcmsg   nummsg2,cnummsg2
  2364.         int     dos
  2365.         mov     ax,max                  ; largest permitted number
  2366.         call    decout
  2367. num0e2: stc
  2368.         ret
  2369. num0e3: mov     ah,prstr
  2370. ;        mov     dx,offset ermes7        ; say command not executed
  2371.          mcmsg   ermes7,cermes7
  2372.         int     dos
  2373.         stc
  2374.         ret
  2375.  
  2376. ; translate the number in ax
  2377. outnum  proc    near
  2378.         mov     dx,0
  2379.         mov     bx,10
  2380.         div     bx              ; divide to get digit
  2381.         push    dx              ; save remainder digit
  2382.         or      ax,ax           ; test quotient
  2383.         jz      outnu1          ; zero, no more of number
  2384.         call    outnum          ; else call for rest of number
  2385. outnu1: pop     ax              ; get digit back
  2386.         add     al,'0'          ; make printable
  2387.         stosb                   ; drop it off
  2388.         ret
  2389. outnum  endp
  2390.  
  2391. ; on/off field
  2392. onoff   proc    near
  2393.         call    stmsg           ; copy message
  2394.         call    stval           ; get value cell
  2395.         mov     al,[si]
  2396.         mov     si,offset onmsg
  2397.         mov     cx,2            ; assume 2-byte 'ON' message
  2398.         or      al,al           ; test value
  2399.         jnz     onof1           ; on, have right msg
  2400.         mov     si,offset offmsg
  2401.         mov     cx,3
  2402. onof1:  rep     movsb           ; copy right message in
  2403.         ret
  2404. onoff   endp
  2405.  
  2406. ; print first message if false, second if true
  2407. msg2    proc    near
  2408.         call    stval           ; get value cell
  2409.         mov     al,[si]
  2410.         mov     si,[bx].msg     ; assume off
  2411.         or      al,al           ; is it?
  2412.         jz      msg21           ; yes, continue
  2413.         mov     si,[bx].val2    ; else use alternate message
  2414. msg21:  jmp     stms1           ; handle copy and return
  2415. msg2    endp
  2416.  
  2417. ; search a keyword table for a value, print that value
  2418. srchkw  proc    near
  2419.         call    stmsg           ; first print message
  2420.         call    stval
  2421.         mov     al,[si]         ; get value to hunt for
  2422.         mov     ah,0            ; high order is 0
  2423.         mov     bx,[bx].val2    ; this is table address
  2424.         jmp     prttab          ; and look in table
  2425. srchkw  endp
  2426.  
  2427. ; search a keyword table for a bit value, print that value. [jrd]
  2428. srchkb  proc    near
  2429.         call    stmsg                   ; first print message
  2430.         call    stbval                  ; get bit set or reset
  2431.         mov     ah,0                    ; al has 0/1, high order is 0
  2432.         mov     bx,[bx].val2            ; this is table address
  2433.         jmp     prttab                  ; and look in table
  2434. srchkb  endp
  2435.  
  2436. ; get address of test value in stent.  Returns address in si. [jrd]
  2437. stbval  proc    near
  2438.         mov     si,[bx].basval          ; get address of test value
  2439.         cmp     si,0                    ; any there?
  2440.         je      stbva1                  ; no, quit with no match
  2441.         mov     ax,[si]                 ; get value
  2442.         test    ax,[bx].tstcel          ; bit test value against data word
  2443.         jz      stbva1                  ; z = they don't match
  2444.         mov     ax,1                    ;  match
  2445.         ret
  2446. stbva1: mov     ax,0                    ; no match
  2447.         ret                             ; and return it
  2448. stbval  endp
  2449.  
  2450.  
  2451. ; Print the drive name
  2452. drnum   proc    near
  2453.         call    stmsg           ; copy message part first
  2454.         call    stval           ; pick up test value address
  2455.         mov     ah,gcurdsk      ; Get current disk
  2456.         int     dos
  2457.         inc     al              ; We want 1 == A (not zero)
  2458.         mov     curdsk,al
  2459.         add     al,'@'          ; Make it printable
  2460.         cld
  2461.         stosb
  2462.         mov     word ptr [di],'\:'
  2463.         add     di,2            ; end with a colon and backslash
  2464.         mov     byte ptr [di],0 ; terminate in case drive is not ready
  2465.         mov     dl,0            ; get current drive
  2466.         mov     ah,gcd          ; get current directory
  2467.         mov     si,di           ; current working buffer position
  2468.         int     dos
  2469.         push    cx
  2470.         push    dx
  2471.         mov     dx,di           ; directory string
  2472.         call    strlen          ; length of path part to cx
  2473.         cmp     cx,26           ; too long to show the whole thing?
  2474.         jbe     drnum3          ; be = is ok, show the whole path
  2475.         push    di              ; scan backward for last backslash
  2476.         mov     al,'\'          ; thing to search for
  2477.         std                     ; backward
  2478.         mov     di,si           ; start of buffer
  2479.         add     di,cx           ; length of string
  2480.         repne   scasb           ; scan backward for a backslash
  2481.         jcxz    drnum2          ; should not happen, but then again
  2482.         repne   scasb           ; do again for second to last path part
  2483. drnum2: cld                     ; reset direction flag
  2484.         dec     di              ; move di two places preceding backslash
  2485.         mov     [di],'--'       ; insert a missing path indicator
  2486.         dec     di
  2487.         mov     byte ptr [di],'-'
  2488.         mov     si,di           ; we will show just this part
  2489.         pop     di              ; recover main status pointer
  2490. drnum3: pop     dx
  2491.         pop     cx
  2492.  
  2493. drnum4: lodsb                   ; copy until null terminator
  2494.         stosb
  2495.         cmp     al,0            ; end of string?
  2496.         jne     drnum4          ; ne = no
  2497.         dec     di              ; offset inc of stosb
  2498.         ret
  2499. drnum   endp
  2500.  
  2501.  
  2502. ; Print the screen-dump filename [jrd]
  2503.  
  2504. pasz    proc    near
  2505.         call    stmsg           ; copy message part
  2506.         mov     si,[bx].val2    ; address of asciiz string
  2507. pasz1:  lodsb                   ; get a byte
  2508.         cmp     al,0            ; at end yet?
  2509.         je      pasz2           ; e = yes
  2510.         stosb                   ; store in buffer
  2511.         jmp     short pasz1     ; keep storing non-null chars
  2512. pasz2:  ret
  2513. pasz    endp
  2514.  
  2515. ; print the End-of-Line characters
  2516. preol   proc    near
  2517.         call    stmsg           ; display leadin part of message
  2518.         mov     al,dtrans.seol  ; send eol char
  2519.         add     al,40H          ; make it printable
  2520.         stosb
  2521.         mov     si,offset mseol2 ; second part of message
  2522.         call    stms1           ; add that
  2523.         mov     al,trans.reol   ; receive eol char
  2524.         add     al,40H          ; make it printable
  2525.         stosb
  2526.         ret
  2527. preol   endp
  2528.  
  2529. ; print Send Delay and Pause
  2530. prsnd   proc    near
  2531.         call    stmsg           ; display leadin part of msg
  2532.         mov     al,trans.sdelay ; Send Delay (sec)
  2533.         xor     ah,ah
  2534.         call    outnum
  2535. ;        mov     si,offset sndmsg2 ; second part of msg
  2536.         mcmsgsi sndmsg2,csndmsg2
  2537.         call    stms1           ; add that
  2538.         mov     al,spause       ; Send Pause (millisec)
  2539.         call    outnum
  2540. ;        mov     si,offset sndmsg3 ; last part of msg
  2541.         mcmsgsi sndmsg3,csndmsg3
  2542.         call    stms1           ; add it too
  2543.         ret
  2544. prsnd   endp
  2545.  
  2546. ; Print the handshake
  2547. prhnd:  
  2548. ;       mov     si,offset handst        ; copy in initial message
  2549.         mcmsgsi handst,chandst
  2550.         call    stms1
  2551. ;        mov     si,offset nonmsg        ; assume no handshake
  2552.         mcmsgsi nonmsg,cnonmsg
  2553.         mov     bx,portval
  2554.         cmp     [bx].hndflg,0           ; Is handshaking in effect?
  2555.         jne     prh0                    ; Yes, print what we're using
  2556.         jmp     stms1                   ; no, say so and return
  2557. prh0:   mov     al,5eh                  ; Doing handshaking with control char
  2558.         stosb
  2559.         mov     al,[bx].hands
  2560.         add     al,40H                  ; Make printable
  2561.         stosb                           ; put in buffer
  2562.         ret                             ; and return
  2563.  
  2564. ; Print the pad character in AL
  2565. prpad:  cmp     al,127                  ; Are they using a delete?
  2566.         jne     prpad0
  2567.         mov     ah,prstr
  2568. ;        mov     dx,offset delmsg
  2569.         mcmsg   delmsg,cdelmsg
  2570.         int     dos
  2571.         ret
  2572. prpad0: mov     dl,5eh                  ; caret
  2573.         mov     ah,conout
  2574.         push    ax
  2575.         int     dos
  2576.         pop     ax
  2577.         mov     dl,al
  2578.         add     dl,40H                  ; Make printable
  2579.         int     dos
  2580.         ret
  2581.  
  2582. ; Print value from table.  BX/address of table, AL/value of variable
  2583. prttab: push    cx                      ; save column count
  2584.         mov     cl,[bx]                 ; Number of entries in our table
  2585.         inc     bx                      ; Point to the data
  2586. prtt0:  mov     dl,[bx]                 ; Length of keyword
  2587.         inc     bx                      ; Point to keyword
  2588.         mov     dh,0
  2589.         inc     dx                      ; Account for "$" in table
  2590.         mov     si,dx                   ; Put to index register
  2591.         cmp     ax,[bx+si]              ; Is this the one?
  2592.         je      prtt1
  2593.         add     bx,dx                   ; Go to end of keyword
  2594.         add     bx,2                    ; Point to next keyword
  2595.         dec     cl                      ; Any more keywords to check?
  2596.         jnz     prtt0                   ; Yes, go to it
  2597. ;        mov     bx,offset prterr
  2598.         mcmsgb  prterr,cprterr
  2599. prtt1:  mov     si,bx
  2600.         pop     cx                      ; recover column count
  2601.         jmp     stms1                   ; copy in message
  2602.  
  2603. ; Print the baud rate
  2604.  
  2605. BAUDPRT PROC     NEAR
  2606. ;        mov     si,offset baudrt        ; "Baud rate is"
  2607.         mcmsgsi baudrt,cbaudrt
  2608.         call    stms1                   ; display that part
  2609.         call    getbaud                 ; read baud rate first
  2610.         mov     bx,portval
  2611.         mov     ax,[bx].baud
  2612.         cmp     al,byte ptr bdtab       ; number of table entries
  2613.         jb      bdprt5                  ; b = in table
  2614. ;        mov     si,offset unrec         ; say unrecognized value
  2615.         mcmsgsi unrec,cunrec
  2616.         jmp     stms1                   ; display text and return
  2617. bdprt5: mov     bx,offset bdtab         ; show ascii rate from table
  2618.         call    prttab
  2619.         ret
  2620. BAUDPRT ENDP
  2621.  
  2622. ; display Take/Macro COUNT
  2623. stcnt   proc    near
  2624.         call    stmsg                   ; display leadin part of msg
  2625.         cmp     taklev,0                ; in a Take file or macro?
  2626.         jne     stcnt1                  ; ne = yes
  2627. ;        mov     si,offset nonemsg       ; say none
  2628.         mcmsgsi nonemsg,cnonemsg
  2629.         call    stms1
  2630.         ret
  2631. stcnt1: push    bx
  2632.         mov     bx,takadr               ; current Take structure
  2633.         mov     ax,[bx].takctr          ; get COUNT
  2634.         pop     bx
  2635.         call    outnum
  2636.         ret
  2637. stcnt   endp
  2638.  
  2639. ; ALARM time
  2640. stalr   proc    near
  2641.         call    stmsg                   ; display leading part of msg
  2642.         push    bx                      ; preserve register
  2643.         mov     bx,0                    ; position index
  2644. stalr1: push    bx                      ; save around calls
  2645.         cmp     alrhms[bx],10           ; two digits?
  2646.         jae     stalr2                  ; ae = yes
  2647.         mov     al,'0'
  2648.         stosb                           ; show leading zero
  2649. stalr2: mov     al,alrhms[bx]           ; show time component
  2650.         mov     ah,0
  2651.         call    outnum
  2652.         pop     bx                      ; recover index
  2653.         inc     bx
  2654.         cmp     bx,3                    ; done all fields?
  2655.         jae     stalr3                  ; ae = yes
  2656.         mov     al,':'
  2657.         stosb
  2658.         jmp     short stalr1            ; do next field
  2659. stalr3: pop     bx
  2660.         ret
  2661. stalr   endp
  2662.  
  2663. ; Jumping to this location is like retskp.    It assumes the instruction
  2664. ;    after the call is a jmp addr
  2665.  
  2666. RSKP    PROC    NEAR
  2667.         pop     bp
  2668.         add     bp,3
  2669.         push    bp
  2670.         ret
  2671. RSKP    ENDP
  2672.  
  2673. ; Jumping here is the same as a ret
  2674.  
  2675. R       PROC    NEAR
  2676.         ret
  2677. R       ENDP
  2678.  
  2679. ; routine to print an error message, then retskp
  2680. ; expects message in dx
  2681. reterr  proc    near
  2682.         mov     ah,prstr
  2683.         int     dos
  2684.         jmp     rskp
  2685. reterr  endp
  2686.  
  2687. code    ends
  2688. ;CHINESE2
  2689. ifdef   MSDOS
  2690.         include mssset2.dat
  2691. else
  2692.         include ccsset2.dat
  2693. endif
  2694.  
  2695. if1
  2696.         %out [End of pass 1]
  2697. else
  2698.         %out [End of assembly]
  2699. endif
  2700.         end
  2701.