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

  1.     .title    k11m41    kermit i/o for RSX11M/M+ v4.1 and 2.1
  2.  
  3.     .ident    /5.0.05/    ; Jerry Hudgins (see below)
  4.  
  5. ;    define macros and things we want for KERMIT-11
  6.  
  7.  
  8.  
  9.  
  10.     .if ndf, K11INC
  11.     .ift
  12.     .include    /IN:K11MAC.MAC/
  13.     .endc
  14.  
  15.     .iif ndf, k11inc, .error ; INCLUDE for IN:K11MAC.MAC failed
  16.     .enabl    gbl
  17.  
  18.  
  19. ;    Copyright (C) 1983 1984 1985 1986  Change Software, Inc.
  20. ;
  21. ;
  22. ;    This software is furnished under a license and may
  23. ;    be  used  and  copied  only in accordance with the
  24. ;    terms of such license and with  the  inclusion  of
  25. ;    the  above copyright notice.  This software or any
  26. ;    other copies thereof may not be provided or other-
  27. ;    wise made available to any other person.  No title
  28. ;    to and ownership of the software is hereby  trans-
  29. ;    ferred.
  30. ;
  31. ;    The information in this  software  is  subject  to
  32. ;    change  without notice and should not be construed
  33. ;    as a commitment by the author.
  34. ;
  35. ;
  36.  
  37.     .sbttl    edits
  38.  
  39.  
  40. ;    20-Jan-84  09:50:18 BDN    Test and fix TTSPEED, SETSPD and BINREAD
  41. ;
  42. ; 03-Mar-84 Bob Denny    4.2.00  [RBD01]
  43. ;            Rewrote namcvt().  Eliminated FCS parsing
  44. ;            in favor of home-brew code which can handle
  45. ;            the infinite variety of filespecs that may
  46. ;            crop up when doing DECnet remote file access.
  47. ;
  48. ; 07-Mar-84 Bob Denny    5.0.00  [Edit trails removed]
  49. ;            Fair rewrite, particularly of terminal handling.
  50. ;            Changed within the existing KERMIT-11 architecture,
  51. ;            which is better suited to RSTS/E (which seems to
  52. ;            have a lot more terminal & communications options).
  53. ;            Modes for RSX now allow operation at 9600 baud for
  54. ;            packet communication.  CONNECT is still a problem.
  55. ;
  56. ; 10-Mar-84 Bob Denny    5.0.01   The method used for CONNECT on RSTS/RSX
  57. ;            will not work reliably on native RSX at baud rates
  58. ;            over 1200 on a busy system.  The "doconn()" routine
  59. ;            was rewritten.  Now there are 2 separate modules.
  60. ;            Also, the binrea() function is now used only for
  61. ;            packet reading, and has been greatly simplified.
  62. ;
  63. ; 16-mar-84 Brian Nelson
  64. ;
  65. ;            Merged origional K11M41 with Bob Denny's mods.
  66. ;
  67. ; 11-Dec-85 Robin Miller 5.0.02  Attach the terminal in the TTYINI routine
  68. ;    (RTM01)        so incoming characters are not lost.  On a /SLAVE
  69. ;            terminal, the terminal must be attached so charac-
  70. ;            ters will be placed in the typeahead buffer.
  71. ;            Also detach the terminal in the TTYFIN routine.
  72. ;
  73. ; 11-Dec-85 Robin Miller 5.0.03  Change routine TTPARS to allow device names
  74. ;    (RTM02)        other name XK, TI, or TT for logical names.  Also
  75. ;            check for an error from ALUN$S directive in ASSDEV.
  76. ;
  77. ; 12-Dec-85 Robin Miller 5.0.04  Change routine ASSDEV to check for logged
  78. ;    (RTM03)        on terminal and to get real device name via GLUN$
  79. ;            incase we've assigned a logical name.
  80. ;
  81. ;
  82. ; 25-Dec-85 Brian Nelson
  83. ; 08-Feb-86 Steve Heflin
  84. ; 10-Feb-86 Brian Nelson
  85. ;            Finish added Steve Heflin's mods for ATOZ in.
  86. ;
  87. ; 03-Feb-89 Jerry Hudgins 5.0.05
  88. ;            Moved GETPRV call in ASSDEV to ensure priv's are
  89. ;            up for SF.SMC; will otherwise crash M+ V4.0.  Set
  90. ;            priv's on in EXIT routine also.
  91. ;
  92. ;
  93. ;    RSX11M,M+ and P/OS support.
  94. ;
  95. ;    If this looks like it's a mess, it's because it IS. It gets changed
  96. ;    a little bit here and there (for the past 2 years),  and thus has a
  97. ;    number of contributions and changes from others, and changes due to
  98. ;    'NEW' versions of M+ and MicroRSX (ie, things stop working).
  99.  
  100.     .sbttl    macros
  101.  
  102.  
  103.     .macro    moverr    val,dst
  104.     movb    val    ,-(sp)
  105.     call    $mover
  106.     movb    (sp)+    ,dst
  107.     .endm    moverr
  108.  
  109.     .iif ndf, r$rsts, r$rsts = 0
  110.  
  111.  
  112.     .save
  113.     .psect    CLECTX    ,RW,D,GBL,REL,CON
  114.     .restore
  115.  
  116.     ef.tmp    =    17
  117.     ef.tt    =    20
  118.     ef.tmo    =    21
  119.     er.tmo    ==    176        ; for now, timeout
  120.     er.nod    ==    177        ; pseudo error for no data
  121.     nodata    ==    er.nod
  122.  
  123.     .library    /LB:[1,1]EXEMC.MLB/
  124.     .mcall    UCBDF$
  125.     UCBDF$
  126.  
  127.     .sbttl    data areas
  128.  
  129.     .psect    $idata    rw,d,lcl,rel,con
  130.  
  131. fu$def::.word    0            ; if rms needs the DNA filled in
  132. ;    The following defaults can be changed in the TKB command file as in:
  133. ;
  134. ;    GBLPAT=K11PAK:DO$APP:1
  135. ;    GBLPAT=K11PAK:DO$APP:0
  136. ;    GBLPAT=K11PAK:DO$APP:0
  137.  
  138. do$dte::.word    0            ; if NE, force PROCOMM to default
  139. do$app::.word    0            ; if NE, then append to logfiles
  140. do$msg::.word    1            ; if EQ, then don't be verbose at times
  141. do$tra::.word    1            ; if we look in logical name tables
  142.                     ; for an available terminal.
  143. do$alt::.word    1            ; Force SET RSX CON ALT
  144.  
  145.     .psect    $idata    rw,d,lcl,rel,con
  146.  
  147. ;
  148. ; Terminal settings and parameter lists for line setting
  149. ;
  150. ;
  151. ;    Add mods from Steve Heflin in (SSH and /41/ comments)
  152. ;
  153. ;    Do not include the TC.TBC in the main GMC or SMC as we will
  154. ;    not know if we are running on M, M+ or Micro-RSX. TC.TBS is
  155. ;    not available on M. If built on M, the undefined global for
  156. ;    TC.TBS won't hurt anything.   BDN 20-DEC-1985 10:29
  157.  
  158. savass:                    ; Remote line saved attributes
  159. savdlu::.byte    TC.DLU,0        ; /{no}REMOTE           /41/
  160.     .byte   TC.SLV,0                ; /{no}SLAVE
  161.     .byte    TC.BIN,0        ; /{no}READ_PASSALL       /45/
  162.     .byte    TC.NEC,0        ; /{no}ECHO           /41/
  163.     .byte    TC.RAT,0        ; /{no}TYPEAHEAD       /41/
  164.     .byte    TC.8BC,0        ; /{no}EIGHT_BIT       /41/
  165. savtbs:    .byte    TC.TBS,0        ; typeahead buffer size       /41/
  166.     .byte    TC.NBR,0        ; /{no}BROADCAST       /41/
  167. diarst    = . - savass            ; Restore this much for DIAL /45/
  168. savxsp: .byte    TC.XSP,0        ; /SPEED:xmt           /41/
  169. savrsp: .byte    TC.RSP,0        ; /SPEED:rcv           /41/
  170. asvlen = .-savass            ;               /41/
  171.  
  172.  
  173.  
  174. setass: .byte   TC.SLV,1                ; /SLAVE=TTnn:
  175.     .byte    TC.NEC,1        ; /NOECHO           /41/
  176.     .byte    TC.RAT,1        ; /TYPEAHEAD           /41/
  177.     .byte    TC.8BC,1        ; /EIGHT_BIT           /41/
  178. settbs:    .byte    TC.TBS,220.        ; typeahead buffer size       /41/
  179.     .byte    TC.NBR,1        ; /NOBROADCAST           /41/
  180. astlen = .-setass            ;               /41/
  181.  
  182.  
  183. assdon: .word   0            ; flag remote save/set done
  184.  
  185. aslspd:                    ; Assigned line speed block/41/
  186. aslxsp::.byte    TC.XSP,0        ; /SPEED:xmt           /41/
  187. aslrsp::.byte    TC.RSP,0        ; /SPEED:rcv           /41/
  188.  
  189. iopend:    .word    0            ; /36/ lun i/o waiting on
  190.  
  191. savchr:                    ; Saved line parameters
  192.     .byte    TC.ACR,0        ; /{NO}WRAP
  193.     .byte    TC.FDX,0        ; /{NO}FULLDUPLEX
  194.     .byte    TC.HFF,0        ; /{NO}FORMFEED
  195.     .byte    TC.HHT,0        ; /{NO}TAB
  196.     .byte    TC.NEC,0        ; /{NO}ECHO
  197.     .byte    TC.SLV,0        ; /{NO}SLAVE
  198.     .byte    TC.SMR,0        ; /{NO}LOWERCASE
  199.     .byte    TC.WID,0        ; /WIDTH = n
  200.     .byte    TC.8BC,0        ; /{NO}EIGHTBIT
  201.     .byte    TC.BIN,0        ; /{NO}RPA    (BDN 04-Aug-84)
  202. savlen = .-savchr
  203. savdon:    .word    0
  204. ;
  205. ; Local line buffer for binary reading
  206. ;
  207. inilun:    .word    0
  208. linbuf:    .blkb    MAXLNG+<MAXLNG/10>        ; /42/ (larger) Buffer itself
  209.     .even                    ; /42/ Safety
  210. maxlin     =     .-linbuf            ; Maximum read length
  211.     .even
  212. linptr:    .word    linbuf                ; Scan pointer
  213. icrem:    .rept    15.                ; # characters remaining
  214.     .word    0
  215.     .endr
  216. privon:    .word    0                ; /41/ Save priv on/off status
  217.  
  218.     ALSIZE    ==    440
  219.     SDBSIZ    ==    440
  220.  
  221. $albuf:    .blkb    ALSIZE                ; /51/ Moved from K11DAT
  222. $phnum:    .blkb    60
  223. $lnrea::.word    RDLIN            ; Default for packet reading
  224.  
  225. ; Other r/w data for dialout line set routines                /45/
  226. ;
  227.     .psect    rwdata    ,rw,d,lcl,rel,con ; read/write data
  228.  
  229. ;  Buffers for Autocall modem fix    ;                /45/
  230.  
  231. fixti2:    .byte    TC.DLU,2,TC.ABD,0    ; values we need for a modem    /45/
  232. sizti2 = . - fixti2            ; size of buffers for autocall    /45/
  233.  
  234.  
  235.  
  236. ; Read only code section
  237.  
  238.  
  239.     .psect    $pdata    ro,d,lcl,rel,con    ; Read-only data
  240.  
  241.  
  242. ; System Macros used to get/set characteristics for dial out        /45/
  243.  
  244.     .mcall    qiow$,dir$        ; call in system macroes    /45/
  245.  
  246.     ef.rem = 14.            ; use remote event flag (14)    /45/
  247.  
  248. set.dlu:    qiow$ sf.smc,lun.ti,ef.rem,,,,<fixti2,sizti2>    ;    /45/
  249. set.chars:  qiow$ sf.smc,lun.ti,ef.rem,,,,<diachr,dialen>     ;    /45/
  250. rest.chars: qiow$ sf.smc,lun.ti,ef.rem,,,,<datchr,datlen>    ;    /45/
  251.  
  252. ;    M+3.0 Carrier loss detection
  253.  
  254. dtrast:    .byte    TC.MHU,0
  255.     .word    carast        
  256. dtrclr:    .byte    TC.MHU,0
  257.     .word    0
  258.  
  259.  
  260. ; Attributes needed to dialout                        /45/
  261.  
  262. diachr:    .byte    TC.BIN,1    ; binary mode to pass CNTR chars    /45/
  263. dialen = .-diachr        ; - length of dialout char set        /45/
  264.  
  265.  
  266.  
  267. ; Other r/w data
  268.  
  269.  
  270.  
  271.     .psect    $pdata    ro,d,lcl,rel,con    ; Read-only data
  272.  
  273. datchr:                        ; Data mode line parameters
  274.     .byte    TC.ACR,0            ; /NOWRAP
  275.     .byte    TC.FDX,1            ; /FULLDUPLEX
  276.     .byte    TC.HFF,1            ; /FORMFEED
  277.     .byte    TC.HHT,1            ; /TAB
  278.     .byte    TC.NEC,1            ; /NOECHO
  279.     .byte    TC.SLV,1            ; /SLAVE
  280.     .byte    TC.SMR,1            ; /LOWERCASE
  281.     .byte    TC.WID,200.            ; /WIDTH = 200.
  282.     .byte    TC.8BC,1            ; /EIGHTBIT
  283.     .byte    TC.BIN,0            ; /NORPA
  284. datlen    = . - datchr
  285. ibmmod:    .byte    tc.bin,1            ; /RPA (need to read XON's)
  286.  
  287.  
  288.  
  289.  
  290.     .sbttl    xinit - assign & attach command terminal
  291.     .mcall    alun$s    ,astx$s    ,QIOW$S    ,SREX$S    ,FEAT$S
  292.  
  293.     FE$EXT    =    1
  294.  
  295.     .psect    $code
  296.  
  297. ; XINIT - Assign and attach the command terminal
  298. ;
  299. ; This routine assigns and attaches the command terminal (the
  300. ; terminal that "ran" this copy of Kermit-11.
  301. ; *** N O T E *** Later, this routine should establish a ^C
  302. ; AST so that user can abort in-progress file transfers, and
  303. ; get Kermit out of server mode without having to send it a
  304. ; finish command.  I'll wait for Brian to send me his changes
  305. ; for graceful transfer abort before I implement this, though.
  306. ;
  307. ; 23-Dec-85  19:28:43 BDN
  308. ;
  309. ;  For P/OS,  M+ v3 and Micro Rsx v3, also do a TLOG (or TRAN) and
  310. ; if we we a translation, do an implicit SET LINE. Can be disabled
  311. ; by setting DO$TRAN eq to zero.
  312.  
  313.     .enabl    lsb
  314.  
  315. xinit::    call    rmsini            ; /53/ Setup SST
  316.     FEAT$S    #FE$EXT            ; /56/ See if 4.2 or M+ 3.x
  317.     bcc    1$            ; /56/ Ok
  318.     mov    sp    ,rsx32        ; /56/ Set 3.2 flag
  319.     SREX$S    #1$            ; /56/ See if this is OLD Rsx (3.2)
  320.     bcs    1$            ; /56/ Must be old RSX
  321.     clr    rsx32            ; /56/ 4.0 or later, or M+ 1.0 and later
  322.     SREX$S                ; /56/ Clear requested exit address
  323. 1$:    mov    #$albuf    ,albuff        ; /51/ Fill in
  324.     mov    #$phnum    ,phnum        ; /51/ Fill in
  325.     clrb    @phnum            ; /51/ Zero it
  326.     clr    @albuff            ; /51/ Init to empty.
  327.     mov    #$cmdbuf,cmdbuf        ; /53/ $CMDBUF defined in K11RMS
  328.     mov    #$argbuf,argbuf        ; /53/ $ARGBUF defined in K11RMS
  329.     mov    do$tran    ,dotran        ; /41/ flag for translation
  330.     mov    do$msg    ,infomsg    ; /41/ flag for msg displaying
  331.     mov    do$app    ,logapp        ; /41/ Append to logfile flag
  332.     mov    do$dte    ,procom        ; /50/ Set default for PRO/COMM
  333.     message    <Linked for RSX11M/M+ and P/OS >
  334.     tst    #dapsup            ; /56/
  335.     bne    4$            ; /56/
  336.     message    <no DAP support>    ; /56/
  337. 4$:    message                ; /56/
  338.     tst    do$alt            ; /46/ Force alternate code?
  339.     beq    5$            ; /46/ No
  340.     mov    #xdorsx    ,con$ds        ; /46/ Yes
  341. 5$:    mov    #xdorsx    ,altcon        ; /44/
  342.     call    getsys            ; Find out whats running
  343.     cmpb    r0    ,#SY$MPL    ; M+?
  344.     bne    10$            ; No
  345.     mov    sp    ,fu$def        ; m+, set SY: as def
  346. 10$:    cmpb    r0    ,#sy$pro    ; p/os?
  347.     bne    20$            ; no
  348.     mov    sp    ,proflg        ; yes, flag it
  349. 20$:    tst    dotran            ; /41/ look for logical name
  350.     beq    30$            ; /41/ no
  351.     CALLS    trntrm    ,<#ttname>    ; /41/ see if translation exits
  352.     tst    r0            ; /41/ did this succeed ?
  353.     bne    30$            ; /41/ no
  354.     MESSAGE    <Logical name translation returned >; /41/ inform the user
  355.     print    #ttname            ; /41/ print the equivalence name
  356.     MESSAGE                ; /41/
  357.     STRCPY    #ttdial    ,#ttname    ; /41/ copy it over here also 
  358.     clr    remote            ; /41/ and we are local
  359.     br    40$            ; /41/ continue
  360. 30$:    tst    proflg            ; /41/ assume default line for P/OS?
  361.     beq    40$            ; /41/ not P/OS
  362.     mov    #poscon    ,con$ds        ; /44/ Force my connect code for p/os
  363.     STRCPY    #ttname    ,#xk$dev    ; /41/ use xk0: device
  364.     STRCPY    #ttdial    ,#xk$dev    ; /41/ use xk0: device
  365.     clr    remote            ; and we are local
  366.     clr    con8bit            ; clear bit 7
  367.     MESSAGE    <Link default set to XK0: for P/OS>,cr    ; tell the user
  368.     CALLS    ttspeed    ,<#ttname>    ; /54/ Find out current speed
  369.     tst    r0            ; /54/ Can't faile
  370.     beq    40$            ; /54/ It did
  371.     MESSAGE    <Current speed: >    ; /54/ A MESSAGE
  372.     DECOUT    r0            ; /54/ Simple
  373.     MESSAGE                ; cr/lf
  374. 40$:    ALUN$S    #LUN.TT,#"TI,#TIUNIT    ; Assign command term.
  375.     QIOW$S    #IO.ATT,#LUN.TT,#EF.TT,,#kbiost; Attach it, also
  376.     QIOW$S    #SF.SMC,#LUN.TT,,,,,<#echoch,#2>
  377.     sub    #10    ,sp        ; /53/ Get terminal driver support
  378.     mov    sp    ,r2        ; /53/ A buffer
  379.     QIOW$S    #IO.GTS,#LUN.TT,,,,,<r2,#4>
  380.     bcs    50$            ; /53/ Oops
  381.     bit    #F2.EIO    ,2(r2)        ; /53/ Extended IO today?
  382.     beq    50$            ; /53/ No
  383.     mov    #eioread,$lnread    ; /53/ M+, try IO.EIO for version 3
  384. 50$:    add    #10    ,sp        ; /53/ Pop buffer
  385.     clr    tcdlu            ; don't change tc.dlu
  386.     call    setcc            ; enable ^C asts
  387.     call    inqter            ; /45/ No, get the terminal type
  388.     mov    r0    ,vttype        ; /45/ Done
  389.     return
  390.  
  391.     .save
  392.     .psect    $xkdev    ,ro,d,lcl,rel,con
  393. echoch:    .byte    TC.NEC,0
  394. xk$dev::.asciz    /XK0:/
  395.     .even
  396.     .dsabl    lsb
  397.     .restore
  398.  
  399.  
  400.     global    <altcon, xdorsx    ,con$ds    ,poscon>    ; /44/
  401.     global    <lun.tt, tiunit>
  402.     global    <ARGBUF,CMDBUF,$ARGBUF,$CMDBUF>    ; /53/
  403.     global    <DAPSUP,RSX32>            ; /56/
  404.  
  405. inqbuf::mov    #200.    ,-(sp)        ; /42/ Assume M+
  406.     call    getsys            ; /42/ M+ today?
  407.     cmpb    r0    ,#SY$MPL    ; /42/ If so, large buffering
  408.     beq    100$            ; /42/ M+
  409.     mov    #500.    ,(sp)        ; /42/ Assume P/OS
  410.     tst    proflg            ; /42/ P/OS and XK:?
  411.     bne    100$            ; /42/ Yes, return(500)
  412.     mov    #90.    ,(sp)        ; /42/ Vanilla RSX11M
  413. 100$:    mov    (sp)+    ,r0        ; /42/ Return buffering available
  414.     return                ; /42/ for LONG PACKET support.
  415.  
  416.  
  417. setcc::    QIOW$S    #io.det,#lun.tt,#ef.tt,,#kbiost
  418.     QIOW$S    #io.ata,#lun.tt,#ef.tt,,#kbiost,,<,0,#ttast>
  419.     return
  420.  
  421.  
  422. ttast:    cmpb    (sp)    ,#'c&37        ; control C ?
  423.     bne    100$            ; no
  424.     call    cctrap            ; yes, call handler to check it
  425.     tst    iopend            ; /36/ Is a QIO pending for packet?
  426.     beq    100$            ; /36/ no
  427.     QIOW$S    #IO.KIL,iopend        ; /36/ Yes, force an IO.ABO error
  428. 100$:    tst    (sp)+
  429.     astx$s                ; and exit from ast service
  430.  
  431.     global    <cctrap>
  432.  
  433.  
  434.  
  435.  
  436.     .sbttl    ttyini - Save & switch line to data mode
  437.  
  438. ;    T T Y I N I
  439. ;
  440. ;    ttyini( %loc device_name ,%val channel_number ,%val ccflag )
  441. ;
  442. ;
  443. ;    input:    @r5    .asciz string of device name (Ignored on native RSX)
  444. ;        2(r5)    channel number (LUN)
  445. ;        4(r5)    mode bits:             (Ignored on native RSX)
  446. ;
  447. ;    output:    r0    error codes
  448. ;
  449. ;    On RSX, this routine does dynamic switching of terminal from
  450. ;    interactive mode(s) to data mode(s).  The ttysav(), ttyset()
  451. ;    and noecho() routines are no-ops ...
  452. ;
  453. ;    It is used only for packet communications.  The "doconn()" in
  454. ;    this module handles the setup and restoration of the terminal
  455. ;    lines for CONNECT modes.
  456. ;
  457. ;    ** Someday, the whole command terminal and communication line handling
  458. ;    architecture should be smoothed out and simplified, once Brian and
  459. ;    I get together and compare notes re: native RSX versus emulated RSX,
  460. ;    and what is required for compatibility without too much pain ...
  461. ;
  462. ;    Added SREX 22-Jun-84  11:15:46  Brian Nelson
  463. ;
  464. ;    Bob Denny
  465. ;
  466.  
  467.     .mcall    srex$s    ,exit$s
  468.  
  469. ttyini::save    <r1>
  470.     call    getprv                ; /41/ May need privs
  471.     call    ttpars                ; Get unit number
  472.     bcs    1$
  473.     alun$s    2(r5),r1,r0            ; Assign LUN
  474.     mov    $dsw,r0                ; get the result
  475.     bcc    2$                ; oops
  476. 1$:    jmp    10$                ; Too far to branch
  477. 2$:    clr    r0                ; Make return success
  478.     clr    savdon                ; not saved tt settings yet
  479.     cmp    2(r5),#lun.co            ; Command terminal (SAFETY)
  480.     beq    10$                ; (yes, ignore this)
  481.     QIOW$S    #io.att,2(r5),#ef.tt        ; Attach the terminal.    (RTM01)
  482.     QIOW$S    #sf.gmc,2(r5),#ef.tt,,#kbiost,,<#savchr,#savlen>
  483.     mov    kbiost,r0
  484.     cmpb    r0,#IS.SUC            ; OK?
  485.     bne    10$                ; (no)
  486.     mov    sp    ,savdon            ; we have done the save
  487.     mov    2(r5)    ,inilun            ; save this lun (BDN)
  488.     srex$s    #abort                ; in case server aborted (BDN)
  489.     tstb    handch                ; IBM crap (BDN 04-Aug-84)
  490.     beq    5$                ; no
  491.     QIOW$S    #sf.smc,2(r5),#ef.tt,,#kbiost,,<#ibmmod,#2> ;
  492. 5$:    QIOW$S    #sf.smc,2(r5),#ef.tt,,#kbiost,,<#datchr,#datlen>
  493.     clr    eioinit                ;
  494.     mov    kbiost,r0
  495.     cmpb    r0,#IS.SUC            ; OK?
  496.     bne    10$                ; (no)
  497.     clr    r0                ; Yes - clear r0 = OK
  498.     QIOW$S    #SF.SMC,2(r5),,,,,<#dtrast,#4>    ; Set this up for carrier loss
  499. 10$:    tst    proflg                ; if a pro/350, ignore errors
  500.     beq    100$                ; not a 350
  501.     clr    r0                ; a 350, forget about the errors
  502. 100$:    unsave    <r1>
  503.     call    drpprv                ; /41/ No privs wanted now
  504.     return
  505.  
  506.  
  507. rstsrv::tst    inserv
  508.     beq    100$
  509.     call    ..abort
  510. 100$:    return
  511.  
  512.  
  513. ..abort:call    getprv            ; /41/ May need privs turned on
  514.     QIOW$S    #sf.smc,inilun,#ef.tt,,#kbiost,,<#savchr,#savlen>
  515.     call    drpprv            ; /41/ Don't want privs anymore
  516.     return
  517.  
  518.  
  519. abort:    call    ..abort
  520.     jmp    exit
  521.  
  522.     global    <inserv>
  523.  
  524.  
  525. ;    T T Y F I N
  526. ;
  527. ;    ttyfin( %loc device_name ,%val channel_number )
  528. ;
  529. ;
  530. ;    input:    @r5    .asciz string of device name (Ignored on native RSX)
  531. ;        2(r5)    channel number (LUN)
  532. ;
  533. ;    No need for ttyrst()
  534. ;
  535.  
  536. ttyfin::call    getprv                ; /41/ May need privs up now
  537.     srex$s                    ; no more abort handling
  538.     cmp    2(r5),#lun.co            ; Command terminal?
  539.     beq    10$                ; (yes, skip it)
  540.     QIOW$S    #SF.SMC,2(r5),,,,,<#dtrclr,#4>    ; Set this up for carrier loss
  541.     QIOW$S    #io.det,2(r5),#ef.tt        ; Attach the terminal.    (RTM01)
  542.     tst    savdon                ; ever save the crap?
  543.     beq    10$                ; no, don't reset it
  544.     QIOW$S    #sf.smc,2(r5),#ef.tt,,,,<#savchr,#savlen>
  545. 10$:    call    drpprv                ; /41/ Don't want privs up
  546.     clr    r0
  547.     return
  548.  
  549. ;    STUB ROUTINES - Not needed here
  550. ;
  551. ttrini::
  552. ttrfin::
  553. ttysav::
  554. ttyset::
  555. ttyrst::
  556. noecho::
  557. echo::
  558.     clr    r0
  559.     return
  560.  
  561.  
  562.  
  563.     .sbttl    get terminal name
  564.  
  565. ;    G T T N A M
  566. ;
  567. ;    input:    @r5    address of 8 character buffer for terminal name
  568. ;    output:        .asciz name of terminal
  569.  
  570.     .mcall    glun$s
  571.  
  572. gttnam::save    <r1,r2,r3>        ; save temps please
  573.     mov    @r5    ,r3        ; point to output buffer please
  574.     sub    #20    ,sp        ; allocate a buffer for GLUN$S
  575.     mov    sp    ,r2        ; point to it please
  576.     glun$s    #lun.tt    ,r2        ; try it
  577.     cmpb    @#$DSW    ,#is.suc    ; did it work ?
  578.     bne    90$            ; no, return the error code please
  579.     movb    g.luna+0(r2),(r3)+    ; get the device name next
  580.     movb    g.luna+1(r2),(r3)+    ; both bytes of it please
  581.     clr    r1            ; get the unit number next please
  582.     bisb    g.lunu(r2),r1        ; simple
  583.     clr    r0            ; now compute the ascii name
  584.     div    #10    ,r0        ; simple (in octal please for RSX)
  585.     mov    r1    ,-(sp)        ; save the low order unit number
  586.     cmp    r0    ,#7        ; unit number > 77 octal ?
  587.     blos    10$            ; no
  588.     mov    r0    ,r1        ; yes, do it again please
  589.     clr    r0            ; simple
  590.     div    #10    ,r0        ; and so on
  591.     add    #'0    ,r0        ; convert to ascii please
  592.     movb    r0    ,(r3)+        ; get the high part copied
  593.     mov    r1    ,r0        ; and now put the next digit back
  594. 10$:    mov    (sp)+    ,r1        ; get the low digit back now
  595.     add    #'0    ,r0        ; convert to ascii
  596.     add    #'0    ,r1        ; likewise
  597.     movb    r0    ,(r3)+        ; move the unit number in now
  598.     movb    r1    ,(r3)+        ; at last ....
  599.     movb    #':    ,(r3)+        ; please insert a colon:
  600.     clrb    @r3            ; make it .asciz
  601.     clr    r0            ; no errors
  602.     br    100$            ; exit
  603. 90$:    moverr    @#$dsw    ,r0        ; get the directive error code
  604. 100$:    add    #20    ,sp        ; pop glun$s buffer
  605.     unsave    <r3,r2,r1>
  606.     return
  607.  
  608.     .sbttl    Vanilla read from command terminal
  609.  
  610.  
  611. ;    K B R E A D
  612. ;
  613. ; Read a line from the command terminal (80 characters max)
  614. ;
  615. ;    Input:    @r5    Address of 80 character buffer
  616. ;
  617. ;    Output:    r0 =    0 if OK, else error code
  618. ;        r1 =     Number of characters if OK, else 0
  619. ;
  620. ;    Echoes a <LF> on completion to counter Dave Cutler's old
  621. ;    FORTRAN record processing view of the world.
  622.  
  623. kbread::
  624.     QIOW$S    #io.rvb,#5,#ef.tt,,#kbiost,,<@r5,#80.>
  625.     clr    r0            ; assume no errors
  626.     mov    kbiost+2,r1        ; return bytecount in r1
  627.     cmpb    kbiost    ,#is.suc    ; successful read ?
  628.     beq    100$            ; yes
  629.     clr    r1            ; no data please
  630.     moverr    kbiost    ,r0        ; return the error
  631. 100$:    print    #lf1
  632.     return
  633.  
  634.     .save
  635.     .psect    $PDATA    ,D
  636. lf1:    .byte    lf,0
  637.     .restore
  638.  
  639.  
  640.  
  641.  
  642.     .sbttl    terminal read/write binary mode
  643.  
  644.  
  645. ;    B I N R E A
  646. ;
  647. ;    binread( %val channel_number, %val timeout )
  648. ;
  649. ;
  650. ;    input:    @r5    channel number
  651. ;        2(r5)    timeout    (if -1, then no wait) (do this for RSX??)
  652. ;
  653. ;    output:    r0    error
  654. ;        r1    character read
  655. ;
  656. ;    This version uses "normal" reading, as KERMIT sends its packets
  657. ;    ending in its "EOL" character, which we need to be a <CR>.  This
  658. ;    makes reading packets a piece'o cake.  We simply buffer lines
  659. ;    here and scan off characters as needed.  Terminal modes have
  660. ;    been set for reasonably low driver overhead.
  661. ;
  662. ;    No longer used by CONNECT
  663. ;
  664.  
  665. pakrea::
  666. binrea::mov    @r5    ,iopend        ; /36/ save lun i/o is waiting on
  667.     tstb    handch            ; doing ibm style xon handshaking  BDN
  668.     beq    5$            ; then we must do single char qios BDN
  669.     call    xbinrea            ; do that and exit           BDN
  670.     br    100$            ; /36/ exit
  671.  
  672. 5$:    save    <r2>
  673.     mov    @r5    ,r2        ; lun to use today
  674.     asl    r2            ; fix it for word indexing
  675. 10$:    tst    icrem(r2)        ; Anything remaining in current line?
  676.     bne    40$            ; (yes)
  677.     jsr    pc    ,@$lnread    ; Call someone to read data
  678.     bcs    50$            ; (read error)
  679.     br    10$            ; Try again
  680.  
  681. 40$:    clr    r1            ; Move next char unsigned ...
  682.     bisb    @linptr,r1        ; ... into r1
  683.     inc    linptr            ; Advance pointer
  684.     dec    icrem(r2)        ; Decrement # characters remaining
  685.     clr    r0            ; Success
  686. 50$:    unsave    <r2>
  687. 100$:    clr    iopend            ; /36/ i/o no longer pending
  688.     return                ; Return
  689.  
  690.  
  691. ;
  692. ; RDLIN - Local read routine
  693. ;
  694. ; Inputs:
  695. ;    @r5    LUN to read on
  696. ;    2(r5)    timeout, seconds
  697. ;
  698. ; Outputs:
  699. ;    C-bit clear    Successful read (something read before timeout)
  700. ;            icrem = number of characters in this line
  701. ;            linptr -> 1st character in the line
  702. ;
  703. ;    C-bit set    Failed
  704. ;            R0 = error code
  705. ;            icrem = 0
  706.  
  707.     .mcall    mrkt$s    ,wtse$s    ,qiow$s
  708.  
  709. rdlin:
  710.     clr    icrem(r2)        ; Reset buffer counter
  711.     mov    #linbuf,linptr        ; Reset scan pointer
  712. 10$:    clr    r0            ; Assume no timeout
  713.     mov    2(r5),r1        ; R1 = timeout in seconds
  714.     ble    20$            ; (no timeout)
  715.     add    #9.,r1            ; Round up to nearest 10 second clicks
  716.     div    #10.,r0            ; Convert to 10 sec. clicks
  717.  
  718. 20$:    tst    proflg            ; pro/350?
  719.     bne    25$            ; yes
  720.     tst    chario            ; force pro/350 style reads today?
  721.     bne    25$            ; yes
  722.     tstb    parity            ; /39/ must check if TTDRV may never
  723.     beq    24$            ; /39/ see it's <CR> to terminate the
  724.     cmpb    parity    ,#PAR$NO    ; /39/ line. Use a read with terminator
  725.     beq    24$            ; /39/ QIO if parity is on.
  726.     br    25$            ; /41/ IO.RTT did not work
  727.  
  728. ;-/41/    mov    #<IO.RTT!TF.RNE!TF.TMO>,r1 ; /39/ 
  729. ;-/41/    QIOW$S    r1,@r5,#ef.tt,,#kbiost,,<#linbuf,#maxlin,r0,#tt$trm> ; /39/
  730. ;-/41/    br    30$            ; /39/
  731.  
  732. 24$:    QIOW$S    #<io.rlb!tf.tmo>,@r5,#ef.tt,,#kbiost,,<#linbuf,#maxlin,r0>
  733.     br    30$
  734.  
  735. 25$:    call    getprv            ; /41/ May need for SF.GMC call
  736.     clr    -(sp)            ; get the typehead buffer size
  737.     mov    sp    ,r1        ; point to the parameter area
  738.     movb    #tc.tbf    ,@r1        ; we want amount in the buffer
  739.     QIOW$S    #sf.gmc,@r5,#ef.tt,,,,<r1,#2>
  740.     movb    1(r1)    ,r1        ; get the typeahead size
  741.     bne    26$            ; we have something to get there
  742.     inc    r1            ; nothing, wait for one character
  743. 26$:    QIOW$S    #<io.ral!tf.tmo!tf.rne>,@r5,#ef.tt,,#kbiost,,<#linbuf,r1,r0>
  744.     tst    (sp)+            ; pop sf.gmc buffer please
  745.     call    drpprv            ; /41/ Drop privs if need be
  746.  
  747. 30$:    movb    kbiost    ,r0        ; /41/
  748.     cmpb    r0    ,#IE.DNR    ; /45/ Did we drop carrier ?
  749.     bne    31$            ; /45/ No
  750.     mrkt$s    #2,#1,#2        ; /45/ Yes, suspend for 1 second
  751.     wtse$s    #2            ; /45/ ...
  752.     br    40$            ; /45/ Treat as timeout at upper lev
  753. 31$:    cmpb    r0    ,#IS.TMO    ; timed out on the read ?
  754.     beq    40$            ; yes
  755.     cmpb    r0    ,#IE.ABO    ; /36/ from IO.KIL on control C ast?
  756.     beq    40$            ; /36/ yes, treat as a timeout then
  757.     cmpb    r0    ,#IE.EOF    ; /41/ End of file today (control Z)?
  758.     beq    80$            ; /41/ Yes, return control Z and 1 byte
  759.     cmpb    kbiost+1,#33        ; /47/ Was \033 the terminator?
  760.     beq    80$            ; /41/ Yes, Again return control Z
  761.     cmpb    linbuf    ,#'Z&37        ; /41/ P/OS style reads and control Z?
  762.     beq    80$            ; /41/ Yes, exit
  763.     tst    r0            ; Some kind of success?
  764.     bmi    90$            ; no
  765.     mov    kbiost+2,icrem(r2)    ; Yes, set up number of characters
  766.     mov    #linbuf,r1        ; R1 --> line buffer
  767.     add    icrem(r2),r1        ; R1 --> first free byte at end of line
  768.     movb    kbiost+1,(r1)        ; Get possible terminator character
  769.     beq    35$            ; (none)
  770.     inc    icrem(r2)        ; Adjust for terminator
  771. 35$:    clrb    (r1)            ; Null terminate just for grins
  772.     clr    r0            ; Clear r0 and C-bit
  773.     return                ; Finished
  774.  
  775. 40$:    movb    #er.tmo    ,r0        ; return timeout error code
  776.     clr    icrem(r2)        ; just to be safe
  777.     sec                ; say it failed
  778.     return
  779.  
  780. 80$:    movb    #'Z&37    ,linbuf        ; /41/ EOF or Escape sequence, return
  781.     mov    #1    ,icrem(r2)    ; /41/ control Z and char_count == 1
  782.     clc                ; /41/ success
  783.     return                ; /41/ exit
  784.  
  785. 90$:    clr    icrem(r2)        ; to be safe
  786.     sec                ; Error
  787.     return                ; bye
  788.  
  789.  
  790.  
  791.     .sbttl    Extended I/O read for M+ and MicroRsx version 3.x
  792.     .enabl    lsb
  793.  
  794. ;    Added 27-Jun-86  13:24:18  Brian Nelson
  795. ;
  796. ;    Now that I finally have an 11/73 running M+, I can do stuff
  797. ;    like this.
  798.  
  799.     E$MOD1    =    0        ; Modifier word 1
  800.     E$MOD2    =    2        ; Modifier word 2
  801.     E$BUFF    =    4        ; Buffer address
  802.     E$LEN    =    6        ; Buffer length
  803.     E$TMO    =    10        ; Timeout (in seconds here)
  804.     E$PRM    =    12        ; Prompt address
  805.     E$PRML    =    14        ; Prompt length
  806.     E$PRMV    =    16        ; Prompt VFC
  807.     E$TT    =    20        ; Terminator table address
  808.     E$TTL    =    22        ; Terminator table length
  809.     E$DFD    =    24        ; Default data address
  810.     E$DFDL    =    26        ; Default data length
  811.  
  812.     .save                ; Save current code psect
  813.     .psect    rwdata    ,d        ; New psect
  814.     .even                ; Insure
  815. eiojnk:    .word    0
  816. eiolst:    .word    0,0,0,0,0,0,0,0,0,0,0,0,0 ; Itemlist for IO.EIO
  817. eioios:    .word    0,0,0,0
  818. eioini:    .word    0
  819. eiochr:    .byte    TC.BIN,0,TC.PTH,0
  820. eiosav:    .byte    TC.BIN,0,TC.PTH,0
  821.     $$eiol    =    . - eiosav
  822.     .restore            ; Restore old psect
  823.  
  824.  
  825. eiorea::mov    r3    ,-(sp)        ; Save please
  826.     tst    eioini            ; Need to set chars for EIO?
  827.     bne    10$            ; No (reset to zero in TTYINI)
  828.     mov    sp    ,eioini        ; Yes, change to /NORPA and /PASTHRU
  829.     tstb    handch            ; Hand shaking in effect?
  830.     bne    10$            ; Yes, leave TC.BIN on please
  831.     call    getprv            ; May need privs on
  832.     QIOW$S    #SF.GMC,(r5),#EF.TT,,,,<#eiosav,#$$EIOL>
  833.     QIOW$S    #SF.SMC,(r5),#EF.TT,,,,<#eiochr,#$$EIOL>
  834.     call    drpprv            ; Drop them now.
  835. 10$:    clr    ICREM(r2)        ; Reset buffer counter
  836.     mov    #linbuf,linptr        ; Reset scan pointer
  837.     mov    #eiolst    ,r3        ; The itemlist
  838.     mov    2(r5)    ,E$TMO(r3)    ; Insert the timeout please
  839.     mov    #linbuf    ,E$BUFF(r3)    ; Insert the buffer address next.
  840.     mov    #maxlin    ,E$LEN(r3)    ; Insert the buffer size also.
  841.     mov    #TF.TMO    ,E$MOD1(r3)    ; Insert desired read modifiers.
  842.     tst    chario            ; Do we read EXACTLY whats in buffer?
  843.     bne    15$            ; Yes.
  844.     tstb    parity            ; Is parity on ?
  845.     beq    20$            ; No, wait for terminators
  846.     cmpb    parity    ,#PAR$NO    ; Well?
  847.     beq    20$            ; Ok. Otherwise, read typeahead ONLY
  848. 15$:    clr    E$TMO(r3)        ; Yes, later we will not timeout first
  849.     bis    #TF.RAL    ,E$MOD1(r3)    ; Also, we want everything AS IS!
  850.                     ;
  851. 20$:    QIOW$S    #IO.EIO!TF.RLB,(r5),#EF.TT,,#eioios,,<#eiolst,#30>
  852.     bcs    90$            ; The directive completely died
  853.     movb    eioios    ,r0        ; Get the QIO result.
  854.     cmpb    r0    ,#IE.IFC    ; Did it die because of this
  855.     beq    90$            ; Yes, reset to old read mode.
  856.     cmpb    r0    ,#IE.ABO    ; Did the ^C ast routine do IO.KIL
  857.     beq    80$            ; Yes, return(TIMEOUT)
  858.     cmpb    r0    ,#IE.DNR    ; Do we lack carrier now?
  859.     beq    70$            ; Yes, sleep a moment, return(TMO)
  860.     cmpb    r0    ,#IE.EOF    ; Well, what about END of FILE?
  861.     beq    60$            ; Thats it, return a control Z
  862.     tst    r0            ; Did we get ANY kind of success?
  863.     bmi    90$            ; No, reset reader address, redo.
  864.     cmpb    eioios+1,#33        ; Did we get ESCAPE as terminator?
  865.     beq    60$            ; Yes, also treat as control Z
  866.     cmpb    linbuf    ,#'Z&37        ; Does the buffer START with ^Z?
  867.     beq    60$            ; Yes, same thing.
  868.     cmpb    r0    ,#IS.TMO    ; Success with a TIMEOUT?
  869.     bne    30$            ; No
  870.     tst    eioios+2        ; Yes, was there ANY data present?
  871.     bne    30$            ; There was data, return it please.
  872.     tstb    E$TMO(r3)        ; No data, but did we want only the
  873.     bne    80$            ; typeahead that was there? No
  874.     mov    2(r5)    ,E$TMO(r3)    ; Yes, stuff a REAL timeout in.
  875.     mov    #1    ,E$LEN(r3)    ; And only ONE character this time.
  876.     bis    #TF.RAL    ,E$MOD1(r3)    ; Insure no waits for terminators.
  877.     br    20$            ; Try the read over again now.
  878.                     ;
  879. 30$:    mov    eioios+2,ICREM(r2)    ; Return the size of the read now.
  880.     mov    #linbuf    ,r1        ; Get the buffer address
  881.     add    ICREM(r2),r1        ; And point to the end of it.
  882.     movb    eioios+1,(r1)        ; Get possible terminator character
  883.     beq    40$            ; (none)
  884.     inc    ICREM(r2)        ; Adjust for terminator
  885. 40$:    clrb    (r1)            ; Null terminate just for grins
  886.     clr    r0            ; Clear r0 and C-bit
  887.     br    100$            ; Exit at last....
  888.                     ;
  889.                     ;
  890. 60$:    movb    #'Z&37    ,linbuf        ; Force a control Z to be returned
  891.     inc    ICREM(r2)        ; Return exactly ONE character.
  892.     clc                ; Successfull
  893.     br    100$            ; Exit
  894.                     ;
  895. 70$:    MRKT$S    #2,#1,#2        ; Lost carrier, suspend for a
  896.     WTSE$S    #2            ; moment and return(TIMEOUT)
  897.                     ; Drop through to timeout
  898. 80$:    movb    #ER.TMO    ,r0        ; Return timeout error code
  899.     sec                ; Say the read failed
  900.     br    100$            ; And exit
  901.                     ;
  902. 90$:    mov    #rdlin    ,$lnread    ; Total failure, switch readers.
  903.     call    getprv            ; May need privs on
  904.     QIOW$S    #SF.SMC,(r5),#EF.TT,,,,<#eiosav,#$$EIOL>
  905.     call    drpprv            ; Drop them now.
  906.     clc                ; Force caller to try again.
  907. 100$:    mov    (sp)+    ,r3        ; Restore r3
  908.     return
  909.  
  910.     .dsabl    lsb
  911.  
  912.  
  913.     .sbttl    BINWRITE(&buffer,size,channel)
  914.  
  915. ;        0(r5)    Buffer address
  916. ;        2(r5)    buffer size
  917. ;        4(r5)    channel number
  918. ;    output:    r0    error code
  919.  
  920.  
  921. ;    Edit:    /40/ 16-Dec-85  14:58:01 BDN    Set timer in case line xoffed
  922.  
  923.  
  924.     .mcall    mrkt$s    ,cmkt$s    ,QIOW$S    ,astx$s    ; /40/
  925.     .enabl    lsb                ; /40/
  926.  
  927. pakwri::
  928. binwri::mov    4(r5)    ,310$            ; /40/ Registers saved in ASTs?
  929.     mrkt$s    #ef.tmo,#7,#2,#200$        ; /40/ start 7 second timeout
  930.     QIOW$S    #io.wal,4(r5),#ef.tt,,#kbiost,,<@r5,2(r5)>
  931.     cmpb    kbiost    ,#IE.ABO        ; /41/ Did the timeout occur?
  932.     beq    90$                ; /41/ Yes, try again
  933.     cmkt$s    #ef.tmo,#200$            ; /40/ write ok, cancel timer
  934.     br    100$                ; /40/ and exit
  935. 90$:    QIOW$S    #io.wal,4(r5),#ef.tt,,#kbiost,,<@r5,2(r5)> ; /40/
  936. 100$:    clr    r0
  937.     return
  938.  
  939.  
  940. 200$:    QIOW$S    #IO.KIL,310$            ; /40/ abort the pending I/O
  941.     call    getprv                ; /41/ May need privs up now
  942.     QIOW$S    #SF.SMC,310$,,,,,<#300$,#2>    ; /40/ insure line is XON'ED
  943.     call    drpprv                ; /41/ Don't want privs anymore
  944.     tst    (sp)+                ; /40/ pop timeout flag and
  945.     astx$s                    ; /40/ exit
  946.  
  947.     .save
  948.     .psect    $idata    rw,d,lcl,rel,con
  949.     .even
  950. 300$:    .byte    TC.CTS,0
  951. 310$:    .word    0
  952.     .restore
  953.     .dsabl    lsb
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.     .sbttl    real binary i/o for doing ^X and ^Z things
  962.  
  963. ;    X B I N R E A
  964. ;
  965. ;    binread( %val channel_number, %val timeout )
  966. ;
  967. ;
  968. ;     XBINREAD is used in Kermit-11 for the DIAL command to read the
  969. ;    responses from the modem on a character by character basis, and
  970. ;    also  is called once per  packet if in local  mode to check for
  971. ;    typeahead  in the form of  CTRL E, X or Z to implement graceful
  972. ;    transfer aborts. While this could be done under M/M+ via an un-
  973. ;    solicited character AST,  that won't work for RT11  and RSTS/E.
  974. ;    Thus the sampling method (XBINREA called by CHKABO).
  975. ;
  976. ;    /38/ Change  QIO timed read to untimed with a MARKTIME (MRKT$S)
  977. ;    to allow better  granularity on the timeout interval.  If time-
  978. ;    out occures, do a IO.KIL
  979. ;
  980. ;
  981. ;    input:    @r5    channel number
  982. ;        2(r5)    timeout    (if -1, then no wait) (do this for RSX??)
  983. ;
  984. ;    output:    r0    error
  985. ;        r1    character read
  986. ;
  987.  
  988.     .mcall    QIOW$S    ,mrkt$s    ,cmkt$s    ,astx$s
  989.  
  990.  
  991. xbinre::save    <r2,r3>            ; save a register for a friend
  992.     clr    -(sp)            ; allocate a buffer please
  993.     mov    sp    ,r2        ; and point to it now
  994.     clr    -(sp)            ; allocate a buffer for SF.GMC
  995.     mov    sp    ,r3        ; and point to it please
  996.     cmp    2(r5)    ,#-1        ; get without any wait today ?
  997.     bne    20$            ; no, check for timeouts now
  998.  
  999.     movb    #tc.tbf    ,@r3        ; create a .byte tc.tbf,0
  1000.     QIOW$S    #sf.gmc,@r5,#ef.tt,#50,#kbiost,,<r3,#2>
  1001.     cmpb    kbiost    ,#is.suc    ; did the read terminal thing work?
  1002.     bne    90$            ; no
  1003.     tstb    1(r3)            ; any data in the typeahead buffer?
  1004.     bne    20$            ; yes
  1005.     movb    #nodata    ,r0        ; fake a psuedo no data error
  1006.     br    100$            ; and exit
  1007.     
  1008. 20$:    tst    2(r5)            ; /38/ a real timed read ?
  1009.     ble    30$            ; /38/ no
  1010.     mov    @r5    ,iopend        ; /38/ save LUN
  1011.     mrkt$s    #ef.tmo,2(r5),#2,#200$    ; /38/ we really want 1 second chuncks
  1012. 30$:    QIOW$S    #io.ral!tf.rne,@r5,#ef.tt,#50,#kbiost,,<r2,#1>
  1013.     cmkt$s    #ef.tmo,#200$        ; /38/ cancel marktime please
  1014.     clr    r1            ; get the character now please
  1015.     bisb    @r2    ,r1        ; copy it with sign extension!
  1016.     clr    r0            ; assume no errors
  1017.     cmpb    #is.suc    ,kbiost        ; did it work ?
  1018.     beq    100$            ; yes, exit
  1019.     cmpb    #IE.ABO    ,kbiost        ; /38/ convert IO.KIL to timeout
  1020.     beq    40$            ; /38/
  1021.     cmpb    #is.tmo    ,kbiost        ; timeout
  1022.     bne    90$            ; no
  1023. 40$:    movb    #er.tmo    ,r0        ; yes
  1024.     br    100$            ; bye
  1025.  
  1026. 90$:    moverr    kbiost    ,r0        ; no, return the error
  1027. 100$:    cmp    (sp)+    ,(sp)+        ; pop the 2 buffers please
  1028.     unsave    <r3,r2>            ; from DIRECTIVE errors
  1029.     clr    iopend            ; /38/
  1030.     return                ; bye
  1031.  
  1032. 200$:    tst    (sp)+            ; mark time ast entry
  1033.     QIOW$S    #IO.KIL,iopend,#ef.tt    ; kill the i/o
  1034.     astx$s                ; exit
  1035.  
  1036. chkabo::CALLS    xbinrea    ,<#lun.tt,#-1>    ; simple read on console terminal
  1037.     tst    r0            ; did it work ok ?
  1038.     bne    100$            ; no
  1039.     mov    r1    ,r0        ; yes, return ch in r0 please
  1040.     return
  1041. 100$:    clr    r0            ; it failed
  1042.     return
  1043.  
  1044.  
  1045.  
  1046.     .sbttl    Special routines for command line editor
  1047.  
  1048. read1c::clr    -(sp)
  1049.     mov    sp    ,r0
  1050.     QIOW$S    #IO.RAL!TF.RNE,#5,#EF.TT,,#kbiost,,<r0,#1>
  1051.     cmpb    kbiost    ,#IS.SUC
  1052.     beq    10$
  1053.     clrb    @r0
  1054. 10$:    movb    kbiost    ,r0
  1055.     mov    (sp)+    ,r0
  1056.     cmpb    r0    ,#CR
  1057.     bne    100$
  1058.     mov    #LF    ,r0
  1059. 100$:    bic    #^C377    ,r0
  1060.     return
  1061.  
  1062. wrtall::SAVE    <r0,r2>            ; Must use IO.WAL for CLE for
  1063.     mov    2+4(sp)    ,r2        ; some versions of RSX11M
  1064.     STRLEN    r2            ; Get the string length.
  1065.     QIOW$S    #IO.WAL,#5,,,,,<r2,r0>    ; Dump the string in pass-all mode
  1066.     UNSAVE    <r2,r0>            ; Pop register
  1067.     mov    (sp)+    ,(sp)        ; Move return address over parameter
  1068.     return                ; Exit
  1069.  
  1070.  
  1071. clrcns::QIOW$S    #SF.SMC,#5,,,,,<#can,#2>; Simple
  1072.     return
  1073.  
  1074.     .save
  1075.     .psect    rwdata    ,d
  1076. can:    .byte    TC.TBF,0
  1077.     .restore
  1078.  
  1079.  
  1080.     .sbttl    normal i/o to the terminal
  1081.  
  1082. ;    S T T Y O U
  1083. ;
  1084. ;    input:    2(sp)    buffer address
  1085. ;        4(sp)    buffer length
  1086. ;    output:    'c'     set on error
  1087. ;        'c'    clear on no error
  1088. ;
  1089. ;
  1090. ;    L $ T T Y O
  1091. ;
  1092. ;    l$ttyou( %loc buffer, %val string_length )
  1093. ;
  1094. ;    input:    @r5    buffer address
  1095. ;        2(r5)    buffer length
  1096.  
  1097.  
  1098. l$ttyo::
  1099.     save    <r0,r1>            ; save temps here please
  1100.     movb    kbiost    ,-(sp)        ; save old io status
  1101.     mov    2(r5)    ,r0        ; string length
  1102.     bne    20$            ; length was passed
  1103.     mov    @r5    ,r0        ; no length, assume .asciz
  1104. 10$:    tstb    (r0)+            ; move along looking for a null
  1105.     bne    10$            ; none yet so far
  1106.     sub    @r5    ,r0        ; get the length
  1107.     dec    r0            ; off by one
  1108. 20$:    QIOW$S    #io.wvb,#5,#ef.tt,,#kbiost,,<@r5,r0>
  1109.     cmpb    kbiost    ,#is.suc    ; did it work ?
  1110.     bne    90$            ; no, exit with carry set
  1111.     clc                ; yes, it worked
  1112.     br    100$            ; exit
  1113. 90$:    sec                ; write failed, set error flag and exit
  1114. 100$:    movb    (sp)+    ,kbiost
  1115.     unsave    <r1,r0>            ; pop registers that we used
  1116.     return                ; and exit
  1117.  
  1118.  
  1119. sttyou::
  1120.     mov    r5    ,-(sp)
  1121.     mov    sp    ,r5
  1122.     add    #4    ,r5
  1123.     call    l$ttyo
  1124.     mov    (sp)+    ,r5
  1125.     return
  1126.  
  1127.  
  1128. l$pcrl::MESSAGE
  1129.     return
  1130.  
  1131.  
  1132.  
  1133.  
  1134.     .sbttl    exit kermit and logout
  1135.  
  1136. ;    Logout a server (LOGOUT:) by requesting ...BYE
  1137. ;    Exit Kermit-11
  1138. ;
  1139. ;    Steve Heflin's mods added 25-Dec-85  12:46:29  BDN
  1140.  
  1141.  
  1142.     .mcall    exit$s    ,rpoi$s    ,exst$s; /41/ add EXST$S
  1143.  
  1144.     .save
  1145.     .psect    $PDATA    ,D
  1146. bye:    .rad50    /...BYE/
  1147.     .restore
  1148.  
  1149. logout::
  1150.     tst    assdon            ; ever slave the line?
  1151.     beq    10$            ; no
  1152.     call    rstass            ; /41/ restore more things now
  1153. 10$:    RPOI$S    #BYE            ; request ...BYE
  1154.     br    exits            ; /41/ exit with status please
  1155.  
  1156. exit::    tst    eioini            ; /54/ Extended IO init
  1157.     beq    10$            ; /54/ No
  1158.     Call    getprv            ; /60/ privs on
  1159.     QIOW$S    #SF.SMC,#LUN.AS,#EF.TT,,,,<#eiosav,#$$EIOL>
  1160.     Call    drpprv            ; /60/ privs off
  1161. 10$:    tst    assdon            ; ever slave the line?
  1162.     beq    exits            ; no
  1163.     call    rstass            ; /41/ restore more things now
  1164. exits:    mov    exstac    ,r0        ; /41/ get exit status
  1165.     bne    20$            ; /41/ something is there to emit
  1166.     EXIT$S                ; /41/ nothing there, exit w/o status
  1167. 20$:    asl    r0            ; /41/ shift over 4 bits
  1168.     asl    r0            ; /41/  ...
  1169.     asl    r0            ; /41/   ...
  1170.     asl    r0            ; /41/    ... done
  1171.     cmp    exstal    ,#15.        ; /41/ Will command file line number
  1172.     blos    30$            ; /41/ fit into exit status word ?
  1173.     mov    #15.    ,exstal        ; /41/ No, stuff 15 (10) into it
  1174. 30$:    bisb    exstal    ,r0        ; /41/ Set bits in from line number
  1175.     EXST$S    r0            ; /41/ Exit with status now
  1176.  
  1177. quochk::
  1178.     clr    r0            ; try to see if the logout will work
  1179.     return
  1180.  
  1181.  
  1182. dskuse::
  1183.     mov    @r5    ,r0
  1184.     copyz    #nogu    ,r0
  1185.     return
  1186.  
  1187.     .save
  1188.     .psect    $PDATA    ,D
  1189. nogu:    .asciz    /Can't do space enquiry for RSX/
  1190.     .even
  1191.     .restore
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.     .sbttl    cantyp    cancel typeahead
  1198.  
  1199.  
  1200. ;    C A N T Y P
  1201. ;
  1202. ;    cantyp(%val channel_number)
  1203. ;
  1204. ;    input:    @r5    device name
  1205. ;        2(r5)    lun
  1206. ;
  1207. ;
  1208. ;     Cantyp tries to dump all pending input on a given terminal
  1209. ;    line.
  1210.  
  1211.  
  1212. cantyp::
  1213.     save    <r0,r1>            ; use r0 to point into xrb
  1214.     call    getprv            ; /41/ May need privs now
  1215.     clr    -(sp)            ; allocate buffer for SF.SMC
  1216.     mov    sp    ,r1        ; point to it please
  1217.     movb    #tc.tbf    ,@r1        ; cancel all typeahead please
  1218.     mov    2(r5)    ,r0        ; get the channel number please
  1219.     asl    r0            ; purge internally buffer chars
  1220.     clr    icrem(r0)        ; simple
  1221.     asr    r0            ; restore lun
  1222.     bne    10$            ; ok
  1223.     mov    #5    ,r0
  1224. 10$:    QIOW$S    #sf.smc,r0,#ef.tt,,#kbiost,,<r1,#2>
  1225. 100$:    tst    (sp)+
  1226.     call    drpprv            ; /41/ Don't want privs right now
  1227.     unsave    <r1,r0>            ; all done
  1228.     return                ; bye
  1229.  
  1230.  
  1231. ;    T T X O N
  1232. ;
  1233. ;    input:    @r5    device name
  1234. ;        2(r5)    lun
  1235. ;    output:    r0    error code (really, it will be zero)
  1236. ;
  1237. ;
  1238. ;    TTXON cancels xoff on a line
  1239.  
  1240.  
  1241. ttxon::    save    <r1,r2>            ; use r0 to point into xrb
  1242.     call    getprv            ; /41/ May need privs turned on
  1243.     clr    -(sp)            ; allocate buffer for SF.SMC
  1244.     mov    sp    ,r1        ; point to it please
  1245.     movb    #tc.cts    ,@r1        ; cancel all typeahead please
  1246.     clrb    1(r1)            ; zero means to cancel xoff
  1247.     mov    2(r5)    ,r2        ; get the channel number please
  1248.     bne    10$            ; ok
  1249.     mov    #5    ,r2
  1250. 10$:    QIOW$S    #sf.smc,r2,#ef.tmp,,,,<r1,#2>
  1251.     QIOW$S    #io.wal,r2,#ef.tmp,,,,<#xon1,#1>
  1252. 100$:    tst    (sp)+
  1253.     unsave    <r2,r1>            ; all done
  1254.     call    drpprv            ; /41/ Don't want privs anymore
  1255.     clr    r0            ; no errors
  1256.     return                ; bye
  1257.  
  1258.     .save
  1259.     .psect    $PDATA    ,D
  1260. xon1:    .byte    'Q&37,0
  1261.     .even
  1262.     .restore
  1263.  
  1264.  
  1265.  
  1266.     .sbttl    get uic
  1267.  
  1268.  
  1269. ;    G E T U I C
  1270. ;
  1271. ;    input:    nothing
  1272. ;    output:    r0    current UIC/PPN of the user
  1273.  
  1274.     .mcall    gtsk$s
  1275.  
  1276.  
  1277. getuic::
  1278.     sub    #40    ,sp        ; allocate gtsk buffer
  1279.     mov    sp    ,r0        ; point to the buffer please
  1280.     gtsk$s    r0            ; simple
  1281.     mov    g.tspc(r0),r0        ; return the uic
  1282.     add    #40    ,sp        ; pop the buffer and exit
  1283.     return
  1284.  
  1285.  
  1286.  
  1287. ;    Drop/Regain privs for M+ v3 and Micro/Rsx V3 /41/
  1288.  
  1289.     .mcall    GIN$S            ; /41/ the macro that does such things
  1290.  
  1291.  
  1292. drpprv::mov    r1    ,-(sp)        ; /41/ save a register today
  1293.     clr    r1            ; /41/ say we want to drop it all
  1294.     br    doprv            ; /41/ off to common code now
  1295.  
  1296. getprv::mov    r1    ,-(sp)        ; /41/ save a register today
  1297.     mov    #-1.,R1            ; /60/ set bit 0 to request privs
  1298.  
  1299. doprv:    mov    r0    ,-(sp)        ; /41/ Lets not trash r0 this time
  1300.     call    getsys            ; /41/ insure that it's not virgin 11M
  1301.     cmpb    r0    ,#SY$11M    ; /41/ old type 11M today ?
  1302.     beq    100$            ; /41/ yes, do nothing
  1303.     tst    proflg            ; /41/ Also skip for P/OS
  1304.     bne    100$            ; /41/ P/OS, then exit
  1305.     tst    #GI.SPR            ; /41/ if this is not defined then skip
  1306.     beq    100$            ; /41/ it
  1307.     mov    r1    ,privon        ; /41/ Save priv on/off status
  1308.     GIN$S    #GI.SPR,r1        ; /41/ Set the privs up/down now
  1309. 100$:    mov    (sp)+    ,r0        ; /41/ Restore R0
  1310.     mov    (sp)+    ,r1        ; /41/ pop a register now
  1311.     return
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.     .sbttl    suspend the job for a while
  1319.  
  1320. ;    S U S P E N
  1321. ;
  1322. ;    suspend(%val sleep_time)
  1323. ;
  1324. ;    input:    @r5    time to go away for
  1325.  
  1326.     .mcall    mrkt$s    ,wtse$s
  1327.  
  1328. suspen::
  1329.     tst    @r5            ; nonzero seconds call ?
  1330.     bne    10$            ; yes
  1331.     mrkt$s    #ef.tt,2(r5),#1        ; no, sleep passed # of ticks
  1332.     br    20$            ; and now wait for the timeout
  1333. 10$:    mrkt$s    #ef.tt,@r5,#2        ; sleep integral # of seconds
  1334. 20$:    wtse$s    #ef.tt
  1335.     return
  1336.  
  1337.  
  1338.     .sbttl    ttypar    set parity stuff for kermit
  1339.  
  1340.  
  1341. ;    T T Y P A R
  1342. ;
  1343. ;    ttypar( %loc terminal name, %val paritycode )
  1344. ;
  1345. ;    input:    @r5    address of terminal name
  1346. ;        2(r5)    parity code
  1347. ;    output:    r0    error code
  1348.  
  1349.     .if ne    ,0            ; we are doing it in software as of
  1350.     .ift                ; 28-Mar-84  09:11:18  (BDN)
  1351.  
  1352. ttypar::
  1353.     call    ttpars            ; get the terminal unit number
  1354.     bcs    100$            ; oops
  1355. 100$:    movb    @#$DSW    ,r0        ; get any errors
  1356.     return
  1357.  
  1358.     .endc
  1359.  
  1360. chkpar::clr    r0
  1361.     return
  1362.  
  1363.  
  1364.     .enabl    lsb
  1365.  
  1366. ;    Inqpar added /53/
  1367.  
  1368. Inqpar::SAVE    <r1>            ; Save this one
  1369.     clr    -(sp)            ; Allocate a buffer
  1370.     call    ttpars            ; the usual, parse the device name
  1371.     bcs    90$            ; oops
  1372.     ALUN$S    #LUN.CO,r1,r0        ; assign the terminal please
  1373.     mov    sp    ,r1        ; Point to it
  1374.     movb    #TC.PAR    ,(r1)        ; Want to know about parity
  1375.     QIOW$S    #SF.GMC,#LUN.CO,,,,,<r1,#2>
  1376.     bcs    90$            ; Oops
  1377.     movb    1(r1)    ,r0
  1378.     mov    sp    ,r0        ; Assume parity
  1379.     tstb    1(r1)            ; Is parity set?
  1380.     bne    100$            ; Yes
  1381. 90$:    clr    r0            ; No parity or directive error
  1382. 100$:    tst    (sp)+            ; Pop buffer
  1383.     UNSAVE    <r1>            ; Restore this one
  1384.     return                ; Exit
  1385.  
  1386.     GLOBAL    <TC.PAR,LUN.CO>
  1387.  
  1388.     .dsabl    lsb
  1389.  
  1390.  
  1391.  
  1392.     .sbttl    hangup a terminal, set dtr on a terminal
  1393.  
  1394.  
  1395. ;    T T Y H A N
  1396. ;
  1397. ;    ttyhan( %loc terminalname )
  1398. ;
  1399. ;    input:    @r5    address of the terminal name
  1400. ;    output:    r0    error code
  1401.  
  1402.  
  1403.     .mcall    ALUN$S    ,CMKT$S    ,MRKT$S    ,QIOW$S
  1404.  
  1405.  
  1406. ttyhan::save    <r1>
  1407.     MRKT$S    #EF.TMO,#2,#2,#200$    ; /41/ Set a timeout up please
  1408.     call    getprv            ; get privs              +SSH
  1409.     tst    assdon            ; /41/ assign ever done ?
  1410.     bne    5$            ; /41/ Yes
  1411.     call    ttpars            ; /41/ No, likely we are on P/OS
  1412.     bcs    100$            ; /41/ Parse failed (?)
  1413.     ALUN$S    #LUN.AS,r1,r0        ; /41/ Never assigned, do it now
  1414.     QIOW$S    #IO.ATT,#LUN.AS        ; /41/ 
  1415. 5$:    tstb    logstr            ; /41/if logoff MESSAGE len > 0      +SSH
  1416.     beq    10$            ; /41/no              +SSH
  1417.     strlen    #logstr            ; /41/yes, send logout line      +SSH
  1418.     QIOW$S    #IO.WLB,#lun.as,#ef.tt,,,,<#logstr,r0,#53> ;/41/      +SSH
  1419.     MRKT$S    #ef.tt,#2,#2        ; wait 2 seconds          +SSH
  1420.     WTSE$S    #ef.tt            ; 2 seconds up when ef set      +SSH
  1421. 10$:
  1422.     QIOW$S  #IO.HNG,#lun.as,#ef.tt,#50,#kbiost    ;          /SSH
  1423.     tst    assdon            ; /41/ Ever reach ASSDEV ?
  1424.     beq    20$            ; /41/ No
  1425.     QIOW$S    #IO.DET,#lun.as        ; /41/ Likely P/OS, so detach NOW
  1426. 20$:    call    rstass            ; restore any old line setting      +SSH
  1427.     CMKT$S    #EF.TMO,#200$        ; /41/ Kill the mark time now
  1428.         moverr  kbiost  ,r0
  1429.     unsave  <r1>
  1430. 100$:    return
  1431.  
  1432.  
  1433. 200$:    QIOW$S    #IO.KIL,#LUN.AS        ; /41/ We get here on a timeout
  1434.     tst    (sp)+            ; /41/ Pop EF
  1435.     ASTX$S                ; /41/ Exit from the AST
  1436.  
  1437.  
  1438.  
  1439. carast:    MESSAGE
  1440.     MESSAGE    <?Carrier lost>,CR
  1441.     ASTX$S
  1442.  
  1443.  
  1444. ;    raise DTR on a terminal line
  1445. ;
  1446. ;    T T Y D T R
  1447. ;
  1448. ;    ttydtr( %loc terminalname )
  1449. ;
  1450. ;    input:    @r5    address of the terminal name
  1451. ;    output:    r0    error code
  1452.  
  1453.  
  1454. ttydtr::
  1455.     call    ttpars            ; the usual, parse the device name
  1456.     bcs    100$            ; oops
  1457. 100$:    movb    @#$DSW    ,r0        ; return error code and exit
  1458.     return                ; bye
  1459.  
  1460.  
  1461. ;    For INQDTR, see same in K11E80.MAC (RSTS/E version)
  1462.  
  1463. inqdtr::mov    #-1    ,r0
  1464.     return
  1465.  
  1466.  
  1467.  
  1468.     .sbttl    ttspeed    get speed for line
  1469.  
  1470.  
  1471. ;    T T S P E E D
  1472. ;
  1473. ;    input:    @r5    name of terminal or address of null for current
  1474. ;    output:    r0    current speed
  1475. ;
  1476.  
  1477.     .psect    $pdata
  1478.  
  1479. splst:    .word    0    ,50.    ,75.    ,110.    ,134.    ,150.    ,200.
  1480.     .word    300.    ,600.    ,1200.    ,1800.    ,2000.    ,2400.    ,3600.
  1481.     .word    4800.    ,7200.    ,9600.    ,19200. ,38400. ,-1
  1482.  
  1483. setlst:    .word    s.0    ,s.50    ,s.75    ,s.110    ,s.134    ,s.150    ,s.200
  1484.     .word    s.300    ,s.600    ,s.1200    ,s.1800    ,s.2000    ,s.2400    ,s.3600
  1485.     .word    s.4800.    ,s.7200    ,s.9600    ,s.19.2 ,s.38.4 ,-1
  1486.  
  1487.  
  1488.     .psect    $code
  1489.  
  1490. ttspee::call    getprv            ; /41/ May need privs turned on
  1491.     save    <r1,r2>
  1492.     clr    -(sp)            ; allocate buffer for SF.GMC
  1493.     clr    -(sp)
  1494.     call    ttpars            ; parse the terminal device name
  1495.     bcs    90$            ; error in device name ?
  1496.     alun$s    #lun.co,r1,r0        ; assign the terminal please
  1497.     mov    sp    ,r2
  1498.     movb    #tc.xsp    ,@r2
  1499.     movb    #tc.rsp    ,2(r2)
  1500.     QIOW$S    #sf.gmc,#lun.co,#ef.tt,,#kbiost,,<r2,#4>
  1501.     movb    kbiost    ,-(sp)
  1502.     movb    (sp)+    ,kbiost
  1503.     clr    r0            ; assume zero speed
  1504.     cmpb    kbiost    ,#is.suc    ; did the read speed thing work ?
  1505.     bne    90$            ; not really
  1506.     movb    1(r2)    ,r2        ; get the speed setting please
  1507.     clr    r1            ; find the index into speed table
  1508. 10$:    cmp    setlst(r1),#-1        ; reached the end of table yet ?
  1509.     beq    90$            ; yes, exit
  1510.     cmpb    setlst(r1),r2        ; a match yet
  1511.     beq    20$            ; yes
  1512.     tst    (r1)+            ; no, index := index + 2
  1513.     br    10$            ; next please
  1514. 20$:    mov    splst(r1),r0        ; return decimal of the speed
  1515.     br    100$            ; bye
  1516.  
  1517. 90$:
  1518. 100$:    cmp    (sp)+    ,(sp)+
  1519.     unsave    <r2,r1>
  1520.     call    drpprv            ; /41/ Insure privs are turned off
  1521.     return
  1522.  
  1523.  
  1524.  
  1525.  
  1526.  
  1527.  
  1528.     .sbttl    set the speed of a terminal line
  1529.     .mcall    astx$s    ,cmkt$s    ,mrkt$s    ,QIOW$S
  1530.  
  1531.  
  1532.  
  1533. ;    S E T S P D
  1534. ;
  1535. ;    setspd(%loc devicename, %val speed)
  1536. ;
  1537. ;    input:    @r5    device name
  1538. ;        2(r5)    speed
  1539. ;        4(r5)    lun
  1540. ;    output:    r0    error code, 255 if invalid speed
  1541.  
  1542. setspd::save    <r1,r2,r3,r4>
  1543.     call    getprv            ; /41/ May need privs turned on
  1544.     mov    2(r5)    ,r2        ; the speed
  1545.     mov    4(r5)    ,r4        ; save the lun
  1546.     call    ttpars            ; parse the terminal name
  1547.     bcs    90$            ; oops
  1548.     clr    r3            ; match the passed speed to the
  1549. 10$:    cmp    splst(r3),#-1        ; speed desired to get the index
  1550.     beq    80$            ; end of the table, invalid speed
  1551.     cmp    splst(r3),r2        ; a match yet ?
  1552.     beq    20$            ; yes
  1553.     tst    (r3)+            ; no, look again please
  1554.     br    10$            ; next
  1555.  
  1556. 20$:    movb    setlst(r3),aslxsp+1    ; /41/ insert the transmitted speed
  1557.     movb    setlst(r3),aslrsp+1    ; /41/ insert the received speed also
  1558.     mov    #aslspd    ,r2        ; /41/ pointer to it
  1559.     alun$s    r4,r1,r0        ; assign the terminal please
  1560.     mrkt$s    #ef.tmo,#2,#2,#spdtmo    ; in case we can't get the device
  1561.     QIOW$S    #sf.smc,r4,#ef.tt,#50,#kbiost,,<r2,#4>
  1562.     cmkt$s    #ef.tmo,#spdtmo        ; we got it ok
  1563.     clr    r0            ; assume success
  1564.     cmpb    kbiost    ,#is.suc    ; did it work ?
  1565.     beq    100$            ; yes, exit without error
  1566. 70$:    moverr    kbiost    ,r0        ; no, return the error and exit
  1567.     br    100$            ; and exit with the error code
  1568.  
  1569. 80$:    mov    #377    ,r0        ; unknown speed
  1570.     br    100$            ; exit
  1571.  
  1572. 90$:    moverr    @#$dsw    ,r0        ; error from parse
  1573.     br    100$
  1574.  
  1575. 100$:    unsave    <r4,r3,r2,r1>        ; bye
  1576.     call    drpprv            ; /41/ Don't want privs on now
  1577.     return
  1578.  
  1579. spdtmo:    tst    (sp)+            ; remove the event flag number
  1580.     QIOW$S    #io.kil,r4,#ef.tt,#50,#kbiost
  1581.     movb    #ie.abo    ,kbiost        ; insure that's the error code
  1582.     astx$s                ; exit from this timeout ast
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.     .sbttl    ttpars    get unit number from ttname
  1589.  
  1590. ;    T T P A R S
  1591. ;
  1592. ;    ttpars( %loc ttname )
  1593. ;
  1594. ;    output:    r0    unit number or 377 for null string
  1595. ;        r1    device name
  1596.  
  1597. ttpars::                ; NEEDS TO BE GLOBAL(RBD)
  1598.     save    <r2,r3>            ; parse a device name
  1599.     clr    r1            ; no device name yet
  1600.     clrb    @#$DSW            ; set no error as of yet
  1601.     mov    #377    ,r0        ; presume no device name
  1602.     mov    @r5    ,r3        ; get the string address
  1603.     tstb    @r3            ; anything there ?
  1604.     beq    90$            ; no, error
  1605.  
  1606. ;    cmpb    @r3    ,#'X&137    ; i may try this on 350 some day(RTM02)
  1607. ;    beq    10$            ; ok                (RTM02)
  1608.     cmpb    @r3    ,#'A&137    ; must be of the format ?Tnnn:
  1609.     blo    90$            ; ok so far
  1610.     cmpb    @r3    ,#'Z&137    ; must be of the format ?Tnnn:
  1611.     blos    10$            ; no
  1612.  
  1613.     cmpb    @r3    ,#'A!40        ; must be of the format ?Tnnn:
  1614.     blo    90$            ; ok so far
  1615.     cmpb    @r3    ,#'Z!40        ; must be of the format ?Tnnn:
  1616.     bhi    90$            ; no
  1617. 10$:    bisb    (r3)    ,r1        ; ok, save the first character    (RTM02)
  1618.     swab    r1            ; and make a place for the next
  1619.     cmpb    (r3)+    ,#'T&137    ; Is this possibly "TI:" ?    (RTM02)
  1620.     bne    15$            ; If NE, no.            (RTM02)
  1621.     cmpb    @r3    ,#'I&137    ; passed 'TI:' ?
  1622.     beq    105$            ; return unit of 377 then please
  1623.     cmpb    @r3    ,#'I!40        ; passed 'TI:' ?
  1624.     beq    105$            ; return unit of 377 then please
  1625.     
  1626. ;    cmpb    @r3    ,#'K&137    ; XK: (?)            (RTM02)
  1627. ;    beq    20$            ; yep                (RTM02)
  1628. ;    cmpb    @r3    ,#'T&137    ; must be of the format TTnnn:    (RTM02)
  1629. ;    beq    20$            ; ok so far            (RTM02)
  1630. ;    cmpb    @r3    ,#'T!40        ; must be of the format TTnnn:    (RTM02)
  1631. ;    bne    90$            ; no                (RTM02)
  1632.  
  1633. 15$:    cmpb    @r3    ,#'A&137    ; Is this possibly uppercase ?    (RTM02)
  1634.     blo    90$            ; If LO, no.            (RTM02)
  1635.     cmpb    @r3    ,#'Z&137    ; Is this really uppercase ?    (RTM02)
  1636.     blos    20$            ; If LOS, yes.            (RTM02)
  1637.     cmpb    @r3    ,#'A!40        ; Is this possibly lowercase ?    (RTM02)
  1638.     blo    90$            ; If LO, no.            (RTM02)
  1639.     cmpb    @r3    ,#'Z!40        ; Is this really lowercase ?    (RTM02)
  1640.     bhi    90$            ; If HI, no.            (RTM02)
  1641.  
  1642. 20$:    bisb    (r3)+    ,r1
  1643.     swab    r1            ; have the device name in r1 now
  1644.     clr    r0            ; could use .parse but this is
  1645.  
  1646. 30$:    movb    (r3)+    ,r2        ; get the next digit in the string
  1647.     beq    90$            ; hit end of string
  1648.     cmpb    r2    ,#':        ; end of the device name ?
  1649.     beq    105$            ; yes, exit please
  1650.     cmpb    r2    ,#'0        ; in the range '0'..'7' ?
  1651.     blo    90$            ; oops
  1652.     cmpb    r2    ,#'7        ; keep checking please
  1653.     bhi    90$            ; bad device name
  1654.     asl    r0            ; r0 = r0 * 8
  1655.     asl    r0            ; ditto
  1656.     asl    r0            ; and so forth
  1657.     sub    #'0    ,r2        ; convert to binary
  1658.     add    r2    ,r0        ; and sum the digit in please
  1659.     br    30$            ; next
  1660.  
  1661. 90$:    movb    #ie.idu    ,@#$dsw        ; fake a bad device name and exit
  1662.     sec                ; ok
  1663.     br    110$            ; bye
  1664. 105$:    clr    @#$dsw            ; no errors
  1665.     clc                ; success
  1666. 110$:    unsave    <r3,r2>            ; bye
  1667.     return
  1668.  
  1669.  
  1670.  
  1671.     .sbttl    assign device
  1672.  
  1673.  
  1674. ;    Fake a device assignment by attaching to a dummy lun. Also
  1675. ;    check for someone else having it via issueing a mark time.
  1676. ;    Thanks to Bob Denny for that one.
  1677. ;
  1678.  
  1679.     .mcall    alun$s    ,astx$s    ,cmkt$s    ,mrkt$s    ,QIOW$S    ,wtse$s
  1680.  
  1681.  
  1682. assdev::tst    proflg            ; if this is a pro/350 we don't
  1683.     beq    1$            ; have to worry about all these
  1684.     clr    r0            ; characteristics.
  1685.     return                ; simply exit
  1686. 1$:    save    <r1,r2,r3>
  1687.     call    rstass            ; /41/ restore possible previous set
  1688.     call    getprv            ; /60/ restore privs again
  1689.     call    ttpars
  1690.     bcc    5$
  1691.     jmp    100$
  1692. 5$:    mov    r0    ,r3        ; save the unit number please
  1693.     cmpb    r3    ,#377        ; local terminal ?
  1694.     bne    10$            ; no
  1695.     alun$s    #lun.as,#"TI,#0        ; assign the terminal please
  1696.     br    20$
  1697. 10$:    alun$s    #lun.as,r1,r3        ; assign the terminal please
  1698.     bcc    12$            ; If CC, device is assigned.    (RTM02)
  1699.     jmp    100$            ; Else, report the error.    (RTM02)
  1700. 12$:    sub    #20    ,sp        ; Allocate a buffer for glun.    (RTM03)
  1701.     mov    sp    ,r2        ; Set pointer to the buffer.    (RTM03)
  1702.     glun$s    #lun.as    ,r2        ; Get real name of terminal.    (RTM03)
  1703.     mov    g.luna(r2),r1        ; Copy the device name.        (RTM03)
  1704.     movb    g.lunu(r2),r3        ; Copy the unit number.        (RTM03)
  1705.     mov    g.lucw(r2),r2        ; Copy the device char. word.    (BDN53)
  1706.     add    #20    ,sp        ; Pop the glun buffer.        (RTM03)
  1707.     bit    #DV.F11!DV.COM!DV.MNT,r2; Insure not disk or tape    (BDN53)
  1708.     beq    15$            ; Yes                (BDN53)
  1709.     movb    #IE.IDU    ,@#$DSW        ; No, force an error please    (BDN53)
  1710.     jmp    100$            ; Exit                 (BDN53)
  1711. 15$:    mov    @r5,r0            ; Copy the device name buffer.    (RTM03)
  1712.     call    fmtdev            ; Format the real device name.    (RTM03)
  1713.  
  1714. 20$:    clr    r2            ; flag if we timed out        (RTM03)
  1715.     mrkt$s    #ef.tmo,#2,#2,#asstmo    ; give 2 seconds to do this    (RTM03)
  1716.     QIOW$S    #io.att,#lun.as,#ef.tt,,#kbiost
  1717.     mov    r2    ,r0        ; did we ever time out
  1718.     beq    25$            ; no
  1719.     jmp    110$            ; yes, return busy device
  1720. 25$:    cmkt$s    #ef.tmo,#asstmo        ; and cancel the mark time
  1721.     sub    #20    ,sp        ; allocate a buffer for glun
  1722.     mov    sp    ,r2        ; and a pointer to it
  1723.     glun$s    #lun.tt    ,r2        ; get name of the console terminal
  1724.     cmpb    r3    ,#377        ; no unit?
  1725.     beq    40$            ; yes, must be TI:
  1726.     cmp    g.luna(r2),r1        ; device name of console same as dev?
  1727.     bne    30$            ; no
  1728.     cmpb    g.lunu(r2),r3        ; unit number the same ?
  1729.     beq    40$            ; yes
  1730. 30$:    QIOW$S    #SF.GMC,#lun.as,#ef.tt,,,,<#savass,#asvlen> ; /41/ more things
  1731.     QIOW$S    #SF.SMC,#lun.as,#ef.tt,,,,<#setass,#astlen> ; /41/ ditto
  1732.     Call    drpprv            ; /60/ drop privs now
  1733.     movb    savrsp+1,aslrsp+1    ; /41/ copy to assigned recv speed
  1734.     movb    savxsp+1,aslxsp+1    ; /41/ copy to assigned xmit speed
  1735.     mov    sp    ,assdon        ; flag we did the set /slave=ttnn:
  1736. 40$:    add    #20    ,sp        ; pop glun buffer
  1737.     clr    r0
  1738.     cmpb    kbiost    ,#is.suc    ; did it work
  1739.     beq    110$            ; yes, return error zero
  1740.     cmpb    kbiost    ,#ie.daa    ; ignore already attached errors
  1741.     beq    110$            ; simple to do
  1742.     moverr    kbiost    ,r0        ; no, get the error code
  1743.     br    110$            ; and exit
  1744. 100$:    moverr    @#$DSW    ,r0
  1745. 110$:    unsave    <r3,r2,r1>
  1746.     return
  1747.  
  1748.  
  1749. asstmo:    tst    (sp)+            ; remove the event flag number
  1750.     QIOW$S    #io.kil,#lun.as,#ef.tt,#50,#kbiost
  1751.     moverr    #ie.daa    ,r2        ; get the error code and exit
  1752.     astx$s                ; exit from this timeout ast
  1753.  
  1754.  
  1755. rstass:    tst    assdon            ; /41/ If line was ever assigned then
  1756.     beq    100$            ; /41/ we need to reset the prev line
  1757.     clr    assdon            ; /41/ no longer assigned
  1758.     call    getprv            ; /41/ insure privs are up
  1759.     QIOW$S    #SF.SMC,#lun.as,#ef.tt,,,,<#savass,#asvlen>
  1760.     QIOW$S    #IO.DET,#lun.as        ; /41/ detach it
  1761.     call    drpprv            ; /41/ Insure no privs now
  1762. 100$:    return
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.     .sbttl    fmtdev - Format the real device name.
  1769. ;+
  1770. ;
  1771. ; fmtdev - Format the real device name.
  1772. ;
  1773. ; Inputs:
  1774. ;    R0 = The output buffer.
  1775. ;    R1 = The ASCII device name.
  1776. ;    R3 = The BINARY unit number.
  1777. ;
  1778. ; Outputs:
  1779. ;    All registers are preserved.
  1780. ;
  1781. ;-
  1782. fmtdev:    save    <r0,r1,r2>        ; Save some registers.        (RTM03)
  1783.     swab    r1            ; Copy                 (RTM03)
  1784.     movb    r1,(r0)+        ;     the            (RTM03)
  1785.     swab    r1            ;       device            (RTM03)
  1786.     movb    r1,(r0)+        ;        name.        (RTM03)
  1787.     mov    r3,r1            ; Copy the binary unit number.    (RTM03)
  1788.     clr    r2            ; Set for zero supression.    (RTM03)
  1789.     call    $cbtmg            ; Convert it to octal ASCII.    (RTM03)
  1790.     movb    #':,(r0)+        ; Finish the device name.    (RTM03)
  1791.     clrb    (r0)            ; And terminate with a null.    (RTM03)
  1792.     unsave    <r0,r1,r2>        ; Restore the registers.    (RTM03)
  1793.     return
  1794.  
  1795.  
  1796.  
  1797.     .sbttl    get date and time
  1798.  
  1799.     .enabl    lc
  1800.     .mcall    gtim$s
  1801.  
  1802.  
  1803. ascdat::save
  1804.     mov    @r5    ,r0        ; r0 := caller result addr
  1805.     sub    #16.    ,sp        ; make room for result
  1806.     mov    sp    ,r1        ; result addr for gtim$
  1807.     gtim$s    r1            ; get time and date
  1808.     mov    g.tida(r1),r2        ; r2 := day
  1809.     jsr    pc    ,cnvert        ; convert and store day
  1810.     movb    #'-    ,(r0)+        ; insert dash
  1811.     mov    g.timo(r1),r2        ; r2 := month
  1812.     asl    r2
  1813.     add    g.timo(r1),r2        ; r2 := 3*month
  1814.     add    #mnthtab-3,r2        ; r2 := mnthtab[3*month]@
  1815.     movb    (r2)+    ,(r0)+
  1816.     movb    (r2)+    ,(r0)+        ; store month name
  1817.     movb    (r2)+    ,(r0)+
  1818.     movb    #'-    ,(r0)+        ; insert dash
  1819.     mov    @r1    ,r2        ; r2 := year
  1820.     jsr    pc    ,cnvert        ; convert and store year
  1821.     movb    #40     ,(r0)+        ; final space
  1822.     clrb    @r0
  1823.     add    #16.    ,sp
  1824.     unsave
  1825.     return
  1826.  
  1827. asctim::save
  1828.     mov    @r5    ,r0        ; the desitination
  1829.     sub    #16.    ,sp        ; make room for result
  1830.     mov    sp    ,r1        ; result addr for gtim$
  1831.     gtim$s    r1            ; get time and date
  1832.     mov    #3,r3            ; loop count := 3
  1833.     add    #g.tihr,r1        ; start with hours
  1834. 1$:    mov    (r1)+,r2        ; begin loop
  1835.     jsr    pc,cnvert        ;   convert to ascii and store
  1836.     dec    r3            ;   if done
  1837.     beq    2$            ;     then exit loop
  1838.     movb    #':,(r0)+        ;     else insert colon
  1839.     br    1$            ; end loop
  1840. 2$:    clrb    @r0
  1841.     add    #16.    ,sp
  1842.     unsave
  1843.     return
  1844.  
  1845. ; cnvert: internal procedure to convert
  1846. ; integer in r2 to ascii.
  1847. cnvert:    add    #366,r2        ;begin loop
  1848.     tstb    r2
  1849.     bpl    cnvert        ;end loop
  1850.     add    #"00-366,r2    ;convert to ascii
  1851.     swab    r2        ;reorder bytes
  1852.     movb    r2,(r0)+    ;store digit
  1853.     swab    r2
  1854.     movb    r2,(r0)+    ;store digit
  1855.     rts    pc
  1856.  
  1857.     .save
  1858.     .psect    $PDATA    ,D
  1859. mnthtab:.ascii    /JanFebMarAprMayJunJulAugSepOctNovDec/
  1860.     .even
  1861.     .restore
  1862.  
  1863.  
  1864.  
  1865.  
  1866.     .sbttl    systat    get list of users logged in
  1867.  
  1868. sercmd::
  1869. systat::
  1870.     moverr    #-1    ,r0
  1871.     return
  1872.  
  1873.  
  1874.  
  1875.     .sbttl    dodir    get a reasonable directory printed
  1876.  
  1877.     .save
  1878.     .psect    dirctx    ,rw,d,lcl,rel,con
  1879. dirnam:    .blkb    120
  1880. dirbuf:    .blkb    120
  1881. diridx:    .word    0
  1882. dirptr:    .word    dirbuf
  1883. dcrlf:    .byte    15,12,0
  1884. wild:    .asciz    /*.*;*/
  1885.     .even
  1886.     .restore
  1887.  
  1888. ;    D O D I R
  1889. ;
  1890. ;    input:    @r5    wildcarded filespec
  1891. ;    output:    r0    error code
  1892. ;
  1893. ;    DODIR prints a directory listing at the local terminal.
  1894. ;
  1895. ;
  1896. ;    S D O D I R
  1897. ;
  1898. ;    Passed:    @r5    wildcarded name
  1899. ;    Return:    r0    error code, zero for no errors
  1900. ;        r1    next character in the directory listing
  1901. ;
  1902. ;    SDODIR is called by the server to respond to a remote directory
  1903. ;    command.  Instead of the pre 2.38 method of dumping output to a
  1904. ;    disk file and then sending the disk file in an extended replay,
  1905. ;    SDODIR  returns the next  character so that  BUFFIL can use it.
  1906. ;    The routine  GETCR0  is actually a dispatch routine to call the
  1907. ;    currently selected GET_NEXT_CHARACTER routine.
  1908.  
  1909.  
  1910. dodir::save    <r1,r2,r3,r4>        ; /38/ Entirely rewritten
  1911.     STRCPY    #dirnam    ,@r5        ; copy the filespec to save area
  1912.     call    dirini            ; initialize things
  1913. 10$:    call    dirnex            ; get next entry to display
  1914.     bcs    100$            ; error, exit please
  1915.     .print    #dirbuf            ; ok, dump it
  1916.     br    10$            ; next please
  1917. 100$:    unsave    <r4,r3,r2,r1>        ; exit
  1918.     clr    diridx            ; clear flag and exit
  1919.     return                ; bye
  1920.  
  1921. sdirin::STRCPY    #dirnam    ,@r5        ; copy name over
  1922.     clr    diridx            ; ditto
  1923.     call    dirini            ; init for CALLS to sdodir
  1924.     bcs    100$
  1925.     mov    #dirbuf    ,dirptr        ; yes, init pointers please
  1926.     clrb    @dirptr            ; yes, zap the buffer
  1927.     call    dirnex            ; preload buffer
  1928. 100$:    return
  1929.  
  1930.  
  1931. sdodir::save    <r2,r3,r4>
  1932. 10$:    movb    @dirptr    ,r1        ; get the next character please
  1933.     bne    20$            ; something was there
  1934.     mov    #dirbuf    ,dirptr        ; reset the pointer
  1935.     clrb    @dirptr            ; yes, zap the buffer
  1936.     call    dirnex            ; empty buffer, load with next file
  1937.     bcs    90$            ; no more, return ER$EOF
  1938.     br    10$            ; and try again
  1939. 20$:    inc    dirptr            ; pointer++
  1940.     clr    r0            ; no errors
  1941.     br    100$            ; exit
  1942. 90$:    mov    #ER$EOF    ,r0        ; failure, return(EOF)
  1943. 95$:    clr    r1            ; return no data also
  1944.     clr    diridx            ; init for next time through
  1945. 100$:    unsave    <r4,r3,r2>
  1946.     return
  1947.     
  1948.  
  1949.  
  1950.  
  1951.     .sbttl    return next directory entry and init directory
  1952.  
  1953. dirini:    clr    diridx            ; clear context flag
  1954.     mov    #dirbuf    ,dirptr        ; set pointer up for SDODIR
  1955.     clrb    @dirptr            ; clear buffer
  1956.     return                ; thats all folks
  1957.  
  1958.  
  1959.  
  1960. dirnex:    movb    defdir    ,-(sp)        ; anything in DEFDIR ?
  1961.     bne    10$            ; yes, don't alter it please
  1962.     STRCPY    #defdir    ,#wild        ; nothing, insert *.*;*
  1963. 10$:    CALLS    lookup    ,<#3,#dirnam,#diridx,#dirbuf>
  1964.     tst    r0            ; successfull?
  1965.     bne    20$            ; no
  1966.     strcat    #dirbuf    ,#dcrlf        ; yes, append <cr><lf>
  1967.     clr    r0            ; strcat returns DST addr in r0
  1968.     br    100$            ; exit
  1969. 20$:    cmp    r0    ,#ER$NMF    ; no more files error ?
  1970.     bne    90$            ; no
  1971.     tst    diridx            ; ever do anything?
  1972.     bne    90$            ; yes
  1973.     mov    #ER$FNF    ,r0        ; no, convert to file not found
  1974. 90$:    sec
  1975. 100$:    movb    (sp)+    ,defdir        ; restore DEFDIR
  1976.     return
  1977.     
  1978.  
  1979.  
  1980.  
  1981.  
  1982.     .sbttl    fix up error codes
  1983.  
  1984.  
  1985. $mover:    tstb    2(sp)
  1986.     bmi    10$
  1987.     clr    2(sp)
  1988.     return
  1989. 10$:    neg    2(sp)
  1990.     return
  1991.  
  1992.  
  1993.     .sbttl    rsxsys    sys command for RSX11M/M+
  1994.  
  1995.  
  1996. ;    21-Aug-83  16:12:37    Brian Nelson
  1997. ;    12-Jan-84  09:54:02    Created from MINITAB v82 source
  1998. ;    07-Mar-84  21:58:10    Bob Denny - Stop instead of wait, nicer.
  1999.  
  2000.     .enabl    gbl
  2001.     .mcall    spwn$s    ,stse$s    ,r50$
  2002.     .enabl    lsb
  2003.  
  2004. runjob::
  2005.     mov    #cli...    ,r0
  2006.     call    rsxsys
  2007.     return
  2008.  
  2009. runmcr::
  2010.     mov    #mcr...    ,r0
  2011.     call    rsxsys
  2012.     return
  2013.  
  2014. rsxsys::
  2015.     save    <r1,r2,r3,r4>
  2016.     QIOW$S    #io.det,#lun.tt,#ef.tt,#50,#kbiost
  2017.     mov    r0    ,r4        ; save the CLI we want to use
  2018.     sub    #12*2    ,sp        ; need eight word exit block BDN
  2019.     mov    sp    ,r2        ; Get address of exit block  BDN
  2020.     clr    @r2            ; to be safe ?
  2021.     mov    2(r5)    ,r1        ; the command buffer address
  2022.     mov    r1    ,r3        ; save it
  2023.     strlen    r1            ; get the command string length
  2024.     add    r0    ,r3        ; point to the end
  2025.     cmpb    -(r3)    ,#cr        ; trailing carriage return ?
  2026.     bne    5$            ; no
  2027.     dec    r0            ; yes, fix the length up
  2028. 5$:    mov    r0    ,r3        ; save the length
  2029.     clr    r0            ; assume no error please
  2030.     spwn$s    r4,,,,,#6,,r2,r1,r3    ; do it
  2031.     bcc    10$            ; Ignore error for now
  2032.     moverr    @#$DSW    ,r0        ; get the error code please
  2033.     QIOW$S    #io.att,#lun.tt,#ef.tt,#50,#kbiost
  2034.     print    #100$
  2035.     br    20$
  2036. 10$:    stse$s    #6            ; Stop for task to exit
  2037. 20$:    add    #12*2    ,sp        ; pop exit status block
  2038.     QIOW$S    #io.att,#lun.tt,#ef.tt,#50,#kbiost
  2039.     unsave    <r4,r3,r2,r1>        ; pop registers and exit
  2040.     return
  2041.  
  2042.  
  2043.  
  2044.     .save
  2045.     .psect    $PDATA    ,D
  2046. 100$:    .asciz    <15><12>/Spawn failure for SYS command/<15><12>
  2047.     .even
  2048.  
  2049. mcr...:    r50$    MCR...
  2050. cli...:    r50$    CLI...
  2051.  
  2052.     .restore
  2053.     .dsabl    lsb
  2054.  
  2055.  
  2056.     .sbttl    spool to printer
  2057.  
  2058.  
  2059.     .mcall    print$
  2060.  
  2061. ;    can we do this with RMS i/o ?????
  2062.  
  2063. qspool::movb    #1    ,r0
  2064.     return
  2065. ;    CALLS    open    ,<@r5,2(r5)>
  2066. ;    CALLS    rsxspl    ,<2(r5)>
  2067. ;100$:    return
  2068. ;
  2069. ;
  2070. ;rsxspl::mov    r0    ,-(sp)        ; save temps
  2071. ;    mov    r1    ,-(sp)        ; also this one
  2072. ;    mov    @r5    ,r1        ; unit number file is open on
  2073. ;    asl    r1            ; get into word offset
  2074. ;    mov    fdblst(r1),r1        ; fdb for that file
  2075. ;    clr    errsav
  2076. ;    print$    r1,,,#"LP,#1        ; spool file to lp0 now
  2077. ;    bcc    100$
  2078. ;    moverr    f.err(r1)
  2079. ;100$:    mov    (sp)+    ,r1        ; pop temps and exit
  2080. ;    mov    (sp)+    ,r0        ;
  2081. ;    return                ; bye
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.     .sbttl    detach for the server
  2088.  
  2089. ;    Much simpler for RSX than for RSTS
  2090.  
  2091. detach::QIOW$S    #io.det,#5,#ef.tt,,#kbiost
  2092.     clr    r0
  2093.     return
  2094.  
  2095.  
  2096. login::    mov    4(r5)    ,r0
  2097.     STRCPY    r0,#nologin
  2098.     mov    #1    ,r0
  2099.     return
  2100.  
  2101.     .save
  2102.     .psect    $PDATA    ,D
  2103. nologin:.asciz    #Can't do REMOTE LOGIN for RSX11M/M+ and P/OS#<15><12>
  2104.     .even
  2105.     .restore
  2106.  
  2107.  
  2108.  
  2109.  
  2110.     .sbttl    error MESSAGE text
  2111.  
  2112. syserp::
  2113.     save    <r0>
  2114.     mov    @r5    ,r0
  2115.     call    rmserp
  2116.     MESSAGE
  2117.     unsave    <r0>
  2118.     return
  2119.  
  2120.  
  2121.  
  2122. syserr::
  2123.     save    <r1>            ; save a register
  2124.     clr    -(sp)            ; allocate variable for error #
  2125.     mov    sp    ,r1        ; and point to it
  2126.     mov    @r5    ,@r1        ; if errornumber > 0
  2127.     bmi    10$            ;  then
  2128.     CALLS    direrr    ,<#2,r1,2(r5)>    ;   call fiperr(num,text)
  2129.     br    100$            ;  else
  2130. 10$:    CALLS    rmserr    ,<#2,r1,2(r5)>    ;   call rmserr(num,text)
  2131. 100$:    tst    (sp)+
  2132.     unsave    <r1>
  2133.     return
  2134.  
  2135.     global    <direrr    ,rmserp    ,rmserr>
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.     .sbttl    dodial for the DIAL command
  2143.     .enabl    lsb
  2144.  
  2145. ;    This is Steve Covey's code for dialing on XT1 or XT2 on the
  2146. ;    PRO/TMS Telephone Management System. BDN 06-Dec-85 11:00:40
  2147. ;
  2148. ; TMS
  2149. ; TMS for a Telephone Management System (TMS) on a PRO/350
  2150. ; TMS supports lines XT1: or XT2: under P/OS V2
  2151. ; TMS
  2152. ; TMS the DIAL command establishes the phone connection
  2153. ; TMS assuming that the appropriate SET LINE XTn: and SET SPEED n
  2154. ; TMS commands have been issued, and that the lun has been assigned
  2155. ; TMS and attached.
  2156. ; TMS
  2157. ; TMS the phone number can consist of the following:
  2158. ; TMS    digits    to be dialed
  2159. ; TMS    !    6 second access pause for dial tone
  2160. ; TMS    !!    40 second access pause for dial tone
  2161. ; TMS    ,    2 second delay
  2162. ; TMS    #    changes to DTMF if initially pulse mode
  2163. ; TMS    *ABCD    other valid DTMF codes
  2164. ; TMS    ^    as the first character causes a "hook flash"
  2165. ; TMS    ()- and spaces ignored.  max total number 48 characters
  2166.  
  2167.  
  2168.     .mcall    QIOW$S    ,alun$s        ; TMS 
  2169.                     ; TMS 
  2170. ef.rem    = 14.                ; TMS 
  2171.  
  2172. tmsdia::save    <r1>            ; TMS 
  2173.     CALLS    ttpars    ,<#ttname>    ; TMS
  2174.     bcs    5$            ; TMS 
  2175.     alun$s    #lun.ti,r1,r0        ; TMS 
  2176.     QIOW$S    #io.att,#lun.ti,#ef.rem,,#tmsios ; TMS 
  2177.     QIOW$S    #sf.smc,#lun.ti,#ef.rem,,#tmsios,,<#smctms,#smclen>     ; TMS 
  2178.     strlen    argbuf            ; TMS get length of phone number
  2179.     QIOW$S    #io.con,#lun.ti,#ef.rem,,#tmsios,,<argbuf,r0>        ; TMS 
  2180.     cmpb    tmsios,#is.suc        ; TMS did it work?
  2181.     beq    10$            ; TMS yes
  2182. 5$:    unsave    <r1>            ; TMS 
  2183.     MESSAGE    <Unsuccessful call>,cr    ; TMS/BDN
  2184.     mov    #-1    ,r0        ; TMS/BDN
  2185.     return                ; TMS 
  2186. 10$:    unsave    <r1>            ; TMS 
  2187.     MESSAGE    <Call complete, type CONNECT to access system>,cr ; TMS/BDN
  2188.     clr    r0            ; TMS/BDN
  2189.     return                ; TMS 
  2190.  
  2191.     .save
  2192.     .psect    $PDATA    ,D
  2193.  
  2194. tmsios:    .word    0,0        ; TMS iosb for tms CALLS
  2195. smctms:    .byte    xt.dmd        ; TMS set data mode
  2196.     .byte    xt.ser        ; TMS serial data (not codec, dtmf, or voice)
  2197.     .byte    xt.dlm        ; TMS set dial mode
  2198.     .byte    xt.dtm        ; TMS DTMF (not pulse 10 or 20, or off hook)
  2199.     .byte    xt.dit        ; TMS set DTMF intertone time * 10ms
  2200.     .byte    10.        ; TMS 100 milliseconds
  2201.     .byte    xt.dtt        ; TMS set DTMF tone time * 10ms
  2202.     .byte    10.        ; TMS 100 milliseconds
  2203. ;    .byte    xt.mtp        ; TMS set modem type - should default from speed
  2204. ;    .byte    xtm.ps        ; TMS DPSK - 1200 baud Bell 212
  2205. smclen    = . - smctms        ; TMS 
  2206.  
  2207.     .restore
  2208.     .dsabl    lsb
  2209.  
  2210.  
  2211.  
  2212.     .sbttl    Look in logical name tables for KERMIT$LINEn
  2213.  
  2214.  
  2215.     .mcall    tlog$s    ,alun$s    ,QIOW$S    ,cmkt$s    ,astx$s    ,mrkt$s
  2216.  
  2217.  
  2218. ;    TRNTRM(&return_name)        ; Added edit /41/
  2219. ;
  2220. ;    Passed:    0(r5)    address of where to return first available dev
  2221. ;    Return:    r0    zero for success, else directive error code.
  2222. ;
  2223. ;
  2224. ;    Look through logical name tables for a free terminal to use. The
  2225. ;    first translation will be on KERMIT$LINEn, where N is null, then
  2226. ;    1 though NN. Stop on first translation that has a free terminal,
  2227. ;    or when we fail on the translation (IE.LNF).  For now, to see if
  2228. ;    the line is free,  try IO.ATT with a short marktime to abort the
  2229. ;    attach in case the line is already in use (actually call ASSDEV)
  2230. ;
  2231. ;    Added edit /41/ 23-DEC-1985 10:20
  2232. ;
  2233. ;    Local copy of TLON$S from M+ v3
  2234. ;
  2235. ;    Since I may have to do this on M+ 2.1 or RSTS v9, those RSXMAC's
  2236. ;    have TLOG$S but not TLON$S.  Thus lets define it here. Note that
  2237. ;    trying to execute TLON or TLOG on old RSX's won't hurt anything,
  2238. ;    they will simply return an error.
  2239.  
  2240.     .MACRO    TLON$S    MOD,TBMSK,STATUS,LNS,LNSSZ,ENS,ENSSZ,RSIZE,RTBMOD,ERR
  2241.     .MCALL    DIR$,MOV$,MVB$,LNMOD$
  2242.     LNMOD$
  2243.     MOV$    STATUS
  2244.     MOV$    RTBMOD
  2245.     MOV$    RSIZE
  2246.     MOV$    ENSSZ
  2247.     MOV$    ENS
  2248.     MOV$    LNSSZ
  2249.     MOV$    LNS
  2250.     MVB$    TBMSK,#0
  2251.     MVB$    #13.,MOD
  2252.     MOV    (PC)+,-(SP)
  2253.     .BYTE    207.,10.
  2254.     DIR$    ,ERR
  2255.     .ENDM    TLON$S
  2256.  
  2257.  
  2258.     tr$res    =    0
  2259.     tr$nam    =    2
  2260.     tr$uni    =    4
  2261.  
  2262. trntrm::save    <r1,r2,r3,r4>        ; +/41/ save temp registers 
  2263.     sub    #10    ,sp        ; local r/w things
  2264.     mov    sp    ,r3        ; base it off of r3
  2265.     sub    #30    ,sp        ; allocate a result buffer
  2266.     mov    sp    ,tr$res(r3)    ; and a pointer to it
  2267.     sub    #30    ,sp        ; allocate buffer for xlate name
  2268.     mov    sp    ,tr$nam(r3)    ; and a pointer to the buffer
  2269.     mov    #-1    ,tr$uni(r3)    ; 'unit' number counter
  2270.     call    getsys            ; vanilla RSX 11M today?
  2271.     cmpb    r0    ,#SY$11M    ; well ?
  2272.     bne    10$            ; no
  2273.     jmp    90$            ; yes, do nothing at all then
  2274.  
  2275. 10$:    STRCPY    tr$nam(r3),#ln$nam    ; copy the prototype name over
  2276.     tst    tr$uni(r3)        ; is this the first time through?
  2277.     bmi    30$            ; yes (ie, it's -1)
  2278.     mov    tr$uni(r3),r1        ; no, append the 'unit' on logical
  2279.     clr    r2            ; so we get a name like KERMIT$LINE2
  2280. 20$:    tstb    (r0)+            ; get to the end of the logical
  2281.     bne    20$            ; not yet
  2282.     dec    r0            ; r0 --> end of copy of prototype
  2283.     call    $cbdmg            ; r0 already had address from STRCPY
  2284.     clrb    @r0            ; insure .asciz
  2285. 30$:    clr    -(sp)            ; allocate buffer for returned_size
  2286.     mov    sp    ,r1        ; and a pointer to it
  2287.     clr    -(sp)            ; allocate buffer for 'RTBMOD'
  2288.     mov    sp    ,r2        ; and a pointer to it also
  2289.     strlen    tr$nam(r3)        ; get length of name to translate
  2290.     tst    proflg            ; is this P/OS today ?
  2291.     bne    40$            ; yes, use TLOG$S then
  2292.     TLON$S    #0,ln$msk,#0,tr$nam(r3),r0,tr$res(r3),#27,r1,r2
  2293.     br    50$            ;    
  2294. 40$:    TLOG$S    #0,ln$msk,#0,tr$nam(r3),r0,tr$res(r3),#27,r1,r2
  2295. 50$:    tst    (sp)+            ; ignore the returned table number
  2296.     mov    (sp)+    ,r1        ; get the length of translated string
  2297.     cmpb    @#$DSW    ,#IS.SUC    ; successfull translation ?
  2298.     bne    70$            ; no
  2299. 60$:    add    tr$res(r3),r1        ; success, make name .asciz
  2300.     clrb    @r1            ; simple
  2301.     CALLS    assdev    ,<tr$res(r3)>    ; parse and assign the device
  2302.     cmpb    r0    ,#IE.DAA    ; device busy today ?
  2303.     beq    80$            ; yes, try next logical
  2304.     tst    r0            ; other errors are fatal
  2305.     bne    100$            ; exit
  2306.     STRCPY    @r5    ,tr$res(r3)    ; success, return device name
  2307.     clr    r0            ; success
  2308.     br    100$            ; exit
  2309.  
  2310. 70$:    tst    tr$uni(r3)        ; translation failure, first time?
  2311.     bpl    90$            ; no, error is fatal
  2312. 80$:    inc    tr$uni(r3)        ; first time, goto KERMIT$LINE0
  2313.     jmp    10$            ; next logical name please
  2314.  
  2315. 90$:    clr    r0            ; return an error
  2316.     bisb    #IE.IDU    ,r0        ; return invalid device name
  2317. 100$:    add    #10+<2*30>,sp        ; pop local buffers
  2318.     unsave    <r4,r3,r2,r1>        ; and pop registers we saved
  2319.     return                ; -/41/ exit
  2320.  
  2321.  
  2322.     .save
  2323.     .psect    $idata
  2324. ln$nam::.asciz    /KERMIT$LINE/        ; prototype logical name
  2325.     .even                ; always please
  2326. ln$msk::.word    0            ; may want .word IN.SYS!IN.GRP
  2327.     .restore
  2328.  
  2329.  
  2330.  
  2331.     .sbttl    dialout line setup routines    ;              /45/
  2332.  
  2333.  
  2334. ;    From Steve Heflin, 08-Feb-86
  2335. ;
  2336. ;    These SET and RESTORE line characteristics for the DIAL command
  2337. ;    that are special for talking to the modem. These are NOT needed
  2338. ;    for RSTS/E and RT11,  so thus are return stubbs to  resolve the
  2339. ;    global symbol references.
  2340.  
  2341.  
  2342. tidias::                ; Setup line for dialout      /45/
  2343.     call    getprv            ; get privledges          /45/
  2344.     cmpb    savdlu+1,tcdlu        ; already in dialout mode ?      /45/
  2345.     beq    45$            ; yes, no need to change it      /45/
  2346.     tstb    tcdlu            ; allowing tc.dlu change?      /45/
  2347.     beq    45$            ; no                  /45/
  2348.     movb    tcdlu    ,fixti2+1     ; adust setting for TC.DLU      /45/
  2349.     dir$    #set.dlu        ; issue set              /45/
  2350. 45$:    dir$    #set.chars        ; set other attribs. for dialout  /45/
  2351.     call    drpprv            ; drop privs              /45/
  2352.     return                ;                   /45/
  2353.  
  2354.  
  2355.  
  2356. tidiar::                ; Restore remote line attrib.      /45/
  2357.     call    getprv            ; get privledges          /45/
  2358.     cmpb    savdlu+1,fixti2+1    ; if TC.DLU param got changed      /45/
  2359.     beq    50$            ; no,                   /45/
  2360.     movb    savdlu+1,fixti2+1    ; yes, restore it like it was      /45/
  2361.     dir$    #set.dlu        ;      issue request          /45/
  2362. 50$:    dir$    #rest.chars        ; restore remote line attributes  /45/
  2363.                     ; that could have been lost when  /45/
  2364.                     ; carrier was detected          /45/
  2365.     call    drpprv            ; drop privs              /45/
  2366.     return                ;                   /45/
  2367.  
  2368.  
  2369.     .sbttl    find out kind of terminal
  2370.  
  2371. ;    INQTER 12-Feb-86  14:51:00 Brian Nelson
  2372. ;
  2373. ;    This returns VT100 for all VT1xx and VT2xx terminals.
  2374. ;    Since we  don't treat VT200's different,  why bother.
  2375. ;    If TC.ANI is unknown on old RSX's, SF.GMC will simply
  2376. ;    stop there,  returning only TC.TPP.  For applications
  2377. ;    that REALLY need to know the terminal type,  take out
  2378. ;    the check for TC.ANI. Including the TC.ANI helps when
  2379. ;    Digital adds new VTxxx terminals.
  2380.  
  2381.     .enabl    lsb
  2382.  
  2383. inqter:    save    <r1,r2>            ; /45/ Get the type of terminal
  2384.     clr    -(sp)            ; /45/ A small buffer to use
  2385.     clr    -(sp)            ; /45/ Another one
  2386.     mov    sp    ,r2        ; /45/ A pointer to that buffer
  2387.     movb    #TC.TTP    ,@r2        ; /45/ Characteristic to read
  2388.     movb    #TC.ANI    ,2(r2)        ; /45/ Does this one work on old RSXs
  2389.     qiow$s    #SF.GMC,#5,,,,,<r2,#4>    ; /45/ Get RSX to tell us now
  2390.     bcs    90$            ; /45/ Failed, return TTY
  2391.     tstb    3(r2)            ; /45/ See if ANSICRT
  2392.     bne    20$            ; /45/ YES, exit now with VT100
  2393.     mov    #200$    ,r1        ; /45/ Check for it
  2394. 10$:    tstb    @r1            ; /45/ End of the list
  2395.     beq    90$            ; /45/ Yes, return TTY
  2396.     cmpb    (r1)+    ,1(r2)        ; /45/ A match ?
  2397.     bne    10$            ; /45/ No, exit please
  2398. 20$:    mov    #VT100    ,r0        ; /45/ Yes, return(VT100)
  2399.     br    100$            ; /45/ Exit
  2400.  
  2401. 90$:    clr    r0            ; /45/ No match, return(TTY)
  2402. 100$:    cmp    (sp)+    ,(sp)+        ; /45/ Pop buffer and exit
  2403.     unsave    <r2,r1>            ; /45/ Pop registers and exit
  2404.     return
  2405.  
  2406.  
  2407. ;    Note: If the PRO/350 is to actually be used for, say, editing
  2408. ;    or if it is to use the Kermit-11 connect code's GRAY key  re-
  2409. ;    mapping, then we should ALWAYS map T.BMP1 to a VT100. This is
  2410. ;    a problem,  however, as the value of T.BMP1 is the same as it
  2411. ;    is for T.V2XX. At least, according to the Micro-RSX doc vt2xx
  2412. ;    code is 35 (8), actual task build shows T.BMP1 to be 35 also.
  2413. ;    Please note the the PRO is NOT totally compatible with VT2xxs
  2414. ;    TC.BMP1 is the PRO terminal type (Bit MaPped)
  2415.  
  2416.     .save
  2417.     .psect    $PDATA    ,D
  2418. 200$:    .byte    T.V100    ,T.V101    ,T.V102    ,T.V105    ,T.V125    ,T.V131
  2419.     .byte    T.V132    ,T.BMP1    ,T.V2XX
  2420.     .byte    0
  2421.     .even
  2422.     .restore
  2423.     .dsabl    lsb
  2424.  
  2425.  
  2426.     .end
  2427.