home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / msk316src.zip / MSSSHO.ASM < prev    next >
Assembly Source File  |  1999-04-24  |  104KB  |  3,629 lines

  1.     name    msssho
  2. ; File MSSSHO.ASM
  3.     include mssdef.h
  4. ;    Copyright (C) 1982, 1999, Trustees of Columbia University in the 
  5. ;    City of New York.  The MS-DOS Kermit software may not be, in whole 
  6. ;    or in part, licensed or sold for profit as a software product itself,
  7. ;    nor may it be included in or distributed with commercial products
  8. ;    or otherwise distributed by commercial concerns to their clients 
  9. ;    or customers without written permission of the Office of Kermit 
  10. ;    Development and Distribution, Columbia University.  This copyright 
  11. ;    notice must not be removed, altered, or obscured.
  12. ;
  13. ; Show & Status commands
  14. ; Edit history
  15. ; 12 Jan 1995 version 3.14
  16. ; Last edit
  17. ; 12 Jan 1995
  18.  
  19.     public    shorx, shomac, shcom, shfile, shlog, shpro, shscpt, shserv
  20.     public    shterm, status, statc, stat0, srchkw, srchkww, srchkb, shmem
  21.     public    destab, seoftab, blktab, dmpname, lsesnam, lpktnam
  22.     public    ltranam, incstb, inactb, rxoffmsg, rxonmsg, lnout, lnouts
  23.     public    shosta, begtim, endtim, fsta, ssta    ; statistics procedures
  24.     public    rtmsg, rppos, stpos, rprpos, sppos, perpos, cxerr, frpos
  25.     public    fmtdsp, ermsg, msgmsg, init, cxmsg, intmsg, kbpr, perpr
  26.     public    winpr, windflag, pktsize, clrfln, oldkbt, oldper
  27.     public  wrpmsg, prttab, pasz, shovar, prnname, filekind, filecps
  28.     public    cntlsho, logtransact, shovarcps, sharray, streampr
  29.     public    ferbyte, ferdate, ferdisp, fertype, ferchar, fername, ferunk
  30.  
  31. mcclen    equ    macmax*10
  32.                 ; equates for screen positioning
  33.  
  34. ifndef    nls_portuguese
  35. scrser    equ    0109H        ; place for server state display line
  36. scrfln    equ    0216H        ; place for file name
  37. scrkind equ    0316h        ; Place for file kind
  38. scrpath equ    0416h        ; Place for current path
  39. scrkb    equ    0516H        ; Place for Kbytes transferred
  40. scrper    equ    0616H        ; Place for percentage transferred
  41.  
  42. scrst    equ    0816H        ; Place for status
  43. scrnp    equ    0a16H        ; Place for number of packets
  44. scrsz    equ    0b16h        ; packet size
  45. scrnrt  equ    0c16H        ; Place for number of retries
  46. screrr  equ    0d16H        ; Place for error msgs
  47. scrmsg    equ    0e16H        ; Last message position
  48. else
  49. scrser    equ    0106H        ; place for server state display line
  50. scrfln    equ    0216H        ; place for file name
  51. scrkind equ    0316h        ; Place for file kind
  52. scrpath equ    0416h        ; Place for current path
  53. scrkb    equ    0516H        ; Place for Kbytes transferred
  54.  
  55. scrper    equ    061aH        ; Place for percentage transferred
  56. scrst    equ    081aH        ; Place for status
  57. scrnp    equ    0a1aH        ; Place for number of packets
  58. scrsz    equ    0b1ah        ; packet size
  59. scrnrt  equ    0c1aH        ; Place for number of retries
  60. screrr  equ    0d1aH        ; Place for error msgs
  61. scrmsg    equ    0e1aH        ; Last message position
  62. endif    ; nls_portuguese
  63.  
  64. scrsp    equ    0f00H        ; Place for send packet
  65. scrrp    equ    1300H        ; Place for receive packet
  66. scrrpr    equ    1700H        ; Prompt when Kermit ends (does cr/lf)
  67. braceop    equ    7bh        ; opening curly brace
  68. bracecl    equ    7dh        ; closing curly brace
  69.  
  70. data    segment
  71.     extrn    termtb:byte, comptab:byte, portval:word,dtrans:byte,rdbuf:byte
  72.     extrn    trans:byte, curdsk:byte, flags:byte, maxtry:byte, comand:byte
  73.     extrn    spause:word, taklev:byte, takadr:word, alrhms:byte, bdtab:byte
  74.     extrn    denyflg:word, rxtable:byte, mcctab:byte, script:byte
  75.     extrn    errlev:byte, luser:byte, srvtmo:byte, mccptr:word, thsep:byte
  76.     extrn    scpbuflen:word, setchtab:byte, xfchtab:byte, xftyptab:byte
  77.     extrn    tfilsz:word, diskio:byte, tloghnd:word, dosnum:word
  78.     extrn    templp:byte, windused:byte, numpkt:word, verident:byte
  79.     extrn    decbuf:byte, flotab:byte, warntab:byte, valtab:byte
  80.     extrn    xfertab1:byte, xfertab2:byte, xfertab3:byte, outpace:word
  81.     extrn    winusedmax:byte, protlist:byte, takeerror:byte,macroerror:byte
  82.     extrn    abftab:byte, sndpathflg:byte, marray:word, rcvpathflg:byte
  83.     extrn    domath_ptr:word, domath_cnt:word, lastfsize:dword
  84.     extrn    crcword:word, streaming:byte, streamok:byte
  85.  
  86. crlf    db       cr,lf,'$'
  87. eqs    db    ' = $'
  88. spaces    db    '    $'
  89.  
  90. outlin1 db    6 dup (' '),'$'
  91. ;;;    version appears here
  92. ifndef    nls_portuguese
  93. outlin2 db    cr,lf
  94.         db      cr,lf,'           File name:'
  95.     db    cr,lf,'           File type:'
  96.     db    cr,lf,'        Current path:'
  97.         db      cr,lf,'  KBytes transferred:'
  98.         db      cr,lf
  99.         db      cr,lf
  100.         db      cr,lf,lf
  101.         db      cr,lf,'   Number of packets:'
  102.     db    cr,lf,'       Packet length:'
  103.         db      cr,lf,'   Number of retries: 0'
  104.         db      cr,lf,'          Last error:'
  105.         db      cr,lf,'        Last message:'
  106.         db      cr,lf,'$'
  107.  
  108. permsg    db    cr,' Percent transferred:$'
  109. perscale db    ': 0....1....2....3....4....5....6....7....8....9....10$'
  110. lastper    db    0
  111. cxzhlp    db    'X: cancel file, Z: cancel group, E: exit nicely,'
  112.     db    ' C: exit abruptly, Enter: retry$'
  113. blanks    db    10 dup (' '),'$'
  114. erword    db    cr,lf,'Error: $'
  115. msword    db    cr,lf,'Message: $'
  116. rtword    db    cr,lf,'Retry $'
  117. cxzser    db    cr,lf,' Type X to cancel file, Z to cancel group,'
  118.     db    cr,lf,' E to exit nicely, C to quit abruptly,'
  119.     db    cr,lf,' or Enter to retry',cr,lf,'$'
  120. windmsg    db    ' Window slots in use:$'
  121. windmsg2 db    ' of $'
  122. streammsg db    '           Streaming: Active$'
  123. else
  124.  
  125. outlin2 db    cr,lf 
  126.     db    cr,lf,'     Nome do arquivo:'
  127.     db    cr,lf,'     Tipo do arquivo:'
  128.     db    cr,lf,'      Percurso atual:' 
  129.     db    cr,lf,' KBytes transferidos:'
  130.     db    cr,lf
  131.     db    cr,lf
  132.     db    cr,lf,lf
  133.     db    cr,lf,'   Quantidade de pacotes:'
  134.     db    cr,lf,'       Tamanho do pacote:'
  135.     db    cr,lf,'           Re-tentativas: 0'
  136.     db    cr,lf,'             Ultimo erro:'
  137.     db    cr,lf,'         Ultima mensagem:'
  138.     db      cr,lf,'$'
  139.  
  140. permsg    db    cr,' Percentagem transferido:$'
  141. perscale db    ': 0....1....2....3....4....5....6....7....8....9....10$'
  142. lastper    db    0
  143. cxzhlp    db    'X: cancela arquivo, Z: cancela grupo, E: encerra elegantemente'
  144.     db    ' C: encerra abruptamente, Enter: re-tenta$'
  145. blanks    db    10 dup (' '),'$'
  146. erword    db    cr,lf,'Erro: $'
  147. msword    db    cr,lf,'Messagem: $'
  148. rtword    db    cr,lf,'Retenta $'
  149. cxzser    db    cr,lf,' X cancela arquivo, Z cancela grupo,'
  150.     db    cr,lf,' E cancela elegantemente, C encerra abruptamente,'
  151.     db    cr,lf,' Enter  re-tenta',cr,lf,'$'
  152. windmsg    db    '      Pacotes por janela:$'
  153. windmsg2 db    ' of $'
  154. streammsg db    '           Streaming: active$'
  155. endif    ; nls_portuguese
  156.  
  157. windflag db    0        ; flag to init windows msg, 0=none
  158. oldwind    db    -1        ; last windows in use value
  159. oldper    dw    0        ; old percentage
  160. oldkbt    dw    0        ; old KB transferred
  161. wrpmsg    db    0        ; non-zero if we wrote percent message
  162. fmtdsp    db    0        ; non-zero if formatted display in use
  163. prepksz    dw    0        ; previous packet size
  164. onehun    dw    100
  165. denom    dw    0
  166. temp    dw    0
  167. temp1    dw    0
  168. shmcnt    dw    0
  169. xfercps    dd    0
  170. sixteen    dw    16
  171.  
  172. ifndef    nls_portuguese
  173. infms1    db    'Server mode: type Control-C to exit',cr,lf,'$'
  174. infms7    db    'File interrupt',cr,lf,'$'
  175. infms8    db    'File group interrupt',cr,lf,'$'
  176. infms9    db    'User ',5eh,'  interrupt',cr,lf,'$'
  177. else
  178. infms1    db    'SModo servidor: digte Control-C para encerrar',cr,lf,'$'
  179. infms7    db    'Interrupcao de arquivo',cr,lf,'$'
  180. infms8    db    'Interrupcao de grupo de arquivo',cr,lf,'$'
  181. infms9    db    'Interrompido ',5eh,'  pelo usuario',cr,lf,'$'
  182. endif    ; nls_portuguese
  183.  
  184. partab    db    9
  185.     mkeyw    'none (8-bit data) ',PARNON
  186.     mkeyw    'even (7-bit data) ',PAREVN
  187.     mkeyw    'odd (7-bit data) ',PARODD
  188.     mkeyw    'mark (7-bit data) ',PARMRK
  189.     mkeyw    'space (7-bit data) ',PARSPC
  190.     mkeyw    'HARDWARE even (9-bit byte)',PAREVNH
  191.     mkeyw    'HARDWARE odd (9-bit byte)',PARODDH
  192.     mkeyw    'HARDWARE mark (9-bit byte)',PARMRKH
  193.     mkeyw    'HARDWARE space (9-bit byte)',PARSPCH
  194.  
  195. destab    db    3
  196.     mkeyw    'Disk',dest_disk
  197.     mkeyw    'Printer',dest_printer
  198.     mkeyw    'Screen',dest_screen
  199.  
  200. seoftab    db    2
  201.     mkeyw    'Ctrl-Z',1
  202.     mkeyw    'NoCtrl-Z',0
  203.  
  204. ; What type of block check to use
  205. blktab    db    4
  206.     mkeyw    '1-char-checksum',1
  207.     mkeyw    '2-char-checksum',2
  208.     mkeyw    '3-char-CRC-CCITT',3
  209.     mkeyw    'Blank-free-2','B'-'0'
  210.  
  211. modtab    db    3                ; Mode line status
  212.     mkeyw    'off',0
  213.     mkeyw    'on',1
  214.     mkeyw    'on (owned by host)',2
  215.  
  216. ontab    db    2
  217.     mkeyw    'off',0
  218.     mkeyw    'on',1
  219.  
  220. unkctab db    2            ; unknown character-set disposition
  221.     mkeyw    'keep',0
  222.     mkeyw    'cancel',1
  223.  
  224. logsta    db    8            ; Log Status table
  225.     mkeyw    'off',logoff        ; suspended or no logging
  226.     mkeyw    'Packet',logpkt
  227.     mkeyw    'Session',logses
  228.     mkeyw    'Packet+Session',logpkt+logses
  229.     mkeyw    'Transaction',logtrn
  230.     mkeyw    'Packet+Transaction',logpkt+logtrn
  231.     mkeyw    'Session+Transaction',logses+logtrn
  232.     mkeyw    'Packet+Session+Transaction',logpkt+logses+logtrn
  233.  
  234. dissta    db    6            ; Status of Display mode
  235.     mkeyw    'Quiet, 7-bit',dquiet
  236.     mkeyw    'Regular, 7-bit',dregular
  237.     mkeyw    'Serial, 7-bit',dserial
  238.     mkeyw    'Quiet, 8-bit',dquiet+d8bit
  239.     mkeyw    'Regular, 8-bit',dregular+d8bit
  240.     mkeyw    'Serial, 8-bit',dserial+d8bit
  241.  
  242. endistab db    2            ; Server ENABLE/DISABLE status
  243.     mkeyw    'enabled',0
  244.     mkeyw    'disabled',1
  245.  
  246. inactb    db    2                ; Set Input Timeout Action
  247.     mkeyw    'Proceed',0            ;[jrs]
  248.     mkeyw    'Quit',1            ;[jrs]
  249.  
  250. incstb    db    2                ;[jrs] Set Input Case
  251.     mkeyw    'Ignore',0
  252.     mkeyw    'Observe',1
  253.  
  254. pathtab    db    3            ; SET SEND/RECEIVE PATHNAMES
  255.     mkeyw    'off',0
  256.     mkeyw    'relative',1
  257.     mkeyw    'absolute',2
  258.  
  259.                 ; Statistics data storage area
  260. fsta    statinfo <>        ; for last operation values
  261. ssta    statinfo <>        ; for session values
  262. sflag    db    0        ; flag for send (1) or receive (0)
  263.                 ;   80h = begtim started
  264.  
  265. statmsg    db   cr,lf,lf,'                               Last Transfer         '
  266.     db    ' Entire Session'
  267.     db    cr,lf,'   Item                      Sent       Rec''d       '
  268.     db    ' Sent       Rec''d',cr,lf,'$'
  269. fchmsg    db    cr,lf,' File characters:    $'
  270. spmsg    db    cr,lf,' Comms port chars:   $'
  271. pktmsg    db    cr,lf,' Packets:            $'
  272. nakmsg    db    cr,lf,' NAKs:               $'
  273. retmsg    db    cr,lf,' Packet retries:     $'
  274. timemsg    db   cr,lf,lf,' Protocol time, secs:$'
  275. chpsmsg    db    cr,lf,' File characters/sec:$'
  276. spedmsg    db    cr,lf,' Comms port bits/sec:$'
  277. filemsg1 db    ' File chars/sec: $'
  278. filemsg2 db    '  Efficiency ($'
  279. filemsg3 db    ' b/s): $'
  280. sndmsg    db    'Sent ',0
  281. rcvmsg    db    'Recv ',0
  282. kind_text db    'TEXT$'
  283. kind_binary db    'BINARY$'
  284. date    db    '00:00:00 00 Jan 1980, ',0
  285. datelen    equ    $-date-1
  286. atmsg    db    cr,lf,'  at '
  287. atlen    equ    $-atmsg
  288. fasmsg    db    ' as '
  289. faslen    equ    $-fasmsg
  290. fsucmsg    db    'completed, ',0
  291. fbadmsg    db    'failed, ',0
  292. fintmsg    db    'interrupted',0
  293. bytesmsg db    'bytes: ',0
  294. streamstat db    ' Streaming used$'
  295.                 ; attributes msgs shared with msssen/mssrcv
  296. ferbyte    db    'file_size',0        ; '1' and '!'
  297. ferdate db    'date/time',0        ; '#'
  298. ferdisp    db    'file_disposition:',0    ; '+'
  299. fertype    db    'file_type',0        ; '"'
  300. ferchar    db    'transfer_char-set',0    ; '*'
  301. fername    db    'filename_collision',0     ; '?'
  302. ferunk    db    'unknown_reason',0    ; other attributes
  303. commamsg db    ', '
  304.  
  305. months    db    'JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP'
  306.     db    'OCT','NOV','DEC'
  307.     even
  308. tens    dd    1,10,100,1000,10000,100000,1000000,10000000,100000000
  309.     dd    1000000000
  310. tenslen    equ    ($-tens) / 4    ; number of double words in array tens
  311. lnoutsep db    0        ; non-zero to separate thousands in lnout
  312.                 ; end statistics data area
  313. sixty    dw    60
  314. ten    dw    10
  315.  
  316. logmsg    db    'Kind         Default filename          Status$'
  317. nologmsg db    '(not active)$'
  318. lsesmsg    db    'Session       (Session.log)$'
  319. lpktmsg    db    'Packets       (Packet.log)$'
  320. ltramsg    db    'Transactions  (Transact.log)$'
  321. dmpmsg    db    'Screen Dump, in Connect mode$'
  322. dmpmsg2    db    'Dump screen: $'    ; for general STATUS display
  323. prnmsg    db    'Printer name, in Connect mode: $'
  324. modst    db    'Mode-line: $'
  325. locst    db    'Local echo: $'
  326. duphlf    db    'Duplex: half$'
  327. dupful    db    'Duplex: full$'
  328. belon    db    'Ring bell after transfer$'
  329. beloff    db    'No bell after transfer$'
  330. vtemst    db    'Terminal type: $'        ; terminal emulator
  331. portst    db    'Communications port: $'
  332. capmsg    db    'Logging: $'
  333. eofmsg    db    'EOF mode: $'
  334. flost    db    'No flow control used$'
  335. floxmsg    db    'Flow control: xon/xoff $'
  336. flost1    db    'Flow control: $'
  337. handst    db    'Handshake character: $'
  338. destst    db    'Destination: $'
  339. xtypmsg    db    'File Type: $'
  340. xchmsg    db    'Transfer char-set: $'
  341. xchmsg1    db    'Transfer locking-shift: $'
  342. xchmsg2    db    'Transfer translation: $'
  343. xchmsg3 db    'Transfer mode sensing: $'
  344. xcrcmsg    db    'Transfer CRC: $'
  345. chmsg    db    'File char set: $'
  346. unkmsg    db    'Unknown-char-set: $'
  347. diskst    db    'Dir: $'
  348. blokst    db    'Block check used: $'
  349. sqcst    db    'Send control char prefix: $'
  350. rqcst    db    'Receive control char prefix: $'
  351. debon    db    'Debug: $'
  352. flwon    db    'Collision (file name): $'
  353. parmsg    db    'Parity: $'
  354. abfst    db    'Incomplete file: $'
  355. repst    db    'Repeat count char: $'
  356. rptqena db    '  on',0            ; Repeat count enable/disable
  357. rptqdis db    '  off',0            ; which much be ASCIIZ
  358. sndmsg1    db    'Send Delay: $'
  359. sndmsg2    db    ' sec, Pause: $'
  360. sndmsg3    db    ' ms$'
  361. msohst    db    'Start-of-Packet char S: ',5eh,'$'
  362. meolst    db    'End-of-Packet char   S: ',5eh,'$'
  363. msrec    db    '  R: ',5eh,'$'
  364. msrecv    db    '  R: $'
  365. tmost    db    'Timeout (seconds)    S: $'
  366. stimst    db    'Send timeout (seconds): $'
  367. rtimst    db    'Receive timeout (seconds): $'
  368. spakst    db    'Send packet size (maximum): $'
  369. rpakst    db    'Receive packet size (maximum): $'
  370. spakst1    db    'Send packet size (current): $'
  371. rpakst1    db    'Receive packet size (current): $'
  372. snpdst    db    'Number of padding chars S: $'
  373. spadst    db    'Padding char S: ',5eh,'$'
  374. retrymsg db    'Retry send/receive packet limit: $'
  375. swinst    db    'Sliding window slots (max): $'
  376. strmmsg db    'Streaming: $'
  377. dispst    db    'Display: $'
  378. timmsg    db    'Timer: $'
  379. srvmsg    db    'Timeout (sec) waiting for a transaction: $'
  380. dblmsg    db    'Send double-char: $'
  381. escmes    db    'Escape character: $'
  382. exitmes    db    'Exit warning: $'
  383. scpmsg    db    'Script commands Echo, If, Input, Minput, Output, Pause,'
  384.     db    ' Reinput,'
  385.     db    cr,lf,'   Transmit, and Wait$'
  386. sechmsg    db    'Input echoing: $'
  387. sfiltmsg db    'Filter-echo: $'
  388. scasmsg    db    'Case sensitivity: $'
  389. stmo1msg db    'Timeout (seconds): $'
  390. stmo2msg db    'Timeout-action: $'
  391. sxfilmsg db    'Transmit fill-empty-line: $'
  392. sxlfmsg db    'Transmit line-feeds-sent: $'
  393. sxpmtmsg db    'Transmit prompt character: $'
  394. sxpaumsg db    'Transmit pause (millisec): $'
  395. stbufmsg db    'INPUT-buffer-length: $'
  396. stinbmsg db    'INPUT-BUFFER follows:$'
  397. opacemsg db    'Output Pacing (millisec): $'
  398. takecmsg db    'Take echo: $'
  399. takermsg db    'Take error: $'
  400. macermsg db    'Macro error: $'
  401. atton    db    'Attributes packets: $'
  402. sachmsg    db    '  Character-set: $'
  403. sadtmsg    db    '  Date-Time: $'
  404. salnmsg    db    '  Length: $'
  405. satymsg    db    '  Type: $'
  406. baudrt    db    'Speed: $'
  407. unrec    db    'unknown$'
  408. kbdmsg    db    'Keyboard translation: $'
  409. stcntmsg db    'Take/Macro COUNT: $'
  410. stargmsg db    'Take/Macro ARGC: $'
  411. nonemsg    db    'not active$'
  412. sterlmsg db    'Errorlevel: $'
  413. stalrmsg db    'Alarm time: $'
  414. lusrmsg    db    'Login Username: $'
  415. ssndmsg    db    'Send pathnames: $'
  416. srcvmsg    db    'Receive pathnames: $'
  417. servmsg    db    'Server commands available to remote user: $'
  418. sdefmsg    db    'ASSIGN: $'
  419. sbyemsg    db    'BYE:    $'
  420. scwdmsg    db    'CD/CWD: $'
  421. sdelmsg    db    'DELETE: $'
  422. sdirmsg    db    'DIR:    $'
  423. sfinmsg    db    'FINISH: $'
  424. sgetmsg    db    'GET:    $'
  425. shstmsg    db    'HOST:   $'
  426. skermsg    db    'KERMIT: $'
  427. slogmsg    db    'LOGIN:  $'
  428. smsgmsg    db    'MESSAGE:$'
  429. sprtmsg    db    'PRINT:  $'
  430. sqrymsg    db    'QUERY:  $'
  431. sretmsg    db    'RETRIEVE: $'
  432. sspcmsg    db    'SPACE:  $'
  433. stypmsg    db    'TYPE:   $'
  434. stekmsg    db    'Term Tek4010 (auto-entry): $'
  435. nonmsg    db    'none$'
  436. onmsg    db    'on'
  437. offmsg    db    'off'
  438. moremsg    db    cr,lf,'-- More -- press space for more,'
  439.     db    ' q or Control-C to quit. $'
  440. rxoffmsg db    cr,lf,'  Input Translation is off$'
  441. rxonmsg    db    cr,lf,'  Input Translation is on$'
  442.  
  443. shormsg    db    cr,lf,'  Translation table of received byte codes while'
  444.     db    ' in CONNECT mode -'
  445.     db    cr,lf,'  Format: [received byte (decimal) -> local byte'
  446.     db    ' (decimal)]',cr,lf,'$'
  447. shopm1    db    ' [\$'            ; Show Translation material
  448. shopm2    db    ' -> \$'
  449. shopm3    db    '] $'
  450. shom9m1    db    cr,lf,' Free space (bytes) for names: $'
  451. shom9m3    db    cr,lf,' No macro(s)$'
  452. memmsg1    db    cr,lf,' DOS free memory (bytes):$'
  453. memmsg2    db    cr,lf,' Total free bytes: $'
  454. varstng    db    ' \v($'
  455. cntlmsg1 db    cr,lf,lf,' Unprefixed control codes (sent as-is without'
  456.     db    ' protective prefixing):',cr,lf,' $'
  457. cntlmsg2 db    cr,lf,lf,' Prefixed control codes (includes 127, 255, and'
  458.     db    ' packet start/end):',cr,lf,' $'
  459. prterr    db    '?Unrecognized value$'
  460. lpktnam    db    'Packet.log',54 dup (0)    ; default packet log filename
  461. lsesnam    db    'Session.log',54 dup (0); default capture/session filename
  462. ltranam    db    'Transact.log',52 dup (0); default transaction log filename
  463. dmpname    db    'Kermit.scn',54 dup (0)    ; file name for screen dumps
  464. prnname    db    'PRN',61 dup (0)    ; file name for printer
  465. fsharr1    db    cr,lf,'Declared arrays:',cr,lf,'$'
  466. fsharr2    db    ']',cr,lf,'$'
  467.     even
  468. stent    struc            ; structure for status information table sttab
  469. sttyp    dw    ?        ; type (actually routine to call)
  470. msg    dw    ?        ; message to print
  471. val2    dw    ?        ; needed value: another message, or tbl addr
  472. tstcel    dw    ?        ; address of cell to test, in data segment
  473. basval    dw    0        ; base value, if non-zero
  474. stent    ends
  475.  
  476. sttab    stent    <baudprt>                ; STATUS
  477.     stent    <srchkww,vtemst,termtb,flags.vtflg>    ; terminal emulator
  478.     stent    <srchkw,portst,comptab,flags.comflg>
  479.     stent    <srchkw,modst,modtab,flags.modflg>
  480.     stent    <srchkw,parmsg,partab,parflg,portval>
  481.     stent    <stlnum,spakst,,dtrans.slong>
  482.     stent    <onoff,locst,,ecoflg,portval>
  483.     stent    <stlnum,rpakst,,dtrans.rlong>
  484.     stent    <srchkw,flost1,flotab,floflg,portval>
  485.     stent    <prsar,msohst,msrec,trans.ssoh,trans.rsoh>
  486.     stent    <prhnd>
  487.     stent    <prsar,meolst,msrec,trans.seol,trans.reol>
  488.     stent    <msg2,dupful,duphlf,duplex,portval>
  489.     stent    <prsarv,tmost,msrecv,dtrans.stime,trans.rtime>
  490.     stent    <drnum,diskst,,curdsk>
  491.     stent    <stnum,retrymsg,,maxtry>
  492.     stent    <srchkw,flwon,warntab,flags.flwflg>
  493.     stent    <srchkw,blokst,blktab,dtrans.chklen>
  494.     stent    <srchkw,destst,destab,flags.destflg>
  495.     stent    <srchkw,capmsg,logsta,flags.capflg>
  496.     stent    <srchkw,abfst,abftab,flags.abfflg>
  497.     stent    <srchkw,debon,logsta,flags.debug>
  498.     stent    <srchkw,dispst,dissta,flags.remflg>
  499.     stent    <onoff,timmsg,,flags.timflg>
  500.     stent    <onechr,escmes,,trans.escchr>
  501.     stent    <srchkw,kbdmsg,ontab,flags.xltkbd>
  502. ;;;    stent    <vtstat>
  503.     dw    0                ; end of table
  504.  
  505. stcom    stent    <srchkw,portst,comptab,flags.comflg>    ; SHOW COMMS
  506.     stent    <baudprt>
  507.     stent    <onoff,locst,,ecoflg,portval>
  508.     stent    <srchkw,parmsg,partab,parflg,portval>
  509.     stent    <prhnd>
  510.     stent    <srchkw,flost1,flotab,floflg,portval>
  511.     stent    <msg2,dupful,duphlf,duplex,portval>
  512.     stent    <srchkw,dispst,dissta,flags.remflg>
  513.     stent    <srchkw,debon,logsta,flags.debug>
  514.     stent    <srchkw,exitmes,ontab,flags.exitwarn>
  515.     dw    0
  516.  
  517. stfile    stent    <drnum,diskst,,curdsk>            ; SHOW FILE
  518.     stent    <srchkw,abfst,abftab,flags.abfflg>
  519.     stent    <srchkw,destst,destab,flags.destflg>
  520.     stent    <srchkw,flwon,warntab,flags.flwflg>
  521.     stent    <srchkw,eofmsg,seoftab,flags.eofcz>
  522.     stent    <srchkww,chmsg,setchtab,flags.chrset>
  523.     stent    <srchkw,xtypmsg,xftyptab,dtrans.xtype>
  524.     stent    <srchkw,xchmsg,xfchtab,dtrans.xchset>
  525.     stent    <msg2,beloff,belon,flags.belflg>
  526.     stent    <srchkw,xchmsg2,xfertab2,dtrans.xchri>
  527.     stent    <stmsg,atton>
  528.     stent    <srchkw,xchmsg1,xfertab1,dtrans.lshift>
  529.     stent    <srchkb,sachmsg,ontab,attchr,flags.attflg>
  530.     stent    <srchkw,unkmsg,unkctab,flags.unkchs>
  531.     stent    <srchkb,sadtmsg,ontab,attdate,flags.attflg>
  532.     stent    <stmsg,spaces>
  533.     stent    <srchkb,salnmsg,ontab,attlen,flags.attflg>
  534.     stent    <stmsg,spaces>
  535.     stent    <srchkb,satymsg,ontab,atttype,flags.attflg>
  536.     dw    0
  537.  
  538. stlog    stent    <stmsg,logmsg>                ; SHOW LOG
  539.     stent    <stmsg,lpktmsg>
  540.     stent    <msg2b,nologmsg,lpktnam,logpkt,flags.capflg>
  541.     stent    <stmsg,lsesmsg>
  542.     stent    <msg2b,nologmsg,lsesnam,logses,flags.capflg>
  543.     stent    <stmsg,ltramsg>
  544.     stent    <msg2b,nologmsg,ltranam,logtrn,flags.capflg>
  545.     stent    <stmsg,dmpmsg>
  546.     stent    <stmsg,dmpname>
  547.     stent    <stmsg,prnmsg>
  548.     stent    <stmsg,prnname>
  549.     dw    0
  550.  
  551. stpro    stent    <stlnum,spakst,,dtrans.slong>        ; SHOW PROTOCOL
  552.     stent    <stlnum,rpakst,,dtrans.rlong>
  553.     stent    <stlnum,spakst1,,trans.slong>
  554.     stent    <stlnum,rpakst1,,trans.rlong>
  555.     stent    <stnum,stimst,,dtrans.stime>
  556.     stent    <stnum,rtimst,,trans.rtime>
  557.     stent    <onechr,sqcst,,dtrans.squote>
  558.     stent    <onechr,rqcst,,trans.rquote>
  559.     stent    <srchkw,ssndmsg,pathtab,sndpathflg>
  560.     stent    <srchkw,srcvmsg,pathtab,rcvpathflg>
  561.     stent    <prsar,msohst,msrec,trans.ssoh,trans.rsoh>
  562.     stent    <prsarv,snpdst,msrecv,dtrans.spad,trans.rpad>
  563.     stent    <prsar,meolst,msrec,trans.seol,trans.reol>
  564.     stent    <prsar,spadst,msrec,dtrans.spadch,trans.rpadch>
  565.     stent    <onechr,dblmsg,,dtrans.sdbl>
  566.     stent    <rptstat,repst>
  567.     stent    <prsnd,sndmsg1>
  568.     stent    <srchkw,blokst,blktab,dtrans.chklen>
  569.     stent    <stnum,retrymsg,,maxtry>
  570.     stent    <stnum,swinst,,dtrans.windo>
  571.     stent    <prhnd>
  572.     stent    <srchkw,strmmsg,ontab,streaming>
  573.     stent    <onoff,timmsg,,flags.timflg>
  574.     stent    <srchkw,xtypmsg,xftyptab,dtrans.xtype>
  575.     stent    <srchkw,capmsg,logsta,flags.capflg>
  576.     stent    <srchkw,xtypmsg,xftyptab,dtrans.xtype>
  577.     stent    <srchkw,debon,logsta,flags.debug>
  578.     stent    <srchkww,chmsg,setchtab,flags.chrset>
  579.     stent    <stmsg,atton>
  580.     stent    <srchkw,xchmsg,xfchtab,dtrans.xchset>
  581.     stent    <srchkb,sachmsg,ontab,attchr,flags.attflg>
  582.     stent    <srchkw,xchmsg2,xfertab2,dtrans.xchri>
  583.     stent    <srchkb,sadtmsg,ontab,attdate,flags.attflg>
  584.     stent    <srchkw,xchmsg1,xfertab1,dtrans.lshift>
  585.     stent    <srchkb,salnmsg,ontab,attlen,flags.attflg>
  586.     stent    <srchkw,xchmsg3,xfertab3,dtrans.xmode>
  587.     stent    <srchkb,satymsg,ontab,atttype,flags.attflg>
  588.     stent    <srchkw,xcrcmsg,ontab,dtrans.xcrc>
  589.     dw    0
  590.  
  591. stscpt    stent    <stmsg,scpmsg>                ; SHOW SCRIPT
  592.     stent    <onoff,sechmsg,,script.inecho>
  593.     stent    <srchkw,scasmsg,incstb,script.incasv>
  594.     stent    <onoff,sfiltmsg,,script.infilter>
  595.     stent    <stalr,stalrmsg>
  596.     stent    <srchkw,stmo2msg,inactb,script.inactv>
  597.     stent    <stlnum,stmo1msg,,script.indfto>
  598.     stent    <prfil>
  599.     stent    <starg,stargmsg>
  600.     stent    <onoff,sxlfmsg,,script.xmitlf>
  601.     stent    <stcnt,stcntmsg>
  602.     stent    <stlnum,sxpaumsg,,script.xmitpause>
  603.     stent    <srchkw,takecmsg,ontab,flags.takflg>
  604.     stent    <onechr,sxpmtmsg,,script.xmitpmt>
  605.     stent    <srchkw,takermsg,ontab,takeerror>
  606.     stent    <stlnum,opacemsg,,outpace>
  607.     stent    <srchkw,macermsg,ontab,macroerror>
  608.     stent    <stlnum,stbufmsg,,scpbuflen>
  609.     stent    <stnum,sterlmsg,,errlev>
  610.     stent    <stmsg,stinbmsg>
  611.     stent    <stinbuf>
  612.     dw    0
  613.  
  614. stserv    stent    <pasz,lusrmsg,offset luser>        ; SHOW SERVER
  615.     stent    <stmsg,servmsg>
  616.     stent    <srchkb,sdefmsg,endistab,defflg,denyflg>
  617.     stent    <srchkb,skermsg,endistab,kerflg,denyflg>
  618.     stent    <srchkb,sbyemsg,endistab,byeflg,denyflg>
  619.     stent    <srchkb,slogmsg,endistab,pasflg,denyflg>
  620.     stent    <srchkb,scwdmsg,endistab,cwdflg,denyflg>
  621.     stent    <srchkb,smsgmsg,endistab,sndflg,denyflg>
  622.     stent    <srchkb,sdelmsg,endistab,delflg,denyflg>
  623.     stent    <srchkb,sprtmsg,endistab,prtflg,denyflg>
  624.     stent    <srchkb,sdirmsg,endistab,dirflg,denyflg>
  625.     stent    <srchkb,sqrymsg,endistab,qryflg,denyflg>
  626.     stent    <srchkb,sfinmsg,endistab,finflg,denyflg>
  627.     stent    <srchkb,sretmsg,endistab,retflg,denyflg>
  628.     stent    <srchkb,sgetmsg,endistab,getsflg,denyflg>
  629. ;; OLD    stent    <srchkb,sspcmsg,endistab,spcflg,denyflg>
  630.     stent    <srchkb,stypmsg,endistab,typflg,denyflg>
  631.     stent    <srchkb,shstmsg,endistab,hostflg,denyflg>
  632.     dw    0
  633. stserv2    stent    <stnum,srvmsg,,srvtmo>
  634.     dw    0
  635. ifndef    no_terminal
  636. stterm    stent    <srchkww,vtemst,termtb,flags.vtflg>    ; SHOW TERMINAL
  637.     stent    <srchkw,dispst,dissta,flags.remflg>
  638.     stent    <srchkw,modst,modtab,flags.modflg>
  639.     stent    <onechr,escmes,,trans.escchr>
  640. ifndef    no_graphics
  641.     stent    <srchkb,stekmsg,endistab,tekxflg,denyflg>
  642. endif    ; no_graphics
  643.     stent    <srchkw,kbdmsg,ontab,flags.xltkbd>
  644.     stent    <vtstat>
  645.     dw    0
  646. endif    ; no_terminal
  647.  
  648. shorxk    stent    <srchkw,kbdmsg,ontab,flags.xltkbd>
  649.     stent    <stmsg,spaces>
  650.     dw    0
  651. data    ends
  652.  
  653. data1    segment
  654. shmmsg    db    ' name of macro, or press ENTER to see all$'
  655. shvmsg    db    ' name of \v(name) variable, or press ENTER to see all$'
  656. data1    ends
  657.  
  658. code1    segment
  659.     extrn    fwrtdir:far, fcsrtype:far, prtscr:far, strlen:far
  660.     extrn    prtasz:far, dec2di:far, domath:far, decout:far
  661.     extrn    buflog:far
  662. code1    ends
  663.  
  664. code    segment
  665.     extrn    comnd:near, locate:near
  666.     extrn    getbaud:near, vtstat:near, shomodem:near, nvaltoa:near
  667.     extrn    cmblnk:near, putmod:near, clrmod:near
  668.     extrn    poscur:near, clearl:near, nout:near, dodec:near
  669. ifndef    no_network
  670.     extrn    shownet:near
  671. endif    ; no_network
  672.  
  673.     assume    cs:code, ds:data, es:nothing
  674.  
  675. flnout    proc    far
  676.     call    lnout
  677.     ret
  678. flnout    endp
  679. flnouts    proc    far
  680.     call    lnouts
  681.     ret
  682. flnouts    endp
  683. fnvaltoa proc    far
  684.     call    nvaltoa
  685.     ret
  686. fnvaltoa endp
  687. fclearl    proc    far
  688.     call    clearl
  689.     ret
  690. fclearl    endp
  691. fposcur    proc    far
  692.     call    poscur
  693.     ret
  694. fposcur    endp
  695. ; Display asciiz message pointed to by DS:DX on Last error line
  696. ERMSG    PROC    NEAR
  697.     test    flags.remflg,dquiet    ; quiet screen?
  698.     jnz    ermsgx            ; nz = yes
  699.     push    si            ; position cursor to Last Error line
  700.     push    dx            ; save preexisting message pointer
  701.     test    flags.remflg,dserial    ; serial mode display?
  702.     jnz    erpo1            ; nz = yes
  703.     cmp    fmtdsp,0        ; formatted display?
  704.     jne    erpo2            ; ne = yes
  705. erpo1:    mov    ah,prstr
  706.     mov    dx,offset erword    ; put out word Error:
  707.     int    dos
  708.     jmp    short erpo3
  709. erpo2:    mov    dx,screrr
  710.     call    poscur
  711.     call    clearl            ; clear the line
  712. erpo3:    pop    dx            ; restore old pointer
  713.     mov    si,dx            ; string pointer
  714.     mov    cx,10            ; try ten items
  715.     cld
  716. ermsg1:    lodsb
  717.     cmp    al,' '            ; strip these leading spaces
  718.     loope    ermsg1
  719.     dec    si            ; backup to non-space
  720.     push    dx            ; preserve caller's dx
  721.     mov    dx,si
  722.     call    prtasz            ; display asciiz message
  723.     pop    dx
  724.     pop    si
  725. ermsgx:    ret
  726. ERMSG    ENDP
  727.  
  728. ; Decode and display Message packet pointed to by SI.
  729. MSGMSG    PROC    NEAR
  730.     mov    decbuf,0        ; clear output buffer for rem query
  731.     call    dodec            ; decode to decbuf, SI is pktinfo ptr
  732.     test    flags.remflg,dquiet    ; quiet screen?
  733.     jnz    msgmsgx            ; nz = yes
  734.     cmp    [si].datlen,0        ; anything present?
  735.     je    msgmsgx            ; e = no
  736.     test    flags.remflg,dserial    ; serial mode display?
  737.     jnz    msgms1            ; nz = yes
  738.     cmp    fmtdsp,0        ; formatted display?
  739.     jne    msgms2            ; ne = yes
  740.     cmp    flags.xflg,0        ; packet header seen?
  741.     je    msgms2            ; e = no
  742. msgms1:    mov    ah,prstr
  743.     mov    dx,offset msword    ; put out word Message:
  744.     int    dos
  745.     jmp    short msgms3        ; display the message
  746. msgms2:    push    si
  747.     mov    dx,scrmsg        ; Last message line
  748.     call    poscur
  749.     call    clearl            ; clear the line
  750.     pop    si
  751. msgms3:    mov    dx,offset decbuf    ; final error message string, asciiz
  752.     call    prtasz            ; display asciiz message
  753. msgmsgx:ret
  754. MSGMSG    ENDP
  755.  
  756. ; Show number of retries message
  757.  
  758. RTMSG    PROC     NEAR
  759.     test    flags.remflg,dquiet    ; quiet display mode?
  760.     jnz    rtmsx            ; nz = yes
  761.     test    flags.remflg,dserver    ; in server mode?
  762.     jnz    rtms0            ; nz = yes
  763.     cmp    flags.xflg,0        ; receiving to screen?
  764.     jne    rtmsx            ; ne = yes
  765.     cmp    fmtdsp,0        ; formatted display?
  766.     je    rtms1            ; e = no, do as normal
  767. rtms0:    test    flags.remflg,dserial    ; serial mode display?
  768.     jnz    rtms1            ; nz = yes
  769.     push    ax
  770.     push    dx
  771.     push    si
  772.     mov    dx,scrnrt
  773.     call    poscur
  774.     call    clearl
  775.     pop    si
  776.     jmp    short rtms3
  777. rtms1:    push    ax
  778.     push    dx
  779.     mov    dx,offset rtword    ; display word Retry
  780.     mov    ah,prstr
  781.     int    dos
  782. rtms3:    mov    ax,fsta.pretry        ; number of retries
  783.     call    decout            ; write the number of group retries
  784.     pop    dx
  785.     pop    ax
  786. rtmsx:    ret
  787. RTMSG    ENDP
  788.  
  789. ; Reassure user that we acknowledge his ^X/^Z
  790.  
  791. INTMSG    PROC    NEAR
  792.     cmp    flags.cxzflg,0        ; anything there?
  793.     je    int1            ; e = no
  794.     test    flags.remflg,dserver    ; server mode?
  795.     jnz    int4            ; nz = yes
  796.     cmp    flags.xflg,0        ; writing to screen?
  797.     jne    int1            ; ne = yes, nothing to do
  798. int4:    test    flags.remflg,dquiet    ; quiet screen?
  799.     jnz    int1            ; yes, suppress msg
  800.     test    flags.remflg,dserial    ; serial mode display?
  801.     jz    int2            ; z = no
  802.     cmp    fmtdsp,0        ; formatted screen?
  803.     jne    int2            ; ne = yes
  804.     mov    dx,offset crlf        ; output initial cr/lf
  805.     mov    ah,prstr
  806.     int    dos
  807.     jmp    short int3        ; display the message
  808. int2:    mov    dx,scrmsg        ; last message position
  809.     call    poscur
  810.     call    clearl
  811. int3:    mov    dx,offset infms7    ; File interrupted
  812.     cmp    flags.cxzflg,'X'    ; File interrupt? 
  813.     je    int0            ; e = yes
  814.     mov    dx,offset infms8    ; File group interrupted
  815.     cmp    flags.cxzflg,'Z'    ; correct?
  816.     je    int0            ; e = yes
  817.     mov    dl,flags.cxzflg        ; say Control ^letter interrupt
  818.     mov    infms9+6,dl        ; store interrupt code letter
  819.     mov    dx,offset infms9
  820. int0:   mov    ah,prstr
  821.         int    dos
  822. int1:    ret
  823. INTMSG    ENDP
  824.  
  825. ;  Clear Last error and Last message lines
  826. cxerr:    mov    temp,0            ; say last error line
  827.     jmp    short cxcomm        ; do common code
  828.  
  829. CXMSG    PROC    NEAR
  830.     mov    temp,1            ; say last message line
  831.  
  832. cxcomm:    test    flags.remflg,dserver    ; server mode?
  833.     jnz    cxm1            ; nz = yes
  834.     cmp    flags.xflg,0        ; Writing to screen?
  835.     jne    cxm0            ; ne = yes
  836. cxm1:    cmp    fmtdsp,0        ; formatted display?
  837.     je    cxm0            ; e = no
  838.     push    dx
  839.     push     si
  840.     mov    dx,screrr        ; Last Error postion
  841.     cmp    temp,0            ; do last error line?
  842.     je    cxm2            ; e = yes
  843.     mov    dx,scrmsg        ; Last Message position
  844. cxm2:    call    poscur
  845.     call    clearl
  846.     pop    si
  847.     pop    dx
  848. cxm0:    ret
  849. CXMSG    ENDP
  850.  
  851. ;  Clear out the old filename on the screen. 
  852.  
  853. CLRFLN    PROC    FAR
  854.     test    flags.remflg,dquiet     ; quiet display?
  855.     jnz    clrflnx            ; nz = yes
  856.     test    flags.remflg,dserial    ; serial display mode?
  857.     jnz    clrfln1            ; nz = yes, use just cr/lf
  858.     cmp    fmtdsp,0        ; formatted display?
  859.     je    clrfln1            ; e = no
  860.     mov    dx,scrfln
  861.     call    poscur
  862.     call    clearl            ; clear to end of line
  863.     ret
  864. clrfln1:push    ax            ; for serial display, does cr/lf
  865.     mov    ah,prstr
  866.     mov    dx,offset crlf
  867.     int    dos
  868.     pop    ax
  869. clrflnx:ret
  870. CLRFLN    ENDP
  871.  
  872.             ; display packet quantity and size, SI has pkt ptr
  873. PKTSIZE    PROC    NEAR
  874.     push    ax
  875.     push    dx
  876.     push    si
  877.     cmp    fmtdsp,0        ; formatted display?
  878.     je    pktsiz2            ; e = no, no display
  879.     mov    ax,[si].datlen        ; packet size (data part)
  880.     cmp    trans.chklen,'B'-'0'    ; this special case?
  881.     jne    pktsiz4            ; ne = no
  882.     add    al,2            ; special case is two byte chksum
  883.     jmp    short pktsiz5
  884. pktsiz4:add    al,trans.chklen        ; plus checksum
  885. pktsiz5:adc    ah,0
  886.     cmp    ax,prepksz        ; same as previous packet?
  887.     je    pktsiz2            ; e = yes, skip display of size
  888.     push    ax
  889.     mov    dx,scrsz        ; position cursor
  890.     call    poscur
  891.     pop    ax
  892.     mov    prepksz,ax        ; remember new value
  893.     add    ax,2            ; plus SEQ, TYPE
  894.     cmp    ax,94            ; larger than Regular?
  895.     jbe    pktsiz1            ; be = no
  896.     add    ax,3            ; add Long Packet len and chksum
  897. pktsiz1:call    decout            ; show packet length
  898.     mov    ah,prstr
  899.     mov    dx,offset blanks    ; spaces to clear old material
  900.     int    dos
  901.                     ; number of packets part
  902. pktsiz2:test    flags.remflg,dquiet    ; quiet screen?
  903.     jnz    pktsiz3            ; nz = yes
  904.     call    nppos            ; number of packets sent
  905.     mov    ax,numpkt        ; number of packets
  906.     call    nout            ; write the packet number
  907. pktsiz3:pop    si
  908.     pop    dx
  909.     pop    ax
  910.     ret
  911. PKTSIZE    ENDP
  912.  
  913. ; some random screen positioning functions, all near callable only
  914. kbpos:    mov    dx,scrkb        ; KBytes transferred
  915.     cmp    fmtdsp,0        ; formatted display?
  916.     jne    setup2            ; ne = yes
  917.     ret                ; else ignore postioning request
  918. perpos:    mov    dx,scrper        ; Percent transferred
  919.     cmp    fmtdsp,0        ; formatted display?
  920.     jne    setup2            ; ne = yes
  921.     ret                ; else ignore postioning request
  922. frpos:    mov    dx,scrmsg        ; say renamed file
  923.     jmp    short setup2
  924. stpos:    mov    dx,scrst        ; status of file transfer
  925.     jmp    short setup2
  926. nppos:    mov    dx,scrnp        ; Number of packets sent
  927.     cmp    fmtdsp,0        ; formatted display?
  928.     jne    setup2            ; ne = yes
  929.     ret
  930. rprpos:    test    flags.remflg,dserial+dquiet ; reprompt position
  931.     jnz    rprpos1            ; nz = no mode line for these
  932.     cmp    fmtdsp,0        ; formatted display?
  933.     je    rprpos1            ; e = no, so no mode line
  934.     call    clrmod            ; clear mode line
  935. rprpos1:mov    dx,scrrpr        ; Reprompt position
  936.     call    setup2            ; position cursor
  937.     mov    fmtdsp,0        ; turn off formatted display flag
  938.     ret
  939. sppos:    mov    dx,scrsp        ; Debug Send packet location
  940.     jmp    short setup1
  941. rppos:    mov    dx,scrrp        ; Debug Receive packet location
  942.     jmp    short setup1
  943.                 ; common service routines for positioning
  944. setup1:    test    flags.remflg,dquiet+dserial; quiet or serial display mode?
  945.     jnz    setupa            ; nz = yes
  946.     cmp    fmtdsp,0        ; non-formatted display?
  947.     je    setupa            ; e = yes
  948.     call    poscur
  949.     ret
  950. setup2:    test    flags.remflg,dquiet+dserial; quiet or serial display mode?
  951.     jnz    setupa            ; nz = yes
  952.     cmp    fmtdsp,0        ; non-formatted display?
  953.     je    setupa            ; e = yes
  954.     call    poscur            ; no
  955.     call    clearl
  956.     ret
  957. setupa: test    flags.remflg,dquiet    ; quiet mode?
  958.     jnz    setupx            ; nz = yes, do nothing
  959.     push    ax            ; display cr/lf and return
  960.     push    dx
  961.     mov    dx,offset crlf
  962.     mov    ah,prstr
  963.     int    dos
  964.     pop    dx
  965.     pop    ax
  966. setupx:    ret
  967.  
  968. ; Initialize formatted screen
  969.  
  970. INIT    PROC    NEAR
  971.     mov    windflag,0        ; init windows in use display flag
  972.     test    flags.remflg,dquiet    ; quiet display mode?
  973.     jnz    init4            ; nz = yes
  974.     test    flags.remflg,dserver    ; server mode?
  975.     jnz    init1            ; nz = yes
  976.     cmp    flags.xflg,0        ; destination is screen
  977.     jne    init4            ; ne = yes
  978. init1:    test    flags.remflg,dserial    ; serial mode display?
  979.     jnz    init3            ; nz = yes
  980.  
  981.     xor    al,al            ; cursor off code is zero
  982.     call    fcsrtype        ; turn off PC cursor (IBM-PC dep)
  983.  
  984.     call    cmblnk            ; clear the screen
  985.     mov    dx,offset cxzhlp
  986.     call    putmod            ; write mode line
  987.     mov    fmtdsp,1        ; say doing formatted display
  988.     test    flags.remflg,dserver    ; server mode?
  989.     jz    init2            ; z = no
  990.     mov    dx,scrser        ; move cursor to top of screen
  991.     call    poscur
  992.     mov    ah,prstr
  993.     mov    dx,offset infms1    ; say now in server mode
  994.     int    dos
  995. init2:    call    locate
  996.     mov    ah,prstr        ; put statistics headers on the screen
  997.     mov    dx,offset outlin1
  998.     int    dos
  999.     mov    dx,offset verident
  1000.     int    dos
  1001.     mov    dx,offset outlin2
  1002.     int    dos
  1003.     mov    wrpmsg,0        ; haven't printed the messsage yet
  1004.     mov    prepksz,0        ; set previous packet size to zero
  1005.     push    es
  1006.     mov    di,seg templp
  1007.     mov    es,di
  1008.     mov    di,offset templp    ; 65 byte buffer from mssfil
  1009.     call    fwrtdir            ; fill with drive:path
  1010.     pop    es
  1011.     mov    dx,scrpath
  1012.     call    poscur            ; set cursor
  1013.     mov    dx,offset templp    ; show string
  1014.     call    prtasz
  1015.     ret
  1016. init3:    mov    ah,prstr
  1017.     mov    dx,offset cxzser    ; status line as a text string
  1018.     int    dos
  1019. init4:    mov    wrpmsg,1        ; suppress display of percentage msg
  1020.     mov    fmtdsp,0        ; say doing unformatted display
  1021.     ret
  1022. INIT    ENDP
  1023.  
  1024. ; show number of Kilobytes transferred
  1025. ; modifies ax
  1026. kbpr    proc    near
  1027.     test    flags.remflg,dquiet    ; quiet display mode?
  1028.     jnz    kbpr1            ; nz = yes, no printing
  1029.     push    bx
  1030.     mov    ax,tfilsz        ; low order word
  1031.     mov    bx,tfilsz+2        ; high order word
  1032.     add    ax,512            ; round up, add half the denominator
  1033.     adc    bx,0
  1034.     rcr    bx,1            ; divide double word by 1024,
  1035.     rcr    ax,1            ; by dword shift right 10
  1036.     rcr    bx,1
  1037.     rcr    ax,1
  1038.     mov    al,ah
  1039.     mov    ah,bl            ; ax has the result
  1040.     pop    bx
  1041.     cmp    ax,oldkbt        ; is it the same?
  1042.     je    kbpr1            ; yes, skip printing
  1043.     mov    oldkbt,ax        ; save new # of kb
  1044.     push    ax
  1045.     mov    dx,scrkb
  1046.     call    poscur            ; position the cursor
  1047.     pop    ax
  1048.     call    decout            ; print number of KBytes transferred
  1049.     mov    ah,prstr
  1050.     mov    dx,offset blanks    ; trim off old trailing junk
  1051.     int    dos
  1052. kbpr1:    ret
  1053. kbpr    endp    
  1054.  
  1055. ; show percent transferred
  1056. ; modifies ax
  1057. perpr    proc    near
  1058.     test    flags.remflg,dquiet    ; quiet display mode?
  1059.     jz    perpr1            ; z = no. allow printing
  1060.     ret                ; skip printing in remote mode
  1061. perpr1:    cmp    diskio.sizehi,0        ; high word of original file size > 0 ?
  1062.     jne    perpr3            ; ne = yes, use big file code
  1063.     cmp    diskio.sizelo,0        ; anything here at all?
  1064.     jne    perpr2            ; ne = yes, use small file code
  1065.     mov    wrpmsg,0        ; init flag, prime to clear display
  1066.     ret                ; otherwise, quit now
  1067. perpr2:    push    cx            ; case for files < 64 Kb
  1068.     push    dx
  1069.     mov    ax,diskio.sizelo    ; original size (low word)
  1070.     mov    denom,ax
  1071.     mov    dx,tfilsz+2        ;transferred size times 256 in [dx,ax]
  1072.     mov    ax,tfilsz
  1073.     mov    dh,dl            ; whole value multiplied by 256
  1074.     mov    dl,ah
  1075.     mov    ah,al
  1076.     xor    al,al
  1077.     mov    cx,denom        ; round up, add half the denominator
  1078.     shr    cx,1
  1079.     add    ax,cx
  1080.     adc    dx,0
  1081.     div    denom            ; (256*xfer)/orig. ax = quo, dx = rem
  1082.     mul    onehun            ; multiply quotient above by 100
  1083.     mov    al,ah            ; divide result (ax) by 256
  1084.     xor    ah,ah            ; percentage is in ax
  1085.     jmp    short perpr5        ; finish in common code
  1086.  
  1087. perpr3:    cmp    byte ptr diskio.sizehi+1,0 ; file > 16MB? (> 3 bytes)
  1088.     jne    perpr4            ; ne = yes, use biggest code
  1089.     push    cx            ; case for file size > 64 KB (3 bytes)
  1090.     push    dx
  1091.     mov    ax,diskio.sizelo    ; original file size low order word
  1092.     mov    al,ah            ; divide by 256
  1093.     xor    ah,ah            ; clear ah        
  1094.     mov    dx,diskio.sizehi    ; high order word
  1095.     xchg    dh,dl            ; divide by 256
  1096.     xor    dl,dl            ; clear low bits
  1097.     or    ax,dx            ; paste together the two parts into ax
  1098.     mov    denom,ax        ; denom = original size divided by 512
  1099.     mov    dx,tfilsz+2        ; high order word of transferred size
  1100.     mov    ax,tfilsz        ; low order word
  1101.     mov    cx,denom        ; round up, add half the denominator
  1102.     shr    cx,1
  1103.     add    ax,cx
  1104.     adc    dx,0
  1105.     div    denom            ; xfer/(orig/256). ax=quot, dx=rem
  1106.     mul    onehun            ; times 100 for 256*percentage, in ax
  1107.     mov    al,ah            ; divide ax by 256
  1108.     xor    ah,ah
  1109.     jmp    short perpr5        ; finish in common code
  1110.  
  1111. perpr4:    push    cx            ; case for files > 16MB (> 3 bytes)
  1112.     push    dx
  1113.     mov    ax,tfilsz+2        ; transferred size / 64K in [dx,ax]
  1114.     or    ax,ax            ; anything showing yet?
  1115.     jz    perpr5            ; z = no, return zero in AX
  1116.     xor    dh,dh
  1117.     mov    dl,ah
  1118.     mov    ah,al            ; value multiplied by 256
  1119.     xor    al,al
  1120.     mov    cx,diskio.sizehi    ; round up, add half the denominator
  1121.     shr    cx,1
  1122.     add    ax,cx
  1123.     adc    dx,0
  1124.     div    diskio.sizehi        ; (256*xfer)/orig. ax = quo, dx = rem
  1125.     mul    onehun            ; multiply quotient above by 100
  1126.     mov    al,ah            ; divide result (ax) by 256
  1127.     xor    ah,ah            ; percentage is in ax
  1128.  
  1129. perpr5:    cmp    ax,oldper        ; same as it was before?
  1130.     je    perpr8            ; yes, don't bother printing
  1131.     cmp    oldper,0        ; inited yet?
  1132.     mov    oldper,ax        ; remember this for next time
  1133.     jl    perpr5a            ; l = needs reiniting of screen
  1134.     cmp    wrpmsg,0        ; did we write the percentage message?
  1135.     jne    perpr6            ; ne = yes, skip this part
  1136. perpr5a:push    ax
  1137.     call    perpos            ; position cursor, clear line
  1138.     mov    dx,offset permsg
  1139.     mov    ah,prstr
  1140.     int    dos            ; write out message
  1141.     mov    dx,scrper
  1142.     inc    dh            ; next row
  1143.     push    dx
  1144.     xor    dl,dl
  1145.     call    setup2            ; clear whole line
  1146.     pop    dx
  1147.     sub    dl,2            ; backup two columns
  1148.     call    poscur            ; set cursor
  1149.     mov    dx,offset perscale    ; show thermometer numeric scale
  1150.     mov    ah,prstr
  1151.     int    dos
  1152.     xor    ax,ax
  1153.     call    perprwork        ; write thermometer
  1154.     pop    ax
  1155.     mov    lastper,0        ; last percentage done
  1156.     mov    wrpmsg,1        ; init flag so we don't do it again
  1157. perpr6: push    ax
  1158.     mov    dx,scrper        ; percentage top line
  1159.     inc    dh
  1160.     sub    dl,6            ; below and to the left
  1161.     call    poscur            ; position the cursor
  1162.     pop    ax
  1163.     cmp    ax,onehun        ; > 100% ?
  1164.     jb    perpr7            ; b = no, accept it
  1165.     mov    ax,onehun        ; else just use 100
  1166. perpr7:    push    ax
  1167.     call    decout
  1168.     mov    dl,25h            ; load a percent sign
  1169.     mov    ah,conout        ; display the character
  1170.     int    dos
  1171.     pop    ax
  1172.     mov    cx,ax            ; current percentage done
  1173.     xchg    al,lastper        ; update last percentage done
  1174.     sub    cl,al            ; minus previous percentage completed
  1175.     jle    perpr8            ; le = no change
  1176. perpr7a:inc    ax            ; write intervening percentages
  1177.     call    perprwork        ; write thermometer
  1178.     loop    perpr7a            ; do all steps
  1179. perpr8:    pop    dx
  1180.     pop    cx
  1181.     ret
  1182.  
  1183. perprwork:push    ax            ; worker to display thermometer
  1184.     mov    dx,scrper
  1185.     inc    al            ; ax is percentage done
  1186.     shr    al,1            ; divide by two
  1187.     add    dl,al            ; get column
  1188.     call    poscur            ; position the cursor
  1189.     pop    ax
  1190.     push    ax
  1191.     mov    dl,0dch            ; half block symbol (IBM-PCs)
  1192.     test    al,1
  1193.     jnz    perprw1            ; nz = odd
  1194.     dec    dl            ; full block symbol
  1195. perprw1:mov    ah,conout        ; display the character
  1196.     int    dos
  1197. perprw2:pop    ax
  1198.     ret
  1199. perpr    endp
  1200.  
  1201. ; Show file kind (text, binary) and character set, must preserve SI
  1202. filekind proc    near
  1203.     cmp    flags.xflg,0        ; receiving to screen?
  1204.     jne    filekx            ; ne = yes, skip displaying
  1205.     cmp    flags.destflg,dest_screen ; destination is screen?
  1206.     je    filekx            ; e = yes
  1207.     test    flags.remflg,dregular    ; regular display?
  1208.     jz    filekx            ; z = no, no display
  1209.     cmp    fmtdsp,0        ; formatted display?
  1210.     je    filekx            ; e = no, no display here
  1211.     mov    dx,scrkind
  1212.     call    setup2            ; clear to end of line
  1213.     mov    ah,prstr
  1214.     mov    dx,offset kind_text    ; assume text
  1215.     cmp    trans.xtype,0        ; text?
  1216.     je    filek1            ; e = yes
  1217.     mov    dx,offset kind_binary    ; say binary
  1218. filek1:    int    dos
  1219.     cmp    trans.xtype,0        ; text?
  1220.     jne    filekx            ; ne = no
  1221.     push    bx
  1222.     push    cx
  1223.     push    di
  1224.     test    sflag,1            ; send operation?
  1225.     jnz    filek2            ; nz = yes
  1226.     mov    al,trans.xchset        ; transfer character set
  1227.     xor    ah,ah
  1228.     mov    bx,offset xfchtab    ; transfer file character set table
  1229.     jmp    short filek3
  1230. filek2:    mov    bx,offset setchtab    ; file character set table
  1231.     mov    ax,flags.chrset        ; current char set (Code Page)
  1232. filek3:    call    filekwork
  1233.     jc    filek6            ; no match
  1234.     push    di
  1235.     mov    ah,conout
  1236.     mov    dl,','            ; say "text, "
  1237.     int    dos
  1238.     mov    dl,' '
  1239.     int    dos
  1240.     pop    di
  1241.     call    prtscr            ; display cx counted string in ds:di
  1242.  
  1243.     test    sflag,1            ; send operation?
  1244.     jnz    filek4            ; nz = yes
  1245.     mov    bx,offset setchtab    ; file character set table
  1246.     mov    ax,flags.chrset        ; current char set (Code Page)
  1247.     jmp    short filek5
  1248. filek4:    mov    al,trans.xchset        ; transfer character set
  1249.     xor    ah,ah
  1250.     mov    bx,offset xfchtab    ; transfer file character set table
  1251. filek5:    call    filekwork
  1252.     jc    filek6            ; no match
  1253.     push    di
  1254.     mov    ah,conout
  1255.     mov    dl,' '
  1256.     int    dos
  1257.     mov    dl,'t'
  1258.     int    dos
  1259.     mov    dl,'o'
  1260.     int    dos
  1261.     mov    dl,' '
  1262.     int    dos
  1263.     pop    di
  1264.     call    prtscr            ; display cx counted string in ds:di
  1265. filek6:    pop    di
  1266.     pop    cx
  1267.     pop    bx
  1268. filekx:    ret
  1269. filekind endp
  1270.  
  1271. ; Worker for filekind. Enter with BX = offset of keyword table, AX = value
  1272. ; to be matched. Returns carry clear, DI = ptr to string, CX = string length,
  1273. ; else returns carry set.
  1274. filekwork proc    near
  1275.     mov    cl,[bx]            ; number of entries in our table
  1276.     inc    bx            ; point to the data
  1277. filewk1:mov    di,[bx]            ; length of keyword
  1278.     cmp    ax,[bx+di+2]        ; value fields match?
  1279.     je    filewk2            ; e = yes
  1280.     add    bx,di            ; add word length
  1281.     add    bx,4            ; skip count and value fields
  1282.     dec    cl            ; more keywords to check?
  1283.     jnz    filewk1            ; nz = yes, go to it
  1284.     stc                ; say no match
  1285.     ret
  1286. filewk2:mov    cx,di            ; string length
  1287.     mov    di,bx
  1288.     add    di,2            ; transfer char set ident string
  1289.     clc                ; say success
  1290.     ret
  1291. filekwork endp
  1292.  
  1293. ; Show file characters/sec msg and value, use after calling endtim.
  1294. filecps    proc    near
  1295.     test    flags.remflg,dregular    ; regular display?
  1296.     jz    filecpsx        ; z = no, no display
  1297.     cmp    fmtdsp,0        ; formatted display?
  1298.     je    filecpsx        ; e = no, no display here
  1299.     cmp    flags.xflg,0        ; receiving to screen?
  1300.     je    filecps1        ; e = no
  1301. filecpsx:ret
  1302.  
  1303. filecps1:push    bx
  1304.     push    si
  1305.     mov    dx,scrper        ; thermometer line
  1306.     inc    dh            ; percentage scale line
  1307.     call    setup2            ; set cursor, clear to eol
  1308.     mov    dx,offset filemsg1    ; File chars per second
  1309.     mov    ah,prstr
  1310.     int    dos
  1311.     mov    bx,offset fsta        ; last file structure
  1312.     test    sflag,2            ; 0 for rcv, 2 for send
  1313.     jz    filecps2        ; z = receive
  1314.     mov    ax,[bx].fsbyte        ; file bytes sent, low
  1315.     mov    dx,[bx].fsbyte+2    ;  high. [dx,ax] = total file bytes
  1316.     jmp    short filecps3
  1317. filecps2:mov    ax,[bx].frbyte        ; file bytes received, low
  1318.     mov    dx,[bx].frbyte+2    ; file bytes received, high
  1319. filecps3:call    far ptr fshowrk        ; do worker
  1320.     mov    temp,ax            ; file chars/sec
  1321.     mov    temp1,dx        ; high word
  1322.     mov    cx,1
  1323.     call    far ptr fshoprt        ; show result
  1324.     call    filebps            ; get port speed to dx:ax
  1325.     jc    filecps8        ; c = not a number
  1326.     push    ax            ; comms bits/sec
  1327.     push    dx            ; ditto, high part
  1328.     mov    dx,offset filemsg2    ; Efficiency msg
  1329.     mov    ah,prstr
  1330.     int    dos
  1331.     mov    dx,offset rdbuf        ; buffer with asciiz baud string
  1332.     call    prtasz
  1333.     mov    ah,prstr
  1334.     mov    dx,offset filemsg3
  1335.     int    dos
  1336.     mov    ax,temp1        ; high order part of file chars/sec
  1337.     mov    cx,1000
  1338.     mul    cx            ; times 100(%) * 10(bits/char)
  1339.     mov    bx,ax            ; save low order part of product
  1340.     mov    ax,temp            ; low order part of file chars/sec
  1341.     mul    cx
  1342.     add    dx,bx            ; add high orders
  1343.     pop    cx            ; high order part
  1344.     pop    bx            ; comms b/s
  1345. filecps4:jcxz    filecps5        ; z = no high order denominator part
  1346.     shr    cx,1            ; divide bottom by 2
  1347.     rcr    bx,1
  1348.     shr    dx,1            ; divide top by 2
  1349.     rcr    ax,1
  1350.     jmp    short filecps4        ; do again if necessary
  1351. filecps5:mov    cx,bx            ; set up for worker divide dx,ax / cx
  1352.     or    cx,cx
  1353.     jnz    filecps6        ; avoid divide by zero
  1354.     inc    cx
  1355. filecps6:push    bx            ; divide dx,ax by cx, results to dx,ax
  1356.     push    ax
  1357.     mov    ax,dx
  1358.     xor    dx,dx
  1359.     div    cx            ; ax = high quo, dx = high rem
  1360.     mov    bx,ax            ; save high quotient
  1361.     pop    ax
  1362.     div    cx               ; bytes div seconds, ax = quo, dx = rem
  1363.     shl    dx,1            ; prepare remainder for rounding test
  1364.     cmp    dx,cx            ; round up?
  1365.     jb    filecps7        ; b = no
  1366.     add    ax,1            ; round up
  1367.     adc    bx,0            ; ripple carry
  1368. filecps7:mov    dx,bx            ; previous high quotient
  1369.     pop    bx            ; 100 * file bps / (comms bits/sec)
  1370.     mov    cx,2            ; field width
  1371.     call    far ptr fshoprt        ; show efficiency
  1372.     mov    ah,conout
  1373.     mov    dl,'%'
  1374.     int    dos
  1375. filecps8:pop    si
  1376.     pop    bx
  1377.     ret
  1378. filecps    endp
  1379.  
  1380. ; Worker to convert comms port bits/second to number in dx:ax
  1381. ; Returns carry set if value is unkown
  1382. filebps    proc    near
  1383.     mov    bx,portval        ; port pointer
  1384.     mov    ax,[bx].baud        ; baud rate index to AX
  1385.     cmp    al,byte ptr bdtab    ; index versus number of table entries
  1386.     jb    fileb1            ; b = index is in the table
  1387.     stc                ; say unknown
  1388.     ret
  1389. fileb1:    push    si
  1390.     mov    si,offset bdtab        ; ascii rate table
  1391.     mov    cl,[si]            ; number of entries
  1392.     inc    si            ; point to an entry
  1393. fileb2:    mov    bx,[si]            ; length of text string
  1394.     cmp    ax,[si+bx+2]        ; our index vs table entry index
  1395.     je    fileb3            ; e = match
  1396.     add    si,bx            ; skip text
  1397.     add    si,4            ; skip count and index word
  1398.     loop    fileb2            ; look again
  1399.     pop    si
  1400.     stc                ; say unknown
  1401.     ret
  1402.  
  1403. fileb3:    mov    cx,bx            ; length of string
  1404.     push    cx            ; save for domath below
  1405.     add    si,2            ; point at string
  1406.     push    es
  1407.     push    di
  1408.     mov    bx,ds
  1409.     mov    es,bx
  1410.     mov    di,offset rdbuf        ; work buffer
  1411.     cld
  1412.     rep    movsb            ; copy string
  1413.     xor    al,al
  1414.     stosb                ; asciiz
  1415.     pop    di
  1416.     pop    es
  1417.     pop    cx
  1418.     mov    domath_ptr,offset rdbuf
  1419.     mov    domath_cnt,cx
  1420.     call    domath            ; convert to number in dx:ax
  1421.     pop    si
  1422.     ret
  1423. filebps    endp
  1424. code    ends
  1425.  
  1426. code1    segment
  1427.     assume    cs:code1
  1428. winpr    proc    far            ; print number of active window slots
  1429.     push    ax
  1430.     mov    al,windused        ; window slots in use
  1431.     cmp    al,winusedmax        ; exceeds running max noted?
  1432.     jbe    winpr5            ; be = no
  1433.     mov    winusedmax,al        ; update max
  1434. winpr5:    pop    ax
  1435.     cmp    trans.windo,1        ; windowing in use?
  1436.     jbe    winprx            ; be = no, no message
  1437.     test    flags.remflg,dregular    ; regular display?
  1438.     jz    winprx            ; z = no, no display
  1439.     cmp    fmtdsp,0        ; formatted display?
  1440.     je    winprx            ; e = no, no display here
  1441.     test    flags.remflg,dserver    ; server mode?
  1442.     jnz    winpr4            ; nz = yes, writing to their screen
  1443.     cmp    flags.xflg,0        ; receiving to screen?
  1444.     je    winpr4            ; e = no
  1445. winprx:    ret
  1446. winpr4:    push    ax
  1447.     push    bx
  1448.     push    cx
  1449.     push    dx
  1450.     push    si
  1451.     cmp    windflag,0        ; have we written an initial value?
  1452.     jne    winpr1            ; ne = yes
  1453.     mov    dx,scrnp        ; position cursor
  1454.     dec    dh
  1455.     xor    dl,dl            ; 0 = left most column for text
  1456.     call    fposcur
  1457.     call    fclearl            ; clear the line
  1458.     mov    ah,prstr
  1459.     mov    dx,offset windmsg    ; the text
  1460.     int    dos
  1461.     xor    al,al            ; display an initial 0
  1462.     mov    oldwind,-1
  1463.     mov    windflag,1        ; say have done the work
  1464.     jmp    short winpr2
  1465. winpr1:    mov    al,windused        ; window slots in use
  1466.     cmp    al,oldwind        ; same as before?
  1467.     je    winpr3            ; e = yes, ignore
  1468. winpr2:    push    ax
  1469.     mov    dx,scrnp        ; position cursor
  1470.     dec    dh
  1471.     call    fposcur
  1472.     call    fclearl
  1473.     pop    ax
  1474.     mov    oldwind,al        ; remember last value
  1475.     xor    ah,ah
  1476.     call    decout            ; display value
  1477.     mov    ah,prstr
  1478.     mov    dx,offset windmsg2    ; ' of '
  1479.     int    dos
  1480.     mov    al,trans.windo        ; number of window slots
  1481.     xor    ah,ah
  1482.     call    decout
  1483. winpr3:    pop    si
  1484.     pop    dx
  1485.     pop    cx
  1486.     pop    bx
  1487.     pop    ax
  1488.     ret
  1489. winpr    endp
  1490.  
  1491. ; Say Streaming: Active on formatted display
  1492. streampr proc    far
  1493.     test    flags.remflg,dregular    ; regular display?
  1494.     jz    strmx            ; z = no, no display
  1495.     cmp    fmtdsp,0        ; formatted display?
  1496.     je    strmx            ; e = no, no display here
  1497.     test    flags.remflg,dserver    ; server mode?
  1498.     jnz    strm1            ; nz = yes, writing to their screen
  1499.     cmp    flags.xflg,0        ; receiving to screen?
  1500.     je    strm1            ; e = no
  1501. strmx:    ret
  1502. strm1:    push    ax
  1503.     push    bx
  1504.     push    cx
  1505.     push    dx
  1506.     push    si
  1507.     mov    dx,scrnp        ; position cursor
  1508.     dec    dh
  1509.     xor    dl,dl            ; 0 = left most column for text
  1510.     call    fposcur
  1511.     call    fclearl            ; clear the line
  1512.     mov    ah,prstr
  1513.     mov    dx,offset streammsg    ; the text
  1514.     int    dos
  1515.     pop    si
  1516.     pop    dx
  1517.     pop    cx
  1518.     pop    bx
  1519.     pop    ax
  1520.     ret
  1521. streampr endp
  1522.  
  1523. ; Start recording of statistics for this operation. Enter with al = 0 for
  1524. ; receive, al = 1 for send.
  1525. fbegtim    proc    FAR
  1526.     mov    crcword,0        ; clear CRC-16 for last file
  1527.     mov    word ptr lastfsize,0    ; clear size of last xfered file
  1528.     mov    word ptr lastfsize+2,0
  1529.     test    sflag,80h        ; is this a duplicate call?
  1530.     jz    begtim1            ; z = no
  1531.     ret                ; else just return
  1532. begtim1:push    ax
  1533.     push    cx
  1534.     push    dx
  1535.     push    di
  1536.     push    es
  1537.     push    ds
  1538.     pop    es
  1539.     and    al,1
  1540.     mov    sflag,al        ; save direction of xfer (1=send)
  1541.     xor    ax,ax        ; clear statistics counters for this file
  1542.     mov    crcword,ax        ; clear CRC-16 value of last group
  1543.     cld
  1544.     mov    di,offset fsta.prbyte    ; start of the structure
  1545.     mov    cx,offset fsta.xstatus2 + 1 - offset fsta.prbyte ; end
  1546.     rep    stosb            ; clear most of the structure
  1547.     pop    es
  1548.     pop    di
  1549.     mov    ah,getdate        ; get current date, convert to ascii
  1550.     int    dos
  1551.     mov    date+9,'0'        ; init day of month
  1552. begtim2:cmp    dl,10            ; day of month. Ten or more days?
  1553.     jl    begtim3            ; l = no
  1554.     sub    dl,10
  1555.     inc    date+9            ; add up tens of days
  1556.     jmp    short begtim2        ; repeat for higher order
  1557. begtim3:add    dl,'0'            ; ascii bias
  1558.     mov    date+10,dl        ; day units
  1559.     mov    dl,dh            ; months (1-12)
  1560.     dec    dl            ; start at zero to index table
  1561.     xor    dh,dh
  1562.     mov    di,dx            ; months
  1563.     shl    di,1
  1564.     add    di,dx            ; times three chars/month
  1565.     mov    al,months[di]        ; get text string for month
  1566.     mov    date+12,al
  1567.     mov    ax,word ptr months[di+1]
  1568.     mov    word ptr date+13,ax
  1569.     mov    ax,cx            ; year since 1980
  1570.     mov    dx,0
  1571.     mov    di,offset date+16    ; destination
  1572.     call    flnout            ; convert number to asciiz in buffer
  1573.     mov    date+20,','        ; needed punctuation for log
  1574.                     ; start time
  1575.     mov    ah,gettim        ; DOS time of day, convert to ascii
  1576.     int    dos
  1577.     push    cx
  1578.     push    dx
  1579.     call    timewrk            ; convert to seconds.01 in dx,ax
  1580.     mov    fsta.btime,ax        ; store ss.s   low word of seconds
  1581.     mov    fsta.btime+2,dx        ;  high word of seconds
  1582.     pop    dx
  1583.     pop    cx
  1584.     mov    date,'0'        ; init begin hours field
  1585. begtim4:cmp    ch,10            ; ten or more hours?
  1586.     jl    begtim5            ; l = no
  1587.     sub    ch,10
  1588.     inc    date            ; add up tens of hours
  1589.     jmp    short begtim4        ; repeat for twenties
  1590. begtim5:add    ch,'0'            ; ascii bias
  1591.     mov    date+1,ch        ; store units of hours
  1592.     mov    date+3,'0'        ; minutes field
  1593. begtim6:cmp    cl,10            ; ten or more minutes?
  1594.     jl    begtim7            ; l = no
  1595.     sub    cl,10
  1596.     inc    date+3            ; add up tens of minutes
  1597.     jmp    short begtim6        ; repeat for higher orders
  1598. begtim7:add    cl,'0'            ; ascii bias
  1599.     mov    date+4,cl        ; store units of minutes
  1600.     mov    date+6,'0'        ; seconds field
  1601. begtim8:cmp    dh,10            ; ten or more seconds?
  1602.     jl    begtim9            ; l = no
  1603.     sub    dh,10
  1604.     inc    date+6            ; add up tens of seconds
  1605.     jmp    short begtim8        ; repeat for higher orders
  1606. begtim9:add    dh,'0'            ; ascii bias
  1607.     mov    date+7,dh
  1608.     or    sflag,80h        ; say begtim has been run
  1609.     pop    dx
  1610.     pop    cx
  1611.     pop    ax
  1612.     ret
  1613. fbegtim    endp
  1614.  
  1615. ; Take snapshot of statistics counters at end of an operation
  1616. ; Enter with ax = 0 for a receive operation, ax = 1 for a send. [jrd]
  1617. fendtim    proc    FAR
  1618.     test    sflag,80h    ; called more than once without calling begtim?
  1619.     jnz    endtim1            ; nz = no, so do statistics snapshot
  1620.     ret                ; yes, do nothing
  1621. endtim1:and    sflag,not (1)        ; assume receive operation
  1622.     or    ax,ax            ; send (ax > 0), receive (ax = 0) flag
  1623.     jz    endtim2            ; z = receive opeation
  1624.     or    sflag,1            ; say send operation
  1625. endtim2:push    ax
  1626.     push    cx
  1627.     push    dx
  1628.     mov    ah,gettim        ; get DOS time of day
  1629.     int    dos            ; ch=hh, cl=mm, dh=ss, dl= 0.01 sec
  1630.     call    timewrk            ; convert to seconds.01 in dx,ax
  1631.     sub    al,byte ptr fsta.btime    ; 0.01 sec field, wrapped?
  1632.     jnc    endtim2a        ; nc = no
  1633.     add    al,100            ; unwrap
  1634.     sub    ah,1            ; borrow one second from end seconds
  1635.     sbb    dx,0
  1636. endtim2a:sub    ah,byte ptr fsta.btime+1 ; minus begin time, sec
  1637.     sbb    dx,fsta.btime+2
  1638.     jnc    endtim2b        ; nc = no day straddling
  1639.     add    ah,128            ; part of one day
  1640.     adc    dx,337            ; rest of 86400 sec/day
  1641. endtim2b:mov    fsta.etime,ax        ; elapsed time
  1642.     mov    fsta.etime+2,dx
  1643.     add    al,byte ptr ssta.etime     ; add to session time, 0.01 sec field
  1644.     cmp    al,100            ; larger than 1 sec?
  1645.     jb    endtim2c        ; b = no
  1646.     sub    al,100            ; keep under 1 sec
  1647.     add    ah,1            ; ripple carry seconds
  1648.     adc    dx,0
  1649. endtim2c:mov    byte ptr ssta.etime,al
  1650.     add    byte ptr ssta.etime+1,ah ; seconds low byte
  1651.     adc    ssta.etime+2,dx        ; add to session time, high word
  1652.     mov    ax,fsta.pretry        ; retries for last transfer
  1653.     add    ssta.pretry,ax        ; retries for this session
  1654.  
  1655.     test    sflag,1            ; completing a receive operation?
  1656.     jnz    endtim3            ; nz = no, a send operation
  1657.     mov    ax,fsta.frbyte
  1658.     add    ssta.frbyte,ax        ; session received file bytes, low word
  1659.     mov    ax,fsta.frbyte+2
  1660.     adc    ssta.frbyte+2,ax
  1661.     mov    ax,fsta.prbyte        ; received pkt byte count
  1662.     add    ssta.prbyte,ax
  1663.     mov    ax,fsta.prbyte+2
  1664.     adc    ssta.prbyte+2,ax
  1665.     xor    ax,ax
  1666.     mov    fsta.psbyte,ax        ; don't count reverse channel bytes
  1667.     mov    fsta.psbyte+2,ax
  1668.     jmp    short endtim4
  1669.  
  1670. endtim3:mov    ax,fsta.fsbyte        ; file bytes sent
  1671.     add    ssta.fsbyte,ax        ; session sent file bytes, low word
  1672.     mov    ax,fsta.fsbyte+2
  1673.     adc    ssta.fsbyte+2,ax
  1674.     mov    ax,fsta.psbyte        ; sent pkt byte count
  1675.     add    ssta.psbyte,ax
  1676.     mov    ax,fsta.psbyte+2
  1677.     adc    ssta.psbyte+2,ax
  1678.     xor    ax,ax
  1679.     mov    fsta.prbyte,ax        ; don't count reverse channel bytes
  1680.     mov    fsta.prbyte+2,ax
  1681.  
  1682. endtim4:mov    ax,fsta.nakrcnt     ; NAKs received for this file
  1683.     add    ssta.nakrcnt,ax     ; session received NAKs
  1684.     mov    ax,fsta.nakscnt     ; NAKs sent for this file
  1685.     add    ssta.nakscnt,ax     ; session sent NAKs
  1686.     mov    ax,fsta.prpkt        ; received packet count
  1687.     add    ssta.prpkt,ax
  1688.     mov    ax,fsta.prpkt+2
  1689.     adc    ssta.prpkt+2,ax
  1690.     mov    ax,fsta.pspkt        ; sent packet count
  1691.     add    ssta.pspkt,ax
  1692.     mov    ax,fsta.pspkt+2
  1693.     adc    ssta.pspkt+2,ax
  1694.     mov    al,sflag
  1695.     and    al,1            ; pick out send/receive bit
  1696.     shl    al,1            ; move bit up for file chars/sec
  1697.     mov    sflag,al        ; say have done ending once already
  1698.     mov    fsta.xname,0        ; clear statistics "as" name
  1699.     pop    dx
  1700.     pop    cx
  1701.     pop    ax
  1702.     ret
  1703. fendtim    endp
  1704.  
  1705. ; Log receive/send transction. Expect sflag to be preset by call to begtim.
  1706. logtransact proc far            ; do transaction logging
  1707.     cmp    tloghnd,0        ; logging transaction? -1 = not opened
  1708.     jg    logtra5            ; g = logging
  1709.     jmp    logtra12        ; skip logging
  1710. logtra5:push    di            ; kind of transaction
  1711.     push    bx            ; save these registers
  1712.     mov    bx,tloghnd        ; handle for transaction log
  1713.     mov    dx,offset rcvmsg    ; assume receive message
  1714.     test    sflag,1            ; 1 for send, 0 for receive
  1715.     jz    logtra6            ; z = receive
  1716.     mov    dx,offset sndmsg    ; send message
  1717. logtra6:call    strlen            ; length of message to cx
  1718.     mov    ah,write2
  1719.     int    dos            ; write kind of transfer
  1720.                     ; File names
  1721.     cmp    diskio.string,0        ; local filename
  1722.     je    logtra9            ; e = no filename
  1723.     test    sflag,1            ; a send operation?
  1724.     jnz    logtra8            ; nz = yes
  1725.                     ; Receive
  1726.     mov    dx,offset fsta.xname    ; remote name
  1727.     call    strlen            ; length to cx
  1728.     jcxz    logtra7            ; no name
  1729.     mov    ah,write2
  1730.     int    dos
  1731.     mov    dx,offset diskio.string    ; local name
  1732.     call    strlen            ; length to cx
  1733.     mov    si,offset fsta.xname    ; compare these two names
  1734.     mov    di,dx
  1735.     push    ds
  1736.     pop    es
  1737.     repe    cmpsb            ; compare
  1738.     je    logtra9            ; e = same, so no 'as' msg
  1739.     mov    dx,offset fasmsg    ; give 'as' message
  1740.     mov    cx,faslen        ; length
  1741.     mov    ah,write2
  1742.     int    dos
  1743. logtra7:mov    dx,offset diskio.string    ; local name
  1744.     call    strlen            ; get length
  1745.     mov    ah,write2        ; write local name
  1746.     int    dos
  1747.     jmp    short logtra9
  1748.  
  1749. logtra8:mov    dx,offset diskio.string; templp    ; Send. local name
  1750.     call    strlen
  1751.     mov    ah,write2
  1752.     int    dos
  1753.     cmp    fsta.xname,0        ; using an alias?
  1754.     je    logtra9            ; e = no
  1755.     mov    dx,offset fasmsg    ; give 'as' message
  1756.     mov    cx,faslen
  1757.     mov    ah,write2
  1758.     int    dos
  1759.     mov    dx,offset fsta.xname    ; get alias
  1760.     call    strlen
  1761.     mov    ah,write2
  1762.     int    dos
  1763.                     ; status of transfer
  1764. logtra9:mov    dx,offset atmsg        ; say At
  1765.     mov    cx,atlen        ; length
  1766.     mov    bx,tloghnd        ; handle
  1767.     mov    ah,write2
  1768.     int    dos
  1769.     mov    dx,offset date        ; write time and date field
  1770.     mov    cx,datelen        ; length
  1771.     mov    ah,write2
  1772.     int    dos
  1773.     mov    dx,offset fsucmsg    ; assume success message
  1774.     cmp    fsta.xstatus,kssuc    ; 0 = completed successfully?
  1775.     je    logtra9c        ; e = completed
  1776.     mov    dx,offset fbadmsg    ; failed message
  1777. logtra9c:call    strlen
  1778.     mov    ah,write2
  1779.     int    dos
  1780. logtra9b:mov    al,fsta.xstatus2    ; get file attributes reason byte
  1781.     or    al,al            ; any transfer codes?
  1782.     jz    logtra10a        ; z = no
  1783.     mov    dx,offset ferbyte    ; assume file size
  1784.     cmp    al,'1'            ; bytes
  1785.     je    logtra10        ; e = yes
  1786.     cmp    al,'!'            ; kilobytes
  1787.     je    logtra10        ; e = yes
  1788.     mov    dx,offset ferdate    ; assume file date/time
  1789.     cmp    al,'#'
  1790.     je    logtra10        ; e = yes
  1791.     mov    dx,offset ferdisp    ; assume file disposition
  1792.     cmp    al,'+'
  1793.     je    logtra10        ; e = yes
  1794.     mov    dx,offset fertype    ; assume file type
  1795.     cmp    al,'"'
  1796.     je    logtra10        ; e = yes
  1797.     mov    dx,offset ferchar    ; assume char set
  1798.     cmp    al,'*'
  1799.     je    logtra10        ; e = yes
  1800.     mov    dx,offset fername
  1801.     cmp    al,'?'            ; filename collision?
  1802.     je    logtra10        ; e = yes
  1803.     mov    dx,offset ferunk    ; assume unknown
  1804.     jmp    short logtra10
  1805. logtra9a:test    fsta.xstatus,ksuser    ; user interrupted?
  1806.     jz    logtra10        ; z = no
  1807.     mov    dx,offset fintmsg    ; interrupted message
  1808. logtra10:call    strlen            ; get length to cx
  1809.     mov    ah,write2
  1810.     int    dos
  1811.     mov    dx,offset commamsg    ; ", "
  1812.     mov    cx,2
  1813.     mov    ah,write2
  1814.     int     dos
  1815. logtra10a:mov    dx,offset bytesmsg    ; "bytes: "
  1816.     call    strlen
  1817.     mov    ah,write2
  1818.     int    dos
  1819.                     ; file bytes transferred
  1820.     mov    ax,tfilsz        ; file bytes, low word
  1821.     mov    dx,tfilsz+2        ; high word
  1822.     mov    di,offset rdbuf        ; work buffer
  1823.     call    flnouts            ; transform to ascii
  1824.     mov    [di],0a0dh        ; append cr/lf
  1825.     add    di,2            ; count them
  1826.     mov    dx,offset rdbuf        ; start of work buffer
  1827.     mov    cx,di            ; next free byte
  1828.     sub    cx,dx            ; compute length
  1829.     mov    ah,write2
  1830.     int    dos
  1831.     cmp    dosnum,300h+30        ; DOS 3.30 or higher?
  1832.     jb    logtra11        ; b = no
  1833.     mov    ah,68h            ; Commit the file now
  1834.     int    dos
  1835. logtra11:pop    bx
  1836.     pop    di
  1837. logtra12:
  1838.     mov    ax,tfilsz        ; low order word of transferred size
  1839.     mov    word ptr lastfsize,ax
  1840.     mov    ax,tfilsz+2        ; high order word
  1841.     mov    word ptr lastfsize+2,ax
  1842.     xor    ax,ax
  1843.     mov    tfilsz,ax        ; clear file size area
  1844.     mov    tfilsz+2,ax
  1845.     mov    fsta.xname,al        ; clear statistics "as" name
  1846.     ret
  1847. logtransact endp
  1848.  
  1849. ; Convert ch=hh, cl=mm, dh=ss, dl= .s to   dx,ah seconds and al 0.01 seconds
  1850. timewrk    proc    near
  1851.     push    bx
  1852.     mov    bl,dl            ; save fractions of seconds
  1853.     push    bx
  1854.     mov    bl,dh            ; clock seconds
  1855.     xor    bh,bh
  1856.     mov    al,ch            ; get hours
  1857.     mov    ch,60
  1858.     mul    ch            ; ax is minutes
  1859.     add    al,cl            ; add clock minutes
  1860.     adc    ah,0
  1861.     mov    cx,60
  1862.     mul    cx            ; minutes to seconds in dx,ax
  1863.     add    ax,bx            ; add clock seconds
  1864.     adc    dx,0
  1865.     mov    dh,dl            ; move up one byte for 0.01 field
  1866.     mov    dl,ah
  1867.     mov    ah,al
  1868.     pop    bx            ; get old 0.01 field (was dl)
  1869.     mov    al,bl
  1870.     pop    bx
  1871.     ret
  1872. timewrk    endp
  1873.  
  1874. fshosta    proc    far            ; STATISTICS display
  1875.     push    bx
  1876.     push    di
  1877.     mov    dx,offset statmsg    ; header
  1878.     mov    ah,prstr
  1879.     int    dos
  1880.     mov    dx,offset fchmsg    ; File characters msg
  1881.     mov    ah,prstr
  1882.     int    dos
  1883.     mov    di,offset ssta        ; session structure
  1884.     mov    bx,offset fsta        ; last file structure
  1885.     mov    ax,[bx].fsbyte        ; last transfer file bytes sent
  1886.     mov    dx,[bx].fsbyte+2
  1887.     mov    cx,12            ; field width
  1888.     call    shoprt            ; show result
  1889.     mov    ax,[bx].frbyte        ; last transfer file bytes received
  1890.     mov    dx,[bx].frbyte+2
  1891.     call    shoprt            ; show result
  1892.     mov    ax,[di].fsbyte        ; session file bytes sent
  1893.     mov    dx,[di].fsbyte+2
  1894.     call    shoprt            ; show result
  1895.     mov    ax,[di].frbyte        ; session file bytes received
  1896.     mov    dx,[di].frbyte+2
  1897.     call    shoprt            ; show result
  1898.  
  1899.     mov    ah,prstr
  1900.     mov    dx,offset spmsg        ; serial port material
  1901.     int    dos
  1902.     mov    ax,[bx].psbyte        ; last transfer port bytes sent
  1903.     mov    dx,[bx].psbyte+2
  1904.     call    shoprt            ; show result
  1905.     mov    ax,[bx].prbyte        ; last transfer port bytes received
  1906.     mov    dx,[bx].prbyte+2
  1907.     call    shoprt            ; show result
  1908.     mov    ax,[di].psbyte        ; session port bytes sent
  1909.     mov    dx,[di].psbyte+2
  1910.     call    shoprt            ; show result
  1911.     mov    ax,[di].prbyte        ; session port bytes received
  1912.     mov    dx,[di].prbyte+2
  1913.     call    shoprt            ; show result
  1914.  
  1915.     mov    dx,offset pktmsg    ; packets material
  1916.     mov    ah,prstr
  1917.     int    dos
  1918.     mov    ax,[bx].pspkt        ; last transfer packets sent
  1919.     mov    dx,[bx].pspkt+2
  1920.     call    shoprt            ; show result
  1921.     mov    ax,[bx].prpkt        ; last transfer packets received
  1922.     mov    dx,[bx].prpkt+2
  1923.     call    shoprt            ; show result
  1924.     mov    ax,[di].pspkt        ; session packets sent
  1925.     mov    dx,[di].pspkt+2
  1926.     call    shoprt            ; show result
  1927.     mov    ax,[di].prpkt        ; session packets received
  1928.     mov    dx,[di].prpkt+2
  1929.     call    shoprt            ; show result
  1930.  
  1931.     mov    dx,offset nakmsg    ; NAKs material
  1932.     mov    ah,prstr
  1933.     int    dos
  1934.     mov    ax,[bx].nakscnt        ; last transfer NAKs sent
  1935.     xor    dx,dx
  1936.     call    shoprt
  1937.     mov    ax,[bx].nakrcnt        ; last transfer NAKs received
  1938.     xor    dx,dx
  1939.     call    shoprt
  1940.     mov    ax,[di].nakscnt        ; session NAKs sent
  1941.     xor    dx,dx
  1942.     call    shoprt
  1943.     mov    ax,[di].nakrcnt        ; session NAKs received
  1944.     xor    dx,dx
  1945.     call    shoprt
  1946.  
  1947.     mov    dx,offset retmsg    ; retries
  1948.     mov    ah,prstr
  1949.     int    dos
  1950.     mov    ax,[bx].pretry        ; last transfer retry count
  1951.     xor    dx,dx
  1952.     mov    cx,18
  1953.     call    shoprt
  1954.     mov    ax,[di].pretry        ; session retries
  1955.     xor    dx,dx
  1956.     mov    cx,24
  1957.     call    shoprt
  1958.  
  1959.     mov    ah,prstr
  1960.     mov    dx,offset crlf
  1961.     int    dos
  1962.     cmp    streamok,0        ; if did not use streaming
  1963.     je    shostat1        ; e = no streaming
  1964.     mov    dx,offset streamstat
  1965.     int     dos
  1966.     jmp    shostat2
  1967. shostat1:mov    dx,offset windmsg    ; Window slots used/negotiated
  1968.     int    dos
  1969.     mov    al,winusedmax        ; max used
  1970.     xor    ah,ah
  1971.     xor    dx,dx
  1972.     mov    cx,16
  1973.     call    shoprt
  1974.     mov    ah,prstr
  1975.     mov    dx,offset windmsg2
  1976.     int    dos
  1977.     mov    al,trans.windo        ; negotiated
  1978.     xor    ah,ah
  1979.     xor    dx,dx
  1980.     mov    cx,1
  1981.     call    shoprt
  1982.  
  1983. shostat2:mov    dx,offset timemsg    ; elapsed time material
  1984.     mov    ah,prstr
  1985.     int    dos
  1986.     mov    cx,15            ; field width
  1987.     call    shoetime        ; show elapsed time as seconds.01
  1988.     xchg    bx,di            ; put session into bx
  1989.     mov    cx,21            ; field width
  1990.     call    shoetime        ; show elapsed time as seconds.01
  1991.     xchg    bx,di            ; unswap pointers
  1992.  
  1993.     mov    dx,offset chpsmsg    ; File chars per second
  1994.     mov    ah,prstr
  1995.     int    dos
  1996.     mov    ax,[bx].frbyte        ; file bytes received, low
  1997.     mov    dx,[bx].frbyte+2    ; file bytes received, high
  1998.     add    ax,[bx].fsbyte        ; file bytes sent, low
  1999.     adc    dx,[bx].fsbyte+2    ;  high. [dx,ax] = total file bytes
  2000.     call    showrk            ; do worker
  2001.     mov    cx,18
  2002.     call    shoprt            ; show result
  2003.     xchg    bx,di            ; swap session and last file pointers
  2004.     mov    ax,[bx].frbyte        ; file bytes received, low
  2005.     mov    dx,[bx].frbyte+2    ; file bytes received, high
  2006.     add    ax,[bx].fsbyte        ; file bytes sent, low
  2007.     adc    dx,[bx].fsbyte+2    ;  high. [dx,ax] = total file bytes
  2008.     call    showrk            ; do worker
  2009.     xchg    bx,di            ; unswap session and last file pointers
  2010.     mov    cx,24
  2011.     call    shoprt            ; show result
  2012.         
  2013.     mov    dx,offset spedmsg    ; speed material
  2014.     mov    ah,prstr
  2015.     int    dos
  2016.     mov    cx,18            ; field width
  2017.     call    showbps            ; do bps display
  2018.     mov    bx,offset ssta        ; session
  2019.     mov    cx,24            ; field width
  2020.     call    showbps            ; do bps display
  2021.     mov    ah,prstr
  2022.     mov    dx,offset crlf
  2023.     int    dos
  2024.     pop    di
  2025.     pop    bx
  2026.     clc
  2027.     ret
  2028. fshosta    endp
  2029.  
  2030. ; Worker for above. Display [BX].etime as seconds.01, field width in CX
  2031. shoetime proc    near
  2032.     mov    ax,[bx].etime        ; elapsed time of last transfer
  2033.     mov    dx,[bx].etime+2
  2034.     mov    al,ah            ; ignore fractions of seconds
  2035.     mov    ah,dl
  2036.     mov    dl,dh
  2037.     xor    dh,dh
  2038.     call    shoprt            ; show result, cx has field width
  2039.     mov    ah,conout
  2040.     mov    dl,'.'
  2041.     int    dos
  2042.     cmp    byte ptr [bx].etime,9    ; small qty of 0.01 sec units?
  2043.     ja    shoetim1        ; a = no
  2044.     mov    dl,'0'
  2045.     int    dos
  2046. shoetim1:mov    al,byte ptr [bx].etime    ; 0.01 sec units
  2047.     xor    ah,ah
  2048.     xor    dx,dx
  2049.     mov    cx,1
  2050.     call    shoprt
  2051.     ret
  2052. shoetime endp
  2053.  
  2054. ; Worker for above
  2055. ; Display baud rate as  10 * total port bytes / elapsed time
  2056. ; BX has structure offset, CX has field width
  2057. showbps    proc    near
  2058.     mov    ax,[bx].prbyte        ; port bytes received, low
  2059.     mov    dx,[bx].prbyte+2    ; port bytes received, high
  2060.     add    ax,[bx].psbyte        ; port bytes sent, low
  2061.     adc    dx,[bx].psbyte+2    ;  high. [dx,ax] = total port bytes
  2062.     push    cx
  2063.     push    bx
  2064.     push    ax            ; save low order part
  2065.     mov    cx,10
  2066.     mov    ax,dx            ; high order part
  2067.     mul    cx            ; high part times 10
  2068.     mov    bx,ax            ; save low order result
  2069.     pop    ax
  2070.     mul    cx            ; low times 10
  2071.     add    dx,bx            ; add high parts
  2072.     pop    bx
  2073.     call    showrk            ; do worker for bytes/sec
  2074.     pop    cx            ; recover field width
  2075.     call    shoprt            ; show result
  2076.     ret
  2077. showbps    endp
  2078.  
  2079. ; Display SHOW STATISTICS line. Enter with dx,ax with long value, cx = width
  2080. fshoprt proc    far
  2081.     call    shoprt
  2082.     ret
  2083. fshoprt    endp
  2084.  
  2085. shoprt    proc    near
  2086.     push    di
  2087.     mov    di,offset rdbuf        ; work space for output
  2088.     call    flnouts            ; show long integer, with separator
  2089.     pop    di
  2090.     mov    dx,offset rdbuf
  2091.     push    bx
  2092.     push    cx
  2093.     push    dx
  2094.     mov    bx,cx            ; field width
  2095.     call    strlen            ; length of string in dx
  2096.     sub    bx,cx            ; number of spaces necessary
  2097.     xchg    bx,cx
  2098.     jle    shoprt2            ; le = no spaces
  2099.     mov    dl,' '
  2100.     mov    ah,conout
  2101. shoprt1:int    dos            ; display the leading spaces
  2102.     loop    shoprt1
  2103. shoprt2:pop    dx
  2104.     pop    cx
  2105.     pop    bx
  2106.     call    prtasz            ; display asciiz string
  2107.     ret
  2108. shoprt    endp
  2109.  
  2110. ; Divide long number in dx,ax by [bx].elapsed time (seconds).
  2111. ; Return result back in dx,ax
  2112. fshowrk proc    far
  2113.     call    showrk
  2114.     ret
  2115. fshowrk    endp
  2116.  
  2117. showrk    proc    near
  2118.     mov    cx,[bx].etime+1        ; low word of sec in cx
  2119.     cmp    byte ptr [bx].etime+2,0    ; high byte of sec zero (< 65536 sec)?
  2120.     jz    showrk1            ; z = yes, ready for arithmetic
  2121.     push    ax            ; else scale values, save byte count
  2122.     push    dx
  2123.     mov    ax,[bx].etime+1        ; elapsed time for file, low word
  2124.     mov    dl,byte ptr [bx].etime+3 ;  high byte
  2125.     xor    dh,dh            ;  ignoring fractions of second
  2126.     shr    ax,1            ; divide seconds by two, low word
  2127.     ror    dx,1            ; get low bit of high word
  2128.     and    dx,8000            ; pick out just that bit
  2129.     or    ax,dx        ; mask in that bit, new time in ax (dx = 0)
  2130.     mov    cx,ax            ; save elapsed time (double-seconds)
  2131.     pop    dx            ; get byte count again
  2132.     pop    ax
  2133.     shr    ax,1            ; divide byte count by two also
  2134.     push    dx
  2135.     ror    dx,1            ; rotate low bit to high position
  2136.     and    dx,8000h        ; get low bit of high word
  2137.     or    ax,dx            ; byte count divided by two, low word
  2138.     pop    dx
  2139.     shr    dx,1            ; and high word
  2140.     jmp    short showrk2
  2141.  
  2142. showrk1:cmp    cx,30            ; small amount of elapsed time?
  2143.     ja    showrk2            ; a = no
  2144.     push    bx
  2145.     push    si
  2146.     mov    bx,100            ; scale in the 0.01 sec part
  2147.     push    ax            ; save low order top
  2148.     mov    ax,dx            ; high order top
  2149.     mul    bx
  2150.     mov    si,ax            ; low order result
  2151.     pop    ax
  2152.     mul    bx            ; low order top
  2153.     add    dx,si            ; dx,ax * 100 in dx,ax
  2154.     push    ax
  2155.     mov    ax,cx            ; seconds
  2156.     mul    bl            ; to units of 0.01 seconds
  2157.     mov    cx,ax
  2158.     pop    ax
  2159.     pop    si
  2160.     pop    bx
  2161.     add    cl,byte ptr [bx].etime    ; 0.01 sec units
  2162.     adc    ch,0            ; elapsed time seconds * 100
  2163.     or    cx,cx
  2164.     jnz    showrk2            ; have a divisor
  2165.     inc    cx            ; else make it 1 (0.01 sec)
  2166.  
  2167. showrk2:push    bx            ; divide dx,ax by cx, results to dx,ax
  2168.     push    ax
  2169.     mov    ax,dx
  2170.     xor    dx,dx
  2171.     div    cx            ; ax = high quo, dx = high rem
  2172.     mov    bx,ax            ; save high quotient
  2173.     pop    ax
  2174.     div    cx               ; bytes div seconds, ax = quo, dx = rem
  2175.     shl    dx,1            ; remainder * 2
  2176.     cmp    dx,cx            ; round up?
  2177.     jb    showrk3            ; b = no
  2178.     add    ax,1            ; round up
  2179.     adc    bx,0
  2180. showrk3:mov    dx,bx            ; previous high quotient
  2181.     pop    bx
  2182.     ret
  2183. showrk    endp
  2184.  
  2185. fshomdef proc    FAR            ; worker, show mac name and def
  2186.     push    ax            ; call with si pointing at macro
  2187.     push    si            ; name, word ptr [si-2] = length
  2188.     push    es
  2189.     cmp    byte ptr[si],0        ; name starts with null char?
  2190.     jne    shomd1            ; ne = no
  2191.     jmp    shomd9            ; yes, TAKE file, ignore
  2192. shomd1:    call    shomdl            ; do newline, check for more/exit
  2193.     jnc    shomd2            ; nc = continue
  2194.     jmp    shomd9            ; exit
  2195. shomd2:    mov    ah,conout
  2196.     mov    dl,' '            ; add a space
  2197.     int    dos
  2198.     inc    bx
  2199.     inc    temp            ; count displayed macros
  2200.     push    cx
  2201.     push    di
  2202.     mov    cx,[si-2]        ; length of definition
  2203.     mov    di,si            ; offset for printing
  2204.     call    prtscr            ; print counted string
  2205.     pop    di
  2206.     pop    cx
  2207.     mov    ah,prstr
  2208.     mov    dx,offset eqs        ; display equals sign
  2209.     int    dos
  2210.     mov    denom,1            ; set flag to do "," to <cr>
  2211.     cmp    word ptr [si],'%\'    ; substitution variable?
  2212.     jne    shomd2a            ; ne = no
  2213.     mov    denom,0            ; clear bare comma sensitivity flag
  2214. shomd2a:mov    ax,[si-2]        ; length of macro name
  2215.     add    si,ax            ; skip over name
  2216.     add    bx,ax            ; count of chars on line
  2217.     add    bx,3            ; plus " = "
  2218.     mov    es,[si]            ; segment of string structure
  2219.     xor    si,si            ; es:si = address of count + string
  2220.     mov    cx,es:[si]        ; length of string
  2221.     jcxz    shomd9            ; z = empty
  2222.     add    si,2            ; si = offset of string text proper
  2223. shomd3:    mov    al,es:[si]        ; get a byte into al
  2224.     inc    si
  2225.     call    shombrk            ; examine for bare comma break
  2226.     cmp    al,' '            ; control char?
  2227.     jae    shomd5            ; ae = no
  2228.     cmp    al,cr            ; carriage return?
  2229.     jne    shomd4            ; ne = no
  2230.     cmp    cx,1            ; more to show?
  2231.     je    shomd6            ; e = no
  2232.     call    shomdl            ; new line, check for continue or exit
  2233.     jc    shomd9            ; c = exit
  2234.     mov    ah,conout        ; show two spaces
  2235.     mov    dl,' '            ; the spaces
  2236.     int    dos
  2237.     int    dos
  2238.     add    bx,2
  2239.     cmp    byte ptr es:[si],lf    ; cr followed by linefeed?
  2240.     jne    short shomd6        ; ne = no
  2241.     inc    si            ; skip the leading lf
  2242.     dec    cx
  2243.     jmp    short shomd6
  2244. shomd4:    push    ax
  2245.     mov    ah,conout
  2246.     mov    dl,5eh            ; caret
  2247.     int    dos
  2248.     pop    ax
  2249.     inc    bx
  2250.     add    al,'A'-1        ; add offset to make printable letter
  2251. shomd5:    mov    ah,conout
  2252.     mov    dl,al            ; display it
  2253.     int    dos
  2254.     inc    bx
  2255. shomd6:    cmp    bx,75            ; time to break the line?
  2256.     jb    shomd8            ; b = no
  2257.     cmp    bx,76            ; at an absolute break point
  2258.     jae    shomd7            ; ae = yes
  2259.     cmp    byte ptr es:[si],' '    ; is next char a space?
  2260.     je    shomd8            ; e = yes, show explicitly
  2261. shomd7:    mov    ah,conout        ; display a line break hyphen
  2262.     mov    dl,'-'
  2263.     int    dos
  2264.     xor    bx,bx            ; column counter
  2265.     cmp    cx,1            ; done?
  2266.     je    fshova7            ; e = yes
  2267.     call    shomdl            ; check for screen full
  2268.     jc    shomd9            ; c = exit now
  2269. shomd8:    loop    shomd3            ; do whole string
  2270. shomd9:    pop    es
  2271.     pop    si
  2272.     pop    ax
  2273.     ret
  2274.                       ; worker, do "more" and Control-C checking
  2275. shomdl    proc    near
  2276.     inc    temp1            ; count lines displayed
  2277.     xor    bx,bx            ; count of chars on the line
  2278.     cmp    temp1,24        ; done a normal screens' worth?
  2279.     jb    shomdl3            ; b = no
  2280.     mov    ah,prstr
  2281.     mov    dx,offset moremsg    ; say more
  2282.     int    dos
  2283.     mov    temp1,0
  2284.     mov    flags.cxzflg,0        ; clear flag so we can see Control-C
  2285.     mov    ah,0ch            ; clear keyboard buffer
  2286.     mov    al,coninq        ; quiet input
  2287.     int    dos
  2288.     cmp    al,3            ; Control-C?
  2289.     je    shomdl1            ; e = yes
  2290.     cmp    al,'q'            ; q for quit?
  2291.     je    shomdl1            ; e = yes
  2292.     cmp    al,'Q'            ; Q for quit?
  2293.     je    shomdl1            ; e = yes
  2294.     or    al,al            ; scan code?
  2295.     jne    shomdl2            ; ne = no
  2296.     mov    ah,coninq        ; read the second byte
  2297.     int    dos
  2298.     or    al,al            ; null for Control-Break?
  2299.     jne    shomdl2            ; ne = no
  2300. shomdl1:mov    flags.cxzflg,'C'    ; say want to exit now
  2301. shomdl2:push    cx
  2302.     push    es            ; and read pointer
  2303.     push    si
  2304.     push    di
  2305.     mov    dl,cr            ; move cursor to left margin
  2306.     mov    ah,conout
  2307.     int    dos
  2308.     call    fclearl            ; clear display's line, reuse it
  2309.     pop    di
  2310.     pop    si
  2311.     pop    es
  2312.     pop    cx
  2313.     cmp    flags.cxzflg,0
  2314.     jne    shomdl4
  2315.     clc
  2316.     ret
  2317. shomdl3:mov    ah,prstr
  2318.     mov    dx,offset crlf
  2319.     int    dos
  2320.     clc
  2321.     ret
  2322. shomdl4:stc
  2323.     ret
  2324. shomdl    endp
  2325.  
  2326. ; Examine char in al. If it is a bare comma and byte ptr denom is non-zero
  2327. ; then return AL as CR
  2328. shombrk    proc    near
  2329.     push    dx
  2330.     mov    dx,denom        ; dh=brace cnt, dl=1 for sensitivity
  2331.     cmp    al,'('            ; consider this to be a brace
  2332.     jne    shombr2            ; ne = no
  2333.     inc    dh            ; count brace level
  2334. shombr2:cmp    al,')'
  2335.     jne    shombr4
  2336.     sub    dh,1            ; count down brace level
  2337.     jns    shombr4            ; ns = not below zero
  2338.     xor    dh,dh            ; set brace level to zero
  2339. shombr4:mov    denom,dx        ; store our brace state
  2340.     or    dh,dh            ; inside braces?
  2341.     jnz    shombr5            ; nz = yes
  2342.     cmp    al,','            ; bare comma?
  2343.     jne    shombr5
  2344.     mov    al,CR
  2345. shombr5:pop    dx
  2346.     ret
  2347. shombrk    endp
  2348. fshomdef endp
  2349.  
  2350. fshovar    proc    FAR            ; worker for SHOW VARIABLE, SHOVAR
  2351.     cmp    word ptr rdbuf,'v\'    ; did user say \v(name)?
  2352.     jne    fshova2            ; ne = no
  2353.     mov    di,offset rdbuf        ; start plus count
  2354.     mov    si,di
  2355.     add    si,3            ; remove \v(
  2356.     mov    cx,shmcnt        ; length of user spec
  2357.     sub    cx,3
  2358.     mov    shmcnt,cx        ; remember "variable)" part
  2359.     jle    fshova1            ; le = nothing left
  2360.     inc    cx            ; include null in the move
  2361.     mov    ax,ds
  2362.     mov    es,ax
  2363.     cld
  2364.     rep    movsb            ; copy down
  2365.     mov    si,offset rdbuf
  2366.     add    si,shmcnt
  2367.     cmp    byte ptr [si-1],')'    ; did user say ')'?
  2368.     jne    fshova2            ; ne = no
  2369.     mov    byte ptr [si-1],0    ; remove it
  2370.     dec    shmcnt
  2371.     jmp    short fshova2
  2372. fshova1:mov    shmcnt,0        ; make user entry empty
  2373. fshova2:mov    si,offset valtab    ; table of variable names
  2374.     cld
  2375.     lodsb
  2376.     mov    cl,al            ; number of variable entries
  2377.     xor    ch,ch
  2378.     jcxz    fshova7            ; z = none
  2379.     mov    temp1,0            ; line counter
  2380. fshova3:push    cx            ; save loop counter
  2381.     lodsw                ; length of var name, incl ')'
  2382.     mov    cx,shmcnt        ; length of user's string
  2383.     jcxz    fshova5            ; show all names
  2384.     push    ax            ; save length
  2385.     dec    ax            ; omit ')'
  2386.     cmp    ax,cx            ; var name shorter that user spec?
  2387.     pop    ax            ; recover full length
  2388.     jb    fshova6            ; b = yes, no match
  2389.     push    ax
  2390.     push    si            ; save these around match test
  2391.     mov    di,offset rdbuf        ; user's string
  2392. fshova4:mov    ah,[di]
  2393.     inc    di
  2394.     lodsb                ; al = var name char, ah = user char
  2395.     and    ax,not 2020h        ; clear bits (uppercase chars)
  2396.     cmp    ah,al            ; same?
  2397.     loope    fshova4            ; while equal, do more
  2398.     pop    si            ; restore regs
  2399.     pop    ax
  2400.     jne    fshova6            ; ne = no match
  2401. fshova5:call    fshova8            ; show this name
  2402.     add    si,ax            ; point to next name, add name length
  2403.     add    si,2            ; and string pointer
  2404.     pop    cx            ; recover loop counter
  2405.     cmp    cx,1            ; last item?
  2406.     je    fshova6a        ; e = yes
  2407.     call    shomdl            ; "more" processor
  2408.     jc    fshova7            ; c = exit now
  2409.     jmp    short fshova6a
  2410. fshova6:add    si,ax            ; point to next name, add name length
  2411.     add    si,2            ; and string pointer
  2412.     pop    cx            ; recover loop counter
  2413. fshova6a:loop    fshova3            ; one less macro to examine
  2414. fshova7:mov    flags.cxzflg,0        ; clear flag before exiting
  2415.     ret
  2416.  
  2417. fshova8    proc    near            ; worker for above
  2418.     push    ax
  2419.     mov    ah,prstr
  2420.     mov    dx,offset varstng    ; put out " \v("
  2421.     int    dos
  2422.     push    si
  2423.     push    cx
  2424.     mov    cx,[si-2]        ; length of name
  2425. fshova9:mov    dl,[si]            ; get a variable character
  2426.     inc    si            ; prep for next char
  2427.     mov    ah,conout
  2428.     int    dos
  2429.     loop    fshova9            ; do the count
  2430.     mov    dl,' '            ; display " = "
  2431.     int    dos
  2432.     mov    dl,'='
  2433.     int    dos
  2434.     mov    dl,' '
  2435.     int    dos
  2436.     mov    bx,[si]            ; get result code to bx
  2437.     xor    dx,dx            ; trim off trailing spaces
  2438.     push    es
  2439.     mov    di,seg decbuf
  2440.     mov    es,di
  2441.     mov    di,offset decbuf
  2442.     call    fnvaltoa        ; fill es:di with string
  2443.     pop    es
  2444.     jc    fshova10        ; c = failure
  2445.     mov    cx,di            ; di is string length
  2446.     mov    di,offset decbuf    ; string text (skips count word)
  2447.     call    prtscr            ; display counted string
  2448. fshova10:pop    cx
  2449.     pop    si
  2450.     pop    ax
  2451.     ret
  2452. fshova8    endp                ; end of worker
  2453. fshovar    endp
  2454.  
  2455. ; Stuff string ds:di with last file transfer char/sec ascii string.
  2456. ; called by show variable code in msscmd.asm
  2457. shovarcps proc    near
  2458.     xor    ax,ax
  2459.     mov    bx,offset fsta        ; last file structure
  2460.     test    sflag,2            ; 0 for rcv, 2 for send
  2461.     jz    shovarcp1        ; z = receive
  2462.     mov    ax,[bx].fsbyte        ; file bytes sent, low
  2463.     mov    dx,[bx].fsbyte+2    ;  high. [dx,ax] = total file bytes
  2464.     jmp    short shovarcp2
  2465. shovarcp1:mov    ax,[bx].frbyte        ; file bytes received, low
  2466.     mov    dx,[bx].frbyte+2    ; file bytes received, high
  2467. shovarcp2:call    showrk            ; do worker
  2468.     call    flnout            ; show long integer, with separator
  2469.     ret
  2470. shovarcps endp
  2471.  
  2472. ; show macro arrays, far worker for sharray
  2473. fsharray proc    far
  2474.     mov    ah,prstr
  2475.     mov    dx,offset fsharr1    ; herald
  2476.     int    dos
  2477.     xor    bx,bx                 ; walk down array list
  2478.     mov    cx,25            ; number of possible arrays
  2479. fshar1:    mov    ax,marray[bx]        ; get seg of array element
  2480.     or    ax,ax            ; any?
  2481.     jz    fshar2            ; z = no
  2482.     push    ax
  2483.     mov    ah,conout
  2484.     mov    dl,' '
  2485.     int    dos
  2486.     mov    dl,'\'
  2487.     int    dos
  2488.     mov    dl,'&'
  2489.     int    dos
  2490.     mov    dl,bl            ; array index (words)
  2491.     shr    dl,1            ; bytes
  2492.     add    dl,'@'+20h        ; bias to lower case
  2493.     int    dos
  2494.     mov    dl,'['
  2495.     int    dos
  2496.     pop    ax            ; recover segment
  2497.     push    es
  2498.     mov    es,ax            ; seg of it
  2499.     mov    ax,es:[0]        ; get number of array elements
  2500.     pop    es
  2501.     call    decout            ; display array size
  2502.     mov    ah,prstr
  2503.     mov    dx,offset fsharr2    ; ']' end of line
  2504.     int    dos
  2505. fshar2:    add    bx,2            ; next array slot
  2506.     loop    fshar1            ; do all
  2507.     ret
  2508. fsharray endp
  2509.  
  2510. code1    ends
  2511.  
  2512. code    segment
  2513.     assume cs:code
  2514.  
  2515. ; Show array
  2516. sharray    proc    near
  2517.     call    fsharray        ; call the far proc above
  2518.     ret
  2519. sharray    endp
  2520.  
  2521. ; SHOW TRANSLATE-RECEIVE
  2522. ; Display characters being changed for Connect mode serial receive translator
  2523.  
  2524. SHORX    PROC    NEAR            ; show translate table of incoming
  2525.                     ; chars, only those changed
  2526.     mov    ah,cmeol        ; get a confirm
  2527.     call    comnd
  2528.     jnc    shorx0a            ; nc = success
  2529.     ret                ; failure
  2530. shorx0a:
  2531.     mov    ah,prstr
  2532.     mov    dx,offset crlf
  2533.     int    dos
  2534.     mov    bx,offset shorxk    ; show keyboard translation
  2535.     xor    cx,cx
  2536.     call    statc
  2537.     mov    ah,prstr
  2538.     mov    dx,offset rxoffmsg    ; assume translation is off
  2539.     cmp    rxtable+256,0        ; is translation off?
  2540.     je    shorx0            ; e = yes
  2541.     mov    dx,offset rxonmsg    ; say translation is on
  2542. shorx0:    int    dos
  2543.     mov    dx,offset shormsg    ; give title line
  2544.     int    dos
  2545.     xor    cx,cx            ; formatted line counter
  2546.     xor    bx,bx            ; entry subscript
  2547. shorx1:    cmp    rxtable[bx],bl        ; entry same as normal?
  2548.     je    shorx2            ; e = yes, skip it
  2549.     call    shorprt            ; display the entry
  2550. shorx2:    inc    bx            ; next entry
  2551.     cmp    bx,255            ; done all entries yet?
  2552.     jbe    shorx1            ; be = not yet
  2553.     mov    ah,prstr
  2554.     mov    dx,offset crlf        ; end with cr/lf
  2555.     int    dos
  2556.     clc                ; success
  2557.     ret
  2558.                     ; worker routine
  2559. shorprt:cmp    cx,4            ; done five entries for this line?
  2560.     jb    shorpr1            ; b = no
  2561.     mov    ah,prstr
  2562.     mov    dx,offset crlf        ; break line now
  2563.     int    dos
  2564.     xor    cx,cx
  2565. shorpr1:mov    ah,prstr
  2566.     mov    dx,offset shopm1    ; start of display
  2567.     int    dos
  2568.     xor    ah,ah
  2569.     mov    al,bl            ; original byte code
  2570.     call    decout            ; display its value
  2571.     mov    ah,prstr
  2572.     mov    dx,offset shopm2    ; intermediate part of display
  2573.     int    dos
  2574.     xor    ah,ah
  2575.     mov    al,rxtable[bx]        ; new byte code
  2576.     call    decout            ; display its value
  2577.     mov    ah,prstr
  2578.     mov    dx,offset shopm3    ; last part of display
  2579.     int    dos
  2580.     inc    cx            ; count item displayed
  2581.     ret
  2582. SHORX    ENDP
  2583.  
  2584. ; SHOW MACRO [macro name]
  2585.  
  2586. SHOMAC    PROC    NEAR
  2587.     mov    ah,cmword
  2588.     mov    bx,offset rdbuf
  2589.     mov    dx,offset shmmsg
  2590.     mov    comand.cmper,1        ; don't react to \%x variables
  2591.     call    comnd
  2592.     jnc    shoma1a            ; nc = success
  2593.     ret                ; failure
  2594. shoma1a:mov    shmcnt,ax        ; save length of user spec
  2595.     mov    ah,cmeol
  2596.     call    comnd
  2597.     jnc    shoma1b            ; nc = success
  2598.     ret                ; failure
  2599. shoma1b:mov    si,offset mcctab    ; table of macro names
  2600.     cld
  2601.     lodsb
  2602.     mov    cl,al            ; number of macro entries
  2603.     xor    ch,ch
  2604.     jcxz    shom6            ; z = none
  2605.     mov    temp,0            ; count of macros displayed
  2606.     mov    temp1,0            ; lines displayed, for more message
  2607. shom2:    push    cx            ; save loop counter
  2608.     lodsw                ; length of macro name
  2609.     mov    cx,shmcnt        ; length of user's string
  2610.     jcxz    shom4            ; show all names
  2611.     cmp    ax,cx            ; mac name shorter that user spec?
  2612.     jb    shom5            ; b = yes, no match
  2613.     push    ax
  2614.     push    si            ; save these around match test
  2615.     mov    di,offset rdbuf        ; user's string
  2616. shom3:    mov    ah,[di]
  2617.     inc    di
  2618.     lodsb                ; al = mac name char, ah = user char
  2619.     and    ax,not 2020h        ; clear bits (uppercase chars)
  2620.     cmp    ah,al            ; same?
  2621.     loope    shom3            ; while equal, do more
  2622.     pop    si            ; restore regs
  2623.     pop    ax
  2624.     jne    shom5            ; ne = no match
  2625. shom4:    call    fshomdef        ; show this name (FAR)
  2626. shom5:    add    si,ax            ; point to next name, add name length
  2627.     add    si,2            ;  and string pointer
  2628.     pop    cx            ; recover loop counter
  2629.     cmp    flags.cxzflg,0        ; does user wish to stop now?
  2630.     jne    shom5a            ; ne = yes
  2631.     loop    shom2            ; one less macro to examine
  2632. shom5a:    mov    flags.cxzflg,0        ; clear flag before exiting
  2633.     cmp    temp,0            ; did we show any macros?
  2634.     jne    shom7            ; ne = yes
  2635. shom6:    mov    ah,prstr
  2636.     mov    dx,offset shom9m3    ; no entries found
  2637.     int    dos
  2638. shom7:    mov    ah,prstr        ; Summary line
  2639.     mov    dx,offset shom9m1    ; free space: name entries
  2640.     int    dos
  2641.     mov    ax,offset mcctab+mcclen
  2642.     sub    ax,mccptr        ; compute # of free name bytes
  2643.     call    decout
  2644.     clc                ; success
  2645.     ret
  2646. SHOMAC    ENDP
  2647.  
  2648. SHCOM    PROC    NEAR            ; Show Comm
  2649.     mov    ah,cmeol
  2650.     call    comnd            ; get a confirm
  2651.     jc    shcom1            ; c = failure
  2652.     mov    dx,offset crlf
  2653.     mov    ah,prstr
  2654.     int    dos            ; print a crlf
  2655.     mov    bx,offset stcom        ; table of items to be shown
  2656.     xor    cx,cx
  2657.     call    statc            ; finish in common code
  2658.     call    shomodem
  2659. ifndef    no_network
  2660.     call    shownet
  2661. endif    ; no_network
  2662.     clc
  2663. shcom1:    ret
  2664. SHCOM    ENDP
  2665.  
  2666. SHFILE    PROC    NEAR            ; Show File
  2667.     mov    ah,cmeol
  2668.     call    comnd            ; get a confirm
  2669.     jnc    shfile1            ; nc = success
  2670.     ret                ; failure
  2671. shfile1:mov    dx,offset crlf
  2672.     mov    ah,prstr
  2673.     int    dos            ; print a crlf
  2674.     mov    bx,offset stfile    ; table of items to be shown
  2675.     xor    cx,cx
  2676.     jmp    statc            ; finish in common code
  2677. SHFILE    ENDP
  2678.  
  2679. SHLOG    PROC    NEAR            ; Show Log
  2680.     mov    ah,cmeol
  2681.     call    comnd            ; get a confirm
  2682.     jnc    shlog1            ; nc = success
  2683.     ret                ; failure
  2684. shlog1:    mov    dx,offset crlf
  2685.     mov    ah,prstr
  2686.     int    dos            ; print a crlf
  2687.     mov    bx,offset stlog        ; table of items to be shown
  2688.     xor    cx,cx
  2689.     jmp    statc            ; finish in common code
  2690. SHLOG    ENDP
  2691.  
  2692. SHMEM    PROC    NEAR            ; Show (free) Memory.   Recursive!
  2693.     mov    ah,cmeol
  2694.     call    comnd            ; get a confirm
  2695.     jnc    shmem1            ; nc = success
  2696.     ret                ; failure
  2697. shmem1:    mov    ah,prstr
  2698.     mov    dx,offset memmsg1    ; header message
  2699.     int    dos
  2700.     mov    word ptr rdbuf,'  '    ; two spaces
  2701.     mov    rdbuf+2,0        ; safety null terminator
  2702.     mov    di,offset rdbuf+1    ; look at first space
  2703.     mov    temp,0            ; total free memory
  2704.     mov    temp1,0            ;  and high word thereof
  2705.     push    es            ; save es
  2706.     call    shmem4            ; allocate memory, recursively
  2707.     mov    dx,offset rdbuf        ; output buffer
  2708.     call    prtasz            ; show pieces
  2709.     mov    dx,offset memmsg2    ; trailer
  2710.     mov    ah,prstr
  2711.     int    dos
  2712.     mov    di,offset rdbuf        ; setup buffer for lnout
  2713.     mov    rdbuf,0
  2714.     mov    ax,temp            ; total free space
  2715.     mov    dx,temp1
  2716.     call    lnouts            ; 32 bit to decimal ascii in di
  2717.     mov    dx,offset rdbuf        ;  with thousands separator
  2718.     call    prtasz
  2719.     pop    es
  2720.     ret
  2721.                     ; worker routine
  2722. shmem4:    mov    bx,0ffffh        ; allocate all memory (must fail)
  2723.     mov    ah,alloc        ; DOS memory allocator
  2724.     int    dos            ; returns available paragraphs in bx
  2725.     jnc    shmem6            ; nc = got it all (not very likely)
  2726.     or    bx,bx            ; bx = # paragraphs alloc'd. Anything?
  2727.     jz    shmem5            ; z = no
  2728.     mov    ah,alloc        ; consume qty now given in bx
  2729.     int    dos
  2730.     jnc    shmem6            ; nc = got the fragment
  2731. shmem5:    ret
  2732. shmem6:    push    ax            ; save allocation segment
  2733.     mov    ax,bx            ; convert paragraphs
  2734.     mul    sixteen            ;  to bytes in dx:ax
  2735.     add    temp,ax            ; running total
  2736.     adc    temp1,dx        ;  32 bits
  2737.     cmp    byte ptr [di],0        ; starting on a null?
  2738.     jne    shmem7            ; ne = no, skip punctuation
  2739.     mov    byte ptr [di],'+'    ; plus punctuation
  2740.     inc    di
  2741. shmem7:    call    lnouts            ; long number to decimal in buffer di
  2742.     call    shmem4            ; recurse
  2743.     pop    es            ; recover allocation segment
  2744.     mov    ah,freemem        ; free the allocation
  2745.     int    dos
  2746.     ret
  2747. SHMEM    ENDP
  2748.  
  2749. shnet    PROC    NEAR            ; Show network
  2750.     mov    ah,cmeol
  2751.     call    comnd            ; get a confirm
  2752.     jc    shnet1            ; c = failure
  2753.     mov    dx,offset crlf
  2754.     mov    ah,prstr
  2755.     int    dos            ; print a crlf
  2756.     mov    bx,offset stcom        ; table of items to be shown
  2757.     xor    cx,cx
  2758.     call    statc            ; finish in common code
  2759. ifndef    no_network
  2760.     call    shownet
  2761. endif    ; no_network
  2762.     clc
  2763. shnet1:    ret
  2764. SHnet    ENDP
  2765.  
  2766. SHPRO    PROC    NEAR            ; Show Protocol
  2767.     mov    ah,cmeol
  2768.     call    comnd            ; get a confirm
  2769.     jnc    shpro1            ; nc = success
  2770.     ret                ; failure
  2771. shpro1:    mov    dx,offset crlf
  2772.     mov    ah,prstr
  2773.     int    dos            ; print a crlf
  2774.     mov    bx,offset stpro        ; table of items to be shown
  2775.     xor    cx,cx
  2776.     jmp    statc            ; finish in common code
  2777. SHPRO    ENDP
  2778.  
  2779. SHSCPT    PROC    NEAR            ; Show Script
  2780.     mov    ah,cmeol
  2781.     call    comnd            ; get a confirm
  2782.     jnc    shscpt1            ; nc = success
  2783.     ret                ; failure
  2784. shscpt1:mov    dx,offset crlf
  2785.     mov    ah,prstr
  2786.     int    dos            ; print a crlf
  2787.     mov    bx,offset stscpt    ; table of items to be shown
  2788.     xor    cx,cx
  2789.     jmp    statc            ; finish in common code
  2790. SHSCPT    ENDP
  2791.  
  2792. SHSERV    PROC    NEAR            ; Show Server
  2793.     mov    ah,cmeol
  2794.     call    comnd            ; get a confirm
  2795.     jnc    shserv1            ; nc = success
  2796.     ret                ; failure
  2797. shserv1:mov    dx,offset crlf
  2798.     mov    ah,prstr
  2799.     int    dos            ; print a crlf
  2800.     mov    bx,offset stserv2    ; do timeout item
  2801.     xor    cx,cx
  2802.     call    statc
  2803.     mov    dx,offset crlf
  2804.     mov    ah,prstr
  2805.     int    dos
  2806.     mov    bx,offset stserv    ; table of items to be shown
  2807.     jmp    statc            ; finish in common code
  2808. SHSERV    ENDP
  2809.  
  2810. SHTERM    PROC    NEAR            ; Show Terminal
  2811.     mov    ah,cmeol
  2812.     call    comnd            ; get a confirm
  2813.     jnc    shterm1            ; nc = success
  2814.     ret                ; failure
  2815. shterm1:mov    dx,offset crlf
  2816.     mov    ah,prstr
  2817.     int    dos            ; print a crlf
  2818. ifdef    no_terminal
  2819.     ret                ; cut short the display
  2820. else
  2821.     mov    bx,offset stterm    ; table of items to be shown
  2822.     xor    cx,cx
  2823.     jmp    statc            ; use common code
  2824. endif    ; no_terminal
  2825. SHTERM    ENDP
  2826.  
  2827. ; SHOW VAR of kind \v(name)
  2828. SHOVAR    proc    near
  2829.     mov    ah,cmword
  2830.     mov    bx,offset rdbuf
  2831.     mov    dx,offset shvmsg
  2832.     mov    comand.cmper,1        ; don't react to \%x variables
  2833.     call    comnd
  2834.     jnc    shovar1            ; nc = success
  2835.     ret                ; failure
  2836. shovar1:mov    shmcnt,ax        ; save length of user spec
  2837.     mov    ah,cmeol
  2838.     call    comnd
  2839.     jnc    shovar2            ; nc = success
  2840.     ret                ; failure
  2841. shovar2:mov    ah,prstr
  2842.     mov    dx,offset crlf
  2843.     int    dos
  2844.     call    fshovar            ; call FAR worker
  2845.     ret
  2846. SHOVAR    endp
  2847.  
  2848. begtim    proc    near
  2849.     call    fbegtim            ; call the real FAR routine
  2850.     ret
  2851. begtim    endp
  2852. endtim    proc    near
  2853.     call    fendtim            ; call the real FAR routine
  2854.     ret
  2855. endtim    endp
  2856.  
  2857. ; SHOW STATISTICS command. Displays last operation and session statistics
  2858. shosta    proc    near            ; show file transfer statistics
  2859.     mov    ah,cmeol        ; confirm with carriage return
  2860.     call    comnd
  2861.     jnc    shosta1
  2862.     ret                ; failure
  2863. shosta1:xor    ax,ax
  2864.     call    endtim            ; update statistics, just in case
  2865.     call    fshosta            ; do a far call to worker
  2866.     ret
  2867. shosta    endp
  2868.  
  2869. ; STATUS command
  2870.  
  2871. STATUS    PROC    NEAR
  2872.     mov    ah,cmeol
  2873.     call    comnd            ; get a confirm
  2874.     jnc    stat0a            ; nc = success
  2875.     ret                ; failure
  2876. stat0a:    mov    dx,offset crlf
  2877.     mov    ah,prstr
  2878.     int    dos            ; print a crlf
  2879.                     ; STAT0 is an external ref (in msster)
  2880. STAT0:    call    cmblnk            ; clear the screen
  2881.     call    locate            ; home the cursor
  2882.     mov    bx,offset sttab        ; table to control printing
  2883.     xor    cx,cx            ; column counter
  2884.                     ; STATC is external ref in msx
  2885. STATC:    cmp    word ptr [bx],0        ; end of table?
  2886.     je    statx            ; e = yes
  2887.     cld                ; string direction is forward
  2888.     push    ds
  2889.     pop    es
  2890.     mov    di,offset rdbuf        ; point to destination buffer
  2891.     mov    byte ptr[di],spc    ; start with two spaces
  2892.     inc    di
  2893.     mov    byte ptr[di],spc
  2894.     inc    di
  2895.     push    cx            ; save column number
  2896.     push    bx
  2897.     call    [bx].sttyp        ; call appropriate routine
  2898.     pop    bx
  2899.     pop    cx
  2900.     sub    di,offset rdbuf        ; number of bytes used
  2901.     add    cx,di            ; new line col count
  2902.     push    cx            ; save col number around print
  2903.     mov    cx,di            ; how much to print now
  2904.     mov    di,offset rdbuf        ; source text
  2905.     cmp    cx,2            ; nothing besides our two spaces?
  2906.     jbe    stat5            ; e = yes, forget it
  2907.     call    prtscr            ; print counted string
  2908. stat5:    pop    cx
  2909.     add    bx,size stent        ; look at next entry
  2910.     cmp    word ptr [bx],0        ; at end of table?
  2911.     je    statx            ; e = yes
  2912.     cmp    cx,38            ; place for second display?
  2913.     jbe    stat2            ; be = only half full
  2914.     mov    dx,offset crlf        ; over half full. send cr/lf
  2915.     mov    ah,prstr
  2916.     int    dos
  2917.     xor    cx,cx            ; say line is empty now
  2918.     jmp    statc
  2919. stat2:    mov    ax,cx
  2920.     mov    cx,38            ; where we want to be next time
  2921.     sub    cx,ax            ; compute number of filler spaces
  2922.     or    cx,cx
  2923.     jle    stat4            ; nothing to do
  2924.     mov    ah,conout
  2925.     mov    dl,' '
  2926. stat3:    int    dos            ; fill with spaces
  2927.     loop    stat3            ; do cx times
  2928. stat4:    mov    cx,38            ; current column number
  2929.     jmp    statc            ; and do it
  2930. statx:    clc
  2931.     ret
  2932. STATUS    ENDP
  2933.  
  2934. ; handler routines for status
  2935. ; all are called with di/ destination buffer, bx/ stat ptr. They can change
  2936. ; any register except es:, must update di to the end of the buffer.
  2937.  
  2938.  
  2939. ; Copy dollar sign terminated string to buffer pointed at by preset di.
  2940. stmsg    proc    near
  2941.     push    ds
  2942.     pop    es        ; ensure es points to data segment
  2943.     mov    si,[bx].msg    ; get message address
  2944. stms1:    lodsb            ; get a byte
  2945.     stosb            ; drop it off
  2946.     or    al,al        ; ending on null?
  2947.     jz    stms2        ; z = yes
  2948.     cmp    al,'$'        ; end of message?
  2949.     jne    stms1        ; no, keep going
  2950. stms2:    dec    di        ; else back up ptr
  2951.     ret
  2952. stmsg    endp
  2953.  
  2954. ; get address of test value in stent. Returns address in si
  2955. stval    proc    near
  2956.     mov    si,[bx].basval    ; get base value
  2957.     or    si,si        ; any there?
  2958.     jz    stva1        ; z = no, keep going
  2959.     mov    si,[si]        ; yes, use as base address
  2960. stva1:    add    si,[bx].tstcel    ; add offset of test cell
  2961.     ret            ; and return it
  2962. stval    endp
  2963.  
  2964. ; print a single character
  2965. onechr    proc    near
  2966.     call    stmsg        ; copy message part first
  2967.     call    stval        ; pick up test value address
  2968.     mov    al,[si]        ; this is char to print
  2969.     cmp    al,7fh        ; in graphics region?
  2970.     jb    onech2        ; b = no
  2971.     mov    byte ptr [di],'\' ; do in \numerical form
  2972.     inc    di
  2973.     xor    ah,ah        ; clear high byte
  2974.     jmp    outnum        ; do number part
  2975. onech2:    cmp    al,' '        ; printable?
  2976.     jae    onech1        ; yes, keep going
  2977.     add    al,64        ; make printable
  2978.     mov    byte ptr [di],5eh    ; caret
  2979.     inc    di        ; note ctrl char
  2980. onech1:    stosb            ; drop char off
  2981.     ret
  2982. onechr    endp
  2983.  
  2984. ; numeric field
  2985. stnum    proc    near        ; for 8 bit numbers
  2986.     call    stmsg        ; copy message
  2987.     call    stval        ; pick up value address
  2988.     mov    al,[si]        ; get value
  2989.     xor    ah,ah        ; high order is 0
  2990.     jmp    outnum        ; put number into buffer
  2991. stnum    endp
  2992.  
  2993. stlnum    proc    near        ; for 16 bit numbers
  2994.     call    stmsg        ; copy message
  2995.     call    stval        ; pick up value address
  2996.     mov    ax,[si]        ; get value
  2997.     jmp    outnum        ; put number into buffer
  2998. stlnum    endp
  2999.  
  3000. ; translate the number in ax
  3001. outnum    proc    near
  3002.     xor    dx,dx
  3003.     mov    bx,10
  3004.     div    bx        ; divide to get digit
  3005.     push    dx        ; save remainder digit
  3006.     or    ax,ax        ; test quotient
  3007.     jz    outnu1        ; zero, no more of number
  3008.     call    outnum        ; else call for rest of number
  3009. outnu1:    pop    ax        ; get digit back
  3010.     add    al,'0'        ; make printable
  3011.     stosb            ; drop it off
  3012.     ret
  3013. outnum    endp
  3014.  
  3015. ; on/off field
  3016. onoff    proc    near
  3017.     call    stmsg        ; copy message
  3018.     call    stval        ; get value cell
  3019.     mov    al,[si]
  3020.     mov    si,offset onmsg
  3021.     mov    cx,2        ; assume 2-byte 'ON' message
  3022.     or    al,al        ; test value
  3023.     jnz    onof1        ; on, have right msg
  3024.     mov    si,offset offmsg
  3025.     mov    cx,3
  3026. onof1:    cld
  3027.     push    ds
  3028.     pop    es
  3029.     rep    movsb        ; copy right message in
  3030.     ret
  3031. onoff    endp
  3032.  
  3033. ; print first message if false, second if true
  3034. msg2    proc    near
  3035.     call    stval        ; get value cell
  3036.     mov    al,[si]
  3037.     mov    si,[bx].msg    ; assume off
  3038.     or    al,al        ; is it?
  3039.     jz    msg21        ; yes, continue
  3040.     mov    si,[bx].val2    ; else use alternate message
  3041. msg21:    jmp    stms1        ; handle copy and return
  3042. msg2    endp
  3043.  
  3044. ; print first message if false, second if true, uses bit in byte for value
  3045. msg2b    proc    near
  3046.     call    stbval        ; get bit value cell
  3047.     mov    si,[bx].msg    ; assume off
  3048.     or    al,al        ; is it?
  3049.     jz    msg2b1        ; yes, continue
  3050.     mov    si,[bx].val2    ; else use alternate message
  3051. msg2b1:    jmp    stms1        ; handle copy and return
  3052. msg2b    endp
  3053.  
  3054. ; search a keyword table for a word value, print that value
  3055. srchkww    proc    near
  3056.     call    stmsg        ; copy the first message
  3057.     call    stval
  3058.     mov    ax,[si]        ; get value to hunt for
  3059.     mov    bx,[bx].val2    ; this is table address
  3060.     jmp    prttab        ; and look in table
  3061. srchkww    endp
  3062.  
  3063. ; search a keyword table for a byte value, print that value
  3064. srchkw    proc    near
  3065.     call    stmsg        ; first print message
  3066.     call    stval
  3067.     mov    al,[si]        ; get value to hunt for
  3068.     xor    ah,ah        ; high order is 0
  3069.     mov    bx,[bx].val2    ; this is table address
  3070.     jmp    prttab        ; and look in table
  3071. srchkw    endp
  3072.  
  3073. ; search a keyword table for a bit value, print that value
  3074. srchkb    proc    near
  3075.     call    stmsg            ; first print message
  3076.     call    stbval            ; get bit set or reset
  3077.     mov    bx,[bx].val2        ; this is table address
  3078.     jmp    prttab            ; and look in table
  3079. srchkb    endp
  3080.  
  3081. ; get address of test value in stent.  Returns address in si.
  3082. stbval    proc    near
  3083.     mov    si,[bx].basval        ; get address of test value
  3084.     or    si,si            ; any there?
  3085.     jz    stbva1            ; z = no, quit with no match
  3086.     mov    ax,[si]            ; get value
  3087.     test    ax,[bx].tstcel         ; bit test value against data word
  3088.     jz    stbva1            ; z = they don't match
  3089.     mov    ax,1            ;  match
  3090.     ret
  3091. stbva1:    xor    ax,ax            ; no match
  3092.     ret                ; and return it
  3093. stbval    endp
  3094.  
  3095.  
  3096. ; Print the drive name
  3097. drnum    proc    near
  3098.     call    stmsg        ; copy message part first
  3099.     call    stval        ; pick up test value address
  3100.     mov    ah,gcurdsk    ; Get current disk
  3101.     int    dos
  3102.     inc    al        ; We want 1 == A (not zero)
  3103.     mov    curdsk,al
  3104.     add    al,'@'        ; Make it printable
  3105.     cld
  3106.     push    ds
  3107.     pop    es
  3108.     stosb
  3109.     mov    word ptr [di],'\:'
  3110.     add    di,2        ; end with a colon and backslash
  3111.     mov    byte ptr [di],0    ; terminate in case drive is not ready
  3112.     xor    dl,dl        ; get current drive
  3113.     mov    ah,gcd        ; get current directory
  3114.     mov    si,di        ; current working buffer position
  3115.     int    dos
  3116.     push    cx
  3117.     push    dx
  3118.     mov    dx,di        ; directory string
  3119.     call    strlen        ; length of path part to cx
  3120.     cmp    cx,26        ; too long to show the whole thing?
  3121.     jbe    drnum3        ; be = is ok, show the whole path
  3122.     push    di        ; scan backward for last backslash
  3123.     mov    al,'\'        ; thing to search for
  3124.     std            ; backward
  3125.     mov    di,si        ; start of buffer
  3126.     add    di,cx        ; length of string
  3127.     repne    scasb        ; scan backward for a backslash
  3128.     jcxz    drnum2        ; should not happen, but then again 
  3129.     repne    scasb        ; do again for second to last path part
  3130. drnum2:    cld            ; reset direction flag
  3131.     dec    di        ; move di two places preceding backslash
  3132.     mov    [di],'--'    ; insert a missing path indicator
  3133.     dec    di
  3134.     mov    byte ptr [di],'-'
  3135.     mov    si,di        ; we will show just this part
  3136.     pop    di        ; recover main status pointer
  3137. drnum3:    pop    dx
  3138.     pop    cx
  3139.     
  3140. drnum4:    lodsb            ; copy until null terminator
  3141.     stosb
  3142.     or    al,al        ; end of string?
  3143.     jnz    drnum4        ; nz = no
  3144.     dec    di        ; offset inc of stosb
  3145.     ret
  3146. drnum    endp
  3147.  
  3148.  
  3149. ; Print the screen-dump filename [jrd]
  3150.  
  3151. pasz    proc    near
  3152.     call    stmsg        ; copy message part
  3153.     mov    si,[bx].val2    ; address of asciiz string
  3154.     push    ds
  3155.     pop    es
  3156.     cld
  3157. pasz1:    lodsb            ; get a byte
  3158.     or    al,al        ; at end yet?
  3159.     jz    pasz2        ; z = yes
  3160.     stosb            ; store in buffer
  3161.     jmp    short pasz1    ; keep storing non-null chars
  3162. pasz2:    ret
  3163. pasz    endp
  3164.  
  3165. ; Repeat quote status presenter
  3166. rptstat    proc    near
  3167.     call    stmsg            ; copy message part
  3168.     mov    al,dtrans.rptq        ; repeat quote char
  3169.     stosb                ; char
  3170.     mov    si,offset rptqena    ; assume enabled
  3171.     cmp    dtrans.rptqenable,0    ; enabled/disabled byte
  3172.     jne    rptstat1        ; ne = no
  3173.     mov    si,offset rptqdis    ; say disabled
  3174. rptstat1:lodsb                ; read byte
  3175.     stosb                ; store byte
  3176.     or    al,al
  3177.     jnz    rptstat1        ; til done
  3178.     ret
  3179. rptstat    endp
  3180.  
  3181. ; Display unprotected control characters
  3182. cntlsho    proc    near
  3183.     mov    ah,cmeol
  3184.     call    comnd
  3185.     jc    cntlsho1        ; c = failure
  3186.     mov    ah,prstr
  3187.     mov    dx,offset cntlmsg1     ; first msg
  3188.     int    dos
  3189.     mov    temp,0            ; show unprotected
  3190.     mov    dx,1            ; do 7-bit unprotected forms
  3191.     call    cntlwk            ; call worker
  3192.     mov    ah,prstr
  3193.     mov    dx,offset crlf
  3194.     int    dos
  3195.     mov    ah,conout
  3196.     mov    dl,' '
  3197.     int     dos
  3198.     mov    dx,8080h        ; do 8-bit unprotected forms
  3199.     call    cntlwk
  3200.  
  3201.     mov    ah,prstr
  3202.     mov    dx,offset cntlmsg2     ; protected msg
  3203.     int    dos
  3204.     mov    dx,1            ; do 7-bit unprotected forms
  3205.     mov    temp,1            ; show protected
  3206.     call    cntlwk            ; call worker
  3207.     mov    ah,prstr
  3208.     mov    dx,offset crlf
  3209.     int    dos
  3210.     mov    ah,conout
  3211.     mov    dl,' '
  3212.     int     dos
  3213.     mov    dx,8080h        ; do 8-bit unprotected forms
  3214.     call    cntlwk
  3215.     clc
  3216. cntlsho1:ret
  3217. cntlsho endp
  3218. code    ends
  3219.  
  3220. code1    segment
  3221.     assume    cs:code1
  3222.  
  3223. ; worker for cntlsho to display prefixed and not code values
  3224. cntlwk    proc    far
  3225.     mov    cx,32
  3226.     xor    bx,bx
  3227.     xor    si,si            ; items per line counter
  3228. cntlwk1:cmp    temp,0            ; doing unprotected?
  3229.     je    cntlwk4            ; e = yes
  3230.     cmp    bl,trans.ssoh        ; packet start of header?
  3231.     je    cntlwk5            ; e = yes, always prefixed
  3232.     cmp    bl,trans.seol        ; packet end of line?
  3233.     je    cntlwk5            ; e = yes, always prefixed
  3234.     test    protlist[bx],dl        ; unprotected?
  3235.     jz    cntlwk5            ; z = no
  3236.     jmp    short cntlwk2        ; skip unprotected
  3237.  
  3238. cntlwk4:cmp    bl,trans.ssoh        ; packet start of header?
  3239.     je    cntlwk2            ; e = yes, always prefixed
  3240.     cmp    bl,trans.seol        ; packet end of line?
  3241.     je    cntlwk2            ; e = yes, always prefixed
  3242.     test    protlist[bx],dl        ; unprotected?
  3243.     jz    cntlwk2            ; z = no
  3244. cntlwk5:mov    ax,bx
  3245.     add    al,dh            ; add possible 128 offset
  3246.     push    dx
  3247.     call    decout
  3248.     mov    ah,conout        ; show space
  3249.     mov    dl,' '
  3250.     int    dos
  3251.     pop    dx
  3252.     inc    si            ; count item displayed
  3253. cntlwk2:inc    bx
  3254.     cmp    si,17            ; done plenty for one line?
  3255.     jb    cntlwk3            ; b = no
  3256.     push    dx
  3257.     mov    ah,prstr
  3258.     mov    dx,offset crlf
  3259.     int    dos
  3260.     mov    ah,conout
  3261.     mov    dl,' '
  3262.     int    dos
  3263.     pop    dx
  3264.     xor    si,si
  3265. cntlwk3:loop    cntlwk1
  3266.     cmp    temp,0            ; showing prefixed?
  3267.     je    cntlwk6            ; e = no
  3268.     xor    ah,ah
  3269.     mov    al,127            ; always prefixed
  3270.     add    al,dh            ; high bit
  3271.     call    decout
  3272. cntlwk6:ret
  3273. cntlwk    endp
  3274. code1    ends
  3275.  
  3276. code    segment
  3277.     assume cs:code
  3278.  
  3279. ; Display Send and Receive chars
  3280. prsar    proc    near
  3281.     call     stmsg        ; display leadin part of message
  3282.     push    ds
  3283.     pop    es
  3284.     cld
  3285.     mov    si,[bx].tstcel    ; get address of first item
  3286.     mov    al,[si]
  3287.     cmp    al,7fh        ; DEL code?
  3288.     jne    prsar1        ; ne = no
  3289.     mov    ax,'1\'        ; say \127
  3290.     cmp    byte ptr [di-1],5eh ; caret present in msg?
  3291.     jne    prsar5        ; ne = no
  3292.     dec    di        ; remove "^"
  3293. prsar5:    stosw
  3294.     mov    ax,'72'
  3295.     stosw
  3296.     jmp    short prsar2
  3297. prsar1:    dec    di        ; remove "^"
  3298.     cmp    al,20h        ; printable now?
  3299.     jae    prsar7        ; ae = yes
  3300.     inc    di        ; restore "^"
  3301.     add    al,40H        ; make it printable
  3302. prsar7:    stosb
  3303. prsar2:    mov    si,[bx].val2    ; get address of second msg
  3304.     call    stms1        ; add that
  3305.     mov    si,[bx].basval    ; second value's address
  3306.     mov    al,[si]        ; second value
  3307.     cmp    al,7fh        ; DEL code?
  3308.     jne    prsar3        ; ne = no
  3309.     mov    ax,'1\'        ; say \127
  3310.     cmp    byte ptr [di-1],5eh ; caret present in msg?
  3311.     jne    prsar6        ; ne = no
  3312.     dec    di        ; remove "^"
  3313. prsar6:    stosw
  3314.     mov    ax,'72'
  3315.     stosw
  3316.     ret
  3317. prsar3:    dec    di        ; remove "^"
  3318.     cmp    al,20h        ; printable now?
  3319.     jae    prsar3a        ; ae = yes
  3320.     inc    di        ; restore "^"
  3321.     add    al,40H        ; make it printable
  3322. prsar3a:stosb
  3323.     ret
  3324. prsar    endp
  3325.  
  3326. ; Display Send and Receive char value
  3327. prsarv    proc    near
  3328.     call     stmsg        ; display leadin part of message
  3329.     mov    si,[bx].tstcel    ; get address of first item
  3330.     mov    al,[si]
  3331.     xor    ah,ah
  3332.     push    bx
  3333.     call    outnum
  3334.     pop    bx
  3335.     mov    si,[bx].val2    ; get address of second msg
  3336.     call    stms1        ; add that
  3337.     mov    si,[bx].basval    ; second value's address
  3338.     mov    al,[si]        ; second value
  3339.     xor    ah,ah
  3340.     jmp    outnum
  3341. prsarv    endp
  3342.  
  3343.  
  3344. ; print Send Delay and Pause
  3345. prsnd    proc    near
  3346.     call    stmsg        ; display leadin part of msg
  3347.     mov    al,trans.sdelay    ; Send Delay (sec)
  3348.     xor    ah,ah
  3349.     call    outnum
  3350.     mov    si,offset sndmsg2 ; second part of msg
  3351.     call    stms1        ; add that
  3352.     mov    ax,spause    ; Send Pause (millisec) 
  3353.     call    outnum
  3354.     mov    si,offset sndmsg3 ; last part of msg
  3355.     jmp    stms1        ; add it too
  3356. prsnd    endp
  3357.  
  3358. ; Print the handshake
  3359. prhnd:    mov    si,offset handst    ; copy in initial message
  3360.     call    stms1
  3361.     mov    si,offset nonmsg    ; assume no handshake
  3362.     mov    bx,portval
  3363.     cmp    [bx].hndflg,0        ; Is handshaking in effect?
  3364.     jne    prh0            ; ne = yes, show what we're using
  3365.     jmp    stms1            ; no, say so and return
  3366. prh0:    mov    al,[bx].hands        ; handshake char
  3367.     xor    ah,ah
  3368.     call    outnum            ; show handshake as decimal number
  3369.     ret
  3370.  
  3371. ; Print the Transmit Fill char
  3372. prfil:    mov    si,offset sxfilmsg    ; copy in initial message
  3373.     call    stms1
  3374.     mov    si,offset nonmsg    ; assume no handshake
  3375.     mov    al,script.xmitfill    ; filling char
  3376.     or    al,al            ; is filling in effect?
  3377.     jnz    prfil1            ; nz = yes, print what we're using
  3378.     jmp    stms1            ; no, say so and return
  3379. prfil1:    push    ds
  3380.     pop    es
  3381.     cld
  3382.     cmp    al,20h            ; printable already?
  3383.     ja    prfil2            ; a = yes
  3384.     push    ax
  3385.     mov    al,5eh            ; control char
  3386.     stosb
  3387.     pop    ax
  3388.     add    al,40H            ; make printable
  3389.     stosb                ; put in buffer
  3390.     ret                ; and return
  3391. prfil2:    cmp    al,126            ; in ordinary printable range?
  3392.     ja    prfil3            ; a = no
  3393.     stosb                ; store in buffer
  3394.     ret
  3395. prfil3:    mov    byte ptr [di],'\'    ; show as \number
  3396.     inc    di
  3397.     xor    ah,ah
  3398.     jmp    outnum            ; do rest of number
  3399.  
  3400. ; Print value from table.  BX is address of table, AX is value of variable
  3401. ; Copy value of table text entry to output buffer (di), given the address
  3402. ; of the table in bx and the value to compare against table values in al.
  3403. prttab    proc    near
  3404.     push    cx            ; save column count
  3405.     mov    cl,[bx]            ; number of entries in our table
  3406.     inc    bx            ; point to the data
  3407. prtta1:    mov    si,[bx]            ; length of keyword
  3408.     cmp    ax,[bx+si+2]        ; value fields match?
  3409.     je    prtta2            ; e = yes
  3410.     add    bx,si            ; add word length
  3411.     add    bx,4            ; skip count and value fields
  3412.     dec    cl            ; more keywords to check?
  3413.     jnz    prtta1            ; nz = yes, go to it
  3414.     pop    cx
  3415.     mov    si,offset prterr
  3416.     jmp    stms1            ; copy dollar terminated string
  3417. prtta2:    push    es
  3418.     push    ds
  3419.     pop    es        ; ensure es points to data segment
  3420.     mov    cx,[bx]        ; get length of counted string
  3421.     push    cx        ; save
  3422.     mov    si,bx
  3423.     add    si,2        ; look at text
  3424.     cld
  3425.     rep    movsb
  3426.     pop    ax
  3427.     pop    es
  3428.     pop    cx        ; original cx
  3429.     add    cx,ax        ; advance column count, return di advanced
  3430.     ret
  3431. prttab    endp
  3432.  
  3433. ; Display port speed
  3434.  
  3435. BAUDPRT    PROC     NEAR
  3436.     mov    si,offset baudrt    ; "Speed: "
  3437.     call    stms1            ; display that part
  3438.     push    di
  3439.     push    cx
  3440.     call    getbaud            ; read baud rate first
  3441.     pop    cx
  3442.     pop    di
  3443.     mov    bx,portval
  3444.     mov    ax,[bx].baud
  3445.     cmp    al,byte ptr bdtab    ; number of table entries
  3446.     jb    bdprt5            ; b = in table
  3447.     mov    si,offset unrec        ; say unrecognized value
  3448.     jmp    stms1            ; display text and return
  3449. bdprt5:    mov    bx,offset bdtab        ; show ascii rate from table
  3450.     jmp    prttab
  3451. BAUDPRT    ENDP
  3452.  
  3453. ; display Take/Macro COUNT
  3454. stcnt    proc    near
  3455.     call    stmsg            ; display leadin part of msg
  3456.     cmp    taklev,0        ; in a Take file or macro?
  3457.     jne    stcnt1            ; ne = yes
  3458.     mov    si,offset nonemsg    ; say none
  3459.     jmp    stms1
  3460. stcnt1:    push    bx
  3461.     mov    bx,takadr        ; current Take structure
  3462.     mov    ax,[bx].takctr        ; get COUNT
  3463.     pop    bx
  3464.     jmp    outnum
  3465. stcnt    endp
  3466.  
  3467. ; display Take/Macro ARGC
  3468. starg    proc    near
  3469.     call    stmsg            ; display leadin part of msg
  3470.     cmp    taklev,0        ; in a Take file or macro?
  3471.     jne    starg1            ; ne = yes
  3472.     mov    si,offset nonemsg    ; say none
  3473.     jmp    stms1
  3474. starg1:    push    bx
  3475.     mov    bx,takadr        ; current Take structure
  3476.     mov    ax,[bx].takargc        ; get ARGC
  3477.     pop    bx
  3478.     jmp    outnum
  3479. starg    endp
  3480.  
  3481. ; ALARM time
  3482. stalr    proc    near
  3483.     call    stmsg            ; display leading part of msg
  3484.     push    bx            ; preserve register
  3485.     xor    bx,bx            ; position index
  3486.     push    ds
  3487.     pop    es
  3488.     cld
  3489. stalr1:    push    bx            ; save around calls
  3490.     cmp    alrhms[bx],10        ; two digits?
  3491.     jae    stalr2            ; ae = yes
  3492.     mov    al,'0'
  3493.     stosb                ; show leading zero
  3494. stalr2:    mov    al,alrhms[bx]        ; show time component
  3495.     xor    ah,ah
  3496.     call    outnum
  3497.     pop    bx            ; recover index
  3498.     inc    bx
  3499.     cmp    bx,3            ; done all fields?
  3500.     jae    stalr3            ; ae = yes
  3501.     mov    al,':'
  3502.     stosb
  3503.     jmp    short stalr1        ; do next field
  3504. stalr3:    pop    bx
  3505.     ret
  3506. stalr    endp
  3507.  
  3508. ; show INPUT buffer
  3509. stinbuf    proc    near
  3510.     push    si
  3511.     push    di
  3512.     push    es
  3513.     mov    di,offset rdbuf
  3514.     mov    byte ptr [di],cr    ; start on the margin
  3515.     inc    di
  3516.     push    di
  3517.     call    buflog            ; get INPUT buffer pointers
  3518.     pop    di
  3519.     mov    bx,cx            ; length of buffer (and max offset)
  3520.     jcxz    stinb5            ; z = empty
  3521. stinb1:    mov    al,es:[si]        ; extract a buffer char into al
  3522.     inc    si            ; move pointer to next byte
  3523.     test    al,80h            ; high bit set?
  3524.     jz    stinb2            ; z = no
  3525.     mov    byte ptr [di],'~'    ; yes, show a tilde
  3526.     inc    di
  3527. stinb2:    and    al,7fh            ; strip eighth bit
  3528.     cmp    al,' '            ; control code?
  3529.     jae    stinb3            ; ae = no
  3530.     mov    byte ptr [di],'^'    ; yes, show caret
  3531.     inc    di
  3532.     or    al,40h            ; convert char to upper case letter
  3533. stinb3:    mov    [di],al
  3534.     inc    di            ; where to write next byte
  3535.     cmp    di,offset rdbuf+78    ; line full?
  3536.     jb    stinb4            ; b = no, have more room
  3537.     mov    word ptr [di],0a0dh    ; add cr/lf
  3538.     mov    byte ptr [di+2],0
  3539.     mov    dx,offset rdbuf
  3540.     mov    di,dx
  3541.     call    prtasz
  3542. stinb4:    loop    stinb1
  3543. stinb5:    mov    word ptr [di],0a0dh    ; add cr/lf
  3544.     mov    byte ptr [di+2],0
  3545.     mov    dx,offset rdbuf        ; reset to start of our local buffer
  3546.     mov    di,dx
  3547.     call    prtasz
  3548.     pop    es
  3549.     pop    di
  3550.     pop    si
  3551.     xor    cx,cx
  3552.     ret
  3553. stinbuf    endp
  3554.  
  3555. ; LNOUT - Table driven unsigned long integer (32 bit) display
  3556. ; Register dx holds high order word and ax holds low order word of unsigned
  3557. ; long integer to be stored in decimal. Storage area is given by DS:[DI]
  3558. ; DI is incremented for each storage, null terminated.
  3559. ; Table TENS holds set of double word values of ten raised to powers 0 to 9
  3560. ; TENSLEN holds the number of these double words
  3561. ; All registers preserved.    8 March 1987 [jrd]
  3562.  
  3563. lnouts    proc    near            ; do lnout with thousands separator
  3564.     push    ax
  3565.     mov    al,thsep        ; get thousands separator
  3566.     mov    lnoutsep,al        ; tell lnout to use it
  3567.     pop    ax
  3568.     call    lnout            ; compute value to di
  3569.     mov    lnoutsep,0        ; clear for future callers
  3570.     ret
  3571. lnouts    endp
  3572.  
  3573. lnout    proc    near
  3574.     push    ax
  3575.     push    bx
  3576.     push    cx
  3577.     push    dx
  3578.     push    si
  3579.     xor    si,si        ; flag to say start printing (no leading 0's)
  3580.     mov    cx,tenslen    ; number of table entries
  3581. lnout1:    push    cx        ; save loop counter
  3582.     mov    bx,cx        ; index into tens double word table
  3583.     dec    bx        ; index starts at zero
  3584.     add    bx,bx
  3585.     add    bx,bx        ; bx times four (double words to bytes)
  3586.     xor    cx,cx        ; cx is now a counter of subtractions
  3587.  
  3588. lnout2:    cmp    dx,word ptr tens[bx+2]  ; pattern 10**(bx/4), high order part
  3589.     jb    lnout4        ; b = present number is less than pattern
  3590.     ja    lnout3        ; a = present number is larger than pattern
  3591.     cmp    ax,word ptr tens[bx] ; high words match, how about lows
  3592.     jb    lnout4        ; b = present number is smaller than pattern
  3593. lnout3:    sub    ax,word ptr tens[bx]    ; subtract low order words
  3594.     sbb    dx,word ptr tens[bx+2]    ; subtract high order words, w/borrow
  3595.     inc    cl        ; count number of subtractions
  3596.     inc    si        ; flag to indicate printing needed
  3597.     jmp    short lnout2    ; try again to deduct present test pattern
  3598.  
  3599. lnout4:    or    bx,bx        ; doing least significant digit?
  3600.     jz    lnout5        ; z = yes, always print this one
  3601.     or    si,si        ; should we print?
  3602.     jz    lnout6        ; z = no, not yet
  3603. lnout5:    add    cl,'0'        ; get number of subtractions
  3604.     mov    [di],cx        ; store it (ch is still zero), asciiz
  3605.     inc    di
  3606.     cmp    bx,9*4        ; places for thousands separator?
  3607.     je    lnout5a        ; e = yes
  3608.     cmp    bx,6*4
  3609.     je    lnout5a
  3610.     cmp    bx,3*4
  3611.     jne    lnout6        ; ne = no
  3612. lnout5a:mov    cl,lnoutsep    ; get thousands separator
  3613.     xor    ch,ch
  3614.     jcxz    lnout6        ; z = none
  3615.      mov    word ptr [di],cx
  3616.     inc    di
  3617. lnout6:    pop    cx        ; recover loop counter
  3618.     loop    lnout1
  3619.     pop    si
  3620.     pop    dx
  3621.     pop    cx
  3622.     pop    bx
  3623.     pop    ax
  3624.     ret
  3625. lnout    endp 
  3626.  
  3627. code    ends
  3628.     end
  3629.