home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / mskermit / msssho.asm < prev    next >
Assembly Source File  |  2020-01-01  |  101KB  |  3,518 lines

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