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

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