home *** CD-ROM | disk | FTP | other *** search
/ kermit.columbia.edu / kermit.columbia.edu.tar / kermit.columbia.edu / test / pdp11 / krteco.mac < prev    next >
Text File  |  1996-10-17  |  18KB  |  631 lines

  1.     .sbttl    KRTECO    New RSTS/E connect code
  2.     .psect
  3.     .ident    /V04.64/
  4.  
  5. ; /E64/    05-May-96  John Santos
  6. ;
  7. ;    Remove message macro and move messages to top
  8. ;    Use mode 33 (binary with flow-control) instead of binary
  9. ;    use wrtall instead of print macro
  10.  
  11.     .include    /SY:[1,2]COMMON.MAC/
  12.  
  13.  
  14.     .if ndf, KRTINC
  15.     .ift
  16.     .include    /IN:KRTMAC.MAC/
  17.     .endc
  18.  
  19.     .enabl    gbl
  20.     
  21. ;    Copyright (C) 1986 Change Software, Inc
  22. ;
  23. ;    02-Apr-86  14:58:29  Brian Nelson
  24. ;
  25. ;    Warning: This uses binary I/O, thus you never want to
  26. ;
  27. ;    (1) Do I/O to channel zero
  28. ;    (2) Timeout on a terminal read
  29. ;
  30. ;    Either one of the above events will cause binary mode
  31. ;    to go away. We can't use multiple delimiters here due
  32. ;    to the terminal drivers processing of C1 controls.
  33. ;
  34. ;    This is tested only on RSTS/E 9.1 and Field Test 9.2
  35. ;    It should work fine on 8.0-07, but no gaurentees.
  36.  
  37.  
  38.     .psect    concod    ,ro,i,lcl,rel,con
  39.     .psect    condat    ,rw,d,lcl,rel,con
  40.  
  41.  
  42.     .macro    READTT    buffer,size=#80.,lun,time=#0
  43.     mov    time    ,-(sp)
  44.     mov    lun    ,-(sp)
  45.     mov    size    ,-(sp)
  46.     mov    buffer    ,-(sp)
  47.     call    $READTT
  48.     .endm    READTT
  49.  
  50.  
  51.     .macro    WRITETT buffer,size=#0,lun
  52.     mov    lun    ,-(sp)
  53.     mov    size    ,-(sp)
  54.     mov    buffer    ,-(sp)
  55.     call    $WRITETT
  56.     .endm    WRITETT
  57.     
  58.     .macro    fqcopy    dst    ,src
  59.     mov    src    ,-(sp)
  60.     mov    dst    ,-(sp)
  61.     call    $fqcopy
  62.     .endm    fqcopy
  63.  
  64.  
  65.     .macro    CLRFQB
  66.     call    $clrfq
  67.     .globl    $clrfq
  68.     .endm    CLRFQB
  69.  
  70.     .macro    CLRXRB
  71.     call    $clrxr
  72.     .globl    $clrxr
  73.     .endm    CLRXRB
  74.  
  75.  
  76.     NODATA    ==    13.        ; no data for terminal read
  77.     DETKEY    ==    27.        ; i/o to detached tt line
  78.  
  79.         .sbttl  Local data              ; /E64/ consolidated here..
  80.  
  81.     .psect    condat
  82.  
  83.     .even
  84. xksdon:    .blkw    1            ; Remote terminal set done
  85. ttsdon:    .blkw    1            ; Local terminal set done
  86. ioseen:    .blkw    1            ; Some input was seen somewhere
  87. ttio:    .blkw    1            ; Console read worked
  88. xkio:    .blkw    1            ; Remote read worked
  89. eseen:    .blkw    1            ; Control \ happened at console
  90. savtt:    .blkb    40            ; Save local terminal chars
  91. savxk:    .blkb    40            ; Save outgoing line chars
  92. bufqxk:    .blkw    1            ; Connect line buffer quota
  93. ttunit:    .blkw    1            ; Our console terminal unit
  94. xkunit:    .blkw    1            ; Connected line's unit number
  95. v9flag:    .blkw    1            ; Iff version 9.x or later
  96.  
  97. XKSIZE    ==    600            ; Large buffers for remote reads
  98. xkbuff::.blkb    XKSIZE+2        ; Buffer for connected line
  99. ttbuff:    .blkb    80.            ; Buffer for console terminal
  100.  
  101.     .psect $pdata
  102. hlptxt:    .ascii    /B    Try to send a  break to the  remote/<cr><lf>
  103.     .ascii    /C    Connect back to the local Kermit-11/<cr><lf>
  104.     .ascii    /I    Drop  and raise DTR (for RSTS only)/<cr><lf>
  105.     .ascii    /Q    Quit console logging.   See SET LOG/<cr><lf>
  106.     .ascii    /R    Resume console logging. See SET LOG/<cr><lf>
  107.     .ascii    /X    Send XON and cancel any active XONs/<cr><lf>
  108.     .asciz    /RUBOUT    Try to fake a break to the remote/<cr><lf>
  109.     .ascii    /?    Print this MESSAGE/<cr><lf>
  110. null2:    .byte    0,0
  111. eco.01:    .asciz    "Please use the SET LINE command"<cr><lf>
  112. eco.02:    .asciz    "Connected line and console line are the same unit"<cr><lf>
  113. eco.03:    .asciz    "Connecting to: "
  114. eco.04:    .asciz    " Speed: "
  115. eco.05:    .asciz    "Type Control "
  116. eco.06:    .asciz    "C to return to the local Kermit-11"<cr><lf>
  117. eco.07:    .asciz    "??DETKEY error - DTR not present or has been lost"<cr><lf>
  118. eco.08:    .asciz    <cr><lf>
  119. eco.09:    .asciz    "Failure to open terminal line - "
  120.     .even
  121.  
  122.     .psect    concod
  123.     .enabl    lsb
  124.  
  125. doconn::call    init            ; Startup
  126.     bcs    100$            ; Oops
  127.     call    ttinit            ; Save terminal characteristics
  128.     bcs    90$            ; Die
  129.                     ;
  130. 10$:    mov    #ttbuff    ,r4        ; Pointer to local term buffer
  131.     mov    #xkbuff    ,r5        ; Pointer to remotes buffers.
  132.     READTT    buffer=r4,lun=#LUN.CO,size=#1 ; Look for data on LOCAL term
  133.     tst    r0            ; Was there anything there?
  134.     bne    50$            ; No
  135.                     ;
  136.     mov    sp    ,ioseen        ; Yes, flag that we saw some I/O
  137.     movb    @r4    ,r0        ; Check for console commands
  138.     bicb    #^C177    ,r0        ; Insure no parity set.
  139.     cmpb    r0    ,conesc        ; Escape command prefix ?
  140.     bne    20$            ; No
  141.     READTT    buffer=r4,lun=#LUN.CO,size=#1,time=#20
  142.     tst    r0            ; Successfull
  143.     bne    50$            ; No, ignore the data
  144.     movb    @r4    ,r0        ; Check for console commands
  145.     bicb    #^C177    ,r0        ; Insure no parity set.
  146.     cmpb    r0    ,conesc        ; Escape command prefix ?
  147.     beq    20$            ; Yes, dump the character now.
  148.     call    concmd            ; Check for console command.
  149.     br    80$            ; And skip the next remote read
  150.  
  151. 20$:    tst    duplex            ; Is this a half duplex line?
  152.     beq    25$            ; No, then don't echo the data
  153.     WRITETT    buffer=r4,lun=#LUN.CO,size=#1
  154. 25$:    mov    r4    ,r2        ; Insure parity is setup now.
  155.     mov    r1    ,r3        ; The byte count next
  156.     beq    50$            ; Nothing there ?
  157. 30$:    setpar    @r2    ,(r2)+        ; Set parity if need be.
  158.     sob    r3    ,30$        ; Next character please.
  159.     WRITETT    buffer=r4,lun=#LUN.XK,size=#1
  160.  
  161. 50$:    READTT    buffer=r5,lun=#LUN.XK,size=#XKSIZE
  162.     tst    r0            ; Did the remote read succeed?
  163.     beq    60$            ; Yes, dump to local terminal.
  164.     call    iocheck            ; No, check for allowable errors
  165.     br    80$            ; And exit with C set for FATAL
  166. 60$:    mov    sp    ,ioseen        ; Had some input, flag no SLEEP
  167.     mov    r5    ,-(sp)        ; Now get rid of XOFF characters
  168.     mov    r1    ,r0        ; Save buffer address and byte count
  169.     beq    75$            ; Be SURE that byte count is nonzero.
  170. 65$:    cmpb    (r5)    ,#'S&37        ; If this is an off then replace it
  171.     bne    66$            ; will a NULL character please.
  172.     clrb    (r5)            ; Was an XOFF, so stuff a NULL in.
  173. 66$:    cmpb    parity    ,#PAR$NONE    ; Parity up?
  174.     beq    70$            ; No
  175.     bicb    #200    ,(r5)        ; Yes, dump it
  176. 70$:    inc    r5            ; Next please
  177.     sob    r0    ,65$        ; Keep going
  178. 75$:    mov    (sp)+    ,r5        ; Restore the buffer pointer.
  179.     WRITETT    buffer=r5,lun=#LUN.CO,size=r1
  180.     call    dumplog            ; May need to dump to log file
  181.     clc                ; Success flag
  182.  
  183. 80$:    bcs    90$            ; If set, it's time to EXIT
  184.     tst    ioseen            ; Not set, do we really want to
  185.     bne    85$            ; take a short nap ? If ne, no.
  186.     CLRXRB                ; Yes, insure future rsts/e's ok
  187.     mov    #1    ,XRB+0        ; One second sleep
  188.     .SLEEP                ; Do it
  189. 85$:    clr    ioseen            ; No more i/o has been seen
  190.     br    10$            ; Next please
  191.  
  192. 90$:    call    ttrst            ; Restore terminal chars
  193. 100$:    return
  194.  
  195.     .dsabl    lsb
  196.  
  197.     .sbttl    misc support routines
  198.     .enabl    lsb
  199.  
  200.  
  201. init:    clr    eseen            ; No escape seen
  202.     clr    xkio            ; No remote I/O seen
  203.     clr    ttio            ; No local I/O seen
  204.     clr    ioseen            ; No I/O at all happened
  205.     clr    ttsdon            ; No terminal settings done yet
  206.     clr    xksdon            ; No terminal settings done yet
  207.     CLRFQB                ; Zap the firqb please
  208.     movb    #UU.PRV    ,FIRQB+FQFUN    ; Execute a V9 only call so we
  209.     .UUO                ; can see if this is still v8
  210.     clr    v9flag            ; Assume v8
  211.     tstb    FIRQB            ; Did this call succeed?
  212.     bne    10$            ; No
  213.     mov    sp    ,v9flag        ; Yes, this is 9.0 or later
  214. 10$:    tstb    ttname            ; Any line previously defined?
  215.     bne    30$            ; Yes
  216.     tstb    @argbuf            ; Any name on the command line?
  217.     bne    20$            ; Yes
  218.     wrtall    #eco.01            ; /E64/
  219.     jmp    90$            ; Error exit
  220. 20$:    strcpy    #ttname    ,argbuf        ; No name, copy from command line
  221. 30$:    CLRFQB                ; Get our console terminal unit #
  222.     movb    #UU.SYS    ,FIRQB+FQFUN    ; Do the systat call now
  223.     .UUO                ; Simple
  224.     movb    FIRQB+5    ,ttunit        ; Save our terminal unit number
  225.     mov    #XRB    ,r3        ; Get the unit number next
  226.     mov    #ttname    ,r2        ; Load up the XRB
  227.     CLRFQB                ; Insure no odd defaults around
  228.     CLRXRB                ; Ditto
  229.     STRLEN    r2            ; Get the length of the device name
  230.     mov    r0    ,(r3)+        ; Copy the length of the name
  231.     mov    r0    ,(r3)+        ; ...Copy the length of the name
  232.     mov    r2    ,(r3)+        ; Copy the device name address
  233.     .FSS                ; Do a filename string scan now
  234.     movb    FIRQB    ,r0        ; Successfull?
  235.     bne    80$            ; No, exit
  236.     movb    FIRQB+FQDEVN,xkunit    ; Save the connected line unit#
  237.     bit    #20000!40000,XRB+10    ; Did we REALLY get a devicename?
  238.     bne    40$            ; Yes
  239.     movb    #6    ,r0        ; No, preload bad device name
  240.     br    80$            ; And exit with error MESSAGE
  241. 40$:    cmpb    xkunit    ,ttunit        ; Are they one and the same ?
  242.     bne    50$            ; No, it's ok
  243.     wrtall    #eco.02            ; /E64/
  244.     br    90$            ; Error if so
  245. 50$:    tst    doallo            ; /58/ Really assign it?
  246.     beq    55$            ; /58/ No
  247.     CLRFQB                ; Insure outgoing line is assigned
  248.     movb    #UU.ASS    ,FIRQB+FQFUN    ; Subfunction code
  249.     mov    #"KB    ,FIRQB+FQDEV    ; KB
  250.     movb    xkunit    ,FIRQB+FQDEVN+0    ; Unit number
  251.     movb    #377    ,FIRQB+FQDEVN+1    ; Unit number is real
  252.     .UUO                ; Simple
  253. 55$:    CALL    ttspeed            ; Get interface speed
  254.     mov    r0    ,r2        ; Save the speed
  255.     wrtall    #eco.03            ; /E64/ Dump the data
  256.     wrtall    #ttname            ; /E64/ And the connect line name
  257.     tst    r2            ; Any speed info available?
  258.     beq    60$            ; No
  259.     wrtall    #eco.04            ; /E64/ Yes, dump the speed
  260.     decout    r2            ; Simple
  261.     .newline            ; /E64/ A crlf
  262.     wrtall    #eco.05            ; /E64/ How to return to local kermit
  263.     clr    -(sp)            ; ....
  264.     bisb    conesc    ,(sp)        ; The current control escape char.
  265.     add    #100    ,(sp)        ; Convert to printable representation
  266.     mov    sp    ,r0        ; .....
  267.     wrtall    r0            ; /E64/ .....
  268.     wrtall    #eco.06            ; /E64/ All done.
  269.     tst    (sp)+            ; Pop this
  270. 60$:    .newline            ; /E64/ A final CR/LF
  271.                     ; 
  272. 70$:    clc                ; Success
  273.     br    100$            ; Exit
  274.  
  275. 80$:    direrr    r0            ; Print RSTS/E error text
  276. 90$:    sec                ; Failure
  277. 100$:    return                ; Exit
  278.  
  279.  
  280.     .dsabl    lsb
  281.  
  282.  
  283.     .sbttl    save/set/restore terminal characteristics
  284.     .enabl    lsb
  285.  
  286. ttinit:    movb    #377    ,r0        ; Console terminal first
  287.     call    200$            ; Get term chars, part 0
  288.     FQCOPY    #savtt+0,#FIRQB        ; Save the characteristics
  289.     movb    xkunit    ,r0        ; Now for the CONNECTED terminal
  290.     call    200$            ; Ditto...
  291.     FQCOPY    #savxk+0,#FIRQB        ; Copy this also
  292.     tst    v9flag            ; Will the second part of the
  293.     beq    10$            ; get terminal chars succeed?
  294.     clrb    bufqxk            ; Clear buffer quota outz
  295.     CLRFQB                ; Yes, read the buffer quota
  296.     movb    #UU.TRM    ,FIRQB+FQFUN    ; Again ...
  297.     incb    FIRQB+4            ; Subfunction = 1
  298.     movb    xkunit    ,FIRQB+5    ; Unit number of connected line
  299.     .UUO                ; Read current buffer quota
  300.     tstb    FIRQB            ; Success?
  301.     bne    10$            ; No, ignore it
  302.     movb    FIRQB+27,bufqxk        ; Save it
  303.     CLRFQB                ; Clear again
  304.     movb    #UU.TRM    ,FIRQB+FQFUN    ; ....
  305.     incb    FIRQB+4            ; Subfunction = 1
  306.     movb    xkunit    ,FIRQB+5    ; Unit number
  307. ..CBFQ    == . + 2            ;
  308.     movb    #<XKSIZE*2>/40,FIRQB+27    ; Buffer twice our internal size
  309.     .UUO                ; Do it ...
  310. 10$:    movb    #377    ,r0        ; Now set chars at last
  311.     mov    #LUN.CO    ,r1        ; Channel number for open
  312.     call    210$            ; .....
  313.     bcs    110$            ; It failed?
  314.     inc    ttsdon            ; Set and open done for local term
  315.     movb    xkunit    ,r0        ; Again please
  316.     mov    #LUN.XK    ,r1        ; Channel number for open
  317.     call    210$            ; .....
  318.     bcs    110$            ; Save success flag
  319.     inc    xksdon            ; Set and open done for remote term
  320. 100$:    clc                ; Say success and exit
  321. 110$:    return                ; At last
  322.  
  323.  
  324. 200$:    CLRFQB                ; Insure FIRQB is cleared out
  325.     movb    #UU.TRM    ,FIRQB+FQFUN    ; Terminal call today.
  326.     movb    r0    ,FIRQB+5    ; Console terminal this time
  327.     .UUO                ; Simple
  328.     clrb    FIRQB+4            ; Insure this field is (v8/v9)
  329.     bisb    FIRQB+36,FIRQB+20    ; Get 8bit setting in correct loc.
  330.     clr    FIRQB+36        ; And clear this field out
  331.     return                ; Exit
  332.  
  333. 210$:    CLRFQB                ; Clear FIRQB again....
  334.     movb    #UU.TRM    ,FIRQB+FQFUN    ; Terminal call today.
  335.     movb    r0    ,FIRQB+5    ; Console terminal this time
  336.     movb    #377    ,FIRQB+12    ; XON
  337.     movb    #377    ,FIRQB+35    ; GAG
  338.     movb    #31    ,FIRQB+20    ; 8bit and NoParity
  339.     movb    #200    ,FIRQB+11    ; LC output
  340.     movb    #377    ,FIRQB+15    ; LC input
  341.     movb    #377    ,FIRQB+23    ; No Uparrow
  342.     movb    #200    ,FIRQB+30    ; No delimiters please
  343.     .UUO                ; Simple
  344.     cmpb    r0    ,#377        ; Console terminal?
  345.     bne    215$            ; No
  346.     movb    ttunit    ,r0        ; Yes, insure valid unit number
  347.                     ;
  348. 215$:    CLRXRB                ; Clear the XRB
  349.     mov    #3    ,XRB+0        ; Function (disable echoing)
  350.     mov    r0    ,XRB+2        ; Terminal number
  351.     movb    #TTYHND    ,XRB+7        ; The device driver index next
  352.     .SPEC                ; Do it.
  353.                     ;
  354.     CLRFQB                ; Now open the terminal up
  355.     movb    #OPNFQ    ,FIRQB+FQFUN    ; Function code
  356.     movb    r1    ,FIRQB+FQFIL    ; Channel number
  357.     aslb    FIRQB+FQFIL        ; Times two, of course.
  358. ; /E64/    mov    #100001    ,FIRQB+FQMODE    ; Binary mode
  359.     mov    #100041    ,FIRQB+FQMODE    ; /E64/ Binary+Xon/Xoff mode
  360.     mov    #"KB    ,FIRQB+FQDEV    ; Device type
  361.     movb    r0    ,FIRQB+FQDEVN+0    ; Unit
  362.     movb    #377    ,FIRQB+FQDEVN+1    ; It's for real
  363.     CALFIP                ; Open it up and exit
  364.     movb    FIRQB    ,r0        ; Did the open succeed?
  365.     beq    220$            ; Yes
  366.     wrtall    #eco.09            ; /E64/
  367.     direrr    r0            ; No, an error MESSAGE please
  368.     sec                ; Exit
  369.     return                ; Bye
  370. 220$:    clc                ; Success
  371.     return                ; Exit
  372.  
  373.     .dsabl    lsb
  374.  
  375.  
  376.  
  377.     .sbttl    restore terminals
  378.  
  379.     .iif ndf, TTYHND, TTYHND = 2
  380.  
  381.  
  382. ttrst:    CLRFQB                ; Close channels up please
  383.     movb    #CLSFQ    ,FIRQB+FQFUN    ; Close a channel function
  384.     movb    #LUN.XK*2,FIRQB+FQFIL    ; Channel number times 2
  385.     CALFIP                ; Simple
  386.     CLRFQB                ; Insure FIRQB is clear again
  387.     movb    #CLSFQ    ,FIRQB+FQFUN    ; Close a channel function
  388.     movb    #LUN.CO*2,FIRQB+FQFIL    ; Channel number times 2
  389.     CALFIP                ; Simple
  390.     CLRXRB                ; Reset echoing on console term
  391.     mov    #2    ,XRB+0        ; Function (enable echoing)
  392.     mov    ttunit    ,XRB+2        ; Terminal number
  393.     movb    #TTYHND    ,XRB+7        ; The device driver index next
  394.     .SPEC                ; Do it.
  395.  
  396.     tst    ttsdon            ; Did we ever set this?
  397.     beq    10$            ; No
  398.     FQCOPY    #FIRQB    ,#savtt+0    ; Restore console terminal
  399.     movb    #UU.TRM    ,FIRQB+FQFUN    ; Function code
  400.     clrb    FIRQB+4            ; Insure cleared for v9..x
  401.     movb    #377    ,FIRQB+5    ; Console
  402.     .UUO                ; Simple
  403. 10$:    tst    xksdon            ; Did we set the remote up?
  404.     beq    100$            ; No
  405.     FQCOPY    #FIRQB    ,#savxk+0    ; Restore connected terminal
  406.     movb    #UU.TRM    ,FIRQB+FQFUN    ; Function code
  407.     clrb    FIRQB+4            ; Insure cleared for v9..x
  408.     movb    xkunit    ,FIRQB+5    ; Console
  409.     .UUO                ; Simple
  410.     tst    v9flag            ; Version 9 or later?
  411.     beq    100$            ; No
  412.     CLRFQB                ; Yes, restore buffer quota
  413.     movb    #UU.TRM    ,FIRQB+FQFUN    ; Function
  414.     incb    FIRQB+4            ; Subfunction = 1
  415.     movb    xkunit    ,FIRQB+5    ; Unit number
  416.     movb    bufqxk    ,FIRQB+27    ; Stuff saved buffer quota
  417.     .UUO                ; Do it
  418. 100$:    clc                ; Say it worked and exit
  419.     return                ; Bye
  420.  
  421.  
  422.  
  423.  
  424.     .sbttl    read/write terminals
  425.  
  426.  
  427. $READTT:mov    #XRB    ,r0        ; Point to the XRB please
  428.     tst    10(sp)            ; No wait desired today?
  429.     beq    10$            ; Yes (the normal case)
  430.     mov    10(sp)    ,(r0)        ; No, SLEEP instead of TIMEOUT
  431.     .SLEEP                ; Sleep until tmo or something
  432. 10$:    mov    4(sp)    ,(r0)+        ; is typed. Stuff a buffer size
  433.     bne    20$            ; Make sure the buffer size is ok
  434.     inc    -2(r0)            ; Not ok, make it one character
  435. 20$:    clr    (r0)+            ; Clear returned byte count
  436.     mov    2(sp)    ,(r0)+        ; Buffer address
  437.     movb    6(sp)    ,(r0)        ; Channel number
  438.     aslb    (r0)+            ; Times two
  439.     clrb    (r0)+            ; Unused (byte)
  440.     clr    (r0)+            ; Unused (word)
  441.     clr    (r0)+            ; No timeouts with binary mode
  442.     mov    #8192.    ,(r0)+        ; No stalling please
  443.     .READ                ; Do it
  444.     clr    r1            ; Assume no data
  445.     movb    FIRQB    ,r0        ; Success?
  446.     bne    100$            ; No
  447.     mov    XRB+XRBC,r1        ; Yes, return byte count
  448. 100$:    mov    (sp)    ,10(sp)        ; Move return address up
  449.     add    #4*2    ,sp        ; Pop parameters and exit
  450.     return                ; Bye
  451.  
  452. $writet:mov    r1    ,-(sp)        ; Save it
  453.     mov    4+2(sp)    ,r0        ; Size of the write
  454.     bne    10$            ; It's ok
  455.     mov    2+2(sp)    ,r1        ; No, get the asciz size now
  456.     strlen    r1            ; ....
  457. 10$:    mov    #XRB    ,r1        ; Point to XRB please
  458.     mov    r0    ,(r1)+        ; Byte count
  459.     mov    r0    ,(r1)+        ; Byte count again
  460.     mov    2+2(sp)    ,(r1)+        ; Buffer address
  461.     movb    6+2(sp)    ,(r1)        ; Channel number
  462.     aslb    (r1)+            ; Times two
  463.     clrb    (r1)+            ; Unused (byte)
  464.     clr    (r1)+            ; Unused (word)
  465.     clr    (r1)+            ; Unused (word) again
  466.     mov    #4096.    ,(r1)+        ; IO.WAL
  467.     .WRITE                ; Do it
  468.     mov    (sp)+    ,r1        ; Restore this one
  469.     mov    (sp)    ,6(sp)        ; Move return address up
  470.     add    #3*2    ,sp        ; Ignore parameters
  471.     return
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479. $fqcopy:save    <r0,r1,r2>        ; Copy a block of data
  480.     mov    2+6(sp)    ,r2        ; Destination
  481.     mov    4+6(sp)    ,r1        ; Source
  482.     mov    #40    ,r0        ; Size of a FIRQB
  483. 10$:    movb    (r1)+    ,(r2)+        ; Copy a byte
  484.     sob    r0    ,10$        ; Next please
  485.     unsave    <r2,r1,r0>        ; Pop registers
  486.     mov    (sp)    ,4(sp)        ; Move return address
  487.     cmp    (sp)+    ,(sp)+        ; Pop stack
  488.     return                ; Exit
  489.  
  490.  
  491. iocheck:cmpb    r0    ,#DETKEY    ; I/O to detached Keyboard?
  492.     beq    80$            ; Yes, it's fatal
  493.     cmpb    r0    ,#NODATA    ; Simply no data present?
  494.     beq    70$            ; Yes, that one is ok
  495.     movb    #ERRFQ    ,FIRQB+FQFUN    ; Dump error text out next
  496.     movb    r0    ,FIRQB+4    ; Pass the error code also
  497.     CALFIP                ; Simple to do
  498.     clrb    FIRQB+37        ; Insure .asciz
  499.     WRITETT    buffer=#FIRQB+4,lun=#LUN.CO
  500.     WRITETT    buffer=#eco.08,lun=#LUN.CO; A finishing CRLF
  501. 70$:    clc                ; Not fatal
  502.     return                ; Exit
  503. 80$:    WRITETT    buffer=#eco.07,lun=#LUN.CO; Dump an error MESSAGE please
  504.     sec                ; This is FATAL
  505.     return                ; Bye
  506.  
  507.     .sbttl    concmd    terminal emulation escape commands
  508.     .enabl    lsb
  509.  
  510. concmd::mov    r1    ,-(sp)        ; Save it
  511.     movb    @r4    ,r1        ; Get the character to check
  512.     bicb    #^C177    ,r1        ; Must drop parity 
  513.     scan    r1    ,#200$        ; look for a match here
  514.     asl    r0            ; word offsets
  515.     jsr    pc    ,@210$(r0)    ; dispatch to the correct routine
  516. 100$:    mov    (sp)+    ,r1        ; Pop R1 and exit
  517.     return
  518.  
  519.  
  520.     .save
  521.     .psect    rwdata    ,rw,d,lcl,rel,con
  522.  
  523. 200$:    .byte    'C&137    ,'c!40        ; drop connection ctrl \ C
  524.     .byte    'I&137    ,'i!40        ; init the line
  525.     .byte    'Q&137    ,'q!40        ; quit logging but leave file open
  526.     .byte    'R&137    ,'r!40        ; resume logging if file is open
  527.     .byte    'X&137    ,'X!40        ; control Q and then thats all
  528.     .byte    'B&137    ,'b!40
  529.     .byte    '?    ,177        ; help, rub for send break
  530.     .byte    'H&137    ,'h!40
  531.     .byte    0
  532.     .even
  533.  
  534. 210$:    .word    con.$            ; unknown escape command
  535.     .word    con.c    ,con.c        ; drop connection
  536.     .word    con.i    ,con.i        ; get modems attention
  537.     .word    con.q    ,con.q        ; turn console logging off
  538.     .word    con.r    ,con.r        ; turn it back on please
  539.     .word    con.x    ,con.x        ; send XON
  540.     .word    con.br    ,con.br        ; break
  541.     .word    con.hl    ,con.br        ; print out commands
  542.     .word    con.hl    ,con.hl        ; help
  543.  
  544.     .restore            ; Pop code psect context
  545.     .dsabl    lsb            ; Turn off current symbol block
  546.  
  547.  
  548. con.$:    WRITETT    buffer=#$bel,lun=#LUN.CO; Send a beep out for unknown
  549.     clc                ; commands. Say it is not fatal.
  550.     return                ; Bye
  551.  
  552.  
  553. con.c:    sec                ; Exit connection
  554.     return                ; And return
  555.  
  556.  
  557. con.i:    CALL    ttydtr            ; try to force DTR up on the line
  558.     clc                ; And say it's NOT fatal
  559.     return                ; Exit
  560.  
  561.  
  562. con.q:    bic    #log$co    ,trace        ; turn off console logging
  563.     clc                ; Successfull
  564.     return                ; Exit
  565.  
  566.  
  567. con.r:    bit    #log$op    ,trace        ; if the file is open do it
  568.     beq    100$            ; no
  569.     bis    #log$co    ,trace        ; yes, enable this
  570. 100$:    clc                ; Success
  571.     return                ; Exit
  572.  
  573.  
  574. con.x:    WRITETT    buffer=#$xon,lun=#LUN.XK; Try hard to send an xon done
  575.     CALL    ttxon            ; and try to clear our xoffed state
  576.     clc                ; Success
  577.     return                ; Exit
  578.  
  579. con.br:    CALL    ttspee            ; get the remotes terminal speed
  580.     mov    r0    ,r2        ; save the old speed
  581.     CALLS    setspd    ,<#50.>        ;try to set it down to 50 baud
  582.     tst    r0            ; did it work ?
  583.     bne    100$            ; no, forget it
  584.     WRITETT    buffer=#null2,lun=#LUN.XK,size=#2
  585.     CALLS    setspd    ,<r2>        ; restore the terminal's speed
  586. 100$:    clc
  587.     return
  588.  
  589.  
  590.  
  591. con.hl::WRITETT    buffer=#hlptxt,lun=#LUN.CO
  592.     clc
  593.     return
  594.  
  595.  
  596.     .sbttl    dump i/o to a log file ?
  597.  
  598.  
  599. ;    Passed:    R5    buffer address
  600. ;        R1    buffer size
  601.  
  602.  
  603. dumplo:    bit    #LOG$CO    ,trace        ; Is this enabled ?
  604.     beq    100$            ; No
  605.     bit    #LOG$OP    ,trace        ; Is it open
  606.     beq    100$            ; No
  607.     save    <r1,r2,r5>        ; Save work registers
  608.     mov    r1    ,r2        ; Get the number of characters
  609.     beq    90$            ; Nothing to do ?
  610. 10$:    clrb    r0            ; Avoid sign extension
  611.     bisb    (r5)+    ,r0        ; Get the next character
  612.     mov    #LUN.LO    ,r1        ; Unit number
  613.     call    putcr0            ; Thats it folks
  614.     sob    r2    ,10$        ; Next please
  615. 90$:    unsave    <r5,r2,r1>        ; Pop registers and exit
  616. 100$:    clc                ; May as well say it worked
  617.     return                ; Bye
  618.  
  619.  
  620.  
  621.     .save
  622.     .psect    rwdata
  623. $xon:    .byte    'Q&37,0
  624. $xoff:    .byte    'S&37,0
  625. $bel:    .byte    'G&37,0
  626.     .even
  627.     .restore
  628.  
  629.  
  630.     .end
  631.