90$: $mterr ; error, map into global and exit 100$: unsave ; pop this and exit return m.ttyrst:: save ; we will use this one clr r2 ; was already attached call ttpars ; parse the unit number please bcs 80$ ; oops mov r0 ,r1 ; copy the parsed unit number .mtset #rtwork,#ttparm,r1 ; get the current settings bcc 20$ ; it worked cmpb @#errbyt,#1 ; not attached? bne 90$ ; no .mtatch #rtwork,#0,r1 ; yes, attach it bcs 90$ ; oops mov sp ,r2 ; flag we just attached it .mtset #rtwork,#ttparm,r1 ; get the current settings bcs 90$ ; error 20$: clr r0 ; success br 100$ ; bye 80$: mov #er$dev ,r0 ; bad device name br 100$ ; bye 90$: $mterr ; error, map into global and exit 100$: tst r2 ; need to detach it again beq 110$ ; no .mtdtch #rtwork,r1 ; yes, do it please 110$: unsave ; pop this and exit return .sbttl binrea read binary ; B I N R E A ; ; input: @r5 LUN ; 2(r5) timeout ; output: r0 error code ; r1 character just read m.xbinre:: m.binrea:: save ; we may want to use these here clr -(sp) ; allocate a single character buffer mov sp ,r4 ; and a pointer to it also clr -(sp) ; allocate a mark time tim buffer clr -(sp) ; simple mov sp ,r2 ; and point to it mov @r5 ,r3 ; get the LUN asl r3 ; and map it into the unit number movb lunmap(r3),r3 ; simple ;- .mtget #rtwork,#ttsts,r3 ; get current terminal setting ;- bcs 90$ ; oops ;- bis #ttmode ,ttsts+m.tsts ; set so we don't wait for anything ;- .mtset #rtwork,#ttsts,r3 ; set this please ;- bcs 90$ ; can't set it for some reason cmp 2(r5) ,#-1 ; read without any wait ? bne 40$ ; no .mtin #rtwork,r4,r3,#1 ; read a single character now bcs 80$ ; it worked clr r1 ; get the character into r1 now bisb @r4 ,r1 ; and exit with success clr r0 ; bye br 100$ ; exit at last 40$: mov 2(r5) ,r1 ; get the timeout in seconds mul #60. ,r1 ; into ticks now 50$: .mtin #rtwork,r4,r3,#1 ; do it please bcc 60$ ; it worked, get the ch into r1 dec r1 ; been here too long ? beq 80$ ; yes, exit with error tst clkflg ; /37/ is there a clock on system? bne 55$ ; /37/ yes cpuwait #1 ; /37/ no, try loop for one tick br 56$ ; /37/ very cpu speed dependent. 55$: .twait #rtwork,#ttime ; sleep a moment please 56$: br 50$ ; and try again please 60$: clr r1 ; it worked, get the character and exit bisb @r4 ,r1 ; simple clr r0 ; success br 100$ 80$: mov #er$nin ,r0 ; no data today br 100$ ; bye 90$: $mterr ; map the error code into a global one 100$: add #6 ,sp ; pop local buffers unsave ; pop registers and exit return 200$: mov #1 ,r1 ; flag a timeout return .sbttl binary write ; B I N W R I ; ; binwri( %loc buffer, %val buffer_size, %val lun ) ; ; output: r0 error code ; ; Assumption: TTYINI has been called to map the Kermit LUN ; into the RT11 unit number for the terminal. m.binwri:: save ; save registers we may need sub #20 ,sp ; a save area for tt settings clr r0 ; preset no errors as of yet mov @r5 ,r1 ; get the string address mov 2(r5) ,r2 ; get the string length beq 100$ ; nothing to do mov #ttsts ,r3 ; for getting tt settings mov 4(r5) ,r4 ; the internal LUN bne 10$ ; map LUN 0 to console print r1,r2 ; simple clr r0 ; no errors br 100$ ; exit 10$: mov sp ,r5 ; point to the stack work area asl r4 ; times two tstb lunmap+1(r4) ; have we mapped the lun into unit? beq 80$ ; no, fatal error movb lunmap(r4),r4 ; map into the rt11 unit number .mtget #rtwork,r3,r4 ; get current settings, set to wait bcs 90$ ; oops, exit with the error code in r0 mov (r3)+ ,(r5)+ ; copy the four words now mov (r3)+ ,(r5)+ ; copy the four words now mov (r3)+ ,(r5)+ ; copy the four words now mov (r3)+ ,(r5)+ ; copy the four words now bit #100 ,ttsts+m.tsts ; is the wait bit set already ? beK11RTTMAC[.050032]K11RTT.MAC[.050032]    X14|H [4;Ik(&'( k ߫H&P` \RrPP2PPzPP{PPPPP2P~\$\\TD 0D \~ hi) +\ ^( n ^( np\^txY\^ˀ\!kVk<\F˰<˴ˬ\VVkˤ1`@lP ABCDEFGHIJKLMNOPQRSTUVWXYZ$.?0123456789<@<SЬTЬ UQS>?\\\\\\\\\`:#@'="\abcdefghi\\\\\\\jklmnopqr\\\\\\\~stuvwxyz\\\\\\\\\\\\\\\\\\\\\\{ABCDEFGHI\\\\\\}JKLMNOPQR\\\\\\\\STUVWXYZ\\\\\\0123456789\\\\\  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~@ggh<i|o<m<4p<p<k|Zn<l fr rwx<x<x<x޺<w@]@@fjnr]Ze@@|> | |v<H|  |  |xz|  |zt f r   < &^ @&@'*/V,"?Lh:hmBmz|z{x`y~|fN|@@|@͂|@ ݃ƃ<ns<|Ŏ |️|ep|u|-@率|<ᄇ2ֻr||ZRM | ntB|xyvZw|J=|R>|J? nnaa|bddftch #rtwork,r1 ; and detach the device now clr r0 ; return 'success' return ; and exit .sbttl speed read and change m.setspd:: save ; save temps that we will use clr r0 ; find the speed map now 10$: tst spdlst(r0) ; reach the end of the table? beq 80$ ; yes, return unknown speed cmp 2(r5) ,spdlst(r0) ; table entry match the passed speed beq 20$ ; yes add #2 ,r0 ; no, try the next one please br 10$ ; next please 20$: mov spdmap(r0),r3 ; and get the speed setting bits call ttpars ; parse the mt unit number bcs 70$ ; oops mov r0 ,r1 ; save the unit number .mtatch #rtwork,#kbiost,r1 ; insure unit is attached mov #ttsts ,r2 ; point to the status area .mtget #rtwork,r2,r1 ; get the current terminal setting bcs 90$ ; oops bic #7400 ,m.tsts(r2) ; clear out old speed bits bis r3 ,m.tsts(r2) ; stuff the dz11 speed bits in .mtset #rtwork,r2,r1 ; set these please bcs 90$ ; oops clr r0 ; all done br 100$ ; bye 70$: mov #er$dev ,r0 ; device name parse failed br 100$ ; bye 80$: mov #er$spe ,r0 ; unknown speed ? br 100$ 90$: $mterr ; map local error into a global one 100$: unsave ; pop and exit return m.ttspee:: save ; save these please call ttpars ; parse the mt unit number bcs 70$ ; oops mov r0 ,r1 ; save the unit number .mtatch #rtwork,#kbiost,r1 ; insure unit is attached mov #ttsts ,r2 ; point to the status area .mtget #rtwork,r2,r1 ; get the current terminal setting bcs 90$ ; oops mov m.tsts(r2),r3 ; get the speed mask out now bic #^C7400 ,r3 ; drop all bits but the speed clr r0 ; now look for the correct speed map 10$: tst spdmap(r0) ; reach the end of the list ? bmi 80$ ; yes, return a speed of zero cmp r3 ,spdmap(r0) ; setting match up now ? beq 20$ ; yes add #2 ,r0 ; no, try again please br 10$ ; next 20$: mov spdlst(r0),r0 ; a match, return the speed setting br 100$ ; bye 70$: mov #er$dev ,r0 ; device name parse failed br 100$ ; bye 80$: clr r0 ; failure br 100$ ; return a speed of zero then 90$: $mterr ; map local error into a global one 100$: unsave ; pop and exit return .save .psect $pdata spdlst: .word 50. ,75. ,110. ,134. ,150. ,300. ,600. .word 1200. ,1800. ,2000. ,2400. ,3600. ,4800. ,7200. .word 9600. ,0 ,0 spdmap: .word 0 ,400 ,1000 ,1400 ,2000 ,2400 ,3000 .word 3400 ,4000 ,4400 ,5000 ,5400 ,6000 ,6400 .word 7000 ,7400 ,-1 .restore .sbttl terminal i/o things we don't need, can't do or haven't done yet m.ttxon:: m.cantyp:: m.ttset:: m.ttydtr:: m.ttrfin:: m.ttrini:: clr r0 return m.ttyhan:: mov #er$iop ,r0 return .mcall .ttyin jsw = 44 m.kbread:: mov r2 ,-(sp) mov r3 ,-(sp) bis #40000 ,@#jsw ; enable lower case tt: input bic #10000 ,@#jsw ; ditch single ch input please mov @r5 ,r1 ; a buffer to put the chars mov #80. ,r3 ; size of the buffer here ;10$: .scca #area ,#kmonbf ; so we can catch control Z 10$: .ttyin ; read a character please tstb r0 beq 15$ ; a null cmpb r0 ,#'Z&37 ; control Z ? beq 20$ ; yes cmpb r0 ,#'C&37 ; control C ? beq 20$ ; yep cmpb r0 ,#15 ; carriage return ? beq 30$ ; yep movb r0 ,(r1)+ ; return what we just got cmpb r0 ,#14 ; form feed ? beq 40$ ; yep 15$: sob r3 ,10$ ; next please 20$: mov #er$eof ,r0 ; say read error and exit br 100$ ; bye 30$: movb #cr ,(r1)+ ; return all terminators please movb #lf ,(r1)+ ; simple .ttyin ; eat the line feed now 40$: clrb @r1 sub @r5 ,r1 ; the length clr r0 100$: mov (sp)+ ,r3 mov (sp)+ ,r2 return m.finrt:: ; /37/ clr r0 ; /37/ return ; /37/ m.senbrk:: calls ttspee ,<@r5> ; get the remotes terminal speed mov r0 ,r2 ; save the old speed calls setspd ,<@r5,#50.,2(r5)>;try to set it down to 50 baud tst r0 ; did it work ? bne 100$ ; no, forget it calls binwri ,<#200$,#2,2(r5)>;yes, send a null over calls setspd ,<@r5,r2,2(r5)> ;K11RTTMAC[.050032]K11RTT.MAC[.050032]    X14|H [4;Ik(&'( k ߫H&P` \RrPP2PPzPP{PPPPP2P~\$\\TD 0D \~ hi) +\ ^( n ^( np\^txY\^ˀ\!kVk<\F˰<˴ˬ\VVkˤ1`@lP ABCDEFGHIJKLMNOPQRSTUVWXYZ$.?0123456789<@<SЬTЬ UQS>?\\\\\\\\\`:#@'="\abcdefghi\\\\\\\jklmnopqr\\\\\\\~stuvwxyz\\\\\\\\\\\\\\\\\\\\\\{ABCDEFGHI\\\\\\}JKLMNOPQR\\\\\\\\STUVWXYZ\\\\\\0123456789\\\\\  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~@ggh<i|o<m<4p<p<k|Zn<l fr rwx<x<x<x޺<w@]@@fjnr]Ze@@|> | |v<H|  |  |xz|  |zt f r   < &^ @&@'*/V,"?Lh:hmBmz|z{x`y~|fN|@@|@͂|@ ݃ƃ<ns<|Ŏ |️|ep|u|-@率|<ᄇ2ֻr||ZRM | ntB|xyvZw|J=|R>|J? nnaa|bddf restore the terminal's speed 100$: clr r0 return 200$: .byte 0,0 .end