home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / b / krtutl.mac < prev    next >
Text File  |  2020-01-01  |  19KB  |  572 lines

  1.     .title    KRTUTL    Mount, rename, delete, copy, paksta, asctim, etc..
  2.     .ident    "V03.63"
  3.  
  4. ; /63/    27-Sep-97  Billy Youdelman  V03.63
  5.  
  6. ; /62/    27-Jul-93  Billy Youdelman  V03.62
  7. ;
  8. ;    modify asctim to output ticks, restored optional time value pointer
  9. ;    move various items here from root to save space
  10.  
  11. ; /BBS/     1-Dec-91  Billy Youdelman  V03.61
  12. ;
  13. ;    added logical disk mount using TSX+ emts
  14. ;    50/60Hz test added to asctim
  15. ;    cleaned up the delete, rename and copy subroutines..
  16. ;    move copy file name checking to c$copy, now shared with PRINT
  17. ;    try to mount .DEV logical disk if .DSK default fails
  18. ;    fixed COPY error handling when out file is too small
  19.  
  20. ;    Copyright 1984 Change Software, Inc.
  21. ;
  22. ;    18-Jul-84  16:14:46 Brian Nelson
  23.  
  24.  
  25.     .include "IN:KRTMAC.MAC"
  26.     .iif ndf  KRTINC  .error    <; .include for IN:KRTMAC.MAC failed>
  27.     .include "IN:KRTDEF.MAC"
  28.     .iif ndf  MSG$DA  .error    <; .include for IN:KRTDEF.MAC failed>
  29.  
  30.  
  31.     .mcall    .CSISPC    ,.DELETE,.GTIM    ,.RENAME
  32.  
  33.  
  34.     .sbttl    Local data        ; /63/ consolidated here..
  35.  
  36.     .psect    $rwdata    ,rw,d,lcl,rel,con
  37. mntemt:    .byte    lun.ld ,163        ; emt args to mount a logical device..
  38. ldunit:    .byte    0 ,0            ; second byte is read/write flag
  39. elfmop:    .word    elfmo            ; pointer to .rad50 file name
  40. elfmo:    .word    0 ,0 ,0 ,0        ; .rad50 file name lives here
  41. dfflag:    .word    0            ; try default extents (.DSK,.DEV) flag
  42. dismnt:    .byte    3 ,135            ; dump the LDn assign for..
  43. disunit:.byte    0 ,0            ; ..this unit number
  44. dkflag:    .word    0            ; assign this mount DK if <>
  45. ;nocache:.byte    2 ,135            ; dismount the world,
  46. ;    .word    0            ; cache wise..
  47. newdk:    .asciz    "LDn:"            ; defdir string is loaded from here
  48.     .even
  49. csiext:    .word    0 ,0 ,0 ,0        ; .csispc default extents
  50. renlst:    .word    0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ; rename list is built here
  51. hitime:    .word    0            ; /62/ high word of time
  52. lotime:    .word    0            ; /62/ low word
  53. hours:    .word    0            ; /62/ output integer hours
  54. mins:    .word    0            ; /62/ minutes
  55. secs:    .word    0            ; /62/ seconds
  56. ticks:    .word    0            ; /62/ ticks
  57. timemt:    .byte    5            ; /62/ number of arguments
  58.     .byte    0            ; /62/ reserved
  59.     .word    hitime            ; /62/ cvttim input time address
  60.     .word    hours            ; /62/ hours address
  61.     .word    mins            ; /62/ mins
  62.     .word    secs            ; /62/ secs
  63.     .word    ticks            ; /62/ ticks
  64.  
  65.     .psect    $pdata
  66. pepmsg:    .asciz    "Error message from remote:"<cr><lf>  ; /63/
  67. sta.0:    .byte    STA.CCA    ,STA.ABO,STA.BRK,STA.COM,STA.DAT,STA.FIL
  68.     .byte    STA.ATR    ,STA.INI,STA.RIN,STA.SIN,STA.TYP,STA.EOF
  69.     .byte    0
  70.     .even
  71. sta.1:    .word    10$
  72.     .word    20$    ,30$    ,40$    ,50$    ,60$    ,70$
  73.     .word    80$    ,90$    ,100$    ,110$    ,120$    ,130$
  74.  10$:    .asciz    "BAD  Unknown State"
  75.  20$:    .asciz    "CCA  ^C Abort"
  76.  30$:    .asciz    "ABO  Abort"
  77.  40$:    .asciz    "BRK  Break Transmission"
  78.  50$:    .asciz    "COM  Transaction Complete"
  79.  60$:    .asciz    "DAT  Data"
  80.  70$:    .asciz    "FIL  File Name"
  81.  80$:    .asciz    "ATR  Attributes"
  82.  90$:    .asciz    "INI  Server Init"
  83.  100$:    .asciz    "RIN  Receive Init"
  84.  110$:    .asciz    "SIN  Send Init"
  85.  120$:    .asciz    "TYP  Extended Reply"
  86.  130$:    .asciz    "EOF  End of File"
  87. sta.2:    .asciz    "TOD "            ; "Time Of Day" header for log entry
  88. sta.3:    .asciz    "  "
  89. sta.4:    .asciz    "Hz   Elapsed-Time: "
  90. sta.5:    .ascii    <cr><lf>        ; two newlines from here
  91. sta.6:    .asciz    <cr><lf>
  92. sta.7:    .asciz    " = STA."
  93.     .even
  94.  
  95.  
  96.     .psect    $code
  97.     .sbttl    The real work of MOUNT    ; /BBS/ added
  98.  
  99. ;    input:    argbuf    = entire argument string, unparsed
  100. ;         r1    = if <> then dismount
  101.  
  102. mount::    upcase    argbuf            ; upper case all args
  103.     mov    argbuf    ,r2        ; pointer to LDn:
  104.     beq    20$            ; not there..
  105.     cmpb    #'L    ,(r2)+        ; is first byte an "L" ?
  106.     bne    20$            ; nope..
  107.     cmpb    #'D    ,(r2)+        ; is second byte a "D" ?
  108.     bne    20$            ; nope..
  109.  
  110.     cmpb    (r2)    ,#':        ; is there a colon after LD?
  111.     beq    30$            ; ya
  112.     tst    r1            ; /62/ dismount?
  113.     beq    10$            ; no
  114.     tstb    (r2)            ; ya, thus a
  115.     beq    30$            ; null here = unit 0
  116. 10$:    cmpb    (r2)    ,#space        ; is there a space delimiter?
  117.     beq    30$            ; ya
  118.     movb    (r2)+    ,r0        ; get unit #, sign bit should be zero
  119.     sub    #'7+1    ,r0        ; check unit is 0 - 7 only, and..
  120.     add    #7+1    ,r0        ; ..turn ascii into integer
  121.     bcs    40$            ; good number crosses 0, "LD:" won't
  122. 20$:    mov    #7    ,r0        ; bad num, insert error code
  123.     br    130$            ; and bail out
  124.  
  125. 30$:    clr    r0            ; set LD unit number to 0
  126. 40$:    movb    r0    ,ldunit        ; save LD unit number
  127.     add    #'0    ,r0        ; turn it into an ascii digit
  128.     movb    r0    ,newdk+2    ; and stick that into "LDn:"
  129.  
  130.     tst    r1            ; /62/ dismount this one?
  131.     beq    50$            ; no
  132.     jmp    170$            ; ya..
  133.  
  134. 50$:    mov    #elfmo    ,r3        ; where to write .rad50 file name
  135.     cmpb    (r2)    ,#':        ; is there a colon after LDn?
  136.     bne    60$            ; no
  137.     tstb    (r2)+            ; ya, bump past it..
  138. 60$:    cmpb    (r2)    ,#space        ; is there a space delimiter?
  139.     bne    78$            ; no
  140.     tstb    (r2)+            ; ya, bump past it..
  141. 78$:    mov    r2    ,-(sp)        ; save pointer
  142.     scan    #space    ,r2        ; look for a trailing space
  143.     tst    r0            ; find one?
  144.     beq    100$            ; not found
  145.     add    r2    ,r0        ; point one byte past the space
  146.     clrb    -(r0)            ; bump back to space and hose it
  147.     tstb    (r0)+            ; point at first char after delimiter
  148.     cmpb    (r0)+    ,#'D        ; iz it a "D" ?
  149.     bne    90$            ; nope..
  150.     cmpb    (r0)+    ,#'K        ; iz it a "K"
  151.     bne    90$            ; nope
  152.     tstb    @r0            ; end of the line?
  153.     beq    80$            ; ya, it's "DK"  (no colon)
  154.     cmpb    (r0)+    ,#':        ; no, is it "DK:" ?  (with colon)
  155.     bne    90$            ; no, so wutever it is, it's no good
  156.     tstb    @r0            ; anything else there?
  157.     bne    90$            ; ya, thus it's a bad assign
  158.  
  159. 80$:    mov    sp    ,dkflag        ; set flag to make it DK:
  160.     br    100$            ; and continue
  161.  
  162. 90$:    mov    #er$dk    ,r0        ; logical assign not supported..
  163.     tst    (sp)+            ; pop now useless pointer
  164.     br    160$            ; bail out
  165.  
  166. 100$:    clr    dfflag            ; init try default extents flag
  167.     mov    (sp)+    ,r2        ; recover pointer to csi input string
  168.     calls    fparse    ,<r2,#srcnam>    ; make "DK:name.dsk"="DEV:name.dsk"
  169.     mov    #srcnam    ,r0        ; pass pointer to docsi
  170.     call    docsi            ; see if it'll fly
  171.     bcs    160$            ; oops, err mapped by docsi
  172.     tst    -(r3)            ; is there an extent??
  173.     bne    110$            ; ya..
  174.     mov    sp    ,dfflag        ; flag to try .DSK and .DEV defaults
  175.     mov    #^rDSK    ,@r3        ; and insert default .DSK extent
  176. 110$:    mov    #mntemt    ,r0        ; load emt args to
  177.     emt    375            ; attempt to mount specified device
  178.     bcc    140$            ; no problem
  179.     movb    @#errbyt,r0        ; get the mount error
  180.     movb    ldunit    ,disunit    ; prep to dump bogus logical device
  181.     cmp    #3    ,r0        ; is LDn already in use?
  182.     bne    120$            ; no
  183.     mov    #dismnt    ,r0        ; ya, load args to
  184.     emt    375            ; dump it then mount new one
  185.     bcc    110$            ; it worked
  186.  
  187.     movb    @#errbyt,r0        ; it didn't work, get the error
  188.     cmp    #3    ,r0        ; is LDn already in use?
  189.     bne    110$            ; no
  190. 120$:    cmp    #6    ,r0        ; file not found?
  191.     bne    130$            ; no
  192.     mov    r0    ,-(sp)        ; ya, save the error code
  193.     mov    #dismnt    ,r0        ; don't leave not avail dev lurking
  194.     emt    375            ; no errors possible here..
  195.     mov    (sp)+    ,r0        ; recover the error code
  196.  
  197.     tst    dfflag            ; couldn't find .DSK default?
  198.     beq    130$            ; no
  199.     mov    #^rDEV    ,@r3        ; ya, now try .DEV extent
  200.     clr    dfflag            ; but only try it once
  201.     br    110$            ; go back for .DEV attempt
  202.  
  203. 130$:    asl    r0            ; error mapping uses word indexing
  204.     mov    mnterr(r0),r0        ; simple
  205.     br    160$
  206. 140$:    tst    dkflag            ; make this mount DK?
  207.     beq    150$            ; no
  208.     strcpy    #defdir    ,#newdk        ; /62/ ya, copy "LDn:" to defdir
  209.     clr    dkflag            ; and reset flag
  210.  
  211. 150$:    clr    r0            ; no errors
  212. 160$: ;    mov    r0    ,-(sp)        ; save any error
  213. ;    mov    #nocache,r0        ; don't leave anything cached
  214. ;    emt    375            ; no errors possible here..
  215. ;    mov    (sp)+    ,r0        ; restore saved error
  216.     return
  217.  
  218. 170$:    movb    ldunit    ,disunit    ; prep to dump logical disk
  219.     mov    #dismnt    ,r0        ; load dismount emt arguments
  220.     emt    375            ; dump it
  221.     bcc    180$            ; it worked
  222.     cmpb    @#errbyt,#3        ; didn't happen, which error?
  223.     bne    180$            ; ignore error other than channel open
  224.     mov    #ld$bsy    ,r0        ; pointer to appropriate error msg
  225.     br    160$            ; and bail out
  226.  
  227. 180$:    mov    #defdir    ,r0        ; string to check
  228.     mov    #newdk    ,r1        ; what it can no longer be
  229.     mov    #5    ,r2        ; number of bytes to compare
  230. 190$:    cmpb    (r0)+    ,(r1)+        ; check one, bump for next time
  231.     bne    150$            ; no match
  232.     sob    r2    ,190$        ; match, try next one
  233.     strcpy    #defdir    ,#dkname    ; /62/ dismounted DK, so goto HOME dir
  234.     br    150$            ; done..
  235.  
  236.  
  237.     .sbttl    The real work of RENAME
  238.  
  239. ;    input:     (r5)    = first file name, .asciz
  240. ;        2(r5)    = second file name, .asciz
  241.  
  242. rename::save    <r2,r3>
  243.     call    check2            ; /BBS/ check file names
  244.     tst    r0            ; /BBS/ ok?
  245.     bne    20$            ; /BBS/ no
  246.     clr    r1            ; /BBS/ init # of files renamed count
  247.     mov    #renlst    ,r3        ; where to build the .rename list
  248.     mov    #srcnam    ,r0        ; string address
  249.     call    docsi            ; do the first one
  250.     bcs    20$            ; /BBS/ oops
  251.     mov    #filnam    ,r0        ; now do the second file name
  252.     call    docsi            ; ok
  253.     bcs    20$            ; /BBS/ oops
  254.     mov    renlst    ,r0        ; get the device name
  255.     calls    fetch    ,<r0>        ; /62/ try to fetch the handler
  256.     tst    r0            ; /62/ did it work?
  257.     bne    20$            ; /62/ no
  258.     .rename    #rtwork,#lun.in,#renlst    ; do the rename please
  259.     bcc    10$            ; /BBS/ ok..
  260.     movb    @#errbyt,r0        ; map the rename error
  261.     asl    r0            ; word indexing
  262.     mov    renerr(r0),r0        ; simple
  263.     br    20$
  264. 10$:    mov    #1    ,r1        ; /BBS/ only one file renamed here..
  265.     clr    r0            ; no errors
  266. 20$:    unsave    <r3,r2>
  267.     return
  268.  
  269.  
  270.     .sbttl    The real work of DELETE
  271.  
  272. ;    input:     (r5)    = file name, .asciz
  273.  
  274. delete::save    <r3>
  275.     call    check1            ; /BBS/ check file name
  276.     tst    r0            ; /BBS/ ok?
  277.     bne    20$            ; /BBS/ no
  278.     mov    #renlst    ,r3        ; where to build the .delete list
  279.     mov    #srcnam,r0        ; string address
  280.     call    docsi            ; do the first one
  281.     bcs    20$            ; /BBS/ oops
  282.     mov    renlst    ,r0        ; get the device name
  283.     calls    fetch    ,<r0>        ; /62/ try to fetch the handler
  284.     tst    r0            ; /62/ did it work?
  285.     bne    20$            ; /62/ no
  286.     .delete    #rtwork,#lun.ou,#renlst    ; /BBS/ do the delete using lun.ou
  287.     bcc    10$            ; /BBS/ ok..
  288.     movb    @#errbyt,r0        ; map the delete error
  289.     asl    r0            ; word indexing
  290.     mov    renerr(r0),r0        ; rename errors are the same as delete
  291.     br    20$            ; /BBS/ bail out..
  292. 10$:    clr    r0            ; no errors
  293. 20$:    unsave    <r3>
  294.     return
  295.  
  296.  
  297.     .sbttl    The real work of COPY    ; /BBS/ heavily modified..
  298.  
  299.     PROT    = 100000        ; /62/ protected file bit
  300.  
  301. ;    input:     (r5)    = input file name
  302. ;        2(r5)    = output file name
  303.  
  304. copy::    save    <r2,r3,r4>
  305.     clr    r2            ; number of blocks = 0
  306.     call    check2            ; check file names
  307.     tst    r0            ; ok?
  308.     bne    done            ; /63/ no
  309.     calls    open    ,<#srcnam,#lun.in,#binary> ; get the input file
  310.     tst    r0            ; did it work?
  311.     bne    done            ; /63/ no
  312.     mov    #lun.out,r0        ; /62/ output file channel
  313.     asl    r0            ; /62/ word indexing
  314.     mov    lokdate    ,date.a(r0)    ; /62/ save create date
  315.     mov    loktime    ,time.a(r0)    ; /62/ and time
  316.     clr    prot.a(r0)        ; /62/ preset as unprotected file
  317.     bit    #prot    ,lokstat    ; /62/ protected?
  318.     beq    10$            ; /62/ nope..
  319.     inc    prot.a(r0)        ; /62/ ya
  320. 10$:    mov    #lun.in    ,r1        ; input file channel
  321.     asl    r1            ; word indexing
  322.     mov    sizof(r1),at$len    ; pass input file size to file opener
  323.     calls    create    ,<#filnam,#lun.out,#binary> ; create destination file
  324.     tst    r0            ; did it work?
  325.     bne    purge            ; no
  326.  
  327. 20$:    mov    #1000    ,r3        ; init 512. byte counter (1 block)
  328. 30$:    calls    getc    ,<#lun.in>    ; get the next char from the file
  329.     tst    r0            ; did it work?
  330.     bne    inerr            ; no, check for EOF condition
  331.     calls    putc    ,<r1,#lun.ou>    ; yes, copy to output file
  332.     tst    r0            ; did that work?
  333.     bne    outerr            ; no
  334.     sob    r3    ,30$        ; next char please
  335.     inc    r2            ; blocks := succ(blocks)
  336.     br    20$            ; copy the next block now
  337.  
  338. inerr:    cmp    r0    ,#er$eof    ; normal exit should be EOF
  339.     bne    purge            ; it's not
  340.     calls    close    ,<#lun.ou>    ; try to close output file
  341.     save    <r0>            ; save error code
  342.     beq    p.clo            ; no error, go close in file
  343.     br    p.del            ; error, go dump bad file first
  344.  
  345. outerr:    cmp    r0    ,#er$eof    ; out file full?
  346.     bne    purge            ; no, it's something else
  347.     mov    #er$ful    ,r0        ; ya, say not enuff free space..
  348. purge:    save    <r0>            ; save error
  349.     calls    close    ,<#lun.ou>    ; flush buffer, close out file
  350. p.del:    calls    delete    ,<#filnam>    ; then dump it, it's no good now
  351. p.clo:    calls    close    ,<#lun.in>    ; close input file
  352.     unsave    <r0>            ; restore error code
  353.  
  354. done:    mov    r2    ,r1        ; return number of blocks copied
  355.     unsave    <r4,r3,r2>
  356.     return
  357.  
  358.  
  359.     .sbttl    Parse device and file name
  360.  
  361. ;    input:     r0    = address of file name
  362. ;         r3    = pointer to result of parse
  363.  
  364. docsi:    save    <r1>
  365.     sub    #ln$max+2,sp        ; /63/ a local file name buffer
  366.     mov    sp    ,r1        ; and a pointer to it please
  367.  
  368. 10$:    movb    (r0)+    ,(r1)+        ; /BBS/ copy it to the csi buffer
  369.     bne    10$            ; until a null byte is found
  370.     movb    #'=    ,-1(r1)        ; fake an output filespec here
  371.     clrb    @r1            ; and .asciz
  372.     mov    sp    ,r1        ; reset pointer (also saving sp)
  373.     .csispc    r1,#csiext,r1        ; and try to parse the name
  374.     mov    r1    ,sp        ; restore from any switches
  375.     bcs    20$            ; it's ok
  376.     mov    (r1)+    ,(r3)+        ; copy the
  377.     mov    (r1)+    ,(r3)+        ; device
  378.     mov    (r1)+    ,(r3)+        ; and
  379.     mov    (r1)+    ,(r3)+        ; file name
  380.     add    #ln$max+2,sp        ; /63/ restore the stack, clears carry
  381.     br    30$
  382.  
  383. 20$:    movb    @#errbyt,r0        ; get the error mapping for .csispc
  384.     asl    r0            ; index to word offsets
  385.     mov    csierr(r0),r0        ; simple
  386.     add    #ln$max+2,sp        ; /63/ restore the stack
  387.     sec                ; flag the error and exit
  388. 30$:    unsave    <r1>
  389.     return
  390.  
  391.  
  392.     .sbttl    Check file name(s)
  393.  
  394. check2:    calls    fparse    ,<2(r5),#filnam> ; /BBS/ added this..
  395.     tst    r0            ; ok?
  396.     bne    ck.fin            ; no
  397.     calls    iswild    ,<#filnam>    ; check second file name
  398.     tst    r0            ; wild?
  399.     bne    ck.fin            ; ya..
  400. check1:    calls    fparse    ,<@r5,#srcnam>    ; check first file name
  401.     tst    r0            ; ok?
  402.     bne    ck.fin            ; no
  403.     calls    iswild    ,<#srcnam>    ; return with
  404. ck.fin:    return                ; /63/ any error will be in r0
  405.  
  406.  
  407.     .sbttl    Like bufemp, but return data to a buffer
  408.  
  409. ;    input:      (r5)    = source buffer, .asciz
  410. ;    output:     2(r5)    = destination buffer
  411. ;           r0    = zero (no errors are possible)
  412. ;           r1    = string length
  413. ;
  414. ;    No 8-bit prefixing will be done as RT-11 does not support 8-bit data
  415. ;    in file names or any where else that would make any difference here.
  416. ;    This routine is used to decode strings received for generic commands
  417. ;    to the server.
  418. ;
  419. ; /63/     NOTE:  This subroutine, as it now exists, can process all unprefixed
  420. ;    control chars as C-Kermit 5A(189) might emit if given the command SET
  421. ;    CONTROL UNPREFIX ALL.  The NULL char is used as the record terminator
  422. ;    here and thus MUST be prefixed.  C-Kermit always prefixes nulls.
  423.  
  424. bufunp::save    <r2,r3,r4,r5>
  425.     mov    @r5    ,r2        ; input record address
  426.     clr    r3            ; length := 0
  427.     mov    2(r5)    ,r4        ; resultant string
  428.  
  429. 10$:    movb    (r2)+    ,r0        ; /63/ get next ch in convenient place
  430.     bic    #^c<177>,r0        ; /53/ always seven bit data
  431.     beq    50$            ; /63/ all done
  432.     mov    #1    ,r5        ; /53/ assume character not repeated
  433.     tst    dorpt            ; /53/ repeat processing off?
  434.     beq    30$            ; /53/ yes, ignore
  435.     cmpb    r0    ,rptquo        ; /53/ is this a repeated char?
  436.     bne    30$            ; /53/ no, normal processing
  437.     movb    (r2)+    ,r5        ; /63/ yes, get the repeat count
  438.     bic    #^c<177>,r5        ; /53/ always seven bit data
  439.     unchar    r5    ,r5        ; /53/ get the value
  440.     tst    r5            ; /53/ good data
  441.     bgt    20$            ; /53/ yes
  442.     mov    #1    ,r5        ; /53/ no, fix it
  443. 20$:    movb    (r2)+    ,r0        ; /63/ now get the real data
  444.     bic    #^c<177>,r0        ; /53/ always seven bit data
  445. 30$:    cmpb    r0    ,senpar+p.qctl    ; is this a quoted character?
  446.     bne    40$            ; no
  447.     clr    r0            ; yes, get the next character
  448.     bisb    (r2)+    ,r0        ; must be one you know  avoid sxt here
  449.     mov    r0    ,r1        ; /63/ copy to compare
  450.     bic    #^c<177>,r1        ; lower 7 bits against the quote char
  451.     cmpb    r1    ,senpar+p.qctl    ; if ch <> myquote
  452.     beq    40$            ;  then
  453.     ctl    r0    ,r0        ;   ch := ctl(ch)
  454. 40$:    movb    r0    ,(r4)+        ; copy the byte over now
  455.     inc    r3            ; length := succ(length)
  456.     sob    r5    ,40$        ; /53/ perhaps data was repeated
  457.     br    10$            ; next character please
  458.  
  459. 50$:    clrb    @r4            ; make the string .asciz
  460.     mov    r3    ,r1        ; return the length
  461.     clr    r0            ; fake no errors please
  462.     unsave    <r5,r4,r3,r2>
  463.     return
  464.  
  465.  
  466.     .sbttl    Calculate time used to send last packet    ; /62/ all new..
  467.  
  468. paksta::mov    r2    ,-(sp)        ; save ptr to "REC.SW" or "SEN.SW"
  469.     mov    pkrate+4,-(sp)        ; save to test for first time through
  470.     mov    pkrate+0,pkrate+4    ; start of last packet time hi word
  471.     mov    pkrate+2,pkrate+6    ; and time lo word
  472.     .gtim    #rtwork    ,#pkrate    ; get start time of next packet
  473.     tst    (sp)+            ; first pass on this transaction?
  474.     bge    10$            ; no
  475.     mov    #sta.6    ,r2        ; ya, kick off with a newline..
  476.     br    30$            ; ..by jumping in here
  477. 10$:    mov    #sta.2    ,r2        ; point to "TOD "
  478.     call    sta.cp            ; copy into output string
  479.     calls    asctim    ,<r1,#pkrate>    ; make it ascii, insert in buff
  480.     add    #11.    ,r1        ; bump past time just written
  481.     mov    #sta.3    ,r2        ; point to "  "
  482.     call    sta.cp            ; copy into output string
  483.     mov    clkflg    ,r0        ; pass clock rate
  484.     call    L10012            ; write same to out string
  485.     mov    #sta.4    ,r2        ; point to "Hz   Elapsed-Time "
  486.     call    sta.cp            ; copy into output string
  487.     mov    pkrate+2,-(sp)        ; time now low word
  488.     mov    pkrate+0,-(sp)        ; and high word
  489.     sub    pkrate+6,2(sp)        ; subtract time then low word
  490.     sbc    (sp)            ; watch the carry
  491.     sub    pkrate+4,(sp)        ; now do the high word
  492.     bge    20$            ; didn't cross midnight
  493.     add    #6656.    ,2(sp)        ; did, low word of # ticks in 24 hours
  494.     adc    (sp)            ; add carry to 32-bit hi word
  495.     add    #79.    ,(sp)        ; hi word of # ticks in 24 hours
  496. 20$:    mov    sp    ,r2        ; pointer to time data on stack
  497.     calls    asctim    ,<r1,r2>    ; make it ascii, insert in buff
  498.     cmp    (sp)+    ,(sp)+        ; pop duration buffer
  499.     add    #11.    ,r1        ; bump past time just written
  500.     mov    #sta.5    ,r2        ; point to <cr><lf><cr><lf>
  501. 30$:    call    sta.cp            ; copy into output string
  502.     mov    (sp)+    ,r2        ; get ptr to "REC.SW" or "SEN.SW"
  503.     call    sta.cp            ; copy into output string
  504.     mov    #sta.7    ,r2        ; point to ".SW = STA."
  505.     call    sta.cp            ; copy into output string
  506.     scan    state    ,#sta.0        ; look for a match
  507.     asl    r0            ; word indexing
  508.     mov    sta.1(r0),r2        ; pointer to description of function
  509.     .br    sta.cp            ; /63/
  510.  
  511. sta.cp:    movb    (r2)+    ,(r1)+        ; /63/ copy some text..
  512.     bne    sta.cp            ; until we find a null
  513.     dec    r1            ; backup over it
  514.     return
  515.  
  516.  
  517.     .sbttl    Print received error packet on terminal
  518.  
  519. ;    P R E R R P
  520. ;
  521. ;    input:     (r5)    = address of .asciz string to print
  522.  
  523. prerrp::tst    remote            ; /BBS/ if running as remote..
  524.     bne    20$            ; /BBS/ ..there's no term to type this
  525.     tstb    (r5)            ; /62/ anything to print?
  526.     beq    20$            ; /62/ no
  527.     tst    logini            ; /BBS/ need a .newline if this is set
  528.     beq    10$            ; /BBS/ no, this line is clean
  529.     .newline            ; start on a fresh line
  530. 10$:    wrtall    #pepmsg            ; a prefix line
  531.     wrtall    @r5            ; the actual error message
  532.     .newline
  533.     clr    logini            ; ensure logging header is retyped
  534. 20$:    return
  535.  
  536.  
  537.     .sbttl    Get time of day        ; /62/ use cvttim to include ticks
  538.  
  539. ;    input:     (r5)    = buffer address for .asciz string
  540. ;        2(r5)    = if <>, location of time value to process    ; /62/
  541.  
  542. asctim::save    <r0,r1,r2,r3>
  543.     mov    2(r5)    ,r3        ; /62/ was a pointer passed?
  544.     bne    10$            ; /62/ ya, do it instead of curr. time
  545.     cmp    -(sp)    ,-(sp)        ; allocate two word buffer
  546.     mov    sp    ,r3        ; and point to the small buffer
  547.     .gtim    #rtwork    ,r3        ; and get the time, ticks past midnite
  548.     cmp    (sp)+    ,(sp)+        ; /62/ pop here, save a couple words..
  549. 10$:    mov    (r3)+    ,hitime        ; /62/ hi word for divide
  550.     mov    (r3)    ,lotime        ; /62/ and lo word
  551.     save    <r5>            ; /63/ save this pointer
  552.     mov    #timemt,r5        ; /62/ give cvttim its arguments
  553.     call    cvttim            ; /62/ convert to hrs/mins/secs/ticks
  554.     unsave    <r5>            ; /63/ restore pointer
  555.     mov    @r5    ,r1        ; buffer address please
  556.     mov    hours    ,r3        ; convert hours to ascii
  557.     call    i2toa            ; simple
  558.     movb    #':    ,(r1)+        ; a delimiter
  559.     mov    mins    ,r3        ; the minutes next please
  560.     call    i2toa            ; simple
  561.     movb    #':    ,(r1)+        ; and a delimiter please
  562.     mov    secs    ,r3        ; /62/ pass seconds to i2toa
  563.     call    i2toa            ; and convert to ascii
  564.     movb    #'.    ,(r1)+        ; /62/ use a dot delimiter
  565.     mov    ticks    ,r3        ; /62/ pass ticks to i2toa
  566.     call    i2toa            ; /62/ convert to ascii
  567.     clrb    @r1            ; all done, make it .asciz
  568.     unsave    <r3,r2,r1,r0>
  569.     return
  570.  
  571.     .end
  572.