home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / pdp11 / k11tsx.mac < prev    next >
Text File  |  2020-01-01  |  9KB  |  416 lines

  1.     .title    k11tsx    terminal service for TSX+
  2.     .ident    /1.0.01/
  3.  
  4. ;    28-May-84  09:06:31  Brian Nelson
  5. ;    09-Nov-84  10:13:19  Edited from mods by NED RHODES for TSX+ and
  6. ;                 created new module, K11TSX.MAC
  7. ;
  8. ;    6-May-85             Removed the .gval and .pval stuff that fooled
  9. ;                            with the tt config word as it is not need under
  10. ;                            TSX-Plus.  Disable wait mode in kbread so that
  11. ;                            other users could run under TSX-Plus.  With
  12. ;                            nowait enabled, job would hang system in tight
  13. ;                            read loop.  (Ned W. Rhodes)
  14. ;
  15. ;
  16. ;    Copyright (C) 1984 Change Software, Inc.
  17.  
  18.  
  19.  
  20.  
  21.  
  22.     .if ndf, K11INC
  23.     .ift
  24.     .include    /IN:K11MAC.MAC/
  25.     .endc
  26.  
  27.     .psect
  28.     .sbttl    definitions for multiple terminal support
  29.  
  30.     .mcall    .mrkt    ,.cmkt    ,.twait
  31.     .mcall    .gval    ,.pval
  32.     .mcall    .ttyout    ,.ttinr
  33.         .mcall  .spfun    ,.writw    ,.lookup,.close
  34.     .mcall    .serr,.herr
  35.     .enabl    gbl
  36.  
  37.  
  38.     jsw    =    44        ; job status word
  39.     ttlc$    =    040000        ; lower case bit
  40.     ttspc$    =    010000        ; terminal special mode
  41.     tcbit$    =    000100        ; inhibit terminal i/o wait
  42.     edit$    =    000020        ; disable sl bit
  43.     gtlin$    =    000010        ; non-terminating .gtlin
  44.     sysgen    =    372        ; sysgen features word
  45.     tsx$p    =    100000        ; running under TSX
  46.     mtty$    =    020000        ; multi terminal support
  47.     $tcfig    =    424        ; terminal configuration word
  48.     crlf$    =    000002        ; ignore width
  49.     ctrl.m    =    35
  50.     .macro    $mterr            ; map multiple terminal service
  51.     movb    @#errbyt,r0        ; into a global error code
  52.     asl    r0            ; simple to do
  53.     mov    mterr(r0),r0        ; thats all there is to it
  54.     .endm    $mterr
  55.  
  56.  
  57.     .save
  58.     .psect    mtmap    ,rw,d,lcl,rel,con
  59.  
  60.     .even
  61. ttsave:    .blkw    4
  62. ttctlc:    .blkw    1            ; for control C things in connect mode
  63. ttime:    .word    0,1            ; a tick sleep for .twait
  64.  
  65. mtty:    .byte    0            ; multiterminal support
  66. tsx:    .byte    0            ; under tsx flag
  67. xlact:    .byte    0            ; xl is being used
  68. tsxrem:    .byte    0            ; logged into tsx
  69.     .even
  70. m.tsxs:    .byte    ctrl.m,'S        ; single character
  71.     .byte    ctrl.m,'W        ; tape mode on
  72.     .byte    ctrl.m,'U        ; No wait
  73. ;    .byte    ctrl.m,'D,'W-100    ; Make ^W an activation char ; jam
  74. ;    .byte    ctrl.m,'D,lf        ; Do it for linefeed, too
  75.     .byte    ctrl.m,'Y        ; No linefeed echo
  76.     .byte    ctrl.m,'R        ; High efficiency
  77.     .byte    0
  78.     .even
  79. m.tsxr:    .byte    ctrl.m,'T        ; single-character off
  80.     .byte    ctrl.m,'X        ; tape mode off
  81.     .byte    ctrl.m,'Z        ; line feed echo
  82.     .byte    0
  83.     .even
  84. hieff:    .byte    0,120            ; hi eff off
  85.     .restore
  86.  
  87.  
  88.  
  89.  
  90.     .sbttl    assign the terminal unit
  91.  
  92.  
  93.  
  94. t.assdev::
  95.     save    <r1>            ; we may want to use these
  96.     movb    #1    ,tsx        ; flag for tsx
  97.     movb    #1    ,tsxrem        ; again
  98.     clr    r0            ; no errors
  99.     unsave    <r1>
  100.     return
  101.  
  102.  
  103. t.deadev::
  104.     save    <r1>            ; save this one, folks
  105.     clrb    tsxrem            ; drop flag
  106.     clr    r0
  107. 100$:    unsave    <r1>            ; exit
  108.     return                ; dh
  109.  
  110.  
  111.  
  112.     .sbttl    initialize the terminal
  113.  
  114.  
  115. ;    T T Y I N I
  116. ;
  117. ;    input:    @r5    device name
  118. ;        2(r5)    LUN
  119. ;        4(r5)    modifiers
  120. ;
  121. ;    output:    r0    error code
  122.     ttmode    =    100 ! 10000 ! 40000
  123.  
  124. t.ttyini::
  125.     save    <r1,r2>            ; we will need this one
  126.  
  127.     call    ttpars            ; parse the device name
  128.     bcs    70$            ; name ok
  129.     bis    #ttmode,@#jsw        ; tt special, no wait, lowercase
  130. ;    .gval    #rtwork,#$tcfig        ; get terminal configuration word
  131. ;    bic    #crlf$,r0        ; no crlf
  132. ;    mov    r0,r1            ; copy it
  133. ;    .pval    #rtwork,#$tcfig,r1    ; and set it in fixed offset area
  134. ;    tstb    tsx            ; are we under tsx??
  135. ;    beq    5$            ; nope
  136.     .gval    #rtwork,#-4        ; get tsx leadin
  137.     cmp    r0,#ctrl.m        ; default?
  138.     beq    4$            ; skip the labor
  139.     movb    r0,m.tsxr        ;  single character activation mode
  140.     movb    r0,m.tsxr+2        ;  and tape mode
  141.     movb    r0,m.tsxr+4        ;  and some more
  142.  
  143.     movb    r0,m.tsxs        ; now set it in the tsx strings
  144.     movb    r0,m.tsxs+2        ;  which enable and disable
  145.     movb    r0,m.tsxs+4        ;  some more
  146.     movb    r0,m.tsxs+6        ;  some more
  147.     movb    r0,m.tsxs+8.        ;  some more
  148. 4$:    .print    #m.tsxs,#10.        ; set the terminal state
  149.  
  150. 5$:    mov    #1000    ,r2
  151. 10$:    calls    binrea    ,<2(r5),#-1>    ; eat anything that's pending please
  152.     dec    r2            ; don't loop forever please
  153.     beq    20$            ; exit the loop
  154.     tst    r0            ; did we get anything at all ?
  155.     beq    10$            ; yes, eat some more input
  156. 20$:    clr    r0            ; all done
  157.     br    100$            ; bye
  158.  
  159. 70$:    mov    #er$dev    ,r0        ; device name parse failed
  160.     br    100$            ; bye
  161.  
  162. 100$:    unsave    <r2,r1>            ; pop and exit
  163.     return
  164.  
  165.  
  166.  
  167.  
  168.  
  169.     .sbttl    save/restore terminal settings
  170.  
  171.  
  172. t.ttysav::
  173.     save    <r1>            ; we will use this one
  174. ;
  175. ;    No multi-terminal support in TSX-plus
  176. ;
  177.     mov    @#jsw,ttparm        ; save jsw
  178. ;    .gval    #rtwork,#$tcfig        ; get terminal configuration
  179. ;    mov    r0,ttparm+2        ; and save it
  180.     clr    r0            ; success
  181. 100$:    unsave    <r1>            ; pop this and exit
  182.     return
  183.  
  184.  
  185.  
  186. t.ttyrst::
  187.     save    <r1>            ; we will use this one
  188. ;
  189. ;    No multi-terminal support
  190. ;
  191.     mov    ttparm,@#jsw        ; restore jsw
  192. ;    .pval    #rtwork,#$tcfig,ttparm+2; restore terminal configuration
  193. ;    tstb    tsx            ; are we under tsx??
  194. ;    beq    70$            ; nope
  195.     mov    #hieff,r0        ; point to block
  196.     tst    tsxflg            ; /38/ really TSX+
  197.     bmi    70$            ; /38/ no
  198.     emt    375            ; and turn off high efficiency
  199.     .print    #m.tsxr,#6        ; reset stuff
  200. 70$:    clr    r0            ; success
  201.     br    100$            ; bye
  202.  
  203. 100$:    unsave    <r1>            ; pop this and exit
  204.     return
  205.  
  206.  
  207.  
  208.     .sbttl    binrea    read binary
  209.  
  210.  
  211. ;    B I N R E A
  212. ;
  213. ;    input:    @r5    LUN
  214. ;        2(r5)    timeout
  215. ;    output:    r0    error code
  216. ;        r1    character just read
  217.  
  218.  
  219. t.xbinre::
  220. t.binrea::
  221.     save    <r2,r3,r4>        ; we may want to use these here
  222.     bis    #10000    ,@#JSW        ; /39/ insure no echoing please
  223.     clr    -(sp)            ; allocate a mark time tim buffer
  224.     clr    -(sp)            ; simple
  225.     mov    sp    ,r2        ; and point to it
  226.     mov    @r5    ,r3        ; get the LUN
  227.  
  228.     cmp    2(r5)    ,#-1        ; read without any wait ?
  229.     bne    20$            ; no
  230.     .ttinr                ; try to read a single character
  231.     bcs    80$            ; nothing was there, so exit
  232.     mov    r0    ,r1        ; return character in r1
  233.     clr    r0            ; no errors
  234.     br    100$            ; exit
  235.  
  236. 20$:    mov    2(r5)    ,r1        ; get the timeout in seconds
  237.     mul    #60.    ,r1        ; into ticks now
  238.  
  239. 30$:    .ttinr                ; try and read console
  240.     bcs    40$            ; none
  241.     mov    r0,r1            ; save character
  242.     clr    r0            ; success
  243.     br    100$            ; exit
  244. 40$:    dec    r1            ; been here too long ?
  245.     beq    80$            ; yes, exit with error
  246.     .twait    #rtwork,#ttime        ; sleep a moment please
  247.     br    30$            ; and try again please
  248.  
  249. 80$:    mov    #er$nin    ,r0        ; no data today
  250.     br    100$            ; bye
  251.  
  252. 100$:    add    #4    ,sp        ; pop local buffers
  253.     unsave    <r4,r3,r2>        ; pop registers and exit
  254.     return
  255.  
  256.     .sbttl    binary write
  257.  
  258.  
  259.  
  260. ;    B I N W R I
  261. ;
  262. ;    binwri( %loc buffer, %val buffer_size, %val lun )
  263. ;
  264. ;    output:    r0    error code
  265. ;
  266.  
  267.  
  268.  
  269. t.binwri::
  270.     save    <r1,r2>            ; save registers we may need
  271.     clr    r0            ; preset no errors as of yet
  272.     mov    @r5    ,r1        ; get the string address
  273.     mov    2(r5)    ,r2        ; get the string length
  274.     beq    100$            ; nothing to do
  275. 10$:    .ttyou    (r1)+            ; dump and exit
  276.     sob    r2    ,10$        ; next please
  277.     clr    r0            ; success today
  278.  
  279. 100$:    unsave    <r2,r1>            ; pop the saved registers
  280.     return                ; and exit
  281.  
  282.  
  283.  
  284.     .sbttl    parse terminal unit
  285.  
  286.  
  287. ;    T T P A R S
  288. ;
  289. ;    input:    @r5    address of RT11 Multiple terminal service unit string
  290. ;    output:    r0    unit in binary
  291.  
  292.  
  293. t.ttpars::
  294.     clr    r0            ; /39/ does not make sense in
  295.     return                ; /39/ this context.
  296.     mov    r1    ,-(sp)        ; save scratch register please
  297.     mov    @r5    ,r0        ; get the address of the string
  298.     call    200$            ; check for legit character
  299.     bcs    110$            ; oops
  300.     movb    (r0)+    ,r1        ; get the first byte please
  301.     sub    #'0    ,r1        ; convert to binary
  302.     call    200$            ; check for legit character
  303.     bcs    110$            ; oops
  304.     movb    @r0    ,r0        ; get the next digit
  305.     beq    100$            ; nothing there then we are done
  306.     mul    #12    ,r1        ; something there, shift over by 10
  307.     sub    #'0    ,r0        ; and convert low digit to binary
  308.     add    r0    ,r1        ; add into the accumulator
  309. 100$:    mov    r1    ,r0        ; and return the result
  310.     clc                ; return success
  311. 110$:    mov    (sp)+    ,r1
  312.     return
  313.  
  314.  
  315. 200$:    tstb    @r0            ; null ?
  316.     beq    210$            ; yes, it's ok
  317.     cmpb    @r0    ,#'0        ; must only be digits today
  318.     blo    220$            ; oops
  319.     cmpb    @r0    ,#'9        ; 0..9
  320.     bhi    220$            ; bad device name
  321. 210$:    clc                ; device name ok so far
  322.     return                ; bye
  323. 220$:    sec                ; bad, set and exit
  324.     return
  325.  
  326.  
  327. ;    G T T N A M
  328. ;
  329. ;    input:    @r5    address of console name to be written
  330. ;    output:    @r5    console name, always .asciz /0/
  331.  
  332.  
  333. t.gttnam::
  334.     mov    @r5    ,r0        ; get the address of where to put it
  335.     movb    #'0    ,(r0)+        ; tt0: is always mt unit 0
  336.     clrb    @r0            ; insure .asciz and exit
  337.     clr    r0            ; return success
  338.     return                ; bye
  339.  
  340.  
  341.  
  342. t.ttyfin::
  343. 100$:    clr    r0            ; return 'success'
  344.     return                ; and exit
  345.  
  346.  
  347.     .sbttl    speed read and change
  348.  
  349. t.ttspee::
  350. t.setspd::
  351.     clr    r0            ; find the speed map now
  352.     return
  353.  
  354.     .sbttl    terminal i/o things we don't need, can't do or haven't done yet
  355.  
  356.  
  357. t.ttxon::
  358. t.cantyp::
  359. t.ttset::
  360. t.ttydtr::
  361. t.ttrfin::
  362. t.ttrini::clr    r0
  363.     return
  364.  
  365. t.ttyhan::mov    #er$iop    ,r0
  366.     return
  367.  
  368.     .mcall    .ttyin
  369.     jsw    =    44
  370.  
  371. t.kbread::mov    r2    ,-(sp)
  372.     mov    r3    ,-(sp)
  373.     bis    #40000    ,@#jsw        ; enable lower case tt: input
  374.     bic    #10000!100,@#jsw    ; ditch single ch input and nowait
  375.     mov    @r5    ,r1        ; a buffer to put the chars
  376.     mov    #80.    ,r3        ; size of the buffer here
  377. ;10$:    .scca    #area    ,#kmonbf    ; so we can catch control Z
  378. 10$:    .ttyin                ; read a character please
  379.     tstb    r0
  380.     beq    15$            ; a null
  381.     cmpb    r0    ,#'Z&37        ; control Z ?
  382.     beq    20$            ; yes
  383.     cmpb    r0    ,#'C&37        ; control C ?
  384.     beq    20$            ; yep
  385.     cmpb    r0    ,#15        ; carriage return ?
  386.     beq    30$            ; yep
  387.     movb    r0    ,(r1)+        ; return what we just got
  388.     cmpb    r0    ,#14        ; form feed ?
  389.     beq    40$            ; yep
  390. 15$:    sob    r3    ,10$        ; next please
  391. 20$:    mov    #er$eof    ,r0        ; say read error and exit
  392.     br    100$            ; bye
  393. 30$:    movb    #cr    ,(r1)+        ; return all terminators please
  394.     movb    #lf    ,(r1)+        ; simple
  395.     .ttyin                ; eat the line feed now
  396. 40$:    clrb    @r1
  397.     sub    @r5    ,r1        ; the length
  398.     clr    r0
  399. 100$:    mov    (sp)+    ,r3
  400.     mov    (sp)+    ,r2
  401.     return
  402.  
  403.  
  404.  
  405.  
  406.  
  407. t.senbrk::
  408. t.finrt::
  409.     clr    r0
  410.     return
  411.  
  412.  
  413.  
  414.  
  415.     .end
  416.