home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / pdp11 / k11e80.mac < prev    next >
Text File  |  2020-01-01  |  66KB  |  2,459 lines

  1.     .title    k11e80    kermit i/o for RSTS verison 8
  2.  
  3.     .ident    /8.0.01/
  4.  
  5.     .psect    $code    ,ro,i,lcl,rel,con
  6.  
  7.  
  8.  
  9. ;    define macros and things we want for KERMIT-11
  10.  
  11.     .include    /SY:[1,2]COMMON.MAC/
  12.     .iif ndf, xrb    , .error ; INCULDE for [1,2]COMMON.MAC failed
  13.  
  14.  
  15.  
  16.     .if ndf, K11INC
  17.     .ift
  18.     .include    /IN:K11MAC.MAC/
  19.     .endc
  20.  
  21.     .iif ndf, k11inc, .error ; INCLUDE for IN:K11MAC.MAC failed
  22.  
  23.     .title    k11e80        ; common.mac destroys our name
  24.  
  25.  
  26.  
  27. ;    Copyright (C) 1983,1984,1985 Change Software, Inc.
  28. ;    
  29. ;    
  30. ;    This software is furnished under a license and may
  31. ;    be  used  and  copied  only in accordance with the
  32. ;    terms of such license and with  the  inclusion  of
  33. ;    the  above copyright notice.  This software or any
  34. ;    other copies thereof may not be provided or other-
  35. ;    wise made available to any other person.  No title
  36. ;    to and ownership of the software is hereby  trans-
  37. ;    ferred.
  38. ;    
  39. ;    The information in this  software  is  subject  to
  40. ;    change  without notice and should not be construed
  41. ;    as a commitment by the author.
  42. ;
  43. ;
  44.  
  45.     .sbttl    the entry points
  46.  
  47. ;    In all cases, R0 will have the returned error code (zero for success)
  48. ;    For KBREAD and READ, R1 will have the size of the read
  49. ;    For BINREAD,  R1 will have the character just read
  50. ;
  51. ;    The use of %LOC and %VAL are from VMS Pascal and Fortran.
  52. ;    %LOC means ADDRESS, whereas %VAL means literal. All call
  53. ;    formats assume the first argument is at 0(r5), the next
  54. ;    at 2(r5) and so on, as in:
  55. ;
  56. ;    clr    -(sp)            ; today's date by default
  57. ;    mov    #datebf    ,-(sp)        ; where to put the converted string
  58. ;    mov    sp    ,r5        ; call ASCDAT
  59. ;    call    ascdat            ; simple
  60. ;    cmp    (sp)+    ,(sp)+        ; all done
  61. ;
  62. ;    or by using the CALLS macro (defined in K11MAC.MAC)
  63. ;
  64. ;    calls    ascdat    ,<#datebf,#0>
  65. ;
  66. ;
  67. ;    Any version of Kermit-11 which can not, due to the lack of
  68. ;    executive  support,  implement a function should return an
  69. ;    error of -1 in r0.  For instance,  RT11 does not have  any
  70. ;    executive primitives to do wildcarding directory lookup.
  71. ;
  72. ;
  73. ;
  74. ;
  75. ;    ASCDAT    ( %loc buffer, %val datevalue )
  76. ;    ASCTIM    ( %loc buffer, %val timevalue )
  77. ;    ASSDEV    ( %loc device_name )
  78. ;    BINREA    ( %val lun, %val timeout )
  79. ;    BINWRI    ( %loc buffer, %val byte_count, %val lun )
  80. ;    CANTYP    ( %loc device_name, %val lun )
  81. ;    CHKABO    ( )
  82. ;    DODIR    ( %loc directory_string, %val lun )
  83. ;    DRPPRV    ( )
  84. ;    DSKUSE    ( %loc returned_string )
  85. ;    ECHO    ( %loc terminal_name )
  86. ;    EXIT    ( )
  87. ;    GETPRV    ( )
  88. ;    GETUIC    ( )
  89. ;    GTTNAM    ( %loc returned_ttname )
  90. ;    KBREAD    ( %loc buffer )
  91. ;    L$PCRL    ( )
  92. ;    L$TTYO    ( %loc buffer, %val bytecount )
  93. ;    LOGOUT    ( )
  94. ;    NAMCVT    ( %loc source_filename, %loc returned_normal_name )
  95. ;    NOECHO    ( %loc device_name, %val lun )
  96. ;    QUOCHK    ( )
  97. ;    READ    ( %loc buffer, %val buffer_length, %val lun, %val block_number )
  98. ;    SETCC    ( %loc control_c_ast_handler )
  99. ;    SETSPD    ( %loc device_name, %val speed )
  100. ;    SUSPEN    ( %val seconds, %val ticks )
  101. ;    SYSERR    ( %val error_number, %loc error_text_buffer )
  102. ;    TTRFIN    ( )
  103. ;    TTRINI    ( )
  104. ;    TTSPEE    ( %loc terminal_name )
  105. ;    TTYDTR    ( %loc terminal_name )
  106. ;    TTYFIN    ( %loc terminal_name, %val lun )
  107. ;    TTYHAN    ( %loc terminal_name )
  108. ;    TTYINI    ( %loc terminal_name, %val lun, %val open_flags )
  109. ;    TTYPAR    ( %loc terminal_name, %val parity_code )
  110. ;    TTYRST    ( %loc terminal_name )
  111. ;    TTYSAV    ( %loc terminal_name )
  112. ;    TTYSET    ( %loc terminal_name )
  113. ;    WRITE    ( %loc buffer, %val buffer_length, %val lun, %val block_number )
  114. ;    XINIT    ( )
  115.  
  116.     .psect    buffer    ,rw,d,lcl,rel,con
  117. lunsize    =    17
  118. lokahd:    .word    0            ; /44/
  119. linit:    .blkw    20
  120. lpoint:    .blkw    20
  121. lsize:    .blkw    20
  122. lbuffer:.blkb    MAXLNG+<MAXLNG/10>    ; /42/ Bigger for LONG PACKETS
  123.     .even
  124. ttsave:    .blkb    40*15
  125. bufqsav:.blkb    15
  126.     .even
  127. ver9.x::.word    0
  128. $xon:    .byte    'Q&37
  129. $off:    .byte    'S&37
  130.  
  131.     ALSIZE    ==    400
  132.     SDBSIZ    ==    400
  133.  
  134. $albuf:    .blkb    ALSIZE
  135. $phnum:    .blkb    60
  136.  
  137.  
  138.     global    <albuff,phnum>
  139.  
  140.  
  141.     .sbttl    edits
  142.  
  143.  
  144. ;    05-Jan-84  14:34:01 BDN    Added  TT8BIT mode to line if no parity
  145. ;                since the terminal driver always strips
  146. ;                bit 7 even if the character is a delim.
  147.  
  148.  
  149.  
  150.  
  151.     .sbttl    macros
  152.  
  153.     .macro    clrfqb
  154.     call    $clrfq
  155.     .endm    clrfqb
  156.  
  157.     .macro    clrxrb
  158.     call    $clrxr
  159.     .endm    clrxrb
  160.  
  161.  
  162.     nodata    ==    13.        ; no data for terminal read
  163.     detkey    ==    27.        ; i/o to detached tt line
  164.  
  165.     .psect    $code
  166.     .enabl    lsb
  167.  
  168. xinit::    save    <r1>
  169.     call    rmsini            ; /53/ Setup SST
  170.     call    getsys            ; /58/ See if really RSTS
  171.     cmpb    r0    ,#SY$RSTS    ; /58/ Well?
  172.     beq    1$            ; /58/ Its ok
  173.     MESSAGE    <This task image was linked for RSTS/E>,CR
  174.     mov    (pc)+    ,-(sp)        ; /58/ RSX exit
  175.     .byte    51.,1            ; /58/ Code for EXIT$S
  176.     emt    377            ; /58/ Do it
  177. 1$:    mov    #$phnum    ,phnum        ; /51/
  178.     mov    #$albuf    ,albuff        ; /51/ Fill address in.
  179.     clrb    @phnum            ; /51/ Clear
  180.     clr    @albuff            ; /51/ Clear first word.
  181.     mov    #$cmdbuf,cmdbuf        ; /53/ $CMDBUF defined in K11RMS
  182.     mov    #$argbuf,argbuf        ; /53/ $ARGBUF defined in K11RMS
  183.     mov    sp    ,infomsg    ; /41/ msg displaying
  184.     mov    #doconn    ,altcon        ; /44/
  185.     clr    df$rat            ; stream ascii please for RSTS?
  186.     movb    #fb$stm    ,df$rfm        ; say so and exit
  187.     mov    #ttsave    ,r1        ; initialize the terminal char
  188.     mov    #15    ,r0        ; save area now.
  189. 10$:    movb    #377    ,(r1)+        ; the ttysave area is set up for
  190.     add    #40    ,r1        ; saving up to 15 (8) settings.
  191.     clrb    bufqsav(r0)        ; /40/ clear old buffer quotas
  192.     sob    r0    ,10$        ; makes it easy to save via LUN
  193.     calls    l$fss    ,<#kb>        ; open terminal on LUN.AS
  194.     movb    #opnfq    ,FIRQB+FQFUN    ; to fix things up if using
  195.     movb    #lun.tt    ,FIRQB+FQFIL    ; it's global please
  196.     aslb    FIRQB+FQFIL        ; times 2 please
  197.     CALFIP                ; simple
  198.     movb    FIRQB    ,r0        ; it can't fail !!
  199.     beq    20$            ; ok
  200.     direrr    r0            ; oops
  201. 20$:    call    inqv9            ; /40/ global flag for version 9.x
  202.     bcs    40$            ; /45/ Not version 9 or later
  203.     clrfqb                ; /45/ V9, get the JOB type
  204.     movb    #UU.SYS    ,FIRQB+FQFUN    ; /45/ Job stats, part 3
  205.     movb    #2    ,FIRQB+5    ; /45/ Subfunction code
  206.     .UUO                ; /45/ Do it please
  207.     mov    #proctype,r0        ; /45/ Address of process_type
  208.     clr    (r0)            ; /45/ Word sized
  209.     movb    FIRQB+20,(r0)        ; /45/ Save our process type now
  210.     clr    jobtype            ; /45/ Assume interactive
  211.     cmpb    (r0)    ,#PRO$NET    ; /45/ Is this a SET HOST job ?
  212.     beq    30$            ; /45/ Yes, let it be INTERACTIVE
  213.     cmpb    (r0)    ,#PRO$BAT    ; /45/ Is this a BATCH job ?
  214.     bne    30$            ; /45/ No, assume INTERACTIVE for now
  215.     mov    #JOB$BAT,jobtype    ; /45/ Set BATCH access
  216. 30$:                    ; /45/ Maybe more kinds in the future
  217. 40$:    call    inqter            ; /39/ get terminal type
  218.     movb    r0    ,vttype        ; /39/ same terminal type
  219.     cmp    jobtype    ,#JOB$BAT    ; /59/ Batch?
  220.     bne    50$            ; /59/ No
  221.     clr    vttype            ; /59/ Yes, dumb terminal
  222.     clr    blip            ; /59/ No packet count updates
  223. 50$:
  224.     clr    r0
  225.     unsave    <r1>
  226.     return
  227.  
  228.     .save
  229.     .psect    $PDATA    ,D
  230. kb:    .asciz    /_KB:/
  231.     .even
  232.     .restore
  233.     .dsabl    lsb
  234.  
  235.     global    <lastli,lastcn>
  236.     global    <df$rat,df$rfm,fb$stm,getuic,lun.tt,vttype>
  237.     global    <infomsg,inqter>
  238.     global    <doconn,altcon,jobtyp,procty>    ; /44/
  239.     global    <ARGBUF,CMDBUF,$ARGBUF,$CMDBUF>    ; /53/
  240.     global    <RMSINI,GETSYS,BLIP>        ; /53/
  241.  
  242.     .assume    JOB$INT eq 0            ; /45/
  243.  
  244.  
  245.     .sbttl    terminal initialization
  246.     .psect    $code
  247.  
  248.  
  249. ;    T T Y I N I
  250. ;
  251. ;    ttyini( %loc device_name ,%val channel_number ,%val ccflag )
  252. ;
  253. ;
  254. ;    input:    @r5    .asciz string of device name
  255. ;        2(r5)    channel number
  256. ;        4(r5)    bitfield for ter$cc and ter$bi
  257. ;
  258. ;             if 4(r5) and ter$bi then use binary open
  259. ;                         else use multiple delimiters
  260. ;             if 4(r5) and ter$cc then set control c as delimiter
  261. ;             if 4(r5) and ter$xo then allow binary mode with XON
  262. ;
  263. ;    output:    r0    error codes
  264. ;
  265. ;
  266. ;     Ttyini sets the  appropiate terminal characteristics  for
  267. ;    the  device name  passsed and returns the  device open (or
  268. ;    attached) on the passed logical unit.  Errors are returned
  269. ;    in r0. For RSTS these could be the usual device not avail-
  270. ;    able or missing monitor feature.
  271. ;
  272. ;    useful things to add: device check for terminal
  273.  
  274.     .enabl    lsb
  275.  
  276. ttyini::save    <r2>
  277.     clr    lokahd            ; /44/ Clear lookahead
  278.     call    getprv            ; will need for binary open
  279.     mov    2(r5)    ,r2        ; channel number
  280.     asl    r2            ; times two
  281.     clr    lpoint(r2)        ; clear offset into local buffer
  282.     clr    linit(r2)        ; we have not set fast packet mode
  283.     clr    lsize(r2)        ; we have not read anyting yet also
  284.     clrfqb                ; insure FIRQB and xrb are cleared
  285.     clrxrb                ; of undesirable defaults
  286.     mov    @r5    ,r0        ; get address of device string
  287.     tstb    @r0            ; anything there ?
  288.     bne    10$            ; yes
  289.     calls    l$fss    ,<#kb>        ; no, use _KB:
  290.     br    20$
  291. 10$:    call    l$fss            ; do the usual .FSS to parse
  292. 20$:    tst    r0            ; the device name
  293.     bne    100$            ; oops
  294.     movb    #opnfq    ,FIRQB+FQFUN    ; open the device up now
  295.     movb    r2    ,FIRQB+FQFIL
  296.     bit    #ter$bi    ,4(r5)        ; use straight binary mode today ?
  297.     beq    30$            ; no
  298.     mov    #100001    ,FIRQB+FQMODE    ; yes
  299.     mov    #lun.tt    ,binmod        ; flag for i/o later on please
  300.     bit    #ter$xo    ,4(r5)        ; want xon/xoff to work normally ?
  301.     beq    30$            ; no
  302.     bis    #40    ,FIRQB+FQMODE    ; yes, add the mode in please
  303.  
  304. 30$:    CALFIP                ; get fip to do it
  305.     movb    FIRQB    ,r0        ; fail ?
  306.     bne    90$            ; yes
  307.     bit    #ter$bi    ,4(r5)        ; use straight binary mode today ?
  308.     bne    50$            ; yes
  309.     clr    r0            ; assume control c's are ok
  310.     bit    #ter$cc    ,4(r5)        ; did the caller want to allow ^C
  311.     beq    40$            ; yes
  312.     dec    r0            ; no, make control C a delimiter
  313.     br    45$
  314. 40$:    bit    #ter$pa    ,4(r5)
  315.     beq    45$
  316.     inc    r0
  317.     mov    sp    ,linit(r2)
  318. 45$:    calls    setdlm    ,<2(r5),r0>    ; no, try to set up delimiter
  319. 50$:    tst    r0            ; did it work also
  320.     bne    80$            ; no
  321.     call    initer            ; yes, set the tty's characteristics
  322.     br    100$            ; and exit (with errors in r0)
  323. 80$:    cmpb    r0    ,#102        ; "missing special feature?"
  324.     bne    100$            ; no
  325.     .print    #200$            ; yes, make it reasonable
  326. 90$:    clr    binmod            ; open failed, clear binary flag
  327. 100$:    call    drpprv            ; no longer want privs please
  328.     unsave    <r2>
  329.     return
  330.  
  331.     .save
  332.     .psect    $PDATA    ,D
  333.     .enabl    lc
  334. 200$:    .ascii    /? This copy of RSTS is missing the multiple private/<cr><lf>
  335.     .ascii    /delimiter SYSGEN option. Please include this option/<cr><lf>
  336.     .asciz    /in RSTS for KERMIT to function/<cr><lf>
  337.     .even
  338.     .restore
  339.     .dsabl    lsb
  340.  
  341.  
  342.  
  343.  
  344.     .sbttl    close up a terminal line
  345.  
  346.  
  347. ttyfin::save    <r1,r2,r3>
  348.     call    ttpars            ; get unit number
  349.     mov    r0    ,r3        ; save it
  350.     movb    FIRQB    ,r0        ; check foor any errors from parse
  351.     bne    100$            ; oops
  352.     calls    clrdlm    ,<2(r5)>    ; clear private delimiters
  353.     mov    2(r5)    ,r0        ; channel number
  354.     asl    r0            ; times 2
  355.     clr    lsize(r0)        ; nothing in packet buffer
  356.     clr    linit(r0)        ; not using packet buffering now
  357.     clr    binmod            ; nothing is binary anymore
  358.     clrfqb                ; close the terminal
  359.     movb    #clsfq    ,FIRQB+FQFUN    ; fip subfunction for closing lun
  360.     movb    2(r5)    ,FIRQB+FQFIL    ; channel number
  361.     aslb    FIRQB+FQFIL        ; times 2
  362.     CALFIP                ; close it now
  363.     movb    FIRQB    ,r0        ; get any errors from close
  364.     bne    100$            ; oops, just exit then
  365.     mov    2(r5)    ,r1        ; get the channel number
  366.     clrfqb                ; /40/ insure no unpleasant effects
  367.     movb    #UU.TRM    ,FIRQB+FQFUN    ; /40/ uuo code for terminals
  368.     incb    FIRQB+4            ; /40/ subfunction one
  369.     movb    r3    ,FIRQB+5    ; /40/ unit number or 377
  370.     movb    bufqsav(r1),FIRQB+27    ; /40/ restore old buffer quotas
  371.     .UUO                ; /40/ ignore errors
  372.     mul    #40    ,r1        ; offset into the TTSAVE area
  373.     add    #ttsave    ,r1        ; finally, the address of saved stuff
  374.     cmpb    @r1    ,#377        ; but is the saved stuff real ?
  375.     beq    100$            ; no
  376.     mov    r1    ,-(sp)        ; yes, try to set terminal chars
  377.     mov    #FIRQB    ,r2        ; where to put the parameters
  378.     mov    #40    ,r0        ; number of bytes to copy
  379. 10$:    movb    (r1)+    ,(r2)+        ; do a byte please
  380.     sob    r0    ,10$        ; next
  381.     clrb    FIRQB+4            ; Version 9 fix here
  382.     bisb    FIRQB+36,FIRQB+20    ; UU.TRM returns 8bit setting here
  383.     clr    FIRQB+36        ; insure unused for future rsts/e?
  384.     movb    #UU.TRM    ,FIRQB+FQFUN    ; uuo subfunction for terminals
  385.     movb    r3    ,FIRQB+5    ; stuff the unit number in
  386.     .UUO                ; try to do it
  387.     movb    FIRQB    ,r0        ; save any errors    
  388.     mov    (sp)+    ,r1        ; get the ttsave address back
  389.     movb    #377    ,@r1        ; mark as being invalid
  390. 100$:    unsave    <r3,r2,r1>        ; pop registers and exit
  391.     return
  392.  
  393.  
  394.     global    <binmod>
  395.  
  396.  
  397.  
  398.  
  399.     .sbttl    get terminal name
  400.  
  401. ;    G T T N A M
  402. ;
  403. ;    input:    @r5    address of 8 character buffer for terminal name
  404. ;    output:        .asciz name of terminal
  405.  
  406. gttnam::save    <r0,r1,r2>        ; may as well save it
  407.     mov    @r5    ,r2        ; now return the name
  408.     movb    #'_    ,(r2)+        ; return _KBnn:
  409.     movb    #'K    ,(r2)+        ; return _KBnn:
  410.     movb    #'B    ,(r2)+        ; return _KBnn:
  411.     clrfqb                ; assume defaults
  412.     movb    #UU.SYS    ,FIRQB+FQFUN    ; for a systat part one
  413.     .UUO                ; simple
  414.     movb    FIRQB+5    ,r1        ; get the name
  415.     bmi    90$            ; detached ?
  416.     clr    r0            ; now compute the ascii name
  417.     div    #100.    ,r0        ; /19/ lots of terminals on system?
  418.     tst    r0            ; /19/ ge kb100: ?
  419.     beq    10$            ; /19/ no
  420.     add    #'0    ,r0        ; /19/ convert the 100's part of unit
  421.     movb    r0    ,(r2)+        ; /19/ and copy it please
  422. 10$:    clr    r0            ; /19/ get the low two digits please
  423.     div    #10.    ,r0        ; simple
  424.     add    #'0    ,r0
  425.     add    #'0    ,r1
  426.     movb    r0    ,(r2)+
  427.     movb    r1    ,(r2)+
  428. 90$:    movb    #':    ,(r2)+
  429.     clrb    @r2
  430.     unsave    <r2,r1,r0>
  431.     return
  432.     
  433.  
  434.  
  435.     .sbttl    set delimiter bitmask up please
  436.  
  437.  
  438. ;    S E T D L M
  439. ;
  440. ;!    setdlm( %val channel_number )
  441. ;
  442. ;    input:    @r5    channel number to use
  443. ;
  444. ;    output:    r0    error code (would be missing sysgen feature)
  445.  
  446.  
  447.  
  448.     .iif ndf, ttyhnd , ttyhnd = 2
  449.  
  450.     global    <dlmmsk>
  451.  
  452.     .save
  453.     .psect    $PDATA    ,D
  454.  
  455. pakmsk:    .byte    ^B11110111
  456.     .byte    377
  457.     .byte    377
  458.     .byte    377
  459.     .rept    13
  460.     .byte    0
  461.     .endr
  462.     .rept    21
  463.     .byte    377
  464.     .endr
  465.  
  466. dlmmsk:    .byte    ^B11110111        ; all chars except control C
  467.     .byte    ^B11111111
  468.     .rept    36
  469.     .byte    377
  470.     .endr
  471.     .even
  472.  
  473. dlmcc:    .rept    40
  474.     .byte    377
  475.     .endr
  476.     .even
  477.  
  478.     .restore
  479.  
  480.     .iif ndf,.spec    ,.spec = emt + 14
  481.  
  482.  
  483.  
  484. snoecho:mov    #xrb    ,r0        ; pointer to parameter block
  485.     mov    #3    ,(r0)+        ; function to disable echo
  486.     clr    (r0)+            ; unused
  487.     clr    (r0)+            ; unused
  488.     movb    2(sp)    ,@r0        ; channel number
  489.     aslb    (r0)+            ; times 2
  490.     movb    #ttyhnd    ,(r0)+        ; driver index (ttdvr)
  491.     clr    (r0)+            ; unused
  492.     clr    (r0)+            ; unused
  493.     clr    (r0)+            ; unused
  494.     .spec                ; now do it
  495.     movb    FIRQB    ,r0        ; return any errors
  496.     mov    (sp)+    ,(sp)        ; pop arg list and exit
  497.     return                ; exit
  498.  
  499.  
  500. setdlm::mov    @r5    ,-(sp)
  501.     call    snoecho
  502.     mov    #xrb    ,r0        ; setup to set a private delim
  503.     mov    #11    ,(r0)+        ; mask now. function code is 11
  504.     mov    #40    ,(r0)+        ; for .spec, 40 byte to copy
  505.     mov    #dlmmsk    ,(r0)+        ; address of delimiter mask
  506.     tst    2(r5)            ; allow control c's to come in
  507.     beq    10$
  508.     bmi    5$
  509.     mov    #pakmsk    ,-2(r0)
  510.     br    10$
  511. 5$:     mov    #dlmcc    ,-2(r0)
  512. 10$:    movb    @r5    ,@r0        ; channel number
  513.     aslb    (r0)+            ; times 2
  514.     movb    #ttyhnd    ,(r0)+        ; device driver index
  515.     clr    (r0)+            ; default to console device
  516.     clr    (r0)+            ; unused
  517.     mov    #1    ,(r0)+        ; subfunction SET DELIMITER
  518.     .spec                ; and do it please
  519.     movb    FIRQB    ,r0        ; did it work ?
  520.     return
  521.  
  522.  
  523.  
  524.  
  525. clrdlm::
  526.     mov    #xrb    ,r0        ; point to it please
  527.     mov    #11    ,(r0)+        ; subfunction 
  528.     clr    (r0)+            ; must be 0
  529.     clr    (r0)+            ; also 0
  530.     movb    @r5    ,@r0        ; channel number please
  531.     aslb    (r0)+
  532.     movb    #ttyhnd    ,(r0)+        ; device driver to call
  533.     clr    (r0)+            ; use channel number
  534.     clr    (r0)+            ; must be zero
  535.     clr    (r0)+            ; subfunction 0
  536.     .spec                ; and call ttdvr
  537. 100$:    return
  538.  
  539.  
  540.  
  541.     .sbttl    special init for receiving files
  542.  
  543. ;    Due to what I would consider a RSTS terminal driver
  544. ;    bug ( .ttddt isn't cleared if you do a read without
  545. ;    wait and  there was  no data)  we have to call this
  546. ;    before we receive any files from a remote kermit.
  547.  
  548.     .save
  549.     .psect    $PDATA    ,D
  550.  
  551. xzmask:    .byte    ^B00100010        ; control E and A (/56/)
  552.     .byte    0
  553.     .byte    0
  554.     .byte    ^B00000101        ; control X and control Z please
  555.     .rept    34
  556.     .byte    0
  557.     .endr
  558.  
  559.     .RESTORE
  560.  
  561. ttrini::mov    #xrb    ,r0        ; setup to set a private delim
  562.     mov    #11    ,(r0)+        ; mask now. function code is 11
  563.     mov    #40    ,(r0)+        ; for .spec, 40 byte to copy
  564.     mov    #xzmask    ,(r0)+        ; address of delimiter mask
  565.     movb    #lun.tt    ,@r0        ; channel number
  566.     aslb    (r0)+            ; times 2
  567.     movb    #ttyhnd    ,(r0)+        ; device driver index
  568.     clr    (r0)+            ; default to console device
  569.     clr    (r0)+            ; unused
  570.     mov    #1    ,(r0)+        ; subfunction SET DELIMITER
  571.     .spec                ; and do it please
  572.     return
  573.  
  574.  
  575. ttrfin::calls    clrdlm    ,<#lun.tt>
  576.     return
  577.  
  578.  
  579.  
  580.  
  581.     .sbttl    other things like echo off and on
  582.  
  583.  
  584. ;    N O E C H O
  585. ;
  586. ;
  587. ;    input:    @r5    terminal name or null or 0 for current terminal
  588. ;    output:    r0    error code
  589.  
  590.  
  591. noecho::save    <r1>            ; save a temp register
  592.     clr    r0            ; assume our terminal
  593.     mov    @r5    ,r1        ; passed address of 0 or a null string?
  594.     beq    10$            ; no address, assume _KB:
  595.     tstb    @r1            ; null string passed ?
  596.     beq    10$            ; yes, assume the console terminal
  597.     call    ttpars            ; parse the terminal device name
  598.     bcs    90$            ; oops
  599.     cmpb    r0    ,#377        ; own terminal ?
  600.     bne    10$            ; no
  601.     call    myterm            ; yes, get correct unit number then
  602. 10$:    clrxrb                ; insure no defaults
  603.     mov    #xrb    ,r1        ; point to the xrb now
  604.     mov    #3    ,(r1)+        ; disable function for .SPEC
  605.     mov    r0    ,(r1)+        ; terminal number or zero for _KB:
  606.     movb    #ttyhnd    ,xrb+7        ; and the device driver index please
  607.     .spec                ; simple
  608.  
  609. 90$:    movb    FIRQB    ,r0        ; error, return it please
  610. 100$:    unsave    <r1>            ; pop the register we saved
  611.     return
  612.  
  613.  
  614. ;    E C H O
  615. ;
  616. ;    input:    @r5    terminal name or null or 0 for current terminal
  617. ;    output:    r0    error code
  618.  
  619.  
  620. echo::    save    <r1>            ; save a temp register
  621.     clr    r0            ; assume our terminal
  622.     mov    @r5    ,r1        ; passed address of 0 or a null string?
  623.     beq    10$            ; no address, assume _KB:
  624.     tstb    @r1            ; null string passed ?
  625.     beq    10$            ; yes, assume the console terminal
  626.     call    ttpars            ; parse the terminal device name
  627.     bcs    90$            ; oops
  628. 10$:    clrxrb                ; insure no defaults
  629.     mov    #xrb    ,r1        ; point to the xrb now
  630.     mov    #2    ,(r1)+        ; enable echo function for .SPEC
  631.     mov    r0    ,(r1)+        ; terminal number or zero for _KB:
  632.     movb    #ttyhnd    ,xrb+7        ; and the device driver index please
  633.     .spec                ; simple
  634.  
  635. 90$:    movb    FIRQB    ,r0        ; error, return it please
  636. 100$:    unsave    <r1>            ; pop the register we saved
  637.     return
  638.  
  639.  
  640.  
  641.  
  642.     .sbttl    write and read
  643.  
  644. ;    W R I T E
  645. ;
  646. ;!    write( %loc buffer, %val buffer_length, %val channel_number,
  647. ;!           %val block_number )
  648. ;
  649. ;
  650. ;    input:    @r5    buffer address
  651. ;        2(r5)    buffer length
  652. ;        4(r5)    channel number
  653. ;        6(r5)    block number
  654. ;
  655. ;    output:    r0    error code
  656.  
  657.  
  658. write::    mov    #xrb    ,r0        ; address of xrb parameter block
  659.     mov    2(r5)    ,(r0)+        ; buffer length
  660.     mov    2(r5)    ,(r0)+        ; byte count for the i/o
  661.     mov    @r5    ,(r0)+        ; address of the buffer
  662.     movb    4(r5)    ,@r0        ; channel number
  663.     aslb    (r0)+            ; times 2
  664.     clrb    (r0)+            ; unused
  665.     clr    (r0)+            ; unused
  666.     clr    (r0)+            ; unused
  667.     clr    (r0)+            ; unused
  668.     mov    6(r5)    ,xrb+xrblk    ; forgot to stuff this one in
  669.     .WRITE
  670.     movb    FIRQB    ,r0        ; return error code and exit
  671.     return
  672.  
  673.  
  674.  
  675. ;    R E A D
  676. ;
  677. ;!    read( %loc buffer, %val buffer_length, %val channel_number,
  678. ;!           %val block_number )
  679. ;
  680. ;    input:    @r5    buffer address
  681. ;        2(r5)    buffer length
  682. ;        4(r5)    channel number
  683. ;        6(r5)    block number
  684. ;
  685. ;    output:    r0    error code
  686. ;        r1    byte count for read
  687.  
  688.  
  689. read::    mov    #xrb    ,r0        ; address of xrb parameter block
  690.     mov    2(r5)    ,(r0)+        ; buffer length
  691.     clr    (r0)+            ; must be zero
  692.     mov    @r5    ,(r0)+        ; address of the buffer
  693.     movb    4(r5)    ,@r0        ; channel number
  694.     bne    10$            ; /52/ Not Chan zero
  695.     .TTECH                ; /52/ Chan zero, insure echo
  696. 10$:    aslb    (r0)+            ; times 2
  697.     clrb    (r0)+            ; unused
  698.     clr    (r0)+            ; unused
  699.     clr    (r0)+            ; unused
  700.     clr    (r0)+            ; unused
  701.     mov    6(r5)    ,xrb+xrblk    ; forgot to stuff this one in
  702.     .READ
  703.     clr    r1            ; /36/ assume error
  704.     movb    FIRQB    ,r0        ; return error code and exit
  705.     bne    100$            ; /36/ insure zero bytecount on error
  706.     mov    xrb+xrbc,r1
  707. 100$:    return
  708.  
  709. kbread::.TTECH
  710.     calls    read    ,<@r5,#80.,#0,#0> ; do the actual read now
  711.     mov    r1    ,-(sp)        ; /36/ save byte count
  712.     add    @r5    ,r1        ; /36/ point to end to make it .asciz
  713.     clrb    @r1            ; /36/ .asciz
  714.     mov    (sp)+    ,r1        ; /36/ restore length
  715.     return
  716.  
  717.  
  718.  
  719.  
  720.     .sbttl    terminal read/write binary mode
  721.  
  722.  
  723. ;    B I N R E A
  724. ;
  725. ;!    binread( %val channel_number, %val timeout )
  726. ;
  727. ;
  728. ;    input:    @r5    channel number
  729. ;        2(r5)    timeout    (if -1, then no wait)
  730. ;
  731. ;    output:    r0    error
  732. ;        r1    character read
  733. ;
  734. ;    assumptions:    the terminal has all characters set up
  735. ;            as private delimeters
  736. ;
  737. ;
  738. ;    BINREAD is called ONLY for packet reading.
  739. ;    XBINREA is called for general single character data reading
  740. ;
  741. ;
  742. ; /44/    If a packet reads gets ESC<letter>, where LETTER is in the
  743. ;    range 100-137,  then we can safely assume that the version
  744. ;    9 terminal driver did us the favor of converting a C1 char
  745. ;    into the equivalent (?) escape sequence. What a hack!
  746.  
  747.  
  748. pakrea::
  749. binrea::tstb    lokahd+1        ; /44/ Anything REALLY there?
  750.     bne    90$            ; /44/ Yes, use it
  751.     call    doread            ; /44/ Read next character
  752.     tst    r0            ; /44/ Success?
  753.     bne    100$            ; /44/ No, just exit with error
  754.     cmpb    r1    ,#33        ; /44/ Escape character?
  755.     bne    100$            ; /44/ No, use it as is
  756.     call    doread            ; /44/ Yes, look for char in 100..137
  757.     tst    r0            ; /44/ Should always work
  758.     bne    95$            ; /44/ But if not, return( '\033' )
  759.     cmpb    r1    ,#100        ; /44/ Is it in the range of \0100
  760.     blo    80$            ; /44/ to \0137 ?
  761.     cmpb    r1    ,#137        ; /44/ Well ?
  762.     bhi    80$            ; /44/ Yes, we can't control it then
  763.     bisb    #100    ,r1        ; /44/ In range, restore to CORRECT
  764.     br    100$            ; /44/ format of CTL+0100
  765.  
  766. 80$:    incb    lokahd+1        ; /44/ Invalid, set lookahead flag
  767.     movb    r1    ,lokahd+0    ; /44/ Save the data please
  768.     movb    #33    ,r1        ; /44/ Return( '\033' )
  769.     br    100$            ; /44/ for next read and exit
  770.  
  771. 90$:    clr    r1            ; /44/ Setup for lookahead data
  772.     bisb    lokahd    ,r1        ; /44/ Insert lookahead data
  773. 95$:    clr    lokahd            ; /44/ No more lookhahead data
  774.     clr    r0            ; /44/ No errors
  775. 100$:    return                ; /44/ Exit
  776.  
  777.  
  778.  
  779.     .sbttl    Really read next character in the buffer now
  780. doread:    save    <r2>            ; save temp register
  781. 5$:    mov    @r5    ,r2        ; get the channel number 
  782.     asl    r2            ; times 2 for word addressing
  783.     tst    linit(r2)        ; has this lun ever been set
  784.     beq    20$            ; up for a partial delimiter mask?
  785.     tst    lsize(r2)        ; yes, is there any data waiting?
  786.     bgt    10$            ; yes, get whats already there
  787.     clr    lpoint(r2)        ; no, clear the pointer
  788.     clr    lsize(r2)        ; insure buffer size is zero
  789.     call    rget            ; and read a record if possible
  790.     tst    r0            ; if it fails, revert to 1 char
  791.     bne    100$            ; i/o
  792. 10$:    dec    lsize(r2)        ; one less character in buffer
  793.     bmi    5$            ; if < 0, nothig was read. do it again
  794.     mov    lpoint(r2),r0        ; get the offset into the buffer
  795.     inc    lpoint(r2)        ; and prime this for next time
  796.     clr    r1            ; avoid pdp-11 sign extension
  797.     bisb    lbuffer(r0),r1        ; get the character from the buffer
  798.     clr    r0            ; no errors
  799.     br    100$            ; and exit
  800. 20$:    call    xbinrea            ;
  801. 100$:    unsave    <r2>            ; pop temp register and exit
  802.     return                ;
  803.  
  804. rget:    mov    #xrb    ,r0        ; address of xrb parameter block
  805.     mov    #MAXLNG    ,(r0)+        ; /42/ buffer length
  806.     clr    (r0)+            ; must be zero
  807.     mov    #lbuffer,(r0)+
  808.     movb    r2    ,(r0)+        ; channel number
  809.     bne    5$            ; /52/ Not zero
  810.     .TTECH                ; /52/ Zero, insure echoing
  811. 5$:    clrb    (r0)+            ; unused
  812.     clr    (r0)+            ; unused
  813.     cmp    2(r5)    ,#-1        ; no wait ?
  814.     bne    10$            ; no
  815.      clr    (r0)+            ; yes
  816.      mov    #8192.    ,(r0)+        ; stuff return without wait in
  817.      br    20$            ; and do it
  818. 10$:    mov    2(r5)    ,(r0)+        ; timeout
  819.     clr    (r0)+            ; unused
  820. 20$:    .READ
  821.     movb    FIRQB    ,r0        ; return error code and exit
  822.     beq    30$            ; /45/ No errors
  823.     cmpb    r0    ,#DETKEY    ; /45/ I/O to detached Keyboard ?
  824.     bne    100$            ; /45/ No
  825.     mov    #1    ,XRB+0        ; /45/ Yes, sleep a moment
  826.     .SLEEP                ; /45/ ...
  827.     br    100$            ; /45/ Exit
  828. 30$:    mov    xrb+xrbc,lsize(r2)    ; Read size, save it
  829.     clr    lpoint(r2)
  830.     add    #1    ,rdrate+4    ; /56/ Stats
  831.     bcs    40$            ; /56/ Overflowed
  832.     add    lsize(r2),rdrate+2    ; /56/ Count the data
  833.     adc    rdrate+0        ; /56/ 32 bits worth
  834.     br    100$            ; /56/ And exit
  835. 40$:    clr    rdrate+0        ; /56/ Overflow, so reset
  836.     clr    rdrate+2        ; /56/ Overflow, so reset
  837.     clr    rdrate+4        ; /56/ Overflow, so reset    
  838. 100$:    return
  839.  
  840.     global    <rdrate>        ; /56/
  841.  
  842. xbinre::mov    #xrb    ,r0        ; address of xrb parameter block
  843.     mov    #1    ,(r0)+        ; buffer length
  844.     clr    (r0)+            ; must be zero
  845.     clr    -(sp)            ; allocate buffer on the stack
  846.     mov    sp    ,(r0)+        ; address of the buffer
  847.     movb    @r5    ,@r0        ; channel number
  848.     bne    5$            ; /52/ Not zero
  849.     .TTECH                ; /52/ Zero, insure echoing
  850. 5$:    aslb    (r0)+            ; times 2
  851.     clrb    (r0)+            ; unused
  852.     clr    (r0)+            ; unused
  853.     cmp    2(r5)    ,#-1        ; no wait ?
  854.     bne    10$            ; no
  855.      clr    (r0)+            ; yes
  856.      mov    #8192.    ,(r0)+        ; stuff return without wait in
  857.      br    20$            ; and do it
  858. 10$:    mov    2(r5)    ,(r0)+        ; timeout
  859.     clr    (r0)+            ; unused
  860. 20$:    .READ
  861.     movb    FIRQB    ,r0        ; return error code and exit
  862.     clr    r1
  863.     bisb    (sp)+    ,r1
  864.     return
  865.  
  866.  
  867. ;    Check for pending input on terminal (like ^X and ^Z)
  868. ;    Note: .TTDDT should be cleared by TTDVR always. It's
  869. ;    not, so for the time being lets forget about it  and
  870. ;    instead setup ^X and ^Z as delimiters.  I would have
  871. ;    preferred to use odt mode for this routine.
  872.  
  873.  
  874. chkabo::tst    jobtyp            ; /45/ Can't do from batch
  875.     bne    110$            ; /45/ Exit then
  876.     calls    xbinrea    ,<#5,#-1>    ; simple read on console terminal
  877.     tst    r0            ; did it work ok ?
  878.     bne    100$            ; no
  879.     mov    r1    ,r0        ; yes, return ch in r0 please
  880.     return
  881. 100$:    cmpb    r0    ,#11.        ; error EOFEOF?
  882.     bne    110$            ; no
  883.     movb    #'Z&37    ,r0        ; yes, return ^Z as the character
  884.     return
  885. 110$:    clr    r0            ; it failed
  886.     return
  887.  
  888.     .assume    JOB$INT eq 0
  889.     .assume    JOB$BAT eq 1
  890.  
  891.  
  892. read1c::CLRXRB                ; Insure XRB is zapped
  893.     .TTNCH                ; No echo
  894.     .TTDDT                ; One shot ODT mode
  895.     CLRXRB                ; Insure XRB zapped
  896.     clr    -(sp)            ; Allocate a buffer
  897.     mov    sp    ,r1        ; A pointer
  898.     mov    r1    ,XRB+XRLOC    ; Buffer address
  899.     inc    XRB+XRLEN        ; One character size buffer
  900.     .READ                ; Simple
  901.     clr    r0            ; Return the character next
  902.     tstb    FIRQB            ; Errors?
  903.     bne    100$            ; Yes, return a NULL
  904.     tst    XRB+XRBC        ; No data?????
  905.     beq    100$            ; Should never happen.
  906.     bisb    @r1    ,r0        ; No, return the data then.
  907. 100$:    tst    (sp)+            ; Pop the buffer and exit
  908.     return                ; Bye
  909.  
  910. Wrtall::SAVE    <r0,r1,r2>        ; Save registers
  911.     mov    2+6(sp)    ,r2        ; String address
  912.     STRLEN    r2            ; Get the length
  913.     mov    #xrb    ,r1        ; address of xrb parameter block
  914.     mov    r0    ,(r1)+        ; buffer length
  915.     mov    r0    ,(r1)+        ; byte count for the i/o
  916.     mov    r2    ,(r1)+        ; address of the buffer
  917.     clr    (r1)+            ; Channel zero
  918.     clr    (r1)+            ; unused
  919.     clr    (r1)+            ; unused
  920.     mov    #4096.    ,(r1)+        ; modifier (ie, io.wal+nostall)
  921.     .WRITE                ; Do the WRITE
  922.     UNSAVE    <r2,r1,r0>        ; Pop registers
  923.     mov    (sp)+    ,(sp)        ; Move return address up
  924.     return                ; And exit
  925.  
  926.  
  927.     .sbttl    write everything to the communications line
  928.  
  929. ;    P A K W R I
  930. ;
  931. ;    input:    @r5    buffer address
  932. ;        2(r5)    buffer size
  933. ;        4(r5)    channel number
  934. ;    output:    r0    error code
  935. ;
  936. ;     Pakwrite(buffer,size,lun) attempts  to  write out the specified
  937. ;    number of bytes in pass all  mode  to  the  line.  Additionally,
  938. ;    NOSTALL  is  specified  the first time to allow us to detect the
  939. ;    line being XOFF'ed. The side effect is  that  we  may  also  get
  940. ;    returned  on  a  lack  of  small  buffers,  so  thus  we must be
  941. ;    prepared to try again if that was the case. If we  are  XOFF'ed,
  942. ;    which  is indicated by the 'bytes not sent' value being equal to
  943. ;    the requested write size, then we force  an  XON  to  the  line.
  944. ;    We also can get an XOFF via line noise in the middle of a packet
  945. ;    thus we should also force an XOFF even for a partial write.
  946. ;     This  is messy, addtionally, it ALWAYS requires SYSIO priv even
  947. ;    if you own the line. The code to do this always has  to  inquire
  948. ;    about  the  unit number, which is currently only possible via an
  949. ;    UU.FCB call. This is undesirable in the unlikely event that  the
  950. ;    first  few  words of the terminal DDB get changed by DIGITAL. We
  951. ;    could, of course, save the  unit  number  in  TTYINI  in  a  LUN
  952. ;    indexed table, but that's conceptually unattractive.  Even if it
  953. ;    does change,  the UU.FCB code is rarely called and not very dan-
  954. ;    gerous if things change.
  955. ;    
  956. ;     Ideally, we  need  a  .SPEC call to return XOFF'ed status and a
  957. ;    .SPEC call to clear XOFF'ed status. The method used in  the  RSX
  958. ;    based  Kermit-11  uses  a QIOW$S with a marktime in front of it,
  959. ;    this if the mark time goes off we can  issue  an  IO.KIL,  clear
  960. ;    the  xoffed  state  with  SF.SMC+IO.CTS,  and  redo  the QIOW$S.
  961. ;    Again, the usefulness of MARK TIME and the equiv of IO.KIL comes
  962. ;    to mind for RSTS/E, as noted before in the case of having a CTRL
  963. ;    C ast routine being able to kill io requests on lines other than
  964. ;    one's console terminal, which a control C always does.
  965. ;     Hopefully, a future  release of  RSTS/E  will  make  these task
  966. ;    simpler.  At  such  time,  we would have to consider the case of
  967. ;    older version of RSTS/E; I would simply  cut  the  current  code
  968. ;    out  and let those user's not upgrading suffer; reverting to the
  969. ;    old code in BINWRI (next page). 
  970. ;     Lately,  I seem to be turning my comments into essays about the
  971. ;    deficiences a given exec may have.  RSTS developers, take heart,
  972. ;    using the RSTS/E terminal  driver is a LOT more predictable than 
  973. ;    than what you find on the various flavors of RSX.  I simply have
  974. ;    spent a lot of time in the last couple of years with RT11,  RSX, 
  975. ;    P/OS, TSX+ and VMS; they all have strong points and weaknesses.
  976. ;    What one likes in one is rarely found in the other.
  977.  
  978.  
  979.     .sbttl    Now for the real packet writer (enough of the soapbox)
  980.  
  981. pakwri::save    <r1,r2,r3>        ; /45/ Save this please
  982.     mov    @r5    ,r2        ; /45/ Address of the write
  983.     mov    2(r5)    ,r3        ; /45/ Size of the write
  984.     mov    #8192.!4096.,r1        ; /45/ First time modifier
  985. 10$:    mov    #XRB    ,r0        ; /45/ Address of xrb parameter block
  986.     mov    r3    ,(r0)+        ; /45/ Buffer length
  987.     mov    r3    ,(r0)+        ; /45/ Byte count for the i/o
  988.     mov    r2    ,(r0)+        ; /45/ Address of the buffer
  989.     movb    4(r5)    ,@r0        ; /45/ Channel number
  990.     aslb    (r0)+            ; /45/ Times 2
  991.     clrb    (r0)+            ; /45/ Unused
  992.     clr    (r0)+            ; /45/ Unused
  993.     clr    (r0)+            ; /45/ Unused
  994.     mov    r1    ,(r0)+        ; /45/ Modifier (ie, io.wal+nostall)
  995.     .WRITE                ; /45/ Really dump the data
  996.     movb    FIRQB    ,r0        ; /45/ return error code and exit
  997.     bne    100$            ; /45/ Error, exit NOW
  998.     tst    XRB+XRBC        ; /45/ Did EVERTHING get dumped ?
  999.     beq    100$            ; /45/ Yes, exit with SUCCESS
  1000.  
  1001.     bic    #8192.    ,r1        ; /45/ No more 'NO STALL' modes
  1002.     mov    r3    ,r0        ; /45/ Get the old write size
  1003.     sub    XRB+XRBC,r0        ; /45/ And compute a new buffer addr
  1004.     add    r0    ,r2        ; /45/ buffer = buffer + (size-left)
  1005.     mov    XRB+XRBC,r3        ; /45/ New write size
  1006.                     ; /45/ Now try to XON the line
  1007.     clrfqb                ; /45/ Try a UU.FCB to get the unit
  1008.     movb    #UU.FCB    ,FIRQB+FQFUN    ; /45/ number. While it's acknowledged
  1009.     movb    4(r5)    ,FIRQB+FQFIL    ; /45/ that data strutures may change,
  1010.     .UUO                ; /45/ its unlikely that terminal DDB's
  1011.     movb    FIRQB    ,r0        ; /45/ will change in the first few
  1012.     bne    100$            ; /45/ words.
  1013.     mov    #XRB    ,r0        ; /45/ Point to the XRB now
  1014.     mov    #5    ,(r0)+        ; /45/ Xoffed, try to clear the line
  1015.     mov    #1    ,(r0)+        ; /45/ One byte, an XON, to force.
  1016.     mov    #$xon    ,(r0)+        ; /45/ XRLOC, address of the buffer.
  1017.     mov    #TTYHND*400,(r0)+    ; /45/ Low byte unused, high=driveridx
  1018.     movb    FIRQB+7    ,(r0)+        ; /45/ Unit number to force to
  1019.     clrb    (r0)+            ; /45/ Unused
  1020.     clr    (r0)+            ; /45/ Unused
  1021.     clr    (r0)+            ; /45/ Unused
  1022.     .SPEC                ; /45/ At last !
  1023.     mov    #4    ,XRB+0        ; /45/ Take a short nap and then retry
  1024.     .SLEEP                ; /45/ Wait a moment.
  1025.     br    10$            ; /45/ Go back, stalled write this time
  1026.  
  1027. 100$:    unsave    <r3,r2,r1>
  1028.     return
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034. ;    B I N W R I
  1035. ;
  1036. ;    input:    @r5    buffer address
  1037. ;        2(r5)    buffer size
  1038. ;        4(r5)    channel number
  1039. ;    output:    r0    error code
  1040.  
  1041.  
  1042. binwri::mov    #xrb    ,r0        ; address of xrb parameter block
  1043.     mov    2(r5)    ,(r0)+        ; buffer length
  1044.     mov    2(r5)    ,(r0)+        ; byte count for the i/o
  1045.     mov    @r5    ,(r0)+        ; address of the buffer
  1046.     movb    4(r5)    ,@r0        ; channel number
  1047.     aslb    (r0)+            ; times 2
  1048.     clrb    (r0)+            ; unused
  1049.     clr    (r0)+            ; unused
  1050.     clr    (r0)+            ; unused
  1051.     mov    #4096.    ,(r0)+        ; modifier (ie, io.wal+nostall)
  1052.     .WRITE
  1053.     movb    FIRQB    ,r0        ; return error code and exit
  1054.     return
  1055.  
  1056.  
  1057.  
  1058.  
  1059.     .sbttl    do a filename string scan
  1060.  
  1061. ;    L $ F S S
  1062. ;
  1063. ;    input:    @r5    .asciz string of the device or filename
  1064. ;    output:    FIRQB    the usual
  1065. ;        r0    error code if any
  1066.  
  1067.  
  1068. l$fss::    clrfqb
  1069. l$fssx::mov    @r5    ,r0        ; get the filename address
  1070. 10$:    tstb    (r0)+            ; and now get the length
  1071.     bne    10$            ; no null, keep going
  1072.     sub    @r5    ,r0        ; now get the length
  1073.     dec    r0            ; which is off by one of course
  1074.     mov    r0    ,xrb+xrlen    ; length of the string
  1075.     mov    r0    ,xrb+xrbc    ; once again
  1076.     mov    #xrb+xrloc,r0        ; finish clearing out
  1077.     mov    @r5    ,(r0)+        ; starting address of string
  1078.     clr    (r0)+            ; unused
  1079.     clr    (r0)+            ; unused
  1080.     clr    (r0)+            ; unused
  1081.     clr    (r0)+            ; unused
  1082.     .FSS                ; now do it please
  1083.     movb    FIRQB    ,r0        ; return error
  1084.     return
  1085.  
  1086.     .assume    <xrb+xrlen+2> eq <xrb+xrbc>
  1087.     .assume    <xrb+xrbc+2>  eq <xrb+xrloc>
  1088.  
  1089.  
  1090.     .sbttl    normal i/o to the terminal
  1091.  
  1092. ;    S T T Y O U
  1093. ;
  1094. ;    input:    2(sp)    buffer address
  1095. ;        4(sp)    buffer length
  1096. ;    output:    'c'     set on error
  1097. ;        'c'    clear on no error
  1098. ;
  1099. ;
  1100. ;    L $ T T Y O
  1101. ;
  1102. ;    l$ttyou( %loc buffer, %val string_length )
  1103. ;
  1104. ;    input:    @r5    buffer address
  1105. ;        2(r5)    buffer length
  1106.  
  1107.  
  1108. l$ttyo::save    <r0,r1>            ; save temps here please
  1109.     mov    2(r5)    ,r0        ; string length
  1110.     bne    20$            ; length was passed
  1111.     mov    @r5    ,r0        ; no length, assume .asciz
  1112. 10$:    tstb    (r0)+            ; move along looking for a null
  1113.     bne    10$            ; none yet so far
  1114.     sub    @r5    ,r0        ; get the length
  1115.     dec    r0            ; off by one
  1116. 20$:    mov    #xrb    ,r1        ; address of xrb parameter block
  1117.     mov    r0    ,(r1)+        ; buffer length
  1118.     mov    r0    ,(r1)+        ; byte count for the i/o
  1119.     mov    @r5    ,(r1)+        ; address of the buffer
  1120.     movb    binmod    ,@r1        ; perhaps we need to preserve
  1121.     aslb    (r1)+            ; binary i/o modes here
  1122.     clrb    (r1)+            ; unused    
  1123.     clr    (r1)+            ; unused
  1124.     clr    (r1)+            ; unused
  1125.     clr    @r1            ; unused
  1126.     tst    binmod            ; in binary mode?
  1127.     bne    25$            ; yes
  1128.     mov    #40000    ,@r1        ; no, stuff xrmod with transparent mode
  1129. 25$:    .WRITE
  1130.     cmpb    FIRQB    ,#11        ; i/o channel not open ?
  1131.     bne    30$            ; no, exit please
  1132.  
  1133.     clr    binmod            ; yes, clear the binary i/o lun
  1134.     mov    #xrb    ,r1        ; address of xrb parameter block
  1135.     mov    r0    ,(r1)+        ; buffer length
  1136.     mov    r0    ,(r1)+        ; byte count for the i/o
  1137.     mov    @r5    ,(r1)+        ; address of the buffer
  1138.     clr    (r1)+            ; unused    
  1139.     clr    (r1)+            ; unused
  1140.     clr    (r1)+            ; unused
  1141.     mov    #40000    ,(r1)+        ; xrmod
  1142.     .WRITE
  1143.     
  1144.  
  1145. 30$:    unsave    <r1,r0>            ; pop registers please
  1146.     tstb    FIRQB            ; any errors ?
  1147.     bne    90$            ; yes
  1148.     clc                ; no
  1149.     return
  1150. 90$:    sec                ; yes, set error flag and exit
  1151.     return
  1152.  
  1153.  
  1154. sttyou::mov    r5    ,-(sp)
  1155.     mov    sp    ,r5
  1156.     add    #4    ,r5
  1157.     call    l$ttyo
  1158.     mov    (sp)+    ,r5
  1159.     return
  1160.  
  1161.  
  1162. l$pcrl::MESSAGE
  1163.     return
  1164.  
  1165.  
  1166.     .sbttl    other junk
  1167.  
  1168. $clrxr::save    <r0>
  1169.     mov    #xrb    ,r0
  1170. 10$:    clr    (r0)+
  1171.     cmp    r0    ,#xrb+14
  1172.     blos    10$
  1173.     unsave    <r0>
  1174.     return
  1175.  
  1176.  
  1177.  
  1178. $clrfq::save    <r0>
  1179.     mov    #FIRQB    ,r0
  1180. 10$:    clr    (r0)+
  1181.     cmp    r0    ,#FIRQB+36
  1182.     blos    10$
  1183.     unsave    <r0>
  1184.     return
  1185.  
  1186.  
  1187.  
  1188.     .sbttl    exit kermit and logout
  1189.  
  1190.  
  1191. exit::    MESSAGE
  1192.     clrxrb                ; /55/ ensure xrb is clear first
  1193.     .TTECH                ; /55/
  1194.     clrxrb                ; ensure xrb is clear first
  1195.     clrfqb                ; this must be cleared out
  1196.     .RTS                ; try to go to users KBM
  1197.     .EXIT                ; failed, go to the system's DEFKBM
  1198.  
  1199. ;    Logout moved to K1180S /54/ 23-Aug-86  12:21:41
  1200.  
  1201.  
  1202.  
  1203.  
  1204.     .sbttl    cantyp    cancel typeahead
  1205.  
  1206.  
  1207. ;    C A N T Y P
  1208. ;
  1209. ;    cantyp(%val channel_number)
  1210. ;
  1211. ;    input:    @r5    the device name to cancel typeahead on
  1212. ;        2(r5)    lun, for RSX compatibilty
  1213. ;
  1214. ;
  1215. ;     Cantyp tries to dump all pending input on a given terminal
  1216. ;    line  by using  the normal  .spec call.   The documentation 
  1217. ;    states that the KB must not be open which I find a bit odd.
  1218. ;    It really should not make any difference. At any rate, call
  1219. ;    the routine before you open it.
  1220.  
  1221.  
  1222. cantyp::save    <r1,r2>            ; use r0 to point into xrb
  1223.     call    ttpars            ; parse the passed device name
  1224.     bcs    90$            ; the parse failed
  1225.     mov    r0    ,r2        ; save the parsed unit number
  1226.     sub    #40    ,sp        ; allocate a buffer for gttnam
  1227.     mov    sp    ,r1        ; and a pointer to it please
  1228.     calls    gttnam    ,<r1>        ; get the local terminal name
  1229.     calls    ttpars    ,<r1>        ; parse the device name now
  1230.     add    #40    ,sp        ; pop the local buffer
  1231.     clr    -(sp)            ; assume _KB: for now
  1232.     cmpb    r0    ,r2        ; is the unit number the same as
  1233.     beq    10$            ; the console terminal ? if eq, Y
  1234.     mov    r2    ,@sp        ; no, stuff the correct unit number
  1235. 10$:    mov    #xrb    ,r1        ; ok
  1236.     mov    #7    ,(r1)+        ; functioncode := cancel_typeahead
  1237.     mov    (sp)+    ,(r1)+        ; the kb number to use
  1238.     clr    (r1)+            ; not used
  1239.     clrb    (r1)+            ; no channel number today
  1240.     movb    #2    ,(r1)+        ; driver index for terminals
  1241.     clr    (r1)+            ; not used
  1242.     clr    (r1)+            ; not used
  1243.     clr    (r1)+            ; not used
  1244.     .spec                ; do a driver special function now
  1245.     mov    2(r5)    ,r0
  1246.     asl    r0
  1247.     clr    lsize(r0)
  1248. 90$:    movb    FIRQB    ,r0        ; return any errors please
  1249. 100$:    unsave    <r2,r1>            ; all done
  1250.     return                ; bye
  1251.  
  1252. clrcns::CLRXRB                ; Insure XRB is cleared
  1253.     mov    #7    ,XRB+XRLEN    ; Cancel typeahead call
  1254.     movb    #2    ,XRB+XRBLKM    ; Driver index
  1255.     .SPEC                ; Should be it
  1256.     return                ; Exit
  1257.  
  1258.  
  1259.  
  1260.     .sbttl    get uic
  1261.  
  1262.  
  1263. ;    G E T U I C
  1264. ;
  1265. ;    input:    nothing
  1266. ;    output:    r0    current UIC/PPN of the user
  1267.  
  1268.  
  1269.  
  1270. getuic::mov    #xrb    ,r0        ; clear xrb out first
  1271. 10$:    clrb    (r0)+            ; simple
  1272.     cmp    r0    ,#xrb+15
  1273.     blos    10$
  1274.     .stat
  1275.     mov    xrb+10    ,r0        ; return uic (ppn) in r0
  1276.     return
  1277.  
  1278.  
  1279.  
  1280. drpprv::mov    #jfsys    ,xrb+0        ; drop temp privs
  1281.     .clear                ; simple
  1282.     return
  1283.  
  1284.  
  1285. getprv::mov    #jfsys    ,xrb+0        ; get temp privs back please
  1286.     .SET
  1287.     return
  1288.  
  1289.  
  1290.  
  1291.     .sbttl    suspend the job for a while
  1292.  
  1293. ;    S U S P E N
  1294. ;
  1295. ;    suspend(%val sleep_time)
  1296. ;
  1297. ;    input:    @r5    time to go away for
  1298.  
  1299.  
  1300. suspen::mov    @r5    ,xrb+0
  1301.     bne    10$
  1302.     inc    xrb+0
  1303. 10$:    .sleep
  1304.     return
  1305.  
  1306.  
  1307.     .sbttl    error text
  1308.  
  1309.  
  1310. fcserr::
  1311. fiperr::save    <r0,r1,r2>
  1312.     mov    4(r5)    ,r2        ; r0 := addr( errtxt )
  1313.     mov    @2(r5)    ,r0
  1314.     bgt    5$
  1315.     neg    r0
  1316. 5$:    movb    r0    ,@#FIRQB+fqerno    ; movbe the error number .
  1317.     movb    #errfq    ,@#FIRQB+FQFUN    ; set up for sys err call
  1318.     CALFIP
  1319.     mov    #28.    ,r0        ; error text length
  1320.     mov    #FIRQB+fqerno    ,r1    ; r1 := addr( actual msg )
  1321. 10$:    movb    (r1)+    ,(r2)+        ; go and transfer the text
  1322.     beq    20$            ; did we find the end yet
  1323.     sob    r0    ,10$        ; all thirty bytes  worth.
  1324. 20$:    clrb    @r2
  1325. 40$:    unsave    <r2,r1,r0>
  1326.     return                ; all done
  1327.  
  1328.  
  1329.  
  1330.  
  1331. syserp::save    <r0>
  1332.     mov    @r5    ,r0
  1333.     call    rmserp
  1334.     MESSAGE
  1335.     unsave    <r0>
  1336.     return
  1337.  
  1338.  
  1339.  
  1340. syserr::save    <r1>            ; save a register
  1341.     clr    -(sp)            ; allocate variable for error #
  1342.     mov    sp    ,r1        ; and point to it
  1343.     mov    @r5    ,@r1        ; if errornumber > 0
  1344.     bmi    10$            ;  then
  1345.     calls    fiperr    ,<#2,r1,2(r5)>    ;   call fiperr(num,text)
  1346.     br    100$            ;  else
  1347. 10$:    calls    rmserr    ,<#2,r1,2(r5)>    ;   call rmserr(num,text)
  1348. 100$:    tst    (sp)+
  1349.     unsave    <r1>
  1350.     return
  1351.  
  1352.     global    <fiperr    ,rmserp    ,rmserr>
  1353.  
  1354.  
  1355.  
  1356.  
  1357.     .sbttl    ttypar    set parity stuff for kermit
  1358.  
  1359.  
  1360. ;    T T Y P A R
  1361. ;
  1362. ;    ttypar( %loc terminal name, %val paritycode )
  1363. ;
  1364. ;    input:    @r5    address of terminal name
  1365. ;        2(r5)    parity code
  1366. ;    output:    r0    error code
  1367.  
  1368.     .if ne    ,0            ; we don't need this anymore
  1369.     .ift
  1370.  
  1371. ttypar::call    ttpars            ; get the terminal unit number
  1372.     bcs    100$            ; oops
  1373.     clrfqb                ; clear FIRQB out for defualts
  1374.     inc    FIRQB+20        ; assume no parity
  1375.     cmpb    2(r5)    ,#par$no    ; really no parity ?
  1376.     beq    10$            ; yes
  1377.     inc    FIRQB+20        ; try next for even parity
  1378.     cmpb    2(r5)    ,#par$ev    ; well ?
  1379.     beq    10$            ; yes
  1380.     inc    FIRQB+20        ; not NONE or EVEN --> ODD
  1381.     cmpb    2(r5)    ,#par$od    ; must be
  1382.     beq    10$            ; yes
  1383.     movb    #18.    ,FIRQB        ; no, return illegal sys usage
  1384.     br    100$
  1385. 10$:    movb    r0    ,FIRQB+5    ; stuff the terminal unit number
  1386.     movb    #UU.TRM    ,FIRQB+FQFUN    ; terminal call today
  1387.     .UUO                ; simple
  1388. 100$:    movb    FIRQB    ,r0        ; get any errors
  1389.     return
  1390.  
  1391.     .endc                ; don't need hardware parity control
  1392.  
  1393. chkpar::clr    r0
  1394.     return
  1395.  
  1396.  
  1397.  
  1398.  
  1399.     .sbttl    hangup a terminal, set dtr on a terminal
  1400.  
  1401.  
  1402. ;    T T Y H A N
  1403. ;
  1404. ;    ttyhan( %loc terminalname )
  1405. ;
  1406. ;    input:    @r5    address of the terminal name
  1407. ;    output:    r0    error code
  1408.  
  1409.  
  1410. ttyhan::call    ttpars            ; the usual, parse the device name
  1411.     bcs    100$            ; oops
  1412.     clrfqb                ; clear the FIRQB please
  1413.     movb    #UU.HNG    ,FIRQB+FQFUN    ; terminal call today
  1414.     movb    r0    ,FIRQB+4    ; unit number
  1415.     movb    #1    ,FIRQB+5    ; do it asap
  1416.     .UUO                ; simple
  1417. 100$:    movb    FIRQB    ,r0        ; return error code and exit
  1418.     return                ; bye
  1419.  
  1420.  
  1421.  
  1422. ;    raise DTR on a terminal line
  1423. ;
  1424. ;    T T Y D T R
  1425. ;
  1426. ;    ttydtr( %loc terminalname )
  1427. ;
  1428. ;    input:    @r5    address of the terminal name
  1429. ;    output:    r0    error code
  1430.  
  1431.  
  1432. ttydtr::call    ttpars            ; the usual, parse the device name
  1433.     bcs    100$            ; oops
  1434.     clrfqb                ; clear the FIRQB please
  1435.     movb    #UU.HNG    ,FIRQB+FQFUN    ; terminal call today
  1436.     movb    r0    ,FIRQB+4    ; unit number
  1437.     movb    #377    ,FIRQB+5    ; set dtr function
  1438.     .UUO                ; simple
  1439. 100$:    movb    FIRQB    ,r0        ; return error code and exit
  1440.     return                ; bye
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.     .sbttl    inquire if DTR is up on a device
  1448.  
  1449. ;    INQDTR(ttname)
  1450. ;
  1451. ;    Find out if DTR is up.
  1452. ;
  1453. ;     On RSTS/E, DTR is up if (1) Carrier detect is up or (2) Ring is up
  1454. ;    Thus,  to connect to a dialout modem,  some means  must be provided
  1455. ;    for the terminal driver to 'See' CD. This can be done from internal
  1456. ;    modem options, or one can cut CD and loop DTR to CD on the cpu side
  1457. ;    and use the Kermit-11 command SET DTR to get CD up. This routine is
  1458. ;    to return the current DTR status.  For RSX, it would be more useful
  1459. ;    to return TRUE if TC.DLU==2 or TRUE if CD is up.
  1460. ;
  1461. ;    Returns:    1    DTR is present
  1462. ;            0    DTR is NOT present
  1463. ;            -1    Line is not modem controlled
  1464. ;
  1465. ;    18-Dec-85  09:16:08 BDN
  1466.  
  1467.     .iif ndf, UU.CFG, UU.CFG = 42    ; So this builds on version 8 systems
  1468.  
  1469. inqdtr::tst    ver9.x            ; /40/ only works on 9.0 or later
  1470.     beq    90$            ; /40/ if so, return(-1)
  1471.     call    ttpars            ; /40/ get device unit number
  1472.     tstb    FIRQB            ; /40/ Was parse successful?
  1473.     bne    90$            ; /40/ No, return(-1)
  1474.     clrfqb                ; /40/ clear firqb out please
  1475.     movb    #UU.CFG    ,FIRQB+FQFUN    ; /40/ Find out if line has Modem ctl
  1476.     mov    #"KB    ,FIRQB+FQDEV    ; /40/ Always a KB: device please
  1477.     movb    r0    ,FIRQB+FQDEVN    ; /40/ Unit number please
  1478.     movb    #377    ,FIRQB+FQDEVN+1    ; /40/ Unit number is 'real'
  1479.     .UUO                ; /40/ do it
  1480.     tstb    FIRQB            ; /40/ If failure, return(nomodem)
  1481.     bne    90$            ; /40/ Failed
  1482.     bitb    #4    ,FIRQB+7    ; /40/ If set, the line is modem ctl
  1483.     beq    90$            ; /40/ No modem control, return(-1)
  1484.     clrfqb                ; /40/ We have modem control, what
  1485.     movb    #UU.TRM    ,FIRQB+FQFUN    ; /40/ about DTR being around ?
  1486.     movb    r0    ,FIRQB+5    ; /40/ Unit number here this time
  1487.     .UUO                ; /40/ get tt characteristics, part 1
  1488.     tstb    FIRQB            ; /40/ Can't fail
  1489.     bne    90$            ; /40/ But it did ?
  1490.     bitb    #200    ,FIRQB+4    ; /40/ At last, is DTR up ?
  1491.     bne    80$            ; /40/ No, return(0)
  1492.     mov    #1    ,r0        ; /40/ Yes, return(1)
  1493.     br    100$            ; /40/ Exit
  1494.  
  1495. 80$:    clr    r0            ; /40/ Modem line and no DTR
  1496.     br    100$            ; /40/ exit
  1497. 90$:    mov    #-1    ,r0        ; /40/ Not modem or pre 9.x system
  1498. 100$:    return
  1499.  
  1500.  
  1501. inqbuf::mov    #maxpak    ,r0        ; /42/ Assume pre RSTS v9
  1502.     tst    ver9.x            ; /42/ 9.X with huge buffer quotas?
  1503.     beq    100$            ; /42/ No
  1504.     mov    #MAXLNG    ,r0        ; /42/ Yes, return the MAX size
  1505. 100$:    return                ; /42/ exit
  1506.  
  1507.     global    <maxpak>        ; /42/
  1508.  
  1509.  
  1510. inqpar::clr    r0
  1511.     return
  1512.  
  1513.  
  1514.  
  1515.     .sbttl    ttspeed    get speed for line
  1516.  
  1517.  
  1518. ;    T T S P E E D
  1519. ;
  1520. ;    input:    @r5    name of terminal or address of null for current
  1521. ;    output:    r0    current speed
  1522. ;
  1523.  
  1524.     .save
  1525.     .psect    $pdata
  1526.  
  1527. ttdevl:    .asciz    /KLDCDLDEPKDJDHDZVH/
  1528.     .even
  1529. splst:    .word    dlalst,dclst,dlclst,dlelst,pklst,djlst,dhlst,dzlst,dhvlst
  1530.     .word    10$,10$,10$,10$,10$,10$
  1531. 10$:    .word    0,0
  1532. dlalst:    .word    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1533. dclst:    .word    -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
  1534. dlclst:    .word    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1
  1535. dlelst:    .word    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1
  1536. pklst:    .word    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1
  1537. djlst:    .word    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1
  1538. dhlst:    .word    0., 50.,75.,110.,134.,150.,200.,300., 600.
  1539.     .word    1200.,1800.,2400.,4800.,9600.,0.,0,-1
  1540. dzlst:    .word    0., 50.,75.,110.,134.,150.,300.,600.,1200.
  1541.     .word    1800.,2000.,2400.,3600.,4800.,7200.,9600.,-1
  1542. dhvlst:    .word     0,  75.,110.,134.,150.,300.,600.,1200.
  1543.     .word    1800.,2000.,2400.,4800.,0    ,9600.,19200.,-1
  1544.     .restore
  1545.  
  1546. ttspee::save    <r1>
  1547.     call    ttpars            ; parse the device name
  1548.     bcs    90$            ; exit
  1549.     clrfqb                ; insure no changes to tty settings
  1550.     movb    #UU.TRM    ,FIRQB+FQFUN    ; uuo code to do it
  1551.     movb    r0    ,FIRQB+5    ; unit number
  1552.     .UUO                ; get terminal characteristics
  1553.     tstb    FIRQB            ; did it work ?
  1554.     bne    90$            ; no
  1555.     movb    FIRQB+24,r1        ; interface type
  1556.     mov    splst(r1),r0        ; /40/ is the speed settable?
  1557.     tst    2(r0)            ; /40/ second entry is always <> 0
  1558.     beq    90$            ; /40/ not settable
  1559.     movb    FIRQB+17,r0        ; get the speed of it
  1560.     dec    r0
  1561.     asl    r0            ; times 2
  1562.     add    splst(r1),r0        ; and the actual speed now
  1563.     mov    @r0    ,r0        ; got it
  1564.     br    100$            ; exit
  1565. 90$:    clr    r0
  1566. 100$:    unsave    <r1>
  1567.     return
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.     .sbttl    set the speed of a terminal line
  1575.  
  1576.  
  1577.  
  1578. ;    S E T S P D
  1579. ;
  1580. ;    setspd(%loc devicename, %val speed)
  1581. ;
  1582. ;    input:    @r5    device name
  1583. ;        2(r5)    speed
  1584. ;    output:    r0    error code, 255 if invalid speed
  1585.  
  1586. setspd::save    <r1,r2>
  1587.     call    ttpars            ; parse the terminal name
  1588.     bcs    90$            ; oops
  1589.     clrfqb
  1590.     movb    #UU.TRM    ,FIRQB+FQFUN    ; uuo code to do it
  1591.     movb    r0    ,FIRQB+5    ; unit number
  1592.     .UUO                ; get terminal characteristics
  1593.     tstb    FIRQB            ; did it work ?
  1594.     bne    90$            ; no
  1595.     movb    FIRQB+24,r1        ; interface type
  1596.     mov    splst(r1),r1        ; point to the speed table for it
  1597.     clr    r2            ; current index
  1598. 10$:    cmp    @r1    ,#-1        ; reached the end of the table
  1599.     beq    80$            ; yes, can't set the speed
  1600.     inc    r2            ; speednum := succ( speednum )
  1601.     cmp    2(r5)    ,(r1)+        ; speed match ?
  1602.     bne    10$            ; no
  1603.     clrfqb                ; clear FIRQB out please
  1604.     movb    #UU.TRM    ,FIRQB+FQFUN    ; uuo function for terminals
  1605.     movb    r0    ,FIRQB+5    ; unit number
  1606.     movb    r2    ,FIRQB+17    ; rec speed
  1607.     movb    r2    ,FIRQB+21    ; xmit speed
  1608.     .UUO                ; do it
  1609.     tstb    FIRQB            ; error ?
  1610.     bne    90$            ; yes
  1611.     clr    r0            ; no
  1612.     br    100$            ; exit
  1613.  
  1614. 80$:    mov    #377    ,r0        ; unknown speed or not settable
  1615.     br    100$            ; exit
  1616.  
  1617. 90$:    movb    FIRQB    ,r0        ; uuo error, return it please
  1618. 100$:    unsave    <r2,r1>            ; bye
  1619.     return
  1620.  
  1621.  
  1622.  
  1623.  
  1624.     .sbttl    INITER    save and set the terminal characteristics
  1625.  
  1626. ;    ttysav( %loc ttname)
  1627. ;    ttyrst()
  1628. ;
  1629. ;    output:    r0    error code
  1630.  
  1631. ttysav::
  1632. ttyrst::
  1633. ttyset::clr    r0
  1634.     return
  1635.  
  1636.  
  1637.  
  1638. ;    INITER
  1639. ;
  1640. ;    Passed:    0(r5)    Address of terminal name
  1641. ;        2(r5)    Channel number to be used on
  1642. ;    Return:    r0    error code
  1643. ;
  1644. ;    INITER is called ONLY internally from TTYINI()
  1645.  
  1646.  
  1647. initer:    save    <r1,r2,r3>
  1648.     call    ttpars            ; set terminal up for KERMIT
  1649.     bcs    90$            ; oops, bad device name
  1650.     mov    2(r5)    ,r1        ; /40/ get the channel number please
  1651.     tst    ver9.x            ; /40/ version 9.x or later?
  1652.     beq    4$            ; /40/ no
  1653.  
  1654.     clrb    bufqsav(r1)        ; /40/ assume nothing saved for quota
  1655.     clrfqb                ; /40/ insure no unpleasant effects
  1656.     movb    #UU.TRM    ,FIRQB+FQFUN    ; /40/ uuo code for terminals
  1657.     incb    FIRQB+4            ; /40/ UU.TRM part two
  1658.     movb    r0    ,FIRQB+5    ; /40/ unit number or 377
  1659.     .UUO                ; /40/ get the current settings
  1660.     tstb    FIRQB            ; /40/ did the set list work ?
  1661.     bne    4$            ; /40/ should have
  1662.     movb    FIRQB+27,bufqsav(r1)    ; /40/ save old buffer quotas
  1663.     clrfqb                ; /40/ insure no unpleasant effects
  1664.     movb    #UU.TRM    ,FIRQB+FQFUN    ; /40/ uuo code for terminals
  1665.     incb    FIRQB+4            ; /40/ subfunction one
  1666.     movb    r0    ,FIRQB+5    ; /40/ unit number or 377
  1667. ..BUFQ    == . + 2            ; /46/ Patchable
  1668.     movb    #40.    ,FIRQB+27    ; /40/ raise buffer quotas now
  1669.     .UUO                ; /40/ ignore errors
  1670.  
  1671. 4$:    clrfqb                ; insure no unpleasant effects
  1672.     movb    #UU.TRM    ,FIRQB+FQFUN    ; uuo code for terminals
  1673.     movb    r0    ,FIRQB+5    ; unit number or 377
  1674.     .UUO                ; get the current settings
  1675.     tstb    FIRQB            ; did the set list work ?
  1676.     bne    90$            ; no, die
  1677.     mov    2(r5)    ,r1        ; get the channel number please
  1678.     mul    #40    ,r1        ; get address of ttsave area for it
  1679.     add    #ttsave    ,r1        ; at last
  1680.     mov    #FIRQB    ,r2        ; get address of current settings
  1681.     mov    #40    ,r3        ; number of bytes to copy now
  1682. 5$:    movb    (r2)+    ,(r1)+        ; copy a byte
  1683.     sob    r3    ,5$        ; next please
  1684.     clr    r1            ; get the parity/8bit setting
  1685.     bisb    FIRQB+20,r1        ; and check for parity being set
  1686.     bic    #^C3    ,r1        ; leave only parity bits here
  1687.     cmpb    r1    ,#1        ; parity set ?
  1688.     bhi    7$            ; /36/ yes, can't set 8bit mode then
  1689.     tstb    parity            ; /36/ If software parity enabled
  1690.     beq    6$            ; /36/ then we must prevent TTDVR
  1691.     cmpb    parity    ,#PAR$NO    ; /36/ from changing characters in
  1692.     bne    7$            ; /36/ range 201-237 into esc seqs.
  1693. 6$:    movb    #30    ,r1        ; no parity so please set 8bit mode
  1694.     br    10$            ; /36/
  1695. 7$:    bisb    #20    ,r1        ; /36/ explicitly turn 8bit mode off
  1696. 10$:    clrfqb                ; now actually set it
  1697.     movb    #UU.TRM    ,FIRQB+FQFUN    ; uuo code for terminals
  1698.     movb    r0    ,FIRQB+5    ; unit number or 377
  1699.     movb    #377    ,FIRQB+12    ; SET XON
  1700.     movb    #377    ,FIRQB+35    ; SET GAG
  1701.     movb    r1    ,FIRQB+20    ; SET 8BIT
  1702.     movb    #200    ,FIRQB+11    ; SET LC OUTPUT
  1703.     movb    #377    ,FIRQB+15    ; SET LC INPUT
  1704.     movb    #200    ,FIRQB+30    ; insure no delimiters are set now
  1705.     cmpb    handch    ,#'Q&37        ; This is a pain. We have to use
  1706.     beq    15$            ; multiple delims cause bin mode
  1707.     cmpb    handch    ,#'S&37        ; perhaps XON also ?
  1708.     bne    20$            ; no
  1709. 15$:    movb    #200    ,FIRQB+22    ; timeouts don't work and xon's
  1710.                     ; don't get thru unless stall is off
  1711. 20$:    
  1712.     .UUO                ; go get RSTS's attention
  1713. 90$:    movb    FIRQB    ,r0        ; return possible errors
  1714.     unsave    <r3,r2,r1>
  1715.     return
  1716.  
  1717.     global    <handch    ,parity    ,ttname>
  1718.  
  1719.  
  1720.  
  1721.  
  1722.     .sbttl    ttpars    get unit number from ttname
  1723.  
  1724. ;    T T P A R S
  1725. ;
  1726. ;    ttpars( %loc ttname )
  1727. ;
  1728. ;    output:    r0    unit number or 377 for null string
  1729.  
  1730.     .enabl    lsb
  1731.  
  1732. ttpars::save    <r1>
  1733.     call    myterm            ; get attached console name
  1734.     movb    r0    ,r1        ; get the name
  1735.     clrfqb                ; no defaults
  1736.     clrxrb
  1737.     mov    #377    ,-(sp)        ; assume KB:
  1738.     mov    @r5    ,r0        ; address of terminal name
  1739. 10$:    tstb    (r0)+            ; get the length of the name
  1740.     bne    10$            ; until we find a NULL
  1741.     sub    @r5    ,r0        ; get the length
  1742.     dec    r0            ; if zero, then use 377 for unit
  1743.     beq    20$            ; use zero
  1744.     mov    r0    ,xrb+xrlen    ; length of string for .FSS
  1745.     mov    r0    ,xrb+xrbc    ; again
  1746.     mov    @r5    ,xrb+xrloc    ; address of the string to parse
  1747.     .FSS                ; and do it
  1748.     tstb    FIRQB            ; did it work ?
  1749.     bne    90$            ; no
  1750.     bit    #20000!40000,xrb+10    ; a device name was parsed ?
  1751.     beq    80$            ; no
  1752.     movb    xrb+14,    r0        ; get the driver index please
  1753.     scan    r0    ,#200$        ; a reasonable device name?
  1754.     tst    r0            ; well ?
  1755.     beq    80$            ; no
  1756.     cmpb    FIRQB+FQDEVN,r1        ; same device as controlling terminal?
  1757.     beq    20$            ; yes
  1758.     movb    FIRQB+FQDEVN,@sp    ; yes, save unit number
  1759.     bne    20$
  1760.     movb    #377    ,@sp        ; no unit, return 377 for self
  1761. 20$:    clc                ; flag success
  1762.     br    100$            ; and exit
  1763.  
  1764. 80$:    movb    #6    ,FIRQB        ; invlaid device name error
  1765. 90$:    sec                ; flag failure
  1766. 100$:    mov    (sp)+    ,r0
  1767.     unsave    <r1>
  1768.     return
  1769.  
  1770.  
  1771.     .iif ndf, ttyhnd, ttyhnd = 2
  1772.     .iif ndf, pkbhnd, pkbhnd = 20
  1773.     .iif ndf, dmchnd, dmchnd = 30
  1774.     .iif ndf, dmphnd, dmphnd = 46
  1775.  
  1776.     .save
  1777.     .psect    $PDATA    ,D
  1778. 200$:    .byte    ttyhnd    ,pkbhnd    ,dmchnd    ,dmphnd    ,0
  1779.     .even
  1780.     .restore
  1781.     .dsabl    lsb
  1782.  
  1783. myterm:    clrfqb
  1784.     movb    #UU.SYS    ,FIRQB+FQFUN    ; for a systat part one
  1785.     .UUO                ; simple
  1786.     movb    FIRQB+5    ,r0        ; get the name
  1787.     return
  1788.  
  1789.  
  1790.  
  1791.     .sbttl    assign device
  1792.     .enabl    lsb
  1793.  
  1794. ;    Assign the device for SET LINE. Device characteristics are
  1795. ;    set in TTYINI and reset in TTYFIN. For edit /41/, check to
  1796. ;    be sure that the JOB privilege mask includes HWCFG,  which
  1797. ;    is needed to alter settings on other terminal lines (9.x).
  1798.  
  1799.     .iif ndf , PRVIOL,    PRVIOL = 12
  1800.  
  1801. assdev::mov    r1    ,-(sp)        ; /41/
  1802.     call    ttpars            ; parse the terminal name
  1803.     bcs    100$            ; oops
  1804.     cmpb    r0    ,#377        ; Return KB: ?
  1805.     bne    10$            ; no
  1806.     clr    r0            ; Yes, simply return
  1807.     br    110$            ; exit
  1808. 10$:    mov    r0    ,r1        ; /41/ save unit number
  1809.     tst    ver9.x            ; /45/ What if this is version 8?
  1810.     beq    20$            ; /45/ If so, don't try this out.
  1811.     mov    #HWCFG    ,-(sp)        ; /41/ See if we have JOB privs
  1812.     call    jobprv            ; /41/ Well?
  1813.     tst    r0            ; /41/ 1 == success
  1814.     beq    90$            ; /41/ No
  1815. 20$:    clrfqb                ; A Real LINE today
  1816.     movb    #UU.ASS    ,FIRQB+FQFUN    ; Assign the device please
  1817.     mov    #FIRQB+FQDEV,r0        ; Where to place the device name
  1818.     movb    #'K    ,(r0)+        ; name
  1819.     movb    #'B    ,(r0)+        ; ..name continued (Always KBnn:)
  1820.     movb    r1    ,(r0)+        ; unit
  1821.     movb    #377    ,@r0        ; Unit is 'real'
  1822.     .UUO                ; get RSTS/E to do the assignment
  1823.     br    100$            ; exit with error in FIRQB+0
  1824. 90$:    message    <You lack the HWCFG privilege to assign a line>,cr
  1825.     mov    #PRVIOL    ,FIRQB        ; /41/
  1826. 100$:    movb    FIRQB    ,r0        ; Return the error code please
  1827. 110$:    mov    (sp)+    ,r1        ; /41/ Restore register please
  1828.     return                ; exit
  1829.  
  1830.     .dsabl    lsb
  1831.  
  1832.     .save
  1833.     .psect    $PDATA
  1834. hwcfg:    .asciz    /HWCFG/
  1835.     .even
  1836.     .restore
  1837.  
  1838.  
  1839.  
  1840.  
  1841.     .sbttl    ascdat    get the ascii string for the date
  1842.  
  1843. ;    A S C D A T
  1844. ;
  1845. ;    input:    @r5    buffer address
  1846. ;        2(r5)    date in system internal format
  1847.  
  1848.  
  1849. ascdat::save    <r0,r1>
  1850.     clrfqb                ; clear the FIRQB out first
  1851.     mov    2(r5)    ,FIRQB+4    ; where to pass the date
  1852.     movb    #UU.CNV    ,FIRQB+FQFUN    ; simple
  1853.     inc    FIRQB+6            ; KERMIT uses ISO date formats
  1854.     .UUO                ; get RSTS to convert the date
  1855.     clrb    FIRQB+22        ; insure .asciz
  1856.     mov    #FIRQB+10,r0        ; where RSTS put the date
  1857.     mov    @r5    ,r1        ; where we want to put it
  1858. 10$:    movb    (r0)+    ,(r1)+        ; simple
  1859.     bne    10$            ; copy until a null byte is found
  1860.     unsave    <r1,r0>            ; pop temps and exit
  1861.     return
  1862.  
  1863.  
  1864.  
  1865.  
  1866.  
  1867.  
  1868. ;    A S C T I M
  1869. ;
  1870. ;    input:    @r5    buffer address
  1871. ;        2(r5)    time in system internal format
  1872.  
  1873.  
  1874. asctim::save    <r0,r1>
  1875.     clrfqb                ; clear the FIRQB out first
  1876.     mov    2(r5)    ,FIRQB+22    ; where to pass the time
  1877.     movb    #UU.CNV    ,FIRQB+FQFUN    ; simple
  1878.     inc    FIRQB+24        ; KERMIT uses ISO time formats
  1879.     .UUO                ; get RSTS to convert the time
  1880.     clrb    FIRQB+36        ; insure .asciz
  1881.     mov    #FIRQB+26,r0        ; where RSTS put the time
  1882.     mov    @r5    ,r1        ; where we want to put it
  1883. 10$:    movb    (r0)+    ,(r1)+        ; simple
  1884.     bne    10$            ; copy until a null byte is found
  1885.     unsave    <r1,r0>            ; pop temps and exit
  1886.     return
  1887.  
  1888.  
  1889.     .sbttl    dodir    get a reasonable directory printed
  1890.  
  1891.  
  1892. ;    D O D I R
  1893. ;
  1894. ;    input:    @r5    wildcarded filespec
  1895. ;    output:    r0    error code
  1896. ;
  1897. ;    DODIR prints a directory listing at the local terminal.
  1898. ;
  1899. ;
  1900. ;    S D O D I R
  1901. ;
  1902. ;    Passed:    @r5    wildcarded name
  1903. ;    Return:    r0    error code, zero for no errors
  1904. ;        r1    next character in the directory listing
  1905. ;
  1906. ;    SDODIR is called by the server to respond to a remote directory
  1907. ;    command.  Instead of the pre 2.38 method of dumping output to a
  1908. ;    disk file and then sending the disk file in an extended replay,
  1909. ;    SDODIR  returns the next  character so that  BUFFIL can use it.
  1910. ;    The routine  GETCR0  is actually a dispatch routine to call the
  1911. ;    currently selected GET_NEXT_CHARACTER routine.
  1912.  
  1913.  
  1914.  
  1915.  
  1916.     .save
  1917.     .psect    dirctx    ,rw,d,lcl,rel,con
  1918. dirnam:    .blkb    120
  1919. dirfir:    .blkb    42
  1920. dirbuf:    .blkb    60
  1921. diridx:    .word    0
  1922. dirptr:    .word    dirbuf
  1923. dcrlf:    .byte    15,12,0
  1924.     .even
  1925.     .restore
  1926.  
  1927.  
  1928. dodir::    save    <r1,r2,r3,r4>
  1929.     strcpy    #dirnam    ,@r5
  1930.     call    dirini            ; init things
  1931.     bcs    100$            ; error in the .FSS parse
  1932. 10$:    call    dirnex            ; get the next file
  1933.     bcs    100$            ; all done
  1934.     .print    #dirbuf
  1935.     br    10$
  1936. 100$:    unsave    <r4,r3,r2,r1>
  1937.     clr    diridx
  1938.     return
  1939.  
  1940.  
  1941. sdirin::strcpy    #dirnam    ,@r5        ; copy name over
  1942.     clr    diridx            ; ditto
  1943.     call    dirini            ; init for calls to sdodir
  1944.     bcs    100$
  1945.     mov    #dirbuf    ,dirptr        ; yes, init pointers please
  1946.     clrb    @dirptr            ; yes, zap the buffer
  1947.     call    dirnex            ; preload buffer
  1948. 100$:    return
  1949.  
  1950. sdodir::save    <r2,r3,r4>
  1951. 10$:    movb    @dirptr    ,r1        ; get the next character please
  1952.     bne    20$            ; something was there
  1953.     mov    #dirbuf    ,dirptr        ; reset the pointer
  1954.     clrb    @dirptr            ; yes, zap the buffer
  1955.     call    dirnex            ; empty buffer, load with next file
  1956.     bcs    90$            ; no more, return ER$EOF
  1957.     br    10$            ; and try again
  1958. 20$:    inc    dirptr            ; pointer++
  1959.     clr    r0            ; no errors
  1960.     br    100$            ; exit
  1961. 90$:    mov    #ER$EOF    ,r0        ; failure, return(EOF)
  1962. 95$:    clr    r1            ; return no data also
  1963.     clr    diridx            ; init for next time through
  1964. 100$:    unsave    <r4,r3,r2>
  1965.     return
  1966.     
  1967.  
  1968.  
  1969.     global    <defdir,ER$EOF>
  1970.  
  1971.  
  1972.  
  1973.     .sbttl    init for the directory
  1974.  
  1975.  
  1976. dirini:    clr    diridx            ; /38/
  1977.     mov    #dirnam    ,r2        ; string address
  1978.     tstb    @r2            ; a null string ?
  1979.     bne    10$            ; no
  1980. 5$:    mov    #wild    ,r2        ; yes, supply *.*
  1981. 10$:    calls    l$fss    ,<#defdir>    ; stuff FIRQB with defaults
  1982.     calls    l$fssx    ,<r2>        ; parse the string with defaults
  1983.     tst    r0            ; did it work ?
  1984.     bne    90$            ; no
  1985.     bit    #1    ,xrb+10        ; was some kind of filename passed?
  1986.     bne    20$            ; yes
  1987.     mov    #134745    ,FIRQB+FQNAM1+0    ; no, insert *
  1988.     mov    #134745    ,FIRQB+FQNAM1+2    ; no, insert *
  1989.  
  1990. 20$:    bit    #20    ,xrb+10        ; was a non-null extension passed ?
  1991.     bne    40$            ; yes
  1992.     bit    #10    ,xrb+10        ; no extension, was the extension an
  1993.     bne    40$            ; explicit null (ie, abcdef.) ?
  1994.     mov    #134745    ,FIRQB+FQNAM1+4    ; no, stuff .* into the filespec
  1995.  
  1996. 40$:    mov    #dirfir    ,r4        ; save the FIRQB save area pointer
  1997.     mov    #FIRQB    ,r3        ; and a pointer to the FIRQB itself
  1998.     mov    #40    ,r0        ; number of bytes to copy
  1999. 50$:    movb    (r3)+    ,(r4)+        ; simple
  2000.     sob    r0    ,50$        ; all done saving the FIRQB
  2001.     clc                ; success
  2002.     br    100$            ; bye
  2003.  
  2004. 90$:    sec                ; failure
  2005. 100$:    return                ; bye
  2006.  
  2007.     global    <getuic>
  2008.  
  2009.  
  2010.     .sbttl    more routines for dodir
  2011.  
  2012.  
  2013. dircvt:    save    <r0,r1,r2>
  2014.     mov    r3    ,-(sp)        ; save the pointer please
  2015.     mov    #FIRQB+FQNAM1,r2    ; first three characters of filename
  2016.     calls    rdtoa    ,<r3,(r2)+>    ; convert it
  2017.     add    #3    ,r3        ; and fix the pointer up
  2018.     calls    rdtoa    ,<r3,(r2)+>    ; convert it
  2019.     add    #3    ,r3        ; and fix the pointer up
  2020.     movb    #'.    ,(r3)+        ; stuff a dot in please
  2021.     calls    rdtoa    ,<r3,(r2)+>    ; convert it
  2022.     add    #3    ,r3        ; bump the pointer along please
  2023.     movb    #40    ,(r3)+        ; some spaces
  2024.     movb    #40    ,(r3)+        ; some spaces
  2025.     mov    FIRQB+16,r0        ; the file size
  2026.     deccvt    r0,r3,#6        ; convert it to ascii
  2027.     add    #6    ,r3        ; point past the number now
  2028.     movb    #40    ,(r3)+        ; some spaces
  2029.     movb    #40    ,(r3)+        ; some spaces
  2030.     mov    FIRQB+24,r2        ; save the date of creation
  2031.     calls    asctim    ,<r3,FIRQB+26>    ; convert the time
  2032.     mov    (sp)    ,r3
  2033.     strlen    r3            ; get the current length
  2034.     add    r0    ,r3        ; and point to the new end of it
  2035.     calls    ascdat    ,<r3,r2>    ; and get the date
  2036.     strcat    r3    ,#dcrlf        ; append crlf
  2037.     mov    (sp)+    ,r3        ; point back to the string
  2038.     unsave    <r2,r1,r0>
  2039.     return
  2040.     
  2041.  
  2042. dirnex:    mov    #dirfir    ,r4        ;
  2043.     mov    #FIRQB    ,r3        ; and a pointer to the FIRQB itself
  2044.     mov    #40    ,r0        ; number of bytes to copy
  2045. 20$:    movb    (r4)+    ,(r3)+        ; simple
  2046.     sob    r0    ,20$        ; all done loading the FIRQB
  2047.     mov    diridx    ,FIRQB+4    ; store the index for the file
  2048.     movb    #lokfq    ,FIRQB+3    ; directory lookup please
  2049.     CALFIP                ; get fip to do it please
  2050.     movb    FIRQB    ,r0        ; did it work ?
  2051.     bne    90$            ; no
  2052.     mov    #dirbuf    ,r3        ; point to the string buffer
  2053.     call    dircvt            ; yes, convert it please
  2054.     inc    diridx            ; setup for the next time
  2055.     clc                ; success
  2056.     return                ; failure
  2057.  
  2058. 90$:    tst    diridx            ; error, did we already find a file?
  2059.     beq    100$            ; no, retain error code
  2060.     clr    r0            ; yes, return zero and C set
  2061. 100$:    clr    diridx            ; clear for next time around
  2062.     sec
  2063.     return
  2064.  
  2065.  
  2066.     .save
  2067.     .psect    $PDATA    ,D
  2068. wild:    .asciz    /*.*/
  2069.     .even
  2070.     .restore    
  2071.  
  2072.  
  2073.  
  2074.     .sbttl    force a xon to the connect line
  2075.  
  2076. ;    T T X O N
  2077. ;
  2078. ;    input:    @r5    device name, asciz
  2079. ;        2(r5)    lun (for rsxm/m+ compatibility)
  2080. ;    output:    r0    error code
  2081.  
  2082.  
  2083. ttxon::    save    <r1>            ; save a temp register
  2084.     mov    @r5    ,r1        ; passed address of 0 or a null string?
  2085.     beq    80$            ; no address, assume _KB:
  2086.     tstb    @r1            ; null string passed ?
  2087.     beq    80$            ; yes, assume the console terminal
  2088.     call    ttpars            ; parse the terminal device name
  2089.     bcs    90$            ; oops
  2090. 10$:    clrxrb                ; insure no defaults
  2091.     mov    #xrb    ,r1        ; point to the xrb now
  2092.     mov    #5    ,(r1)+        ; force to kb: function for .SPEC
  2093.     inc    (r1)+            ; one byte to force please
  2094.     mov    #$xon    ,(r1)+        ; address of the buffer for output
  2095.     mov    #ttyhnd*400,(r1)+    ; channel zero, device driver index
  2096.     mov    r0    ,(r1)+        ; terminal number
  2097.     .spec                ; simple
  2098.     br    90$
  2099.  
  2100. 80$:    mov    #6    ,r0        ; ?invalid device name
  2101.     br    100$            ; bye
  2102. 90$:    movb    FIRQB    ,r0        ; error, return it please
  2103. 100$:    unsave    <r1>            ; pop the register we saved
  2104.     return
  2105.  
  2106.  
  2107.  
  2108.     .sbttl    printer spooling for RSTS
  2109.  
  2110.  
  2111.     .iif ndf, UU.SPL, UU.SPL = -28.
  2112.  
  2113.  
  2114. ;    Q S P O O L
  2115. ;
  2116. ;    calls QSPOOL    ,<address(filename)>
  2117. ;
  2118. ;    returns:    r0 := rsts error code (if any)
  2119.  
  2120.     .save
  2121.     .psect    $PDATA    ,D
  2122. sp.dev::.word    0
  2123. sp.mod::.word    0            ; use 4!40 for delete and noheader
  2124.     .restore
  2125.  
  2126. qspool::save    <r1>
  2127.     call    l$fss            ; do the .FSS now
  2128.     tst    r0            ; fail ?
  2129.     bne    100$            ; yes, exit
  2130.     mov    #FIRQB+16,r1        ; stuff the rest of the params
  2131.     mov    #"LP    ,(r1)+        ; LP of course
  2132.     movb    sp.dev    ,(r1)+        ; assume LP0 for a moment
  2133.     movb    #377    ,(r1)+        ; unit is real for sure
  2134.     clr    (r1)+            ; must be zero
  2135.     mov    sp.mod    ,(r1)+        ; /nodelete/header
  2136.     movb    #UU.SPL    ,FIRQB+FQFUN    ; uuo function code to do
  2137.     .UUO                ; simple to do
  2138.     movb    FIRQB    ,r0        ; return any error codes
  2139. 100$:    unsave    <r1>            ; pop temps and exit
  2140.     return
  2141.  
  2142.  
  2143.  
  2144.  
  2145.     .sbttl    inqterm    get terminal type (v9.x only)
  2146.  
  2147. ;    Assume:    Login.com did a $ SET TER/INQ
  2148.  
  2149.     .enabl    lsb
  2150.  
  2151. inqter:    call    inqv9            ; /39/ RSTS/E 9.x ?
  2152.     bcs    90$            ; /39/ no
  2153.     clrfqb                ; /39/ clear out again
  2154.     movb    #UU.TRM    ,FIRQB+FQFUN    ; /39/ terminal char function
  2155.     mov    #1+<400*377>,FIRQB+4    ; /39/ subfunction 1, KB:
  2156.     .UUO                ; /39/ read chars
  2157.     tstb    FIRQB            ; /39/ success?
  2158.     bne    90$            ; /39/ no
  2159.     mov    #200$    ,r0        ; /39/ yes, look for VT type term
  2160. 10$:    tstb    @r0            ; /39/ end of list yet?
  2161.     beq    90$            ; /39/ yes, return( TTY )
  2162.     cmpb    (r0)+    ,FIRQB+6    ; /39/ no, check for a match
  2163.     bne    10$            ; /39/ not yet
  2164.     mov    #VT100    ,r0        ; /39/ yes, return(VT100)
  2165.     br    100$            ; /39/ exit
  2166.  
  2167. 90$:    mov    #TTY    ,r0        ; /39/ nothing
  2168. 100$:    return                ; /39/ exit
  2169.  
  2170.  
  2171.     .save
  2172.     .psect    $PDATA    ,D
  2173. 200$:    .byte    6.            ; /39/  vt100
  2174.     .byte    13.            ; /39/  vt101
  2175.     .byte    14.            ; /39/  vt102
  2176.     .byte    15.            ; /39/  vt125
  2177.     .byte    16.            ; /39/  vt131
  2178.     .byte    17.            ; /39/  vt132
  2179.     .byte    18.            ; /39/  vt220
  2180.     .byte    19.            ; /39/  vt240
  2181.     .byte    20.            ; /39/  vt241
  2182.     .byte    21.            ; /39/  vt105
  2183.     .byte    22.            ; /39/  vk100 (gigi)
  2184.     .byte    23.            ; /39/  rt02
  2185.     .byte    48.            ; /58/  VT330
  2186.     .byte    49.            ; /58/  VT430
  2187.     .byte    0            ; /39/  end
  2188.     .even
  2189.     .restore
  2190.     .dsabl    lsb
  2191.  
  2192.  
  2193.     .sbttl    login
  2194.  
  2195.  
  2196.     .iif ndf , UU.CHK,    UU.CHK = 40
  2197.     .iif ndf , UU.PRV,    UU.PRV = 34
  2198.     .iif ndf , NOSUCH,    NOSUCH = 5
  2199.     .iif ndf , NOTAVL,    NOTAVL = 10
  2200.     .iif ndf , PRVIOL,    PRVIOL = 12
  2201.     .iif ndf , QUOTA ,    QUOTA  = 105
  2202.  
  2203. ;    LOGIN    24-Sep-85  10:01:33  Brian Nelson (V9.x and later only)
  2204. ;        Added on Edit 2.36
  2205. ;        Moved to K1180S 11-Apr-86  12:27:18
  2206.  
  2207.  
  2208.  
  2209.  
  2210.     .sbttl    Check for given privilege (V9.x and later)
  2211.  
  2212. ;     SETPRV is intended to reset the CURRENT privilege mask to the
  2213. ;    user's AUTHORIZED mask. They could be different as a result of
  2214. ;    the REMOTE LOGIN command, moving from a high access account to
  2215. ;    once with lesser access.
  2216.  
  2217. setprv::sub    #12    ,sp        ; a buffer
  2218.     mov    #JFSYS    ,XRB+0        ; drop all privs that are not mine
  2219.     .CLEAR                ; in case we inherited privilege
  2220.     clrfqb                ; now read the authorized priv mask
  2221.     movb    #UU.PRV    ,FIRQB+FQFUN    ; UUO function code
  2222.     .UUO                ; simple
  2223.     mov    #FIRQB+FQFIL,r0        ; and save them
  2224.     mov    sp    ,r2        ; copy them onto stack save area
  2225.     mov    (r0)+    ,(r2)+        ; copy
  2226.     mov    (r0)+    ,(r2)+        ; ..copy
  2227.     mov    (r0)+    ,(r2)+        ; ....copy
  2228.     mov    (r0)+    ,(r2)+        ; ......copy
  2229.     mov    #JFSYS    ,XRB+0        ; now get all we had back again
  2230.     .SET                ; simple
  2231.  
  2232.     clrfqb                ; 
  2233.     movb    #UU.PRV    ,FIRQB+FQFUN    ; read current privilege
  2234.     .UUO                ; call RSTS to do so
  2235.     mov    #FIRQB+FQFIL,r0        ; now setup to copy current over
  2236.     mov    #FIRQB+FQNAM2,r1    ; the current mask to the 'clear'
  2237.     mov    #4    ,r2        ; mask
  2238. 10$:    mov    @r0    ,(r1)+        ; copy the privilege mask
  2239.     clr    (r0)+            ; and clear this one out
  2240.     sob    r2    ,10$        ; next please
  2241.     movb    #UU.PRV    ,FIRQB+FQFUN    ; now drop ALL privileges we had
  2242.     .UUO                ; simple
  2243.     clrfqb                ; At last, make current privs the
  2244.     mov    sp    ,r2        ; ones that the user is authorized
  2245.     mov    #FIRQB+FQFIL,r1        ; to have
  2246.     mov    (r2)+    ,(r1)+        ; insert these privileges
  2247.     mov    (r2)+    ,(r1)+        ; ..insert these privileges
  2248.     mov    (r2)+    ,(r1)+        ; ....insert these privileges
  2249.     mov    (r2)+    ,(r1)+        ; ......insert these privileges
  2250.     movb    #UU.PRV    ,FIRQB+FQFUN    ; at last, set the correct mask
  2251.     .UUO                ; simple
  2252.     add    #12    ,sp        ; exit
  2253.     mov    #1    ,r0        ;
  2254.     return
  2255.  
  2256.  
  2257. chkprv::mov    2(sp)    ,r1        ; get address of priv to look for
  2258.     clrfqb                ; clear the FIRQB out
  2259.     mov    #FIRQB+FQFUN,r0        ; setup to get the bit value of WACNT
  2260.     movb    #UU.CHK    ,(r0)+        ; UUO subfunction
  2261.     inc    (r0)+            ; UU.CHK subfunction
  2262.     tst    (r0)+            ; not used
  2263. 10$:    movb    (r1)+    ,(r0)+        ; copy the desired priv to check
  2264.     bne    10$            ; next please
  2265.     .UUO                ; try it out
  2266.     movb    FIRQB    ,r0        ; if this fails its not verison 9.x
  2267.     bne    90$            ; or later
  2268.     movb    FIRQB+4    ,r0        ; success, check if priv is present
  2269.     bne    90$            ; no
  2270.     mov    #1    ,r0        ; yes, return(1)
  2271.     br    100$            ; exit
  2272. 90$:    clr    r0            ; no,  return(0)
  2273. 100$:    mov    (sp)+    ,(sp)        ; pop stack and exit
  2274.     return                ; bye
  2275.  
  2276.  
  2277. inqv9::    clrfqb                ; /39/ clear FIRQB out
  2278.     clr    ver9.x            ; /40/ assume old RSTS/E
  2279.     movb    #UU.PRV    ,FIRQB+FQFUN    ; /39/ see if version 9 or later
  2280.     .UUO                ; /39/ always works (read priv mask)
  2281.     tstb    FIRQB            ; /39/ success?
  2282.     bne    90$            ; /39/ no
  2283.     mov    sp    ,ver9.x        ; /40/ flag for v9.x and later
  2284.     clc                ; /39/ v.9x
  2285.     return                ; /39/ exit
  2286. 90$:    sec                ; /39/ not 9.x
  2287.     return                ; /39/ return
  2288.  
  2289.  
  2290.  
  2291.     .sbttl    check for current JOB priv , not PROGRAM priv.
  2292.  
  2293. ;     Added edit  2.41 to check if a user has HWCFG authorized to
  2294. ;    effect a SET LINE command. Note that this  will  not  affect
  2295. ;    the  current mask, it just checks to see if the JOB has this
  2296. ;    priv. This is different than UU.CHK in that here we look  at
  2297. ;    current  'JOB'  mask  where  the other (CHKPRV) looks at the
  2298. ;    CURRENT program priv mask. To find AUTHORIZED priv, you must
  2299. ;    call AUTHPR.
  2300. ;     Added cause the  M+  v3  Kermit will get and drop privs for
  2301. ;    SET LINE.
  2302. ;
  2303. ;    Passed:    2(sp)    Address of priv name to check
  2304. ;    Return:    r0    1 for success (or pre 9.x), zero for no priv
  2305. ;
  2306. ;    Example:
  2307. ;
  2308. ;    mov    #HWCFG    ,-(sp)
  2309. ;    call    JOBPRV
  2310. ;    tst    r0
  2311. ;    beq    error
  2312. ;
  2313. ;
  2314. ; hwcfg:.asciz    /HWCFG/
  2315. ;    .even
  2316.  
  2317.  
  2318.  
  2319. jobprv::mov    r1    ,-(sp)        ; /41/ Save a register
  2320.     mov    r2    ,-(sp)        ; /41/ ... save another one
  2321.     sub    #10    ,sp        ; /41/ temp save area
  2322.     mov    #1    ,r2        ; /41/ Assume success
  2323.     tst    ver9.x            ; /41/ version nine or later?
  2324.     beq    100$            ; /41/ no, return( success )
  2325.     clrfqb                ; /41/
  2326.     mov    #FIRQB+3,r1        ; /41/ point to FQFUN offset
  2327.     movb    #UU.PRV    ,(r1)+        ; /41/ read current priv mask.
  2328.     .UUO                ; /41/ Do it
  2329.     tstb    FIRQB            ; /41/ Check status (has to work)
  2330.     bne    90$            ; /41/ Return( failure )
  2331.     mov    sp    ,r0        ; /41/ a pointer to mask save area
  2332.     mov    (r1)+    ,(r0)+        ; /41/ save current priv mask
  2333.     mov    (r1)+    ,(r0)+        ; /41/ .save current priv mask
  2334.     mov    (r1)+    ,(r0)+        ; /41/ ..save current priv mask
  2335.     mov    (r1)+    ,(r0)+        ; /41/ ...save current priv mask
  2336.     mov    #JFSYS    ,XRB+0        ; /41/ what to do
  2337.     .CLEAR                ; /41/ Drop ALL privs now
  2338.     clrfqb                ; /41/ clear firqb out
  2339.     mov    #FIRQB+FQFUN,r0        ; /41
  2340.     movb    #UU.CHK    ,(r0)+        ; /41/ Convert priv name to bitmask
  2341.     inc    (r0)+            ; /41/ Subfunbction code = 1
  2342.     tst    (r0)+            ; /41/ skip this field
  2343.     mov    2+14(sp),r1        ; /41/ copy the priv over
  2344. 10$:    movb    (r1)+    ,(r0)+        ; /41/ copy the asciz name over
  2345.     bne    10$            ; /41/ simple
  2346.     .UUO                ; /41/ convert NAME to MASK
  2347.     mov    sp    ,r1        ; /41/ point back to save area
  2348.     mov    #FIRQB+FQNAM1,r0    ; /41/ Where the bit pattern is
  2349.     mov    #4    ,r2        ; /41/ Four words to check
  2350. 20$:    bit    (r0)+    ,(r1)+        ; /41/ Any bit(s) set here ?
  2351.     bne    30$            ; /41/ Yes, we have it
  2352.     sob    r2    ,20$        ; /41/ No, keep looking
  2353.     clr    r2            ; /41/ Flag not found
  2354.     br    40$            ; /41/ Restore old priv mask
  2355. 30$:    mov    #1    ,r2        ; /41/ Flag we have it
  2356. 40$:    clrfqb                ; /41/ Now restore JOB privs
  2357.     mov    #FIRQB+FQFUN,r0        ; /41/ point to FQFUN offset
  2358.     movb    #UU.PRV    ,(r0)+        ; /41/ read current priv mask.
  2359.     mov    sp    ,r1        ; /41/ Saved OLD priv mask
  2360.     mov    (r1)+    ,(r0)+        ; /41/ save current priv mask
  2361.     mov    (r1)+    ,(r0)+        ; /41/ .save current priv mask
  2362.     mov    (r1)+    ,(r0)+        ; /41/ ..save current priv mask
  2363.     mov    (r1)+    ,(r0)+        ; /41/ ...save current priv mask
  2364.     .UUO                ; /41/ Do it
  2365.     br    100$            ; /41/ exit
  2366.  
  2367. 90$:    clr    r2            ; /41/ failure
  2368. 100$:    mov    r2    ,r0        ; /41/ Return the status now
  2369.     add    #10    ,sp        ; /41/ Pop buffer
  2370.     mov    (sp)+    ,r2        ; /41/ ...Pop a register
  2371.     mov    (sp)+    ,r1        ; /41/ Pop a register
  2372.     mov    (sp)+    ,(sp)        ; /41/ pop parameter
  2373.     return                ; /41/ At last
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.     .sbttl    setcc    setup a control C trap
  2381.  
  2382.  
  2383. ;    SETCC    arm the control C trap
  2384. ;    TTAST    field the ast
  2385. ;
  2386. ;    It would be REALLY nice if we had the equivalent of an IO.KIL
  2387. ;    so we could cancel a pending terminal read as I do in the RSX
  2388. ;    based Kermits. While it is true that control C will terminate
  2389. ;    a read on your console terminal, we need to be able to cancel
  2390. ;    a read that's waiting on another terminal,  as is the case if
  2391. ;    Kermit is running LOCAL (set lin ttnn:).  Hopefully, some day
  2392. ;    DIGITAL will provide that.
  2393.  
  2394.  
  2395.  
  2396. setcc::    mov    #ttast    ,@#24
  2397.     .ttrst
  2398.     .ttech
  2399.     return
  2400.  
  2401. ttast:    save    <r0,r1>
  2402.     call    cctrap
  2403.     mov    #lunsize*2,r1
  2404. 10$:    tst    linit(r1)
  2405.     beq    20$
  2406.     mov    r1    ,-(sp)
  2407.     asr    (sp)
  2408.     call    snoecho
  2409. 20$:    sub    #2    ,r1
  2410.     bge    10$
  2411.     unsave    <r1,r0>
  2412.     rti
  2413.  
  2414.     global    <cctrap>
  2415.  
  2416.  
  2417. ;    dummy epts and symbols for rsx11m/m+ compatibility
  2418.  
  2419. tidias::
  2420. tidiar::return
  2421. tmsdia::
  2422. setsla::clr    r0
  2423.     return
  2424.  
  2425. wtmask    ==    0            ; dummy definitions for event flags
  2426. ef.co    ==    0            ; used under RSX
  2427. ef.ti    ==    0
  2428. bit.co    ==    0
  2429. bit.ti    ==    0
  2430. sf.gmc    ==    2560 
  2431. sf.smc    ==    2440 
  2432. tc.fdx    ==    64 
  2433. tf.ral    ==    10    
  2434. tc.tbf    ==    71    
  2435. tc.slv    ==    0
  2436. tc.abd    ==    0
  2437. tc.dlu    ==    0
  2438. tc.xsp    ==    0
  2439. tc.rsp    ==    0
  2440. tf.rne    ==    20
  2441. tf.wal    ==    10
  2442.  
  2443.     .save
  2444.     .psect    $PDATA    ,D
  2445. fu$def::.word    177777            ; do we need a defdir for RMS11v2
  2446.     .restore
  2447.  
  2448. xdorsx::call    doconn
  2449.     return
  2450.  
  2451.     global    <doconn>
  2452.  
  2453. rstsrv::clr    r0
  2454.     return
  2455.  
  2456.  
  2457.  
  2458.     .end
  2459.