home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / extra / nyenhuis3.arc / MSSSHO.ASM < prev    next >
Assembly Source File  |  1990-01-14  |  71KB  |  2,413 lines

  1.     name    msssho
  2. ; File MSSSHO.ASM
  3.     include mssdef.h
  4. ; Show & Status commands
  5. ; edit history:
  6. ; Last edit 14 Jan 1990
  7.  
  8.     public    shorx, shomac, shcom, shfile, shlog, shpro, shscpt, shserv
  9.     public    shterm, status, statc, stat0, srchkw, srchkb, shmem
  10.     public    partab, destab, seoftab, blktab, dmpname, lsesnam, lpktnam
  11.     public    ltranam, incstb, inactb, rxoffmsg, rxonmsg, lnout, lnouts
  12.     public    shosta, begtim, endtim, fsta, ssta    ; statistics procedures
  13.     public    rtmsg, rppos, stpos, rprpos, sppos, perpos, cxerr, frpos
  14.     public    fmtdsp, ermsg, msgmsg, init, cxmsg, intmsg, kbpr, perpr
  15.     public    winpr, windflag, pktsize, clrfln, oldkbt, oldper
  16.     public  wrpmsg
  17.  
  18. mcclen    equ    macmax*10
  19.                 ; equates for screen positioning
  20. scrser    equ    0209H        ; place for server state display line
  21. scrfln    equ    0316H        ; place for file name
  22. scrkb    equ    0416H        ; Place for percent transferred
  23. scrper    equ    0516H        ; Place for Kbytes transferred
  24. scrst    equ    0616H        ; Place for status
  25. scrnp    equ    0816H        ; Place for number of packets
  26. scrsz    equ    0916h        ; packet size
  27. scrnrt  equ    0A16H        ; Place for number of retries
  28. screrr  equ    0B16H        ; Place for error msgs
  29. scrmsg    equ    0C16H        ; Last message position
  30. scrsp    equ    0E00H        ; Place for send packet
  31. scrrp    equ    1300H        ; Place for receive packet
  32. scrrpr    equ    1700H        ; Prompt when Kermit ends (does cr/lf)
  33.  
  34. data    segment
  35.     extrn    termtb:byte, comptab:byte, portval:word,dtrans:byte,rdbuf:byte
  36.     extrn    trans:byte, curdsk:byte, flags:byte, maxtry:byte, comand:byte
  37.     extrn    spause:byte, taklev:byte, takadr:word, alrhms:byte, bdtab:byte
  38.     extrn    denyflg:word, rxtable:byte, mcctab:byte, script:byte
  39.     extrn    errlev:byte, luser:byte, srvtmo:byte, mccptr:word, thsep:byte
  40.     extrn    scpbuflen:word, setchtab:byte, xfchtab:byte, xftyptab:byte
  41.     extrn    tfilsz:word, diskio:byte, tloghnd:word, dosnum:word
  42.     extrn    templp:byte, windused:byte, numpkt:word, verident:byte
  43.     extrn    decbuf:byte
  44.  
  45. crlf    db       cr,lf,'$'
  46. eqs    db    ' = $'
  47. spaces    db    '    $'
  48.  
  49. outlin1 db    10 dup (' '),'$'
  50. ;;;    version appears here
  51. outlin2 db    cr,lf,lf
  52.         db      cr,lf,'           File name:'
  53.         db      cr,lf,'  KBytes transferred:'
  54.         db      cr,lf
  55.         db      cr,lf
  56.         db      cr,lf
  57.         db      cr,lf,'   Number of packets:'
  58.     db    cr,lf,'       Packet length:'
  59.         db      cr,lf,'   Number of retries: 0'
  60.         db      cr,lf,'          Last error:'
  61.         db      cr,lf,'        Last message:'
  62.         db      cr,lf,'$'
  63.  
  64.  
  65. permsg    db    cr,' Percent transferred:$'
  66. cxzhlp    db    'X: cancel file, Z: cancel group, E: exit nicely,'
  67.     db    ' C: exit abruptly, Enter: retry$'
  68. erword    db    cr,lf,'Error: $'
  69. msword    db    cr,lf,'Message: $'
  70. rtword    db    cr,lf,'Retry $'
  71. cxzser    db   cr,lf,'Type X to cancel file, Z to cancel group,'
  72.     db    cr,lf,' E to exit nicely, C to quit abruptly,'
  73.     db    cr,lf,' or Enter to retry',cr,lf,'$'
  74. windmsg    db    ' Window slots in use:$'
  75. windflag db    0            ; flag to init windows msg, 0=none
  76. oldwind    db    -1            ; last windows in use value
  77. oldper    dw    0        ; old percentage
  78. oldkbt    dw    0        ; old KB transferred
  79. wrpmsg    db    0        ; non-zero if we wrote percent message
  80. fmtdsp    db    0        ; non-zero if formatted display in use
  81. prepksz    dw    0        ; previous packet size
  82. onehun    dw    100
  83. denom    dw    0
  84. temp    dw    0
  85. temp1    dw    0
  86. shmcnt    dw    0
  87. sixteen    dw    16
  88. infms1    db    'Server mode: type Control-C to exit',cr,lf,'$'
  89. infms7    db    'File interrupt',cr,lf,'$'
  90. infms8    db    'File group interrupt',cr,lf,'$'
  91. infms9    db    'User ',5eh,'  interrupt',cr,lf,'$'
  92.  
  93. partab    db    5
  94.     mkeyw    'none (8-bit data) ',PARNON
  95.     mkeyw    'even (7-bit data) ',PAREVN
  96.     mkeyw    'odd (7-bit data) ',PARODD
  97.     mkeyw    'mark (7-bit data) ',PARMRK
  98.     mkeyw    'space (7-bit data) ',PARSPC
  99.  
  100. destab    db    3
  101.     mkeyw    'Disk',1
  102.     mkeyw    'Printer',0
  103.     mkeyw    'Screen',2
  104.  
  105. seoftab    db    2
  106.     mkeyw    'Ctrl-Z',1
  107.     mkeyw    'NoCtrl-Z',0
  108.  
  109. warntab    db    3            ; File Warning table
  110.     mkeyw    'overwrite',1
  111.     mkeyw    'rename',0
  112.     mkeyw    'no-supersede',4
  113.  
  114. ; What type of block check to use
  115. blktab    db    3
  116.     mkeyw    '1-char-checksum',1
  117.     mkeyw    '2-char-checksum',2
  118.     mkeyw    '3-char-CRC-CCITT',3
  119.  
  120. modtab    db    3                ; Mode line status
  121.     mkeyw    'off',0
  122.     mkeyw    'on',1
  123.     mkeyw    'on (owned by host)',2
  124.  
  125. ontab    db    2
  126.     mkeyw    'off',0
  127.     mkeyw    'on',1
  128.  
  129. unkctab db    2            ; unknown character-set disposition
  130.     mkeyw    'keep',0
  131.     mkeyw    'cancel',1
  132.  
  133. logsta    db    8            ; Log Status table
  134.     mkeyw    'off',logoff        ; suspended or no logging
  135.     mkeyw    'Packet',logpkt
  136.     mkeyw    'Session',logses
  137.     mkeyw    'Packet+Session',logpkt+logses
  138.     mkeyw    'Transaction',logtrn
  139.     mkeyw    'Packet+Transaction',logpkt+logtrn
  140.     mkeyw    'Session+Transaction',logses+logtrn
  141.     mkeyw    'Packet+Session+Transaction',logpkt+logses+logtrn
  142.  
  143. dissta    db    6            ; Status of Display mode [jrd]
  144.     mkeyw    'Quiet, 7-bit',dquiet
  145.     mkeyw    'Regular, 7-bit',dregular
  146.     mkeyw    'Serial, 7-bit',dserial
  147.     mkeyw    'Quiet, 8-bit',dquiet+d8bit
  148.     mkeyw    'Regular, 8-bit',dregular+d8bit
  149.     mkeyw    'Serial, 8-bit',dserial+d8bit
  150.  
  151. endistab db    2            ; Server ENABLE/DISABLE status
  152.     mkeyw    'enabled',0
  153.     mkeyw    'disabled',1
  154.  
  155. inactb    db    2                ; Set Input Timeout Action
  156.     mkeyw    'Proceed',0            ;[jrs]
  157.     mkeyw    'Quit',1            ;[jrs]
  158.  
  159. incstb    db    2                ;[jrs] Set Input Case
  160.     mkeyw    'Ignore',0dfh            ;[jrs]
  161.     mkeyw    'Observe',0ffh            ;[jrs]
  162.  
  163.                 ; Statistics data storage area
  164. fsta    statinfo <>        ; for last operation values
  165. ssta    statinfo <>        ; for session values
  166. sflag    dw    0        ; flag for send (1) or receive (0)
  167.                 ;   80h = begtim started
  168.  
  169. statmsg    db   cr,lf,lf,'                               Last Transfer         '
  170.     db    ' Entire Session'
  171.     db    cr,lf,'   Item                      Sent       Rec''d       '
  172.     db    ' Sent       Rec''d',cr,lf,'$'
  173. fchmsg    db    cr,lf,' File characters:    $'
  174. spmsg    db    cr,lf,' Comms port chars:   $'
  175. pktmsg    db    cr,lf,' Packets:            $'
  176. nakmsg    db    cr,lf,' NAKs:               $'
  177. retmsg    db    cr,lf,' Packet retries:     $'
  178. timemsg    db   cr,lf,lf,' Protocol time, secs:$'
  179. chpsmsg    db    cr,lf,' File characters/sec:$'
  180. spedmsg    db    cr,lf,' Comms port bits/sec:$'
  181. sndmsg    db    'Sent ',0
  182. rcvmsg    db    'Recv ',0
  183. date    db    '00:00:00 00 Jan 1980',0
  184. datelen    equ    $-date-1
  185. atmsg    db    cr,lf,'  at '
  186. atlen    equ    $-atmsg
  187. fasmsg    db    ' as '
  188. faslen    equ    $-fasmsg
  189. fsucmsg    db    ', completed, bytes: ',0
  190. fbadmsg    db    ', failed, bytes: ',0
  191. fintmsg    db    ', interrupted, bytes: ',0
  192. months    db    'JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP'
  193.     db    'OCT','NOV','DEC'
  194.     even
  195. tens    dd    1,10,100,1000,10000,100000,1000000,10000000,100000000
  196.     dd    1000000000
  197. tenslen    equ    ($-tens) / 4    ; number of double words in array tens
  198. lnoutsep db    0        ; non-zero to separate thousands in lnout
  199.                 ; end statistics data area
  200. sixty    dw    60
  201. ten    dw    10
  202.  
  203. logmsg    db    'Kind         Default filename          Status$'
  204. nologmsg db    '(not active)$'
  205. lsesmsg    db    'Session       (Session.log)$'
  206. lpktmsg    db    'Packets       (Packet.log)$'
  207. ltramsg    db    'Transactions  (Transact.log)$'
  208. dmpmsg    db    'Screen Dump, in Connect mode$'
  209. dmpmsg2    db    'Dump screen: $'    ; for general STATUS display
  210. modst    db    'Mode line: $'
  211. locst    db    'Local echo: $'
  212. duphlf    db    'Duplex: half$'
  213. dupful    db    'Duplex: full$'
  214. belon    db    'Ring bell after transfer$'
  215. beloff    db    'No bell after transfer$'
  216. vtemst    db    'Terminal emulation: $'        ; terminal emulator
  217. portst    db    'Communications port: $'
  218. capmsg    db    'Logging: $'
  219. eofmsg    db    'EOF mode: $'
  220. flost    db    'No flow control used$'
  221. floxmsg    db    'Flow control: xon/xoff $'
  222. handst    db    'Handshake used: $'
  223. destst    db    'Destination: $'
  224. xtypmsg    db    'File Type: $'
  225. xchmsg    db    'Transfer char-set: $'
  226. chmsg    db    'File char set: $'
  227. unkmsg    db    'Unknown-char-set: $'
  228. diskst    db    'Path: $'
  229. blokst    db    'Block check used: $'
  230. sqcst    db    'Send control char prefix: $'
  231. rqcst    db    'Receive control char prefix: $'
  232. debon    db    'Debug: $'
  233. flwon    db    'Warning (file names): $'
  234. parmsg    db    'Parity: $'
  235. abfdst    db    'Incomplete file: discard$'
  236. abfkst    db    'Incomplete file: keep$'
  237. sndmsg1    db    'Send Delay: $'
  238. sndmsg2    db    ' sec, Pause: $'
  239. sndmsg3    db    ' ms$'
  240. msohst    db    'Start-of-Packet char S: ',5eh,'$'
  241. meolst    db    'End-of-Packet char   S: ',5eh,'$'
  242. msrec    db    '  R: ',5eh,'$'
  243. msrecv    db    '  R: $'
  244. tmost    db    'Timeout (seconds)    S: $'
  245. stimst    db    'Send timeout (seconds): $'
  246. rtimst    db    'Receive timeout (seconds): $'
  247. spakst    db    'Send packet size (maximum): $'
  248. rpakst    db    'Receive packet size (maximum): $'
  249. spakst1    db    'Send packet size (current): $'
  250. rpakst1    db    'Receive packet size (current): $'
  251. snpdst    db    'Number of padding chars S: $'
  252. spadst    db    'Padding char S: ',5eh,'$'
  253. retrymsg db    'Retry send/receive packet limit: $'
  254. swinst    db    'Sliding window slots (max): $'
  255. dispst    db    'Display: $'
  256. timmsg    db    'Timer: $'
  257. srvmsg    db    'Timeout (sec) waiting for a transaction: $'
  258. escmes    db    'Escape character: $'
  259. scpmsg    db    'Script commands Echo, If, Input, Output, Pause, Reinput,'
  260.     db    ' Transmit, Wait$'
  261. sechmsg    db    'Input echoing: $'
  262. scasmsg    db    'Case sensitivity: $'
  263. stmo1msg db    'Timeout (seconds): $'
  264. stmo2msg db    'Timeout-action: $'
  265. sxfilmsg db    'Transmit fill-empty-line: $'
  266. sxlfmsg db    'Transmit line-feeds-sent: $'
  267. sxpmtmsg db    'Transmit prompt character: $'
  268. stbufmsg db    'INPUT-buffer-length: $'
  269. takon    db    'Take-echo: $'
  270. atton    db    'Attributes packets: $'
  271. sachmsg    db    '  Character-set: $'
  272. sadtmsg    db    '  Date-Time: $'
  273. salnmsg    db    '  Length: $'
  274. satymsg    db    '  Type: $'
  275. baudrt    db    'Speed: $'
  276. unrec    db    'unknown$'
  277. kbdmsg    db    'Keyboard translation: $'
  278. stcntmsg db    'Take/Macro COUNT: $'
  279. stargmsg db    'Take/Macro ARGC: $'
  280. nonemsg    db    'not active$'
  281. sterlmsg db    'Errorlevel: $'
  282. stalrmsg db    'Alarm time: $'
  283. lusrmsg    db    'Login Username: $'
  284. servmsg    db    'Server commands available to remote user: $'
  285. scwdmsg    db    'CD/CWD: $'
  286. sdelmsg    db    'DELETE: $'
  287. sdirmsg    db    'DIR:    $'
  288. sfinmsg    db    'FINISH: $'
  289. sgetmsg    db    'GET:    $'
  290. shstmsg    db    'HOST:   $'
  291. skermsg    db    'KERMIT: $'
  292. slogmsg    db    'LOGIN:  $'
  293. ssndmsg    db    'MESSAGE:$'
  294. sspcmsg    db    'SPACE:  $'
  295. stypmsg    db    'TYPE:   $'
  296. stekmsg    db    'Tek4010: $'
  297. nonmsg    db    'none$'
  298. onmsg    db    'on'
  299. offmsg    db    'off'
  300. moremsg    db    cr,lf,'-- More --$'
  301.  
  302. rxoffmsg db    cr,lf,' Input Translation is off$'
  303. rxonmsg    db    cr,lf,' Input Translation is on$'
  304.  
  305. shormsg    db    cr,lf,' Translation table of received byte codes while'
  306.     db    ' in CONNECT mode -'
  307.     db    cr,lf,' Format: [received byte (decimal) -> local byte'
  308.     db    ' (decimal)]',cr,lf,'$'
  309. shopm1    db    ' [\$'            ; Show Translation material
  310. shopm2    db    ' -> \$'
  311. shopm3    db    '] $'
  312. shmmsg    db    ' name of macro, or press ENTER to see all$'
  313. shom9m1    db    cr,lf,' Free space (bytes) for names: $'
  314. shom9m3    db    cr,lf,' No macro(s)$'
  315. shom9m4    db    '<cr>$'
  316. memmsg1    db    cr,lf,' DOS free memory (bytes):$'
  317. memmsg2    db    cr,lf,' Total free bytes: $'
  318.  
  319. prterr    db    '?Unrecognized value$'
  320. lpktnam    db    'Packet.log',54 dup (0)    ; default packet log filename
  321. lsesnam    db    'Session.log',54 dup (0); default capture/session filename
  322. ltranam    db    'Transact.log',52 dup (0); default transaction log filename
  323. dmpname    db    'Kermit.scn',54 dup (0)    ; file name for screen dumps [jrd]
  324.  
  325.     even
  326. stent    struc            ; structure for status information table sttab
  327. sttyp    dw    ?        ; type (actually routine to call)
  328. msg    dw    ?        ; message to print
  329. val2    dw    ?        ; needed value: another message, or tbl addr
  330. tstcel    dw    ?        ; address of cell to test, in data segment
  331. basval    dw    0        ; base value, if non-zero
  332. stent    ends
  333.  
  334. sttab    stent    <baudprt>                ; STATUS
  335.     stent    <srchkw,vtemst,termtb,flags.vtflg>    ; terminal emulator
  336.     stent    <srchkw,portst,comptab,flags.comflg>
  337.     stent    <srchkw,modst,modtab,flags.modflg>
  338.     stent    <srchkw,parmsg,partab,parflg,portval>
  339.     stent    <stlnum,spakst,,dtrans.slong>
  340.     stent    <onoff,locst,,ecoflg,portval>
  341.     stent    <stlnum,rpakst,,dtrans.rlong>
  342.     stent    <msg2,flost,floxmsg,floflg,portval>
  343.     stent    <prsar,msohst,msrec,trans.ssoh,trans.rsoh>
  344.     stent    <prhnd>
  345.     stent    <prsar,meolst,msrec,trans.seol,trans.reol>
  346.     stent    <drnum,diskst,,curdsk>
  347.     stent    <prsarv,tmost,msrecv,dtrans.stime,trans.rtime>
  348.     stent    <srchkw,flwon,warntab,flags.flwflg>
  349.     stent    <prsnd, sndmsg1>
  350.     stent    <srchkw,destst,destab,flags.destflg>
  351.     stent    <stnum,retrymsg,,maxtry>
  352.     stent    <msg2,abfkst,abfdst,flags.abfflg>
  353.     stent    <srchkw,blokst,blktab,dtrans.chklen>
  354.     stent    <srchkw,eofmsg,seoftab,flags.eofcz>
  355.     stent    <srchkw,capmsg,logsta,flags.capflg>
  356.     stent    <msg2,beloff,belon,flags.belflg>
  357.     stent    <srchkw,debon,logsta,flags.debug>
  358.     stent    <onechr,escmes,,trans.escchr>
  359.     stent    <onoff,timmsg,,flags.timflg>
  360.     stent    <srchkw,dispst,dissta,flags.remflg>
  361.     stent    <pasz,dmpmsg2,offset dmpname>
  362.     stent    <msg2,dupful,duphlf,duplex,portval>
  363.     stent    <srchkw,kbdmsg,ontab,flags.xltkbd>
  364.     stent    <vtstat>
  365.     dw    0                ; end of table
  366.  
  367. stcom    stent    <srchkw,portst,comptab,flags.comflg>    ; SHOW COMMS
  368.     stent    <baudprt>
  369.     stent    <onoff,locst,,ecoflg,portval>
  370.     stent    <srchkw,parmsg,partab,parflg,portval>
  371.     stent    <prhnd>
  372.     stent    <msg2,flost,floxmsg,floflg,portval>
  373.     stent    <msg2,dupful,duphlf,duplex,portval>
  374.     stent    <srchkw,dispst,dissta,flags.remflg>
  375.     stent    <srchkw,debon,logsta,flags.debug>
  376.     dw    0
  377. stfile    stent    <drnum,diskst,,curdsk>            ; SHOW FILE
  378.     stent    <msg2,abfkst,abfdst,flags.abfflg>
  379.     stent    <srchkw,destst,destab,flags.destflg>
  380.     stent    <srchkw,flwon,warntab,flags.flwflg>
  381.     stent    <srchkw,eofmsg,seoftab,flags.eofcz>
  382.     stent    <srchkww,chmsg,setchtab,flags.chrset>
  383.     stent    <srchkw,xtypmsg,xftyptab,dtrans.xtype>
  384.     stent    <srchkw,xchmsg,xfchtab,dtrans.xchset>
  385.     stent    <stmsg,atton>
  386.     stent    <srchkw,unkmsg,unkctab,flags.unkchs>
  387.     stent    <srchkb,sachmsg,ontab,attchr,flags.attflg>
  388.     stent    <stmsg,spaces>
  389.     stent    <srchkb,sadtmsg,ontab,attdate,flags.attflg>
  390.     stent    <stmsg,spaces>
  391.     stent    <srchkb,salnmsg,ontab,attlen,flags.attflg>
  392.     stent    <stmsg,spaces>
  393.     stent    <srchkb,satymsg,ontab,atttype,flags.attflg>
  394.     dw    0
  395.  
  396. stlog    stent    <stmsg,logmsg>                ; SHOW LOG
  397.     stent    <stmsg,lpktmsg>
  398.     stent    <msg2b,nologmsg,lpktnam,logpkt,flags.capflg>
  399.     stent    <stmsg,lsesmsg>
  400.     stent    <msg2b,nologmsg,lsesnam,logses,flags.capflg>
  401.     stent    <stmsg,ltramsg>
  402.     stent    <msg2b,nologmsg,ltranam,logtrn,flags.capflg>
  403.     stent    <stmsg,dmpmsg>
  404.     stent    <stmsg,dmpname>
  405.     dw    0
  406.  
  407. stpro    stent    <stlnum,spakst,,dtrans.slong>        ; SHOW PROTOCOL
  408.     stent    <stlnum,rpakst,,dtrans.rlong>
  409.     stent    <stlnum,spakst1,,trans.slong>
  410.     stent    <stlnum,rpakst1,,trans.rlong>
  411.     stent    <stnum,stimst,,dtrans.stime>
  412.     stent    <stnum,rtimst,,trans.rtime>
  413.     stent    <onechr,sqcst,,dtrans.squote>
  414.     stent    <onechr,rqcst,,trans.rquote>
  415.     stent    <prsar,msohst,msrec,trans.ssoh,trans.rsoh>
  416.     stent    <prsarv,snpdst,msrecv,dtrans.spad,trans.rpad>
  417.     stent    <prsar,meolst,msrec,trans.seol,trans.reol>
  418.     stent    <prsar,spadst,msrec,dtrans.spadch,trans.rpadch>
  419.     stent    <prsnd,sndmsg1>
  420.     stent    <srchkw,blokst,blktab,dtrans.chklen>
  421.     stent    <stnum,retrymsg,,maxtry>
  422.     stent    <stnum,swinst,,dtrans.windo>
  423.     stent    <onoff,timmsg,,flags.timflg>
  424.     stent    <prhnd>
  425.     stent    <srchkw,debon,logsta,flags.debug>
  426.     stent    <srchkw,capmsg,logsta,flags.capflg>
  427.     stent    <srchkw,xtypmsg,xftyptab,dtrans.xtype>
  428.     stent    <srchkww,chmsg,setchtab,flags.chrset>
  429.     stent    <stmsg,atton>
  430.     stent    <srchkw,xchmsg,xfchtab,dtrans.xchset>
  431.     stent    <srchkb,sachmsg,ontab,attchr,flags.attflg>
  432.     stent    <stmsg,spaces>
  433.     stent    <srchkb,sadtmsg,ontab,attdate,flags.attflg>
  434.     stent    <stmsg,spaces>
  435.     stent    <srchkb,salnmsg,ontab,attlen,flags.attflg>
  436.     stent    <stmsg,spaces>
  437.     stent    <srchkb,satymsg,ontab,atttype,flags.attflg>
  438.     dw    0
  439.     dw    0
  440.  
  441. stscpt    stent    <stmsg,scpmsg>                ; SHOW SCRIPT
  442.     stent    <onoff,sechmsg,,script.inecho>
  443.     stent    <srchkw,scasmsg,incstb,script.incasv>
  444.     stent    <stlnum,stmo1msg,,script.indfto>
  445.     stent    <srchkw,stmo2msg,inactb,script.inactv>
  446.     stent    <stalr,stalrmsg>
  447.     stent    <stlnum,stbufmsg,,scpbuflen>
  448.     stent    <stnum,sterlmsg,,errlev>
  449.     stent    <prfil>
  450.     stent    <onoff,sxlfmsg,,script.xmitlf>
  451.     stent    <onechr,sxpmtmsg,,script.xmitpmt>
  452.     stent    <stcnt,stcntmsg>
  453.     stent    <srchkw,takon,ontab,flags.takflg>
  454.     stent    <starg,stargmsg>
  455.     dw    0
  456.  
  457. stserv    stent    <pasz,lusrmsg,offset luser>        ; SHOW SERVER
  458.     stent    <stmsg,servmsg>
  459.     stent    <srchkb,scwdmsg,endistab,cwdflg,denyflg>
  460.     stent    <srchkb,skermsg,endistab,kerflg,denyflg>
  461.     stent    <srchkb,sdelmsg,endistab,delflg,denyflg>
  462.     stent    <srchkb,slogmsg,endistab,pasflg,denyflg>
  463.     stent    <srchkb,sdirmsg,endistab,dirflg,denyflg>
  464.     stent    <srchkb,ssndmsg,endistab,sndflg,denyflg>
  465.     stent    <srchkb,sfinmsg,endistab,finflg,denyflg>
  466.     stent    <srchkb,sspcmsg,endistab,spcflg,denyflg>
  467.     stent    <srchkb,sgetmsg,endistab,getsflg,denyflg>
  468.     stent    <srchkb,stypmsg,endistab,typflg,denyflg>
  469.     stent    <srchkb,shstmsg,endistab,hostflg,denyflg>
  470.     dw    0
  471. stserv2    stent    <stnum,srvmsg,,srvtmo>
  472.     dw    0
  473.  
  474. stterm    stent    <srchkw,vtemst,termtb,flags.vtflg>    ; SHOW TERMINAL
  475.     stent    <srchkw,dispst,dissta,flags.remflg>
  476.     stent    <srchkb,stekmsg,endistab,tekxflg,denyflg>
  477.     stent    <onechr,escmes,,trans.escchr>
  478.     stent    <srchkw,modst,modtab,flags.modflg>
  479.     stent    <srchkw,kbdmsg,ontab,flags.xltkbd>
  480.     stent    <vtstat>
  481.     dw    0
  482.  
  483. data    ends
  484.  
  485. code    segment
  486.     extrn    comnd:near, decout:near, locate:near, prtscr:near, strlen:near
  487.     extrn    getbaud:near, vtstat:near, shomodem:near
  488.     extrn    cmblnk:near, prtasz:near, putmod:near, clrmod:near
  489.     extrn    poscur:near, clearl:near, nout:near, dodec:near
  490.  
  491.     assume    cs:code, ds:data, es:nothing
  492.  
  493. ; Display asciiz message pointed to by DS:DX on Last error line
  494. ERMSG    PROC    NEAR
  495.     test    flags.remflg,dquiet    ; quiet screen?
  496.     jnz    ermsgx            ; nz = yes
  497.     push    si            ; position cursor to Last Error line
  498.     push    dx            ; save preexisting message pointer
  499.     test    flags.remflg,dserial    ; serial mode display?
  500.     jnz    erpo1            ; nz = yes
  501.     cmp    fmtdsp,0        ; formatted display?
  502.     jne    erpo2            ; ne = yes
  503. erpo1:    mov    ah,prstr
  504.     mov    dx,offset erword    ; put out word Error:
  505.     int    dos
  506.     jmp    short erpo3
  507. erpo2:    mov    dx,screrr
  508.     call    poscur
  509.     call    clearl            ; clear the line
  510. erpo3:    pop    dx            ; restore old pointer
  511.     mov    si,dx            ; string pointer
  512.     mov    cx,10            ; try ten items
  513.     cld
  514. ermsg1:    lodsb
  515.     cmp    al,' '            ; strip these leading spaces
  516.     loope    ermsg1
  517.     dec    si            ; backup to non-space
  518.     push    dx            ; preserve caller's dx
  519.     mov    dx,si
  520.     call    prtasz            ; display asciiz message
  521.     pop    dx
  522.     pop    si
  523. ermsgx:    ret
  524. ERMSG    ENDP
  525.  
  526. ; Decode and display Message packet pointed to by SI.
  527. MSGMSG    PROC    NEAR
  528.     test    flags.remflg,dquiet    ; quiet screen?
  529.     jnz    msgmsgx            ; nz = yes
  530.     cmp    [si].datlen,0        ; anything present?
  531.     je    msgmsgx            ; e = no
  532.     test    flags.remflg,dserial    ; serial mode display?
  533.     jnz    msgms1            ; nz = yes
  534.     cmp    fmtdsp,0        ; formatted display?
  535.     jne    msgms2            ; ne = yes
  536.     cmp    flags.xflg,0        ; packet header seen?
  537.     je    msgms2            ; e = no
  538. msgms1:    mov    ah,prstr
  539.     mov    dx,offset msword    ; put out word Message:
  540.     int    dos
  541.     jmp    short msgms3        ; display the message
  542. msgms2:    push    si
  543.     mov    dx,scrmsg        ; Last message line
  544.     call    poscur
  545.     call    clearl            ; clear the line
  546.     pop    si
  547. msgms3:    call    dodec            ; decode to decbuf, SI is pktinfo ptr
  548.     mov    dx,offset decbuf    ; final error message string, asciiz
  549.     call    prtasz            ; display asciiz message
  550. msgmsgx:ret
  551. MSGMSG    ENDP
  552.  
  553. ; Show number of retries message
  554.  
  555. RTMSG    PROC     NEAR
  556.     test    flags.remflg,dquiet    ; quiet display mode?
  557.     jnz    rtmsx            ; nz = yes
  558.     test    flags.remflg,dserver    ; in server mode?
  559.     jnz    rtms0            ; nz = yes
  560.     cmp    flags.xflg,0        ; receiving to screen?
  561.     jne    rtmsx            ; ne = yes
  562.     cmp    fmtdsp,0        ; formatted display?
  563.     je    rtms1            ; e = no, do as normal
  564. rtms0:    test    flags.remflg,dserial    ; serial mode display?
  565.     jnz    rtms1            ; nz = yes
  566.     push    ax
  567.     push    dx
  568.     push    si
  569.     mov    dx,scrnrt
  570.     call    poscur
  571.     call    clearl
  572.     pop    si
  573.     jmp    short rtms3
  574. rtms1:    push    ax
  575.     push    dx
  576.     mov    dx,offset rtword    ; display word Retry
  577.     mov    ah,prstr
  578.     int    dos
  579. rtms3:    mov    ax,fsta.pretry        ; number of retries
  580.     call    decout            ; write the number of group retries
  581.     pop    dx
  582.     pop    ax
  583. rtmsx:    ret
  584. RTMSG    ENDP
  585.  
  586. ; Reassure user that we acknowledge his ^X/^Z
  587.  
  588. INTMSG    PROC    NEAR
  589.     cmp    flags.cxzflg,0        ; anything there?
  590.     je    int1            ; e = no
  591.     test    flags.remflg,dserver    ; server mode?
  592.     jnz    int4            ; nz = yes
  593.     cmp    flags.xflg,0        ; writing to screen?
  594.     jne    int1            ; ne = yes, nothing to do
  595. int4:    test    flags.remflg,dquiet    ; quiet screen?
  596.     jnz    int1            ; yes, suppress msg
  597.     test    flags.remflg,dserial    ; serial mode display?
  598.     jz    int2            ; z = no
  599.     cmp    fmtdsp,0        ; formatted screen?
  600.     jne    int2            ; ne = yes
  601.     mov    dx,offset crlf        ; output initial cr/lf
  602.     mov    ah,prstr
  603.     int    dos
  604.     jmp    short int3        ; display the message
  605. int2:    mov    dx,scrmsg        ; last message position
  606.     call    poscur
  607.     call    clearl
  608. int3:    mov    dx,offset infms7    ; File interrupted
  609.     cmp    flags.cxzflg,'X'    ; File interrupt? 
  610.     je    int0            ; e = yes
  611.     mov    dx,offset infms8    ; File group interrupted
  612.     cmp    flags.cxzflg,'Z'    ; correct?
  613.     je    int0            ; e = yes
  614.     mov    dl,flags.cxzflg        ; say Control ^letter interrupt
  615.     mov    infms9+6,dl        ; store interrupt code letter
  616.     mov    dx,offset infms9
  617. int0:   mov    ah,prstr
  618.         int    dos
  619. int1:    ret
  620. INTMSG    ENDP
  621.  
  622. ;  Clear Last error and Last message lines
  623. cxerr:    mov    temp,0            ; say last error line
  624.     jmp    short cxcomm        ; do common code
  625.  
  626. CXMSG    PROC    NEAR
  627.     mov    temp,1            ; say last message line
  628.  
  629. cxcomm:    test    flags.remflg,dserver    ; server mode?
  630.     jnz    cxm1            ; nz = yes
  631.     cmp    flags.xflg,0        ; Writing to screen?
  632.     jne    cxm0            ; ne = yes
  633. cxm1:    cmp    fmtdsp,0        ; formatted display?
  634.     je    cxm0            ; e = no
  635.     push    dx
  636.     push     si
  637.     mov    dx,screrr        ; Last Error postion
  638.     cmp    temp,0            ; do last error line?
  639.     je    cxm2            ; e = yes
  640.     mov    dx,scrmsg        ; Last Message position
  641. cxm2:    call    poscur
  642.     call    clearl
  643.     pop    si
  644.     pop    dx
  645. cxm0:    ret
  646. CXMSG    ENDP
  647.  
  648. ;  Clear out the old filename on the screen. 
  649.  
  650. CLRFLN    PROC    NEAR
  651.     test    flags.remflg,dquiet     ; quiet display?
  652.     jnz    clrflnx            ; nz = yes
  653.     test    flags.remflg,dserial    ; serial display mode?
  654.     jnz    clrfln1            ; nz = yes, use just cr/lf
  655.     cmp    fmtdsp,0        ; formatted display?
  656.     je    clrfln1            ; e = no
  657.     mov    dx,scrfln
  658.     call    poscur
  659.     call    clearl            ; clear to end of line
  660.     ret
  661. clrfln1:push    ax            ; for serial display, does cr/lf
  662.     mov    ah,prstr
  663.     mov    dx,offset crlf
  664.     int    dos
  665.     pop    ax
  666. clrflnx:ret
  667. CLRFLN    ENDP
  668.  
  669.             ; display packet quantity and size, SI has pkt ptr
  670. PKTSIZE    PROC    NEAR
  671.     push    ax
  672.     push    dx
  673.     push    si
  674.     cmp    fmtdsp,0        ; formatted display?
  675.     je    pktsiz2            ; e = no, no display
  676.     mov    ax,[si].datlen        ; packet size (data part)
  677.     add    al,trans.chklen        ; plus checksum
  678.     adc    ah,0
  679.     cmp    ax,prepksz        ; same as previous packet?
  680.     je    pktsiz2            ; e = yes, skip display of size
  681.     push    ax
  682.     mov    dx,scrsz        ; position cursor
  683.     call    poscur
  684.     call    clearl            ; clear to end of line
  685.     pop    ax
  686.     mov    prepksz,ax        ; remember new value
  687.     add    ax,3            ; plus LEN, SEQ, TYPE
  688.     cmp    ax,94            ; larger than Regular?
  689.     jbe    pktsiz1            ; be = no
  690.     add    ax,3            ; add Long Packet len and chksum
  691. pktsiz1:call    decout            ; show packet length
  692.                     ; number of packets part
  693. pktsiz2:test    flags.remflg,dquiet    ; quiet screen?
  694.     jnz    pktsiz3            ; nz = yes
  695.     call    nppos            ; number of packets sent
  696.     mov    ax,numpkt        ; number of packets
  697.     call    nout            ; write the packet number
  698. pktsiz3:pop    si
  699.     pop    dx
  700.     pop    ax
  701.     ret
  702. PKTSIZE    ENDP
  703.  
  704. ; some random screen positioning functions
  705. kbpos:    mov    dx,scrkb        ; KBytes transferred
  706.     cmp    fmtdsp,0        ; formatted display?
  707.     jne    setup2            ; ne = yes
  708.     ret                ; else ignore postioning request
  709. perpos:    mov    dx,scrper        ; Percent transferred
  710.     cmp    fmtdsp,0        ; formatted display?
  711.     jne    setup2            ; ne = yes
  712.     ret                ; else ignore postioning request
  713. frpos:    mov    dx,scrmsg        ; say renamed file
  714.     jmp    short setup2
  715. stpos:    mov    dx,scrst        ; status of file transfer
  716.     jmp    short setup2
  717. nppos:    mov    dx,scrnp        ; Number of packets sent
  718.     cmp    fmtdsp,0        ; formatted display?
  719.     jne    setup2            ; ne = yes
  720.     ret
  721. rprpos:    test    flags.remflg,dserial+dquiet ; reprompt position
  722.     jnz    rprpos1            ; nz = no mode line for these
  723.     cmp    fmtdsp,0        ; formatted display?
  724.     je    rprpos1            ; e = no, so no mode line
  725.     call    clrmod            ; clear mode line
  726. rprpos1:mov    dx,scrrpr        ; Reprompt position
  727.     call    setup2            ; position cursor
  728.     mov    fmtdsp,0        ; turn off formatted display flag
  729.     ret
  730. sppos:    mov    dx,scrsp        ; Debug Send packet location
  731.     jmp    short setup1
  732. rppos:    mov    dx,scrrp        ; Debug Receive packet location
  733.     jmp    short setup1
  734.                 ; common service routines for positioning
  735. setup1:    test    flags.remflg,dquiet+dserial; quiet or serial display mode?
  736.     jnz    setupa            ; nz = yes
  737.     cmp    fmtdsp,0        ; non-formatted display?
  738.     je    setupa            ; e = yes
  739.     jmp    poscur
  740. setup2:    test    flags.remflg,dquiet+dserial; quiet or serial display mode?
  741.     jnz    setupa            ; nz = yes
  742.     cmp    fmtdsp,0        ; non-formatted display?
  743.     je    setupa            ; e = yes
  744.     call    poscur            ; no
  745.     jmp    clearl
  746. setupa: test    flags.remflg,dquiet    ; quiet mode?
  747.     jnz    setupx            ; nz = yes, do nothing
  748.     push    ax            ; display cr/lf and return
  749.     push    dx
  750.     mov    dx,offset crlf
  751.     mov    ah,prstr
  752.     int    dos
  753.     pop    dx
  754.     pop    ax
  755. setupx:    ret
  756.  
  757. ; Initialize formatted screen
  758.  
  759. INIT    PROC    NEAR
  760.     mov    windflag,0        ; init windows in use display flag
  761.     test    flags.remflg,dquiet    ; quiet display mode?
  762.     jnz    init4            ; nz = yes
  763.     test    flags.remflg,dserver    ; server mode?
  764.     jnz    init1            ; nz = yes
  765.     cmp    flags.xflg,0        ; destination is screen
  766.     jne    init4            ; ne = yes
  767. init1:    test    flags.remflg,dserial    ; serial mode display?
  768.     jnz    init3            ; nz = yes
  769.     call    cmblnk            ; clear the screen
  770.     mov    dx,offset cxzhlp
  771.     call    putmod            ; write mode line
  772.     mov    fmtdsp,1        ; say doing formatted display
  773.     test    flags.remflg,dserver    ; server mode?
  774.     jz    init2            ; z = no
  775.     mov    dx,scrser        ; move cursor to top of screen
  776.     call    poscur
  777.     mov    ah,prstr
  778.     mov    dx,offset infms1    ; say now in server mode
  779.     int    dos
  780. init2:    call    locate
  781.     mov    ah,prstr        ; put statistics headers on the screen
  782.     mov    dx,offset outlin1
  783.     int    dos
  784.     mov    dx,offset verident
  785.     int    dos
  786.     mov    dx,offset outlin2
  787.     int    dos
  788.     mov    wrpmsg,0        ; haven't printed the messsage yet
  789.     mov    prepksz,0        ; set previous packet size to zero
  790.     ret
  791. init3:    mov    ah,prstr
  792.     mov    dx,offset cxzser    ; status line as a text string
  793.     int    dos
  794. init4:    mov    wrpmsg,1        ; suppress display of percentage msg
  795.     mov    fmtdsp,0        ; say doing unformatted display
  796.     ret
  797. INIT    ENDP
  798.  
  799. ; show number of Kilobytes transferred
  800. ; modifies ax
  801. kbpr    proc    near
  802.     test    flags.remflg,dquiet    ; quiet display mode?
  803.     jnz    kbpr1            ; nz = yes, no printing
  804.     push    bx
  805.     mov    ax,tfilsz        ; low order word
  806.     mov    bx,tfilsz+2        ; high order word
  807.     add    ax,512            ; round up, add half the denominator
  808.     adc    bx,0
  809.     rcr    bx,1            ; divide double word by 1024,
  810.     rcr    ax,1            ; by dword shift right 10
  811.     rcr    bx,1
  812.     rcr    ax,1
  813.     mov    al,ah
  814.     mov    ah,bl            ; ax has the result
  815.     pop    bx
  816.     cmp    ax,oldkbt        ; is it the same?
  817.     je    kbpr1            ; yes, skip printing
  818.     mov    oldkbt,ax        ; save new # of kb
  819.     push    ax
  820.     call    kbpos            ; postion the cursor
  821.     pop    ax
  822.     call    decout            ; print number of KBytes transferred
  823. kbpr1:    ret
  824. kbpr    endp    
  825.  
  826. ; show percent transferred
  827. ; modifies ax
  828. perpr    proc    near
  829.     test    flags.remflg,dquiet    ; quiet display mode?
  830.     jz    perpr1            ; z = no. allow printing
  831.     ret                ; skip printing in remote mode
  832. perpr1:    cmp    diskio.sizehi,0        ; high word of original file size > 0 ?
  833.     jne    perpr3            ; ne = yes, use big file code
  834.     cmp    diskio.sizelo,0        ; anything here at all?
  835.     jne    perpr2            ; ne = yes, use small file code
  836.     ret                ; otherwise, quit now
  837. perpr2:    push    cx            ; case for files < 64 Kb
  838.     push    dx
  839.     mov    ax,diskio.sizelo    ; original size (low word)
  840.     mov    denom,ax
  841.     mov    dx,tfilsz+2        ;transferred size times 256 in [dx,ax]
  842.     mov    ax,tfilsz
  843.     mov    dh,dl            ; whole value multiplied by 256
  844.     mov    dl,ah
  845.     mov    ah,al
  846.     xor    al,al
  847.     mov    cx,denom        ; round up, add half the denominator
  848.     shr    cx,1
  849.     add    ax,cx
  850.     adc    dx,0
  851.     div    denom            ; (256*xfer)/orig. ax = quo, dx = rem
  852.     mul    onehun            ; multiply quotient above by 100
  853.     mov    al,ah            ; divide result (ax) by 256
  854.     xor    ah,ah            ; percentage is in ax
  855.     jmp    perpr4            ; finish in common code
  856. perpr3:    push    cx            ; case for file size > 64 KB
  857.     push    dx
  858.     mov    ax,diskio.sizelo    ; original file size low order word
  859.     shr    ax,1            ; divide by 2
  860.     mov    al,ah            ; divide again by 256 for total of 512
  861.     xor    ah,ah            ; clear ah        
  862.     mov    dx,diskio.sizehi    ; high order word
  863.     xchg    dh,dl            ; do shl dx,cl=7
  864.     ror    dx,1            ; old low bit of dh to high bit of dh
  865.     and    dl,80h            ; clear lower bits. divided by two
  866.     or    ax,dx            ; paste together the two parts into ax
  867.     mov    denom,ax        ; denom = original size divided by 512
  868.     mov    dx,tfilsz+2        ; high order word of transferred size
  869.     mov    ax,tfilsz        ; low order word
  870.     mov    cx,denom        ; round up, add half the denominator
  871.     shr    cx,1
  872.     add    ax,cx
  873.     adc    dx,0
  874.     div    denom            ; xfer/(orig/512). ax=quot, dx=rem
  875.     mul    onehun            ; times 100 for 512*percentage, in ax
  876.     mov    al,ah            ; divide ax by 512
  877.     xor    ah,ah
  878.     shr    al,1            ; final percentage, in ax
  879. perpr4:    cmp    ax,oldper        ; same as it was before?
  880.     je    perpr7            ; yes, don't bother printing
  881.     mov    oldper,ax        ; remember this for next time
  882.     cmp    wrpmsg,0        ; did we write the percentage message?
  883.     jne    perpr5            ; ne = yes, skip this part
  884.     push    ax
  885.     call    perpos            ; position cursor
  886.     mov    dx,offset permsg
  887.     mov    ah,prstr
  888.     int    dos            ; write out message
  889.     pop    ax
  890.     mov    wrpmsg,1        ; init flag so we don't do it again
  891. perpr5: push    ax
  892.     call    perpos            ; position the cursor
  893.     pop    ax
  894.     cmp    ax,onehun        ; > 100% ?
  895.     jle    perpr6            ; no, accept it
  896.     mov    ax,onehun        ; else just use 100
  897. perpr6:    call    decout
  898.     mov    dl,25h            ; load a percent sign
  899.     mov    ah,conout        ; display the character
  900.     int    dos
  901. perpr7:    pop    dx
  902.     pop    cx
  903.     ret
  904. perpr    endp
  905.  
  906. winpr    proc    near            ; print number of active window slots
  907.     cmp    trans.windo,1        ; windowing in use?
  908.     jbe    winprx            ; be = no, no message
  909.     test    flags.remflg,dregular    ; regular display?
  910.     jz    winprx            ; z = no, no display
  911.     cmp    fmtdsp,0        ; formatted display?
  912.     je    winprx            ; e = no, no display here
  913.     test    flags.remflg,dserver    ; server mode?
  914.     jnz    winpr4            ; nz = yes, writing to their screen
  915.     cmp    flags.xflg,0        ; receiving to screen?
  916.     je    winpr4            ; e = no
  917. winprx:    ret
  918. winpr4:    push    ax
  919.     push    bx
  920.     push    cx
  921.     push    dx
  922.     push    si
  923.     cmp    windflag,0        ; have we written an initial value?
  924.     jne    winpr1            ; ne = yes
  925.     mov    dx,scrnp        ; position cursor
  926.     dec    dh
  927.     xor    dl,dl            ; 0 = left most column for text
  928.     call    poscur
  929.     call    clearl            ; clear the line
  930.     mov    ah,prstr
  931.     mov    dx,offset windmsg    ; the text
  932.     int    dos
  933.     xor    al,al            ; display an initial 0
  934.     mov    oldwind,-1
  935.     mov    windflag,1        ; say have done the work
  936.     jmp    short winpr2
  937. winpr1:    mov    al,windused        ; window slots in use
  938.     cmp    al,oldwind        ; same as before?
  939.     je    winpr3            ; e = yes, ignore
  940. winpr2:    push    ax
  941.     mov    dx,scrnp        ; position cursor
  942.     dec    dh
  943.     call    poscur
  944.     call    clearl
  945.     pop    ax
  946.     mov    oldwind,al        ; remember last value
  947.     xor    ah,ah
  948.     call    decout            ; display value
  949. winpr3:    pop    si
  950.     pop    dx
  951.     pop    cx
  952.     pop    bx
  953.     pop    ax
  954.     ret
  955. winpr    endp
  956.  
  957.  
  958.  
  959. ; SHOW TRANSLATE-RECEIVE
  960. ; Display characters being changed for Connect mode serial receive translator
  961.  
  962. SHORX    PROC    NEAR            ; show translate table of incoming
  963.                     ; chars, only those changed
  964.     mov    ah,cmeol        ; get a confirm
  965.     call    comnd
  966.     jnc    shorx0a            ; nc = success
  967.     ret                ; failure
  968. shorx0a:mov    ah,prstr
  969.     mov    dx,offset rxoffmsg    ; assume translation is off
  970.     cmp    rxtable+256,0        ; is translation off?
  971.     je    shorx0            ; e = yes
  972.     mov    dx,offset rxonmsg    ; say translation is on
  973. shorx0:    int    dos
  974.     mov    dx,offset shormsg    ; give title line
  975.     int    dos
  976.     xor    cx,cx            ; formatted line counter
  977.     xor    bx,bx            ; entry subscript
  978. shorx1:    cmp    rxtable[bx],bl        ; entry same as normal?
  979.     je    shorx2            ; e = yes, skip it
  980.     call    shorprt            ; display the entry
  981. shorx2:    inc    bx            ; next entry
  982.     cmp    bx,255            ; done all entries yet?
  983.     jbe    shorx1            ; be = not yet
  984.     mov    ah,prstr
  985.     mov    dx,offset crlf        ; end with cr/lf
  986.     int    dos
  987.     clc                ; success
  988.     ret
  989.                     ; worker routine
  990. shorprt:cmp    cx,4            ; done five entries for this line?
  991.     jb    shorpr1            ; b = no
  992.     mov    ah,prstr
  993.     mov    dx,offset crlf        ; break line now
  994.     int    dos
  995.     xor    cx,cx
  996. shorpr1:mov    ah,prstr
  997.     mov    dx,offset shopm1    ; start of display
  998.     int    dos
  999.     xor    ah,ah
  1000.     mov    al,bl            ; original byte code
  1001.     call    decout            ; display its value
  1002.     mov    ah,prstr
  1003.     mov    dx,offset shopm2    ; intermediate part of display
  1004.     int    dos
  1005.     xor    ah,ah
  1006.     mov    al,rxtable[bx]        ; new byte code
  1007.     call    decout            ; display its value
  1008.     mov    ah,prstr
  1009.     mov    dx,offset shopm3    ; last part of display
  1010.     int    dos
  1011.     inc    cx            ; count item displayed
  1012.     ret
  1013. SHORX    ENDP
  1014.  
  1015. ; SHOW MACRO [macro name]
  1016.  
  1017. SHOMAC    PROC    NEAR
  1018.     mov    ah,cmword
  1019.     mov    dx,offset rdbuf
  1020.     mov    bx,offset shmmsg
  1021.     mov    comand.cmper,1        ; don't react to \%x variables
  1022.     call    comnd
  1023.     jnc    shoma1a            ; nc = success
  1024.     ret                ; failure
  1025. shoma1a:mov    al,ah
  1026.     xor    ah,ah
  1027.     mov    shmcnt,ax        ; save length of user spec
  1028.     mov    ah,cmeol
  1029.     call    comnd
  1030.     jnc    shoma1b            ; nc = success
  1031.     ret                ; failure
  1032. shoma1b:mov    si,offset mcctab    ; table of macro names
  1033.     cld
  1034.     lodsb
  1035.     mov    cl,al            ; number of macro entries
  1036.     xor    ch,ch
  1037.     jcxz    shom6            ; z = none
  1038.     mov    temp,0            ; count of macros displayed
  1039.     mov    temp1,0            ; lines displayed, for more message
  1040. shom2:    push    cx            ; save loop counter
  1041.     lodsb                ; length of macro name
  1042.     xor    ah,ah
  1043.     mov    cx,shmcnt        ; length of user's string
  1044.     jcxz    shom4            ; show all names
  1045.     cmp    al,cl            ; mac name shorter that user spec?
  1046.     jb    shom5            ; b = yes, no match
  1047.     push    ax
  1048.     push    si            ; save these around match test
  1049.     mov    di,offset rdbuf        ; user's string
  1050. shom3:    mov    ah,[di]
  1051.     inc    di
  1052.     lodsb                ; al = mac name char, ah = user char
  1053.     and    ax,not 2020h        ; clear bits (uppercase chars)
  1054.     cmp    ah,al            ; same?
  1055.     loope    shom3            ; while equal, do more
  1056.     pop    si            ; restore regs
  1057.     pop    ax
  1058.     jne    shom5            ; ne = no match
  1059. shom4:    call    shom9            ; show this name
  1060. shom5:    add    si,ax            ; point to next name, add name length
  1061.     add    si,3            ; and '$', and string pointer
  1062.     pop    cx            ; recover loop counter
  1063.     cmp    flags.cxzflg,0        ; does user wish to stop now?
  1064.     jne    shom5a            ; ne = yes
  1065.     loop    shom2            ; one less macro to examine
  1066. shom5a:    mov    flags.cxzflg,0        ; clear flag before exiting
  1067.     cmp    temp,0            ; did we show any macros?
  1068.     jne    shom7            ; ne = yes
  1069. shom6:    mov    ah,prstr
  1070.     mov    dx,offset shom9m3    ; no entries found
  1071.     int    dos
  1072. shom7:    mov    ah,prstr        ; Summary line
  1073.     mov    dx,offset shom9m1    ; free space: name entries
  1074.     int    dos
  1075.     mov    ax,offset mcctab+mcclen
  1076.     sub    ax,mccptr        ; compute # of free name bytes
  1077.     call    decout
  1078.     mov    ah,prstr
  1079.     mov    dx,offset crlf
  1080.     int    dos
  1081.     clc                ; success
  1082.     ret
  1083.  
  1084.                     ; worker, show mac name and def
  1085. shom9:    push    ax            ; call with si pointing at macro
  1086.     push    si            ; name, byte ptr [si-1] = length
  1087.     push    es
  1088.     cmp    byte ptr[si],0        ; name starts with null char?
  1089.     jne    shom9g            ; ne = no
  1090.     jmp    shom9e            ; yes, TAKE file, ignore
  1091. shom9g:    call    shom20            ; do newline, check for more/exit
  1092.     jnc    shom9h            ; nc = continue
  1093.     jmp    shom9e            ; exit
  1094. shom9h:    mov    ah,conout
  1095.     mov    dl,' '            ; add a space
  1096.     int    dos
  1097.     inc    temp            ; count displayed macros
  1098.     mov    dx,si            ; display macro name
  1099.     mov    ah,prstr
  1100.     int    dos
  1101.     mov    dx,offset eqs        ; display equals sign
  1102.     int    dos
  1103.     mov    al,[si-1]        ; length of macro name
  1104.     xor    ah,ah
  1105.     add    si,ax            ; skip over name
  1106.     inc    si            ; skip '$' field
  1107.     mov    es,[si]            ; segment of string structure
  1108.     xor    si,si            ; es:si = address of count + string
  1109.     mov    cl,es:[si]        ; length of string
  1110.     xor    ch,ch
  1111.     inc    si            ; si = offset of string text proper
  1112. shom9a:    mov    al,es:[si]        ; get a byte into al
  1113.     inc    si
  1114.     cmp    al,' '            ; control char?
  1115.     jae    shom9c            ; ae = no
  1116.     cmp    al,cr            ; carriage return?
  1117.     jne    shom9b            ; ne = no
  1118.     mov    ah,prstr
  1119.     mov    dx,offset shom9m4    ; show <cr>
  1120.     int    dos
  1121.     cmp    cx,1            ; more to show?
  1122.     je    shom9d            ; e = no
  1123.     call    shom20            ; new line, check for continue or exit
  1124.     jc    shom9e            ; c = exit
  1125.     mov    ah,conout        ; show two spaces
  1126.     mov    dl,' '            ; the spaces
  1127.     int    dos
  1128.     int    dos
  1129.     cmp    byte ptr es:[si],lf    ; cr followed by linefeed?
  1130.     jne    short shom9d        ; ne = no
  1131.     inc    si            ; skip the leading lf
  1132.     dec    cx
  1133.     jmp    short shom9d
  1134. shom9b:    push    ax
  1135.     mov    ah,conout
  1136.     mov    dl,5eh            ; caret
  1137.     int    dos
  1138.     pop    ax
  1139.     add    al,'A'-1        ; add offset to make printable letter
  1140. shom9c:    mov    ah,conout
  1141.     mov    dl,al            ; display it
  1142.     int    dos
  1143. shom9d:    loop    shom9a            ; do whole string
  1144. shom9e:    pop    es
  1145.     pop    si
  1146.     pop    ax
  1147.     ret
  1148.  
  1149. shom20:    inc    temp1            ; count lines displayed
  1150.     cmp    temp1,24        ; done a normal screens' worth?
  1151.     jb    shom22            ; b = no
  1152.     mov    ah,prstr
  1153.     mov    dx,offset moremsg    ; say more
  1154.     int    dos
  1155.     mov    temp1,0
  1156.     mov    flags.cxzflg,0        ; clear flag so we can see Control-C
  1157.     mov    ah,0ch            ; clear keyboard buffer
  1158.     mov    al,coninq        ; quiet input
  1159.     int    dos
  1160.     cmp    al,3            ; Control-C?
  1161.     je    shom21            ; e = yes
  1162.     or    al,al            ; scan code?
  1163.     jne    shom22            ; ne = no
  1164.     mov    ah,coninq        ; read the second byte
  1165.     int    dos
  1166.     or    al,al            ; null for Control-Break?
  1167.     jne    shom22            ; ne = no
  1168. shom21:    mov    flags.cxzflg,'C'    ; say want to exit now
  1169. shom22:    mov    ah,prstr
  1170.     mov    dx,offset crlf
  1171.     int    dos
  1172.     cmp    flags.cxzflg,0        ; want to exit?
  1173.     jne    shom23            ; ne = yes
  1174.     clc
  1175.     ret
  1176. shom23:    stc                ; say exit now
  1177.     ret
  1178. SHOMAC    ENDP
  1179.  
  1180. SHCOM    PROC    NEAR            ; Show Modem
  1181.     mov    ah,cmeol
  1182.     call    comnd            ; get a confirm
  1183.     jc    shcom1            ; c = failure
  1184.     mov    dx,offset crlf
  1185.     mov    ah,prstr
  1186.     int    dos            ; print a crlf
  1187.     mov    bx,offset stcom        ; table of items to be shown
  1188.     call    statc            ; finish in common code
  1189.     call    shomodem
  1190.     clc
  1191. shcom1:    ret
  1192. SHCOM    ENDP
  1193.  
  1194. SHFILE    PROC    NEAR            ; Show File
  1195.     mov    ah,cmeol
  1196.     call    comnd            ; get a confirm
  1197.     jnc    shfile1            ; nc = success
  1198.     ret                ; failure
  1199. shfile1:mov    dx,offset crlf
  1200.     mov    ah,prstr
  1201.     int    dos            ; print a crlf
  1202.     mov    bx,offset stfile    ; table of items to be shown
  1203.     jmp    statc            ; finish in common code
  1204. SHFILE    ENDP
  1205.  
  1206. SHLOG    PROC    NEAR            ; Show Log
  1207.     mov    ah,cmeol
  1208.     call    comnd            ; get a confirm
  1209.     jnc    shlog1            ; nc = success
  1210.     ret                ; failure
  1211. shlog1:    mov    dx,offset crlf
  1212.     mov    ah,prstr
  1213.     int    dos            ; print a crlf
  1214.     mov    bx,offset stlog        ; table of items to be shown
  1215.     jmp    statc            ; finish in common code
  1216. SHLOG    ENDP
  1217.  
  1218. SHMEM    PROC    NEAR            ; Show (free) Memory.   Recursive!
  1219.     mov    ah,cmeol
  1220.     call    comnd            ; get a confirm
  1221.     jnc    shmem1            ; nc = success
  1222.     ret                ; failure
  1223. shmem1:    mov    ah,prstr
  1224.     mov    dx,offset memmsg1    ; header message
  1225.     int    dos
  1226.     mov    word ptr rdbuf,'  '    ; two spaces
  1227.     mov    rdbuf+2,0        ; safety null terminator
  1228.     mov    di,offset rdbuf+1    ; look at first space
  1229.     mov    temp,0            ; total free memory
  1230.     mov    temp1,0            ;  and high word thereof
  1231.     push    es            ; save es
  1232.     call    shmem4            ; allocate memory, recursively
  1233.     mov    dx,offset rdbuf        ; output buffer
  1234.     call    prtasz            ; show pieces
  1235.     mov    dx,offset memmsg2    ; trailer
  1236.     mov    ah,prstr
  1237.     int    dos
  1238.     mov    di,offset rdbuf        ; setup buffer for lnout
  1239.     mov    rdbuf,0
  1240.     mov    ax,temp            ; total free space
  1241.     mov    dx,temp1
  1242.     call    lnouts            ; 32 bit to decimal ascii in di
  1243.     mov    dx,offset rdbuf        ;  with thousands separator
  1244.     call    prtasz
  1245.     pop    es
  1246.     ret
  1247.                     ; worker routine
  1248. shmem4:    mov    bx,0ffffh        ; allocate all memory (must fail)
  1249.     mov    ah,alloc        ; DOS memory allocator
  1250.     int    dos            ; returns available paragraphs in bx
  1251.     jnc    shmem6            ; nc = got it all (not very likely)
  1252.     or    bx,bx            ; bx = # paragraphs alloc'd. Anything?
  1253.     jz    shmem5            ; z = no
  1254.     mov    ah,alloc        ; consume qty now given in bx
  1255.     int    dos
  1256.     jnc    shmem6            ; nc = got the fragment
  1257. shmem5:    ret
  1258. shmem6:    push    ax            ; save allocation segment
  1259.     mov    ax,bx            ; convert paragraphs
  1260.     mul    sixteen            ;  to bytes in dx:ax
  1261.     add    temp,ax            ; running total
  1262.     adc    temp1,dx        ;  32 bits
  1263.     cmp    byte ptr [di],0        ; starting on a null?
  1264.     jne    shmem7            ; ne = no, skip punctuation
  1265.     mov    byte ptr [di],'+'    ; plus punctuation
  1266.     inc    di
  1267. shmem7:    call    lnouts            ; long number to decimal in buffer di
  1268.     call    shmem4            ; recurse
  1269.     pop    es            ; recover allocation segment
  1270.     mov    ah,freemem        ; free the allocation
  1271.     int    dos
  1272.     ret
  1273. SHMEM    ENDP
  1274.  
  1275. SHPRO    PROC    NEAR            ; Show Protocol
  1276.     mov    ah,cmeol
  1277.     call    comnd            ; get a confirm
  1278.     jnc    shpro1            ; nc = success
  1279.     ret                ; failure
  1280. shpro1:    mov    dx,offset crlf
  1281.     mov    ah,prstr
  1282.     int    dos            ; print a crlf
  1283.     mov    bx,offset stpro        ; table of items to be shown
  1284.     jmp    statc            ; finish in common code
  1285. SHPRO    ENDP
  1286.  
  1287. SHSCPT    PROC    NEAR            ; Show Script
  1288.     mov    ah,cmeol
  1289.     call    comnd            ; get a confirm
  1290.     jnc    shscpt1            ; nc = success
  1291.     ret                ; failure
  1292. shscpt1:mov    dx,offset crlf
  1293.     mov    ah,prstr
  1294.     int    dos            ; print a crlf
  1295.     mov    bx,offset stscpt    ; table of items to be shown
  1296.     jmp    statc            ; finish in common code
  1297. SHSCPT    ENDP
  1298.  
  1299. SHSERV    PROC    NEAR            ; Show Server
  1300.     mov    ah,cmeol
  1301.     call    comnd            ; get a confirm
  1302.     jnc    shserv1            ; nc = success
  1303.     ret                ; failure
  1304. shserv1:mov    dx,offset crlf
  1305.     mov    ah,prstr
  1306.     int    dos            ; print a crlf
  1307.     mov    bx,offset stserv2    ; do timeout item
  1308.     call    statc
  1309.     mov    dx,offset crlf
  1310.     mov    ah,prstr
  1311.     int    dos
  1312.     mov    bx,offset stserv    ; table of items to be shown
  1313.     jmp    statc            ; finish in common code
  1314. SHSERV    ENDP
  1315.  
  1316. SHTERM    PROC    NEAR            ; Show Terminal
  1317.     mov    ah,cmeol
  1318.     call    comnd            ; get a confirm
  1319.     jnc    shterm1            ; nc = success
  1320.     ret                ; failure
  1321. shterm1:mov    dx,offset crlf
  1322.     mov    ah,prstr
  1323.     int    dos            ; print a crlf
  1324.     mov    bx,offset stterm    ; table of items to be shown
  1325.     jmp    statc            ; use common code
  1326. SHTERM    ENDP
  1327.  
  1328. ; Start recording of statistics for this operation.
  1329. begtim    proc    near
  1330.     test    sflag,80h        ; is this a duplicate call?
  1331.     jz    begtim1            ; z = no
  1332.     ret                ; else just return
  1333. begtim1:push    ax
  1334.     push    cx
  1335.     push    dx
  1336.     xor    ax,ax        ; clear statistics counters for this file
  1337.     mov    fsta.prbyte,ax        ; bytes received from serial port
  1338.     mov    fsta.prbyte+2,ax
  1339.     mov    fsta.psbyte,ax        ; bytes sent out serial port
  1340.     mov    fsta.psbyte+2,ax
  1341.     mov    fsta.frbyte,ax        ; bytes received for this file
  1342.     mov    fsta.frbyte+2,ax
  1343.     mov    fsta.fsbyte,ax        ; bytes sent for this file
  1344.     mov    fsta.fsbyte+2,ax
  1345.     mov    fsta.prpkt,ax        ; packets received for this file
  1346.     mov    fsta.prpkt+2,ax
  1347.     mov    fsta.pspkt,ax        ; packets sent for this file
  1348.     mov    fsta.pspkt+2,ax
  1349.     mov    fsta.nakrcnt,ax        ; NAKs received for this file
  1350.     mov    fsta.nakscnt,ax        ; NAKs sent for this file
  1351.     mov    fsta.xstatus,al        ; clear status byte
  1352.     mov    ah,getdate        ; get current date, convert to ascii
  1353.     int    dos
  1354.     mov    date+9,'0'        ; init day of month
  1355. begtim2:cmp    dl,10            ; day of month. Ten or more days?
  1356.     jl    begtim3            ; l = no
  1357.     sub    dl,10
  1358.     inc    date+9            ; add up tens of days
  1359.     jmp    short begtim2        ; repeat for higher order
  1360. begtim3:add    dl,'0'            ; ascii bias
  1361.     mov    date+10,dl        ; day units
  1362.     mov    dl,dh            ; months (1-12)
  1363.     dec    dl            ; start at zero to index table
  1364.     xor    dh,dh
  1365.     mov    di,dx            ; months
  1366.     shl    di,1
  1367.     add    di,dx            ; times three chars/month
  1368.     mov    al,months[di]        ; get text string for month
  1369.     mov    date+12,al
  1370.     mov    ax,word ptr months[di+1]
  1371.     mov    word ptr date+13,ax
  1372.     mov    ax,cx            ; year since 1980
  1373.     mov    dx,0
  1374.     mov    di,offset date+16    ; destination
  1375.     call    lnout            ; convert number to asciiz in buffer
  1376.                     ; start time
  1377.     mov    ah,gettim        ; DOS time of day, convert to ascii
  1378.     int    dos
  1379.     mov    fsta.btime,dx        ; store ss.s   low word of seconds
  1380.     mov    fsta.btime+2,cx        ; store hhmm   high word of seconds
  1381.     mov    date,'0'        ; init begin hours field
  1382. begtim4:cmp    ch,10            ; ten or more hours?
  1383.     jl    begtim5            ; l = no
  1384.     sub    ch,10
  1385.     inc    date            ; add up tens of hours
  1386.     jmp    short begtim4        ; repeat for twenties
  1387. begtim5:add    ch,'0'            ; ascii bias
  1388.     mov    date+1,ch        ; store units of hours
  1389.     mov    date+3,'0'        ; minutes field
  1390. begtim6:cmp    cl,10            ; ten or more minutes?
  1391.     jl    begtim7            ; l = no
  1392.     sub    cl,10
  1393.     inc    date+3            ; add up tens of minutes
  1394.     jmp    short begtim6        ; repeat for higher orders
  1395. begtim7:add    cl,'0'            ; ascii bias
  1396.     mov    date+4,cl        ; store units of minutes
  1397.     mov    date+6,'0'        ; seconds field
  1398. begtim8:cmp    dh,10            ; ten or more seconds?
  1399.     jl    begtim9            ; l = no
  1400.     sub    dh,10
  1401.     inc    date+6            ; add up tens of seconds
  1402.     jmp    short begtim8        ; repeat for higher orders
  1403. begtim9:add    dh,'0'            ; ascii bias
  1404.     mov    date+7,dh
  1405.     mov    sflag,80h        ; say begtim has been run
  1406.     pop    dx
  1407.     pop    cx
  1408.     pop    ax
  1409.     ret
  1410. begtim    endp
  1411.  
  1412. ; Take snapshot of statistics counters at end of an operation
  1413. ; Enter with ax = 0 for a receive operation, ax = 1 for a send. [jrd]
  1414. endtim    proc    near
  1415.     test    sflag,80h    ; called more than once without calling begtim?
  1416.     jnz    endtim1            ; ne = no, so do statistics snapshot
  1417.     ret                ; yes, do nothing
  1418. endtim1:and    sflag,not (1)        ; assume receive operation
  1419.     or    ax,ax            ; send (ax > 0), receive (ax = 0) flag
  1420.     jz    endtim2            ; z = receive opeation
  1421.     or    sflag,1            ; say send operation
  1422. endtim2:push    ax
  1423.     push    cx
  1424.     push    dx
  1425.     mov    ah,gettim        ; get DOS time of day
  1426.     int    dos
  1427.     mov    fsta.etime,dx        ; store ss. s
  1428.     mov    fsta.etime+2,cx        ; hhmm
  1429.     cmp    cx,fsta.btime+2        ; end time less than start time?
  1430.     ja    endtim2a    ; a = above (no need to test low order word)
  1431.     cmp    dx,fsta.btime        ; be. How about low order word
  1432.     jae    endtim2a        ; ae = no wrap around of time
  1433.     add    ch,24            ; add one day to hours field
  1434. endtim2a:sub    dl,byte ptr fsta.btime ; 0.01 sec difference
  1435.     jns    endtim2b
  1436.     dec    dh            ; borrow a second
  1437.     add    dl,100            ; make difference positive
  1438. endtim2b:sub    dh,byte ptr fsta.btime+1; seconds difference
  1439.     jns    endtim2c
  1440.     dec    cl            ; borrow a minute
  1441.     add    dh,60            ; make difference positive
  1442. endtim2c:xor    bh,bh
  1443.     mov    bl,dh            ; bx has seconds difference
  1444.     sub    cl,byte ptr fsta.btime+2 ; minutes
  1445.     jns    endtim2d
  1446.     dec    ch            ; borrow an hour
  1447.     add    cl,60
  1448. endtim2d:mov    al,cl
  1449.     xor    ah,ah
  1450.     mul    sixty            ; minutes to seconds
  1451.     add    bx,ax            ; seconds to bx
  1452.     sub    ch,byte ptr fsta.btime+3 ; hours difference
  1453.     jns    endtim2e
  1454.     add    ch,24
  1455. endtim2e:mov    al,ch
  1456.     xor    ah,ah
  1457.     mul    sixty            ; hours to minutes in ax
  1458.     mul    sixty            ; minutes to seconds in dx,ax
  1459.     add    ax,bx            ; ax = seconds
  1460.     adc    dx,0            ; dx = high word of seconds
  1461.     mov    fsta.etime,ax        ; store elapsed time, seconds, low wd
  1462.     mov    fsta.etime+2,dx        ; high word
  1463.     add    ssta.etime,ax        ; add to session time, low word
  1464.     adc    ssta.etime+2,dx        ; add to session time, high word
  1465.     mov    ax,fsta.pretry        ; retries for last transfer
  1466.     add    ssta.pretry,ax        ; retries for this session
  1467.  
  1468.     test    sflag,1            ; completing a receive operation?
  1469.     jnz    endtim3            ; nz = no, a send operation
  1470.     mov    ax,tfilsz        ; file bytes received, low word
  1471.     mov    fsta.frbyte,ax
  1472.     add    ssta.frbyte,ax        ; session received file bytes, low word
  1473.     mov    ax,tfilsz+2        ; high word
  1474.     mov    fsta.frbyte+2,ax
  1475.     adc    ssta.frbyte+2,ax
  1476.     jmp    short endtim4
  1477.  
  1478. endtim3:mov    ax,tfilsz        ; file bytes sent, low word
  1479.     mov    fsta.fsbyte,ax        ; file bytes sent
  1480.     add    ssta.fsbyte,ax        ; session sent file bytes, low word
  1481.     mov    ax,tfilsz+2        ; high word
  1482.     mov    fsta.fsbyte+2,ax
  1483.     adc    ssta.fsbyte+2,ax
  1484.  
  1485. endtim4:mov    ax,fsta.nakrcnt     ; NAKs received for this file
  1486.     add    ssta.nakrcnt,ax     ; session received NAKs
  1487.     mov    ax,fsta.nakscnt     ; NAKs sent for this file
  1488.     add    ssta.nakscnt,ax     ; session sent NAKs
  1489.                     ; do transaction logging
  1490.     cmp    tloghnd,0        ; logging transaction? -1 = not opened
  1491.     jg    endtim5            ; g = logging
  1492.     jmp    endtim12        ; skip logging
  1493. endtim5:push    di            ; kind of transaction
  1494.     push    bx            ; save these registers
  1495.     mov    bx,tloghnd        ; handle for transaction log
  1496.     mov    dx,offset rcvmsg    ; assume receive message
  1497.     test    sflag,1            ; 1 for send, 0 for receive
  1498.     jz    endtim6            ; z = receive
  1499.     mov    dx,offset sndmsg    ; send message
  1500. endtim6:call    strlen            ; length of message to cx
  1501.     mov    ah,write2
  1502.     int    dos            ; write kind of transfer
  1503.                     ; File names
  1504.     cmp    diskio.string,0        ; local filename
  1505.     je    endtim9            ; e = no filename
  1506.     test    sflag,1            ; a send operation?
  1507.     jnz    endtim8            ; nz = yes
  1508.                     ; Receive
  1509.     mov    dx,offset fsta.xname    ; remote name
  1510.     call    strlen            ; length to cx
  1511.     jcxz    endtim7            ; no name
  1512.     mov    ah,write2
  1513.     int    dos
  1514.     mov    dx,offset diskio.string    ; local name
  1515.     call    strlen            ; length to cx
  1516.     mov    si,offset fsta.xname    ; compare these two names
  1517.     mov    di,dx
  1518.     push    ds
  1519.     pop    es
  1520.     repe    cmpsb            ; compare
  1521.     je    endtim9            ; e = same, so no 'as' msg
  1522.     mov    dx,offset fasmsg    ; give 'as' message
  1523.     mov    cx,faslen        ; length
  1524.     mov    ah,write2
  1525.     int    dos
  1526. endtim7:mov    dx,offset diskio.string    ; local name
  1527.     call    strlen            ; get length
  1528.     mov    ah,write2        ; write local name
  1529.     int    dos
  1530.     jmp    short endtim9
  1531.  
  1532. endtim8:mov    dx,offset templp    ; Send. local name
  1533.     call    strlen
  1534.     mov    ah,write2
  1535.     int    dos
  1536.     cmp    fsta.xname,0        ; using an alias?
  1537.     je    endtim9            ; e = no
  1538.     mov    dx,offset fasmsg    ; give 'as' message
  1539.     mov    cx,faslen
  1540.     mov    ah,write2
  1541.     int    dos
  1542.     mov    dx,offset fsta.xname    ; get alias
  1543.     call    strlen
  1544.     mov    ah,write2
  1545.     int    dos
  1546.                     ; status of transfer
  1547. endtim9:mov    dx,offset atmsg        ; say At
  1548.     mov    cx,atlen        ; length
  1549.     mov    bx,tloghnd        ; handle
  1550.     mov    ah,write2
  1551.     int    dos
  1552.     mov    dx,offset date        ; write time and date field
  1553.     mov    cx,datelen        ; length
  1554.     mov    ah,write2
  1555.     int    dos
  1556.     mov    dx,offset fsucmsg    ; assume success message
  1557.     cmp    fsta.xstatus,0        ; 0 = completed?
  1558.     je    endtim10        ; e = completed
  1559.     mov    dx,offset fbadmsg    ; failed message
  1560.     test    fsta.xstatus,80h    ; interrupted?
  1561.     jz    endtim10        ; z = no
  1562.     mov    dx,offset fintmsg    ; interrupted message
  1563. endtim10:call    strlen            ; get length to cx
  1564.     mov    ah,write2
  1565.     int    dos
  1566.                     ; file bytes transferred
  1567.     mov    ax,tfilsz        ; file bytes, low word
  1568.     mov    dx,tfilsz+2        ; high word
  1569.     mov    di,offset rdbuf        ; work buffer
  1570.     call    lnouts            ; transform to ascii
  1571.     mov    [di],0a0dh        ; append cr/lf
  1572.     add    di,2            ; count them
  1573.     mov    dx,offset rdbuf        ; start of work buffer
  1574.     mov    cx,di            ; next free byte
  1575.     sub    cx,dx            ; compute length
  1576.     mov    ah,write2
  1577.     int    dos
  1578.     cmp    dosnum,300h+30        ; DOS 3.30 or higher?
  1579.     jb    endtim11        ; b = no
  1580.     mov    ah,68h            ; Commit the file now
  1581.     int    dos
  1582. endtim11:pop    bx
  1583.     pop    di
  1584. endtim12:mov    tfilsz,0        ; clear file size area
  1585.     mov    tfilsz+2,0
  1586.     mov    sflag,0            ; say have done ending once already
  1587.     mov    fsta.xname,0        ; clear statistics "as" name
  1588.     pop    dx
  1589.     pop    cx
  1590.     pop    ax
  1591.     ret
  1592. endtim    endp
  1593.  
  1594. ; SHOW STATISTICS command. Displays last operation and session statistics
  1595. ; 9 March 1987 [jrd]
  1596. shosta    proc    near            ; show file transfer statistics
  1597.     mov    ah,cmeol        ; confirm with carriage return
  1598.     call    comnd
  1599.     jnc    shosta1
  1600.     ret                ; failure
  1601. shosta1:xor    ax,ax
  1602.     call    endtim            ; update statistics, just in case
  1603.     push    bx
  1604.     push    cx
  1605.     push    dx
  1606.     mov    dx,offset statmsg    ; header
  1607.     mov    ah,prstr
  1608.     int    dos
  1609.     mov    dx,offset fchmsg    ; File characters msg
  1610.     mov    ah,prstr
  1611.     int    dos
  1612.     mov    bx,offset fsta        ; last file structure
  1613.     mov    ax,fsta.fsbyte        ; last transfer file bytes sent
  1614.     mov    dx,fsta.fsbyte+2
  1615.     mov    cx,12            ; field width
  1616.     call    shoprt            ; show result
  1617.     mov    ax,fsta.frbyte        ; last transfer file bytes received
  1618.     mov    dx,fsta.frbyte+2
  1619.     call    shoprt            ; show result
  1620.     mov    ax,ssta.fsbyte        ; session file bytes sent
  1621.     mov    dx,ssta.fsbyte+2
  1622.     call    shoprt            ; show result
  1623.     mov    ax,ssta.frbyte        ; session file bytes received
  1624.     mov    dx,ssta.frbyte+2
  1625.     call    shoprt            ; show result
  1626.  
  1627.     mov    ah,prstr
  1628.     mov    dx,offset spmsg        ; serial port material
  1629.     int    dos
  1630.     mov    ax,fsta.psbyte        ; last transfer port bytes sent
  1631.     mov    dx,fsta.psbyte+2
  1632.     call    shoprt            ; show result
  1633.     mov    ax,fsta.prbyte        ; last transfer port bytes received
  1634.     mov    dx,fsta.prbyte+2
  1635.     call    shoprt            ; show result
  1636.     mov    ax,ssta.psbyte        ; session port bytes sent
  1637.     mov    dx,ssta.psbyte+2
  1638.     call    shoprt            ; show result
  1639.     mov    ax,ssta.prbyte        ; session port bytes received
  1640.     mov    dx,ssta.prbyte+2
  1641.     call    shoprt            ; show result
  1642.  
  1643.     mov    dx,offset pktmsg    ; packets material
  1644.     mov    ah,prstr
  1645.     int    dos
  1646.     mov    ax,fsta.pspkt        ; last transfer packets sent
  1647.     mov    dx,fsta.pspkt+2
  1648.     call    shoprt            ; show result
  1649.     mov    ax,fsta.prpkt        ; last transfer packets received
  1650.     mov    dx,fsta.prpkt+2
  1651.     call    shoprt            ; show result
  1652.     mov    ax,ssta.pspkt        ; session packets sent
  1653.     mov    dx,ssta.pspkt+2
  1654.     call    shoprt            ; show result
  1655.     mov    ax,ssta.prpkt        ; session packets received
  1656.     mov    dx,ssta.prpkt+2
  1657.     call    shoprt            ; show result
  1658.  
  1659.     mov    dx,offset nakmsg    ; NAKs material
  1660.     mov    ah,prstr
  1661.     int    dos
  1662.     mov    ax,fsta.nakscnt        ; last transfer NAKs sent
  1663.     xor    dx,dx
  1664.     call    shoprt
  1665.     mov    ax,fsta.nakrcnt        ; last transfer NAKs received
  1666.     xor    dx,dx
  1667.     call    shoprt
  1668.     mov    ax,ssta.nakscnt        ; session NAKs sent
  1669.     xor    dx,dx
  1670.     call    shoprt
  1671.     mov    ax,ssta.nakrcnt        ; session NAKs received
  1672.     xor    dx,dx
  1673.     call    shoprt
  1674.  
  1675.     mov    dx,offset retmsg    ; retries
  1676.     mov    ah,prstr
  1677.     int    dos
  1678.     mov    ax,fsta.pretry        ; last transfer retry count
  1679.     xor    dx,dx
  1680.     mov    cx,18
  1681.     call    shoprt
  1682.     mov    ax,ssta.pretry        ; session retries
  1683.     xor    dx,dx
  1684.     mov    cx,24
  1685.     call    shoprt
  1686.  
  1687.     mov    dx,offset timemsg    ; elapsed time material
  1688.     mov    ah,prstr
  1689.     int    dos
  1690.     mov    ax,fsta.etime        ; elapsed time of last transfer
  1691.     mov    dx,fsta.etime+2
  1692.     mov    cx,18
  1693.     call    shoprt            ; show result
  1694.     mov    ax,ssta.etime        ; elapsed time of session
  1695.     mov    dx,ssta.etime+2
  1696.     mov    cx,24
  1697.     call    shoprt            ; show result
  1698.  
  1699.     mov    dx,offset chpsmsg    ; File chars per second
  1700.     mov    ah,prstr
  1701.     int    dos
  1702.     mov    ax,fsta.frbyte        ; file bytes received, low
  1703.     mov    dx,fsta.frbyte+2    ; file bytes received, high
  1704.     add    ax,fsta.fsbyte        ; file bytes sent, low
  1705.     adc    dx,fsta.fsbyte+2    ;  high. [dx,ax] = total file bytes
  1706.     mov    bx,offset fsta
  1707.     call    showrk            ; do worker
  1708.     xor    dx,dx            ; discard the fractional cps
  1709.     mov    cx,18
  1710.     call    shoprt            ; show result
  1711.     mov    ax,ssta.frbyte        ; file bytes received, low
  1712.     mov    dx,ssta.frbyte+2    ; file bytes received, high
  1713.     add    ax,ssta.fsbyte        ; file bytes sent, low
  1714.     adc    dx,ssta.fsbyte+2    ;  high. [dx,ax] = total file bytes
  1715.     mov    bx,offset ssta
  1716.     call    showrk            ; do worker
  1717.     xor    dx,dx            ; discard the fractional cps
  1718.     mov    cx,24
  1719.     call    shoprt            ; show result
  1720.         
  1721.     mov    dx,offset spedmsg    ; speed material
  1722.     mov    ah,prstr
  1723.     int    dos
  1724.         ; compute baud rate as  10 * total port bytes / elapsed time
  1725.     mov    ax,fsta.prbyte        ; port bytes received, low
  1726.     mov    dx,fsta.prbyte+2    ; port bytes received, high
  1727.     add    ax,fsta.psbyte        ; port bytes sent, low
  1728.     adc    dx,fsta.psbyte+2    ;  high. [dx,ax] = total port bytes
  1729.     mov    bx,offset fsta
  1730.     call    showrk            ; do worker for bytes/sec and fraction
  1731.     mov    cx,dx            ; save remainder of bytes/second
  1732.     mul    ten            ; bytes/sec times ten to dx,ax
  1733.     push    dx            ; save high order part
  1734.     push    ax            ; save partial baud rate
  1735.     mov    ax,cx            ; remainder to ax
  1736.     xor    dx,dx            ; clear extension
  1737.     mul    ten        ; remainder times ten too (keep only overflow)
  1738.     mov    cx,dx            ; overflow part
  1739.     pop    ax            ; recover main partial result
  1740.     pop    dx            ; high order part
  1741.     add    ax,cx            ; add two partial results
  1742.     adc    dx,0            ; add to extension
  1743.     mov    cx,18
  1744.     call    shoprt            ; show result
  1745.  
  1746.     mov    ax,ssta.prbyte        ; port bytes received, low
  1747.     mov    dx,ssta.prbyte+2    ; port bytes received, high
  1748.     add    ax,ssta.psbyte        ; port bytes sent, low
  1749.     adc    dx,ssta.psbyte+2    ;  high. [dx,ax] = total port bytes
  1750.     mov    bx,offset ssta
  1751.     call    showrk            ; do worker for bytes/sec and fraction
  1752.     mov    cx,dx            ; save remainder of bytes/second
  1753.     mul    ten            ; bytes/sec times ten to dx,ax
  1754.     push    dx            ; save high order part
  1755.     push    ax            ; save partial baud rate
  1756.     mov    ax,cx            ; remainder to ax
  1757.     xor    dx,dx            ; clear extension
  1758.     mul    ten        ; remainder times ten too (keep only overflow)
  1759.     mov    cx,dx            ; overflow part
  1760.     pop    ax            ; recover main partial result
  1761.     pop    dx            ; high order part
  1762.     add    ax,cx            ; add two partial results
  1763.     adc    dx,0            ; add to extension
  1764.     mov    cx,24
  1765.     call    shoprt            ; show result
  1766.  
  1767.     mov    ah,prstr
  1768.     mov    dx,offset crlf
  1769.     int    dos
  1770.     pop    dx
  1771.     pop    cx
  1772.     pop    bx
  1773.     clc
  1774.     ret
  1775. shosta    endp
  1776.  
  1777. ; baud rate and char/sec worker for above
  1778. ; Enter with dx,ax holding the byte count, returns (dx,ax / seconds in
  1779. ; ax (whole number) and dx (fraction).
  1780. showrk    proc    near    
  1781.     mov    cx,[bx].etime        ; low word of sec in cx
  1782.     cmp    [bx].etime+2,0    ; is high word of sec zero (e.t. < 65536 sec)?
  1783.     jz    showrk1            ; z = yes, ready for arithmetic
  1784.     push    ax            ; else scale values, save byte count
  1785.     push    dx
  1786.     mov    ax,[bx].etime        ; elapsed time for file, low word
  1787.     mov    dx,[bx].etime+2        ;  high word    
  1788.     shr    ax,1            ; divide seconds by two, low word
  1789.     ror    dx,1            ; get low bit of high word
  1790.     and    dx,8000            ; pick out just that bit
  1791.     or    ax,dx        ; mask in that bit, new time in ax (dx = 0)
  1792.     mov    cx,ax            ; save elapsed time (double-seconds)
  1793.     pop    dx            ; get byte count again
  1794.     pop    ax
  1795.     shr    ax,1            ; divide byte count by two also
  1796.     push    dx
  1797.     ror    dx,1            ; rotate low bit to high position
  1798.     and    dx,8000h        ; get low bit of high word
  1799.     or    ax,dx            ; byte count divided by two, low word
  1800.     pop    dx
  1801.     shr    dx,1            ; and high word
  1802. showrk1:or    cx,cx               ; is elapsed time (in cx) zero seconds?
  1803.     jnz    showrk2            ; nz = no
  1804.     inc    cx                ; set time to one second (no div by 0)
  1805. showrk2:div    cx               ; bytes div seconds, ax = quo, dx = rem
  1806.     ret
  1807. showrk    endp
  1808.  
  1809. ; Display SHOW STATISTICS line. Enter with dx,ax with long value, cx = width
  1810. shoprt    proc    near
  1811.     push    di
  1812.     mov    di,offset rdbuf        ; work space for output
  1813.     call    lnouts            ; show long integer, with separator
  1814.     pop    di
  1815.     mov    dx,offset rdbuf
  1816.     push    bx
  1817.     push    cx
  1818.     push    dx
  1819.     mov    bx,cx            ; field width
  1820.     call    strlen            ; length of string in dx
  1821.     sub    bx,cx            ; number of spaces necessary
  1822.     xchg    bx,cx
  1823.     jle    shoprt2            ; le = no spaces
  1824.     mov    dl,' '
  1825.     mov    ah,conout
  1826. shoprt1:int    dos            ; display the leading spaces
  1827.     loop    shoprt1
  1828. shoprt2:pop    dx
  1829.     pop    cx
  1830.     pop    bx
  1831.     jmp    prtasz            ; display asciiz string
  1832. shoprt    endp
  1833.  
  1834.  
  1835. ; STATUS command
  1836.  
  1837. STATUS    PROC    NEAR
  1838.     mov    ah,cmeol
  1839.     call    comnd            ; get a confirm
  1840.     jnc    stat0a            ; nc = success
  1841.     ret                ; failure
  1842. stat0a:    mov    dx,offset crlf
  1843.     mov    ah,prstr
  1844.     int    dos            ; print a crlf
  1845.                     ; STAT0 is an external ref (in mster)
  1846. STAT0:    call    cmblnk            ; clear the screen
  1847.     call    locate            ; home the cursor
  1848.     mov    bx,offset sttab        ; table to control printing
  1849.     xor    cx,cx            ; column counter
  1850.                     ; STATC is external ref in msx
  1851. STATC:    cmp    word ptr [bx],0        ; end of table?
  1852.     je    statx            ; e = yes
  1853.     cld                ; string direction is forward
  1854.     push    ds
  1855.     pop    es
  1856.     mov    di,offset rdbuf        ; point to destination buffer
  1857.     mov    byte ptr[di],spc    ; start with two spaces
  1858.     inc    di
  1859.     mov    byte ptr[di],spc
  1860.     inc    di
  1861.     push    cx            ; save column number
  1862.     push    bx
  1863.     call    [bx].sttyp        ; call appropriate routine
  1864.     pop    bx
  1865.     pop    cx
  1866.     sub    di,offset rdbuf        ; number of bytes used
  1867.     add    cx,di            ; new line col count
  1868.     push    cx            ; save col number around print
  1869.     mov    cx,di            ; how much to print now
  1870.     mov    di,offset rdbuf        ; source text
  1871.     cmp    cx,2            ; nothing besides our two spaces?
  1872.     jbe    stat5            ; e = yes, forget it
  1873.     call    prtscr            ; print counted string
  1874. stat5:    pop    cx
  1875.     add    bx,size stent        ; look at next entry
  1876.     cmp    word ptr [bx],0        ; at end of table?
  1877.     je    statx            ; e = yes
  1878.     cmp    cx,38            ; place for second display?
  1879.     jbe    stat2            ; be = only half full
  1880.     mov    dx,offset crlf        ; over half full. send cr/lf
  1881.     mov    ah,prstr
  1882.     int    dos
  1883.     xor    cx,cx            ; say line is empty now
  1884.     jmp    statc
  1885. stat2:    mov    ax,cx
  1886.     mov    cx,38            ; where we want to be next time
  1887.     sub    cx,ax            ; compute number of filler spaces
  1888.     or    cx,cx
  1889.     jle    stat4            ; nothing to do
  1890.     mov    ah,conout
  1891.     mov    dl,' '
  1892. stat3:    int    dos            ; fill with spaces
  1893.     loop    stat3            ; do cx times
  1894. stat4:    mov    cx,38            ; current column number
  1895.     jmp    statc            ; and do it
  1896. statx:    clc
  1897.     ret
  1898. STATUS    ENDP
  1899.  
  1900. ; handler routines for status
  1901. ; all are called with di/ destination buffer, bx/ stat ptr. They can change
  1902. ; any register except es:, must update di to the end of the buffer.
  1903.  
  1904. ; copy the message into the buffer
  1905. stmsg    proc    near
  1906.     push    ds
  1907.     pop    es        ; ensure es points to data segment
  1908.     mov    si,[bx].msg    ; get message address
  1909. stms1:    lodsb            ; get a byte
  1910.     stosb            ; drop it off
  1911.     or    al,al        ; ending on null?
  1912.     jz    stms2        ; z = yes
  1913.     cmp    al,'$'        ; end of message?
  1914.     jne    stms1        ; no, keep going
  1915. stms2:    dec    di        ; else back up ptr
  1916.     ret
  1917. stmsg    endp
  1918.  
  1919. ; get address of test value in stent. Returns address in si
  1920. stval    proc    near
  1921.     mov    si,[bx].basval    ; get base value
  1922.     or    si,si        ; any there?
  1923.     jz    stva1        ; z = no, keep going
  1924.     mov    si,[si]        ; yes, use as base address
  1925. stva1:    add    si,[bx].tstcel    ; add offset of test cell
  1926.     ret            ; and return it
  1927. stval    endp
  1928.  
  1929. ; print a single character
  1930. onechr    proc    near
  1931.     call    stmsg        ; copy message part first
  1932.     call    stval        ; pick up test value address
  1933.     mov    al,[si]        ; this is char to print
  1934.     cmp    al,' '        ; printable?
  1935.     jae    onech1        ; yes, keep going
  1936.     add    al,64        ; make printable
  1937.     mov    byte ptr [di],5eh    ; caret
  1938.     inc    di        ; note ctrl char
  1939. onech1:    stosb            ; drop char off
  1940.     ret
  1941. onechr    endp
  1942.  
  1943. ; numeric field
  1944. stnum    proc    near        ; for 8 bit numbers
  1945.     call    stmsg        ; copy message
  1946.     call    stval        ; pick up value address
  1947.     mov    al,[si]        ; get value
  1948.     xor    ah,ah        ; high order is 0
  1949.     jmp    outnum        ; put number into buffer
  1950. stnum    endp
  1951.  
  1952. stlnum    proc    near        ; for 16 bit numbers [jrd]
  1953.     call    stmsg        ; copy message
  1954.     call    stval        ; pick up value address
  1955.     mov    ax,[si]        ; get value
  1956.     jmp    outnum        ; put number into buffer
  1957. stlnum    endp
  1958.  
  1959. ; translate the number in ax
  1960. outnum    proc    near
  1961.     xor    dx,dx
  1962.     mov    bx,10
  1963.     div    bx        ; divide to get digit
  1964.     push    dx        ; save remainder digit
  1965.     or    ax,ax        ; test quotient
  1966.     jz    outnu1        ; zero, no more of number
  1967.     call    outnum        ; else call for rest of number
  1968. outnu1:    pop    ax        ; get digit back
  1969.     add    al,'0'        ; make printable
  1970.     stosb            ; drop it off
  1971.     ret
  1972. outnum    endp
  1973.  
  1974. ; on/off field
  1975. onoff    proc    near
  1976.     call    stmsg        ; copy message
  1977.     call    stval        ; get value cell
  1978.     mov    al,[si]
  1979.     mov    si,offset onmsg
  1980.     mov    cx,2        ; assume 2-byte 'ON' message
  1981.     or    al,al        ; test value
  1982.     jnz    onof1        ; on, have right msg
  1983.     mov    si,offset offmsg
  1984.     mov    cx,3
  1985. onof1:    cld
  1986.     push    ds
  1987.     pop    es
  1988.     rep    movsb        ; copy right message in
  1989.     ret
  1990. onoff    endp
  1991.  
  1992. ; print first message if false, second if true
  1993. msg2    proc    near
  1994.     call    stval        ; get value cell
  1995.     mov    al,[si]
  1996.     mov    si,[bx].msg    ; assume off
  1997.     or    al,al        ; is it?
  1998.     jz    msg21        ; yes, continue
  1999.     mov    si,[bx].val2    ; else use alternate message
  2000. msg21:    jmp    stms1        ; handle copy and return
  2001. msg2    endp
  2002.  
  2003. ; print first message if false, second if true, uses bit in byte for value
  2004. msg2b    proc    near
  2005.     call    stbval        ; get bit value cell
  2006.     mov    si,[bx].msg    ; assume off
  2007.     or    al,al        ; is it?
  2008.     jz    msg2b1        ; yes, continue
  2009.     mov    si,[bx].val2    ; else use alternate message
  2010. msg2b1:    jmp    stms1        ; handle copy and return
  2011. msg2b    endp
  2012.  
  2013. ; search a keyword table for a word value, print that value
  2014. srchkww    proc    near
  2015.     call    stmsg        ; first print message
  2016.     call    stval
  2017.     mov    ax,[si]        ; get value to hunt for
  2018.     mov    bx,[bx].val2    ; this is table address
  2019.     jmp    prttab        ; and look in table
  2020. srchkww    endp
  2021.  
  2022. ; search a keyword table for a byte value, print that value
  2023. srchkw    proc    near
  2024.     call    stmsg        ; first print message
  2025.     call    stval
  2026.     mov    al,[si]        ; get value to hunt for
  2027.     xor    ah,ah        ; high order is 0
  2028.     mov    bx,[bx].val2    ; this is table address
  2029.     jmp    prttab        ; and look in table
  2030. srchkw    endp
  2031.  
  2032. ; search a keyword table for a bit value, print that value
  2033. srchkb    proc    near
  2034.     call    stmsg            ; first print message
  2035.     call    stbval            ; get bit set or reset
  2036.     mov    bx,[bx].val2        ; this is table address
  2037.     jmp    prttab            ; and look in table
  2038. srchkb    endp
  2039.  
  2040. ; get address of test value in stent.  Returns address in si. [jrd]
  2041. stbval    proc    near
  2042.     mov    si,[bx].basval        ; get address of test value
  2043.     or    si,si            ; any there?
  2044.     jz    stbva1            ; z = no, quit with no match
  2045.     mov    ax,[si]            ; get value
  2046.     test    ax,[bx].tstcel         ; bit test value against data word
  2047.     jz    stbva1            ; z = they don't match
  2048.     mov    ax,1            ;  match
  2049.     ret
  2050. stbva1:    xor    ax,ax            ; no match
  2051.     ret                ; and return it
  2052. stbval    endp
  2053.  
  2054.  
  2055. ; Print the drive name
  2056. drnum    proc    near
  2057.     call    stmsg        ; copy message part first
  2058.     call    stval        ; pick up test value address
  2059.     mov    ah,gcurdsk    ; Get current disk
  2060.     int    dos
  2061.     inc    al        ; We want 1 == A (not zero)
  2062.     mov    curdsk,al
  2063.     add    al,'@'        ; Make it printable
  2064.     cld
  2065.     push    ds
  2066.     pop    es
  2067.     stosb
  2068.     mov    word ptr [di],'\:'
  2069.     add    di,2        ; end with a colon and backslash
  2070.     mov    byte ptr [di],0    ; terminate in case drive is not ready
  2071.     xor    dl,dl        ; get current drive
  2072.     mov    ah,gcd        ; get current directory
  2073.     mov    si,di        ; current working buffer position
  2074.     int    dos
  2075.     push    cx
  2076.     push    dx
  2077.     mov    dx,di        ; directory string
  2078.     call    strlen        ; length of path part to cx
  2079.     cmp    cx,26        ; too long to show the whole thing?
  2080.     jbe    drnum3        ; be = is ok, show the whole path
  2081.     push    di        ; scan backward for last backslash
  2082.     mov    al,'\'        ; thing to search for
  2083.     std            ; backward
  2084.     mov    di,si        ; start of buffer
  2085.     add    di,cx        ; length of string
  2086.     repne    scasb        ; scan backward for a backslash
  2087.     jcxz    drnum2        ; should not happen, but then again 
  2088.     repne    scasb        ; do again for second to last path part
  2089. drnum2:    cld            ; reset direction flag
  2090.     dec    di        ; move di two places preceding backslash
  2091.     mov    [di],'--'    ; insert a missing path indicator
  2092.     dec    di
  2093.     mov    byte ptr [di],'-'
  2094.     mov    si,di        ; we will show just this part
  2095.     pop    di        ; recover main status pointer
  2096. drnum3:    pop    dx
  2097.     pop    cx
  2098.     
  2099. drnum4:    lodsb            ; copy until null terminator
  2100.     stosb
  2101.     or    al,al        ; end of string?
  2102.     jnz    drnum4        ; nz = no
  2103.     dec    di        ; offset inc of stosb
  2104.     ret
  2105. drnum    endp
  2106.  
  2107.  
  2108. ; Print the screen-dump filename [jrd]
  2109.  
  2110. pasz    proc    near
  2111.     call    stmsg        ; copy message part
  2112.     mov    si,[bx].val2    ; address of asciiz string
  2113.     push    ds
  2114.     pop    es
  2115.     cld
  2116. pasz1:    lodsb            ; get a byte
  2117.     or    al,al        ; at end yet?
  2118.     jz    pasz2        ; z = yes
  2119.     stosb            ; store in buffer
  2120.     jmp    short pasz1    ; keep storing non-null chars
  2121. pasz2:    ret
  2122. pasz    endp
  2123.  
  2124. ; Display Send and Receive chars
  2125. prsar    proc    near
  2126.     call     stmsg        ; display leadin part of message
  2127.     push    ds
  2128.     pop    es
  2129.     cld
  2130.     mov    si,[bx].tstcel    ; get address of first item
  2131.     mov    al,[si]
  2132.     cmp    al,7fh        ; DEL code?
  2133.     jne    prsar1        ; ne = no
  2134.     mov    ax,'1\'        ; say \127
  2135.     cmp    byte ptr [di-1],5eh ; caret present in msg?
  2136.     jne    prsar5        ; ne = no
  2137.     dec    di        ; remove "^"
  2138. prsar5:    stosw
  2139.     mov    ax,'72'
  2140.     stosw
  2141.     jmp    short prsar2
  2142. prsar1:    add    al,40H        ; make it printable
  2143.     stosb
  2144. prsar2:    mov    si,[bx].val2    ; get address of second msg
  2145.     call    stms1        ; add that
  2146.     mov    si,[bx].basval    ; second value's address
  2147.     mov    al,[si]        ; second value
  2148.     cmp    al,7fh        ; DEL code?
  2149.     jne    prsar3        ; ne = no
  2150.     mov    ax,'1\'        ; say \127
  2151.     cmp    byte ptr [di-1],5eh ; caret present in msg?
  2152.     jne    prsar6        ; ne = no
  2153.     dec    di        ; remove "^"
  2154. prsar6:    stosw
  2155.     mov    ax,'72'
  2156.     stosw
  2157.     ret
  2158. prsar3:    add    al,40H        ; make it printable
  2159.     stosb
  2160.     ret
  2161. prsar    endp
  2162.  
  2163. ; Display Send and Receive char value
  2164. prsarv    proc    near
  2165.     call     stmsg        ; display leadin part of message
  2166.     mov    si,[bx].tstcel    ; get address of first item
  2167.     mov    al,[si]
  2168.     xor    ah,ah
  2169.     push    bx
  2170.     call    outnum
  2171.     pop    bx
  2172.     mov    si,[bx].val2    ; get address of second msg
  2173.     call    stms1        ; add that
  2174.     mov    si,[bx].basval    ; second value's address
  2175.     mov    al,[si]        ; second value
  2176.     xor    ah,ah
  2177.     jmp    outnum
  2178. prsarv    endp
  2179.  
  2180.  
  2181. ; print Send Delay and Pause
  2182. prsnd    proc    near
  2183.     call    stmsg        ; display leadin part of msg
  2184.     mov    al,trans.sdelay    ; Send Delay (sec)
  2185.     xor    ah,ah
  2186.     call    outnum
  2187.     mov    si,offset sndmsg2 ; second part of msg
  2188.     call    stms1        ; add that
  2189.     mov    al,spause    ; Send Pause (millisec) 
  2190.     call    outnum
  2191.     mov    si,offset sndmsg3 ; last part of msg
  2192.     call    stms1        ; add it too
  2193.     ret
  2194. prsnd    endp
  2195.  
  2196. ; Print the handshake
  2197. prhnd:    mov    si,offset handst    ; copy in initial message
  2198.     call    stms1
  2199.     mov    si,offset nonmsg    ; assume no handshake
  2200.     mov    bx,portval
  2201.     cmp    [bx].hndflg,0        ; Is handshaking in effect?
  2202.     jne    prh0            ; Yes, print what we're using
  2203.     jmp    stms1            ; no, say so and return
  2204. prh0:    mov    al,5eh            ; Doing handshaking with control char
  2205.     push    ds
  2206.     pop    es
  2207.     cld
  2208.     stosb
  2209.     mov    al,[bx].hands
  2210.     add    al,40H            ; Make printable
  2211.     stosb                ; put in buffer
  2212.     ret                ; and return
  2213.  
  2214. ; Print the Transmit Fill char
  2215. prfil:    mov    si,offset sxfilmsg    ; copy in initial message
  2216.     call    stms1
  2217.     mov    si,offset nonmsg    ; assume no handshake
  2218.     mov    al,script.xmitfill    ; filling char
  2219.     or    al,al            ; is filling in effect?
  2220.     jnz    prfil1            ; nz = yes, print what we're using
  2221.     jmp    stms1            ; no, say so and return
  2222. prfil1:    push    ds
  2223.     pop    es
  2224.     cld
  2225.     cmp    al,20h            ; printable already?
  2226.     ja    prfil2            ; a = yes
  2227.     push    ax
  2228.     mov    al,5eh            ; control char
  2229.     stosb
  2230.     pop    ax
  2231.     add    al,40H            ; make printable
  2232.     stosb                ; put in buffer
  2233.     ret                ; and return
  2234. prfil2:    cmp    al,126            ; in ordinary printable range?
  2235.     ja    prfil3            ; a = no
  2236.     stosb                ; store in buffer
  2237.     ret
  2238. prfil3:    mov    byte ptr [di],'\'    ; show as \number
  2239.     inc    di
  2240.     xor    ah,ah
  2241.     jmp    outnum            ; do rest of number
  2242.  
  2243. ; Print value from table.  BX/address of table, AL/value of variable
  2244. prttab:    push    cx            ; save column count
  2245.     mov    cl,[bx]            ; number of entries in our table
  2246.     inc    bx            ; point to the data
  2247. prtt0:    mov    dl,[bx]            ; length of keyword
  2248.     inc    bx            ; point to keyword
  2249.     xor    dh,dh
  2250.     inc    dx            ; account for "$" in table
  2251.     mov    si,dx            ; put to index register
  2252.     cmp    ax,[bx+si]        ; this one?
  2253.     je    prtt1            ; e = yes
  2254.     add    bx,dx            ; go to end of keyword
  2255.     add    bx,2            ; point to next keyword
  2256.     dec    cl            ; more keywords to check?
  2257.     jnz    prtt0            ; nz = yes, go to it
  2258.     mov    bx,offset prterr
  2259. prtt1:    mov    si,bx
  2260.     pop    cx            ; recover column count
  2261.     jmp    stms1            ; copy in message
  2262.  
  2263. ; Print the baud rate
  2264.  
  2265. BAUDPRT    PROC     NEAR
  2266.     mov    si,offset baudrt    ; "Speed: "
  2267.     call    stms1            ; display that part
  2268.     push    di
  2269.     push    cx
  2270.     call    getbaud            ; read baud rate first
  2271.     pop    cx
  2272.     pop    di
  2273.     mov    bx,portval
  2274.     mov    ax,[bx].baud
  2275.     cmp    al,byte ptr bdtab    ; number of table entries
  2276.     jb    bdprt5            ; b = in table
  2277.     mov    si,offset unrec        ; say unrecognized value
  2278.     jmp    stms1            ; display text and return
  2279. bdprt5:    mov    bx,offset bdtab        ; show ascii rate from table
  2280.     jmp    prttab
  2281. BAUDPRT    ENDP
  2282.  
  2283. ; display Take/Macro COUNT
  2284. stcnt    proc    near
  2285.     call    stmsg            ; display leadin part of msg
  2286.     cmp    taklev,0        ; in a Take file or macro?
  2287.     jne    stcnt1            ; ne = yes
  2288.     mov    si,offset nonemsg    ; say none
  2289.     call    stms1
  2290.     ret
  2291. stcnt1:    push    bx
  2292.     mov    bx,takadr        ; current Take structure
  2293.     mov    ax,[bx].takctr        ; get COUNT
  2294.     pop    bx
  2295.     jmp    outnum
  2296. stcnt    endp
  2297.  
  2298. ; display Take/Macro ARGC
  2299. starg    proc    near
  2300.     call    stmsg            ; display leadin part of msg
  2301.     cmp    taklev,0        ; in a Take file or macro?
  2302.     jne    starg1            ; ne = yes
  2303.     mov    si,offset nonemsg    ; say none
  2304.     call    stms1
  2305.     ret
  2306. starg1:    push    bx
  2307.     mov    bx,takadr        ; current Take structure
  2308.     mov    ax,[bx].takargc        ; get ARGC
  2309.     pop    bx
  2310.     jmp    outnum
  2311. starg    endp
  2312.  
  2313. ; ALARM time
  2314. stalr    proc    near
  2315.     call    stmsg            ; display leading part of msg
  2316.     push    bx            ; preserve register
  2317.     xor    bx,bx            ; position index
  2318.     push    ds
  2319.     pop    es
  2320.     cld
  2321. stalr1:    push    bx            ; save around calls
  2322.     cmp    alrhms[bx],10        ; two digits?
  2323.     jae    stalr2            ; ae = yes
  2324.     mov    al,'0'
  2325.     stosb                ; show leading zero
  2326. stalr2:    mov    al,alrhms[bx]        ; show time component
  2327.     xor    ah,ah
  2328.     call    outnum
  2329.     pop    bx            ; recover index
  2330.     inc    bx
  2331.     cmp    bx,3            ; done all fields?
  2332.     jae    stalr3            ; ae = yes
  2333.     mov    al,':'
  2334.     stosb
  2335.     jmp    short stalr1        ; do next field
  2336. stalr3:    pop    bx
  2337.     ret
  2338. stalr    endp
  2339.  
  2340. ; LNOUT - Table driven unsigned long integer (32 bit) display
  2341. ; Register dx holds high order word and ax holds low order word of unsigned
  2342. ; long integer to be stored in decimal. Storage area is given by DS:[DI]
  2343. ; DI is incremented for each storage, null terminated.
  2344. ; Table TENS holds set of double word values of ten raised to powers 0 to 9
  2345. ; TENSLEN holds the number of these double words
  2346. ; All registers preserved.    8 March 1987 [jrd]
  2347.  
  2348. lnouts    proc    near            ; do lnout with thousands separator
  2349.     push    ax
  2350.     mov    al,thsep        ; get thousands separator
  2351.     mov    lnoutsep,al        ; tell lnout to use it
  2352.     pop    ax
  2353.     call    lnout            ; compute value to di
  2354.     mov    lnoutsep,0        ; clear for future callers
  2355.     ret
  2356. lnouts    endp
  2357.  
  2358. lnout    proc    near
  2359.     push    ax
  2360.     push    bx
  2361.     push    cx
  2362.     push    dx
  2363.     push    si
  2364.     xor    si,si        ; flag to say start printing (no leading 0's)
  2365.     mov    cx,tenslen    ; number of table entries
  2366. lnout1:    push    cx        ; save loop counter
  2367.     mov    bx,cx        ; index into tens double word table
  2368.     dec    bx        ; index starts at zero
  2369.     add    bx,bx
  2370.     add    bx,bx        ; bx times four (double words to bytes)
  2371.     xor    cx,cx        ; cx is now a counter of subtractions
  2372.  
  2373. lnout2:    cmp    dx,word ptr tens[bx+2]  ; pattern 10**(bx/4), high order part
  2374.     jb    lnout4        ; b = present number is less than pattern
  2375.     ja    lnout3        ; a = present number is larger than pattern
  2376.     cmp    ax,word ptr tens[bx] ; high words match, how about lows
  2377.     jb    lnout4        ; b = present number is smaller than pattern
  2378. lnout3:    sub    ax,word ptr tens[bx]    ; subtract low order words
  2379.     sbb    dx,word ptr tens[bx+2]    ; subtract high order words, w/borrow
  2380.     inc    cl            ; count number of subtractions
  2381.     inc    si        ; flag to indicate printing needed
  2382.     jmp    lnout2        ; try again to deduct present test pattern
  2383.  
  2384. lnout4:    or    bx,bx        ; doing least significant digit?
  2385.     jz    lnout5        ; z = yes, always print this one
  2386.     or    si,si        ; should we print?
  2387.     jz    lnout6        ; z = no, not yet
  2388. lnout5:    add    cl,'0'        ; get number of subtractions
  2389.     mov    [di],cx        ; store it (ch is still zero), asciiz
  2390.     inc    di
  2391.     cmp    bx,9*4        ; places for thousands separator?
  2392.     je    lnout5a        ; e = yes
  2393.     cmp    bx,6*4
  2394.     je    lnout5a
  2395.     cmp    bx,3*4
  2396.     jne    lnout6        ; ne = no
  2397. lnout5a:mov    cl,lnoutsep    ; get thousands separator
  2398.     jcxz    lnout6        ; z = none
  2399.      mov    word ptr [di],cx
  2400.     inc    di
  2401. lnout6:    pop    cx        ; recover loop counter
  2402.     loop    lnout1
  2403.     pop    si
  2404.     pop    dx
  2405.     pop    cx
  2406.     pop    bx
  2407.     pop    ax
  2408.     ret
  2409. lnout    endp 
  2410.  
  2411. code    ends
  2412.     end
  2413.