Network Mail received on 06-Apr-82 at 20:27 From: PSEUDO::SMITH "David Smith" To: MOLSON::OREILLY Subject: Enclosed file "S:(1,112)ITTINR.MAC" .TITLE ITTINR - SINGLE CHARACTER ROUTINE .ENABL LC .PSECT MYIO ; ; Space Invader single character I/O routine to emulate ; RT-11 ITTINR function. Returns either a or a ; single character to FORTRAN via R0. ; ; ; Useful places and things to know about ; FIRQB = 402 FQMODE = 22 XRB = 442 XRLEN = 0 XRLOC = 4 XRCI = 6 XRMOD = 14 .READ = EMT+2 .SPEC = EMT+0 DEBUG = 0 ; ; Register storage macros - "MOV (SP)+,Rn" is so tacky. ; .MACRO POP ARG1 MOV (SP)+,ARG1 .ENDM ; .MACRO PUSH ARG1 MOV ARG1,-(SP) .ENDM ; ; FIRQB capture macro - used to determine if an error has occured ; and to help debug I/O. Debugging with ODT wipes out FIRQB and ; XRB data so great care (!) is taken to preserve the error code ; in FIRQB+0. That's why the nonsense of MOVB, etc. instead of ; grinding out just half as many word MOV's. ; .MACRO CHKFRQ ARG1, ?ARG2 .IF EQ DEBUG ; If debug is turned off just test FIRQB MOVB FIRQB,FRQSTR TSTB FRQSTR BNE ARG1 .IFF MOVB FIRQB,FRQSTR PUSH R0 PUSH R1 PUSH R2 MOV #55,R0 MOV #FIRQB+1,R1 MOV #FRQSTR+1,R2 ARG2: MOVB (R1)+,(R2)+ SOB R0,ARG2 POP R2 POP R1 POP R0 TSTB FRQSTR BNE ARG1 .ENDC .ENDM ; ; Useful global symbols ; .GLOBL ITTINR ; ; The thrilling part... ; ITTINR: CALL FRQCLR ; Clear FIRQB CALL XRBCLR ; and XRB MOV #100000,FIRQB+FQMODE ; Undoc.ed hack to force XRB's command MOV #4.,XRB+0 ; Select ODT mode for input MOVB #2.,XRB+7 ; Set device index to 2 for terminals MOVB #CHAN*2,XRB+XRCI ; Find somewhere for this to happen EMT 377 ; Tell RT-11 this is a RSTS/E call .SPEC ; Invoke SPEC function CALL XRBCLR ; Tidey up XRB so we can read a character MOV #100000,FIRQB+FQMODE ; Undoc.ed hack to force XRB's command MOV #1,XRB+XRLEN ; Set the buffer size MOV #LOCBUF,XRB+XRLOC ; Point to local character buffer MOVB #CHAN*2,XRB+XRCI ; Find somewhere for this to happen MOV #8192.,XRB+XRMOD ; Select record 8192% - no wait EMT 377 ; Tell RT-11 this is a RSTS/E call .READ ; Go get something amusing, maybe... CMPB FIRQB,#13. ; Did we get a "USER DATA ERROR"? BEQ 2$ ; "Yes, we have no (data)..." MOVB LOCBUF,R0 ; No, therefore a character was snarfed in BR 3$ ; Go wash up before leaving 2$: CLR R0 ; Be sure to return a 3$: RETURN ; Back to the invasion, already in progress... ; ; FIRQB and XRB clearance routines ; FRQCLR: PUSH R0 ; Save altered registers PUSH R1 MOV #FIRQB,R0 ; Point to start of FIRQB MOV #20,R1 ; and begin to count 20 words 1$: CLR (R0)+ ; leaving a trail of zeroes behind SOB R1,1$ ; until R1 = 0 POP R1 ; Clean up altered registers POP R0 RETURN ; Back for more thrills ; XRBCLR: PUSH R0 ; Save altered registers PUSH R1 MOV #XRB,R0 ; Point to start of XRB MOV #7,R1 ; and begin to count 7 words 1$: CLR (R0)+ ; leaving a trail of zeroes behind SOB R1,1$ ; until R1 = 0 POP R1 ; Clean up altered registers POP R0 RETURN ; Back for more thrills ; ; Storage areas worth knowing about ; LOCBUF: .BLKW 1 .IF EQ DEBUG FRQSTR: .WORD 1 ; Hold just the first word of FIRQB .IFF FRQSTR: .WORD 40 ; Chaos is expected, keep all of FIRQB .ENDC .END