.TITLE RNRT11.MAC RT-11 INTERFACE FOR RSX RUNOFF .ENABL LC .NLIST BEX,TOC .SBTTL M01-C 26-Apr-80 .IF EQ 1 Author: C G Wilson, 71 Galatea St., Charleville 4470, Australia. Version M01-B: Adapted and rewritten from START.MAC RNFIO.MAC RNORSX.MAC Version M01-C [26-Apr-80] Bug fix and general tidying .ENDC .MCALL .SRESET,.SETTOP,.CSIGEN,.PRINT,.RCTRLO,.CLOSE .MCALL .TTYOU,.TTYIN,.READW,.WRITW,.WAIT .GLOBL F.RCTL,FD.TTY .GLOBL $INITL,$ULMSW,$ULSSW,$ULNSW,$ERMSG .GLOBL FOOTP1,FOOTP2,FOOTP3,XTOP,XBOT .GLOBL FFDSW,HYPSW,PAUSW,UPCSW,LGO,LINSET .GLOBL CR,LF,EOF .GLOBL HFIN,HFOUT,INBUF,OUBUF,S1 .GLOBL HGHPAG,LOWPAG,PAGENO,INPERR,OUTERR .MACRO TYPE A .PSECT MESAGE CON $$$=. .ASCII A .PSECT .PRINT #$$$ .ENDM .PSECT MESAGE CON VER: .ASCIZ /Runoff M01-C RT-11 (from RSX)/ .PSECT .PAGE ;Data Locations SPSAV:: 0 ;For saving SP for re-runs $SWTCH::0 ;Switch register (bits defined in RUNOFF) TTIBLK::-1 ;Fudge to convince RUNOFF/FORM:(40$)+14 that ; we are taking input for PAUSING from TT:. F.RCTL=0 ;(ibid) FD.TTY=1 ;(and again). AREA:: .BLKW 6 ;Programmed request workspace. OBLK: 0 ;Output block # IBLK: 0 ;Input block # ICHN: 0 ;Input channel LIMIT: .LIMIT ;Low and High Program Limits (2 words) DEFTYP: .RAD50 /RNODOC / ;Default input & output extensions .PAGE .SBTTL Start - initialization section $START:: ;Entered here from RUNOFF/.END START MOV SP,SPSAV RUNOFF:: MOV SPSAV,SP .SRESET .RCTRLO CALL $INITL ;Initialize variables CLR IBLK CLR OBLK MOV #3,ICHN ;First Input Channel is #3. MOV LIMIT+2,R1 ;Free space .CSIGEN R1,#DEFTYP DEC R0 ;New free space after handlers loaded MOV R0,FOOTP1 MOV R0,FOOTP2 MOV R0,FOOTP3 BIS #FFDSW,$SWTCH ;Default is form-feeds proper. BIC #HYPSW,$SWTCH ;Default is no hyphenation. MOV (SP)+,R4 ;# of switches BEQ NOSWT ;None specified NEXSWT: MOV (SP)+,R1 ;b15 set if value specified, b14-8 file on which ; switch specified, b7-0 ascii value of switch. BIC #40,R1 ;In case lower case MOV (SP),R2 ;Value CMPB R1,#'U ;/U=Underscore :B backspace :S simulate :L line BNE CHKF CLRB $ULMSW ;Set default /U as /U:L CLRB $ULSSW CLRB $ULNSW TST R1 BGE ENDSWT ;/U = /U:L CMP R2,(PC)+ .RAD50 /B/ BNE 10$ COMB $ULMSW ;/U:B BR ENDSWT 10$: CMP R2,(PC)+ .RAD50 /S/ BNE 20$ COMB $ULSSW ;/U:S BR ENDSWT 20$: CMP R2,(PC)+ .RAD50 /N/ BNE 30$ COMB $ULNSW ;/U:N BR ENDSWT 30$: CMP R2,(PC)+ ;/U:L .RAD50 /L/ BNE ILLSWT BR ENDSWT CHKF: CMPB R1,#'F ;/F - simulate ff's with lf's BNE CHKH TST R1 ;Value specified? BLT NOVAL ;Yes - tell him it's not necessary BIC #FFDSW,$SWTCH BR ENDSWT CHKH: CMPB R1,#'H ;/H - Allow Hyphenation BNE CHKP TST R1 BLT NOVAL BIS #HYPSW,$SWTCH BR ENDSWT CHKP: CMPB R1,#'P ;/P - Pause between pages BNE CHKR TST R1 BLT NOVAL BIS #PAUSW,$SWTCH BR ENDSWT CHKR: CMPB R1,#'R ;/R:: BNE CHKC TST R1 ;/R requires a value BGE ILLVAL TST HGHPAG ;First one encountered should be high limit BGE 10$ MOV R2,HGHPAG BR ENDSWT 10$: MOV R2,LOWPAG BR ENDSWT CHKC: CMPB R1,#'C ;/C - Force upper case BNE ILLSWT TST R1 BLT NOVAL BIS #UPCSW,$SWTCH BR ENDSWT ILLSWT: TYPE <"Illegal Switch. Only /U:B:S:L:N, /F, /H, /P, /C, /R:l:h"<0>> JMP RUNOFF ILLVAL: TYPE <"/R switch requires 2 values"<0>> JMP RUNOFF NOVAL: TYPE <"/F, /C, /H, & /P may not have values"<0>> JMP RUNOFF ENDSWT: TST R1 ;Value specified? BGE 10$ TST (SP)+ ;Yes - scrub it from stack 10$: DEC R4 ;Any more switches? BGT NEXSWT ;Yep - see what he wants. NOSWT: .WAIT #0 BCC 10$ ;If no output channel, just type ident. .PRINT #VER JMP RUNOFF 10$: .SETTOP #-2 ;How are we off for free space? MOV R0,XTOP MOV R0,XBOT JSR PC,LINSET JMP LGO ;And at last off we go to process something. ENDFIL:: JSR PC,OUTPUT .CLOSE #0 JMP RUNOFF .PAGE .SBTTL Rnfio section ; File output routines FMSG:: MOVB @S1,R1 BEQ FRET JSR PC,FOUT ;Output character by character INC S1 BR FMSG CRLF:: MOV (PC)+,R1 ;Send .BYTE LF,CR MOV PC,-(SP) ;So when returns, get next character (neat, eh?) SWAB R1 FOUT:: CMP PAGENO,LOWPAG ;Check page limits line by line BLO FRET CMP PAGENO,HGHPAG BHI OUT2 MOVB R1,@HFOUT+2 ;Put char into buffer INC HFOUT+2 DEC HFOUT+4 ;Has that filled the buffer? BEQ OUTPUT ;Yes if zero. FRET: RTS PC ; Output the current contents of the output buffer OUTPUT:: MOV HFOUT+4,-(SP) ;Determine remaining space in buffer, BEQ 20$ 10$: CLRB @HFOUT+2 ; and clear it. INC HFOUT+2 DEC (SP) BGT 10$ 20$: TST (SP)+ .WRITW #AREA,#0,#OUBUF,#256.,OBLK BCS WRERR3 INC OBLK OUT1: MOV HFOUT,HFOUT+4 ;Reset byte count and MOV #OUBUF,HFOUT+2 ; byte pointer. RTS PC OUT2: TST HGHPAG ;Second time through? BEQ OUT1 ;Yes JSR PC,OUTPUT ;Send last buffer CLR HGHPAG JMP ENDFIL ;No - initiate termination. ; File Input FIN:: DEC HFIN+4 ;Any more left? BGE RBL READBK: .READW #AREA,ICHN,#INBUF,#256.,IBLK BCS INPUTX INC IBLK ;For next block next time MOV HFIN,HFIN+4 ;Reset count and RBK: MOV #INBUF-1,HFIN+2 ; pointer. RBL: INC HFIN+2 ;Point to character to be taken this time MOVB @HFIN+2,R1 BIC #^C<177>,R1 ;Clear excess bits BEQ FIN ;Ignore nulls and rubouts CMP R1,#177 BEQ FIN 40$: RTS PC INPUTX: TSTB @#52 ;Check cause of error in error byte BNE RDERR3 ;Not EOF, anyway. 10$: CMP ICHN,#10 ;Have we tried all available input channels? BGE IEOF ;Yes - just give him EOF. INC ICHN ;No - try the next. .WAIT ICHN BCS 10$ ;Not in use. CLR IBLK ;Start at block 0 on this channel BR READBK IEOF: MOV #EOF,INBUF MOVB #1,HFIN+4 BR RBK ; I/O Error exits WRERR3: JSR PC,$ERMSG .WORD OUTERR BR ERR3 RDERR3: JSR PC,$ERMSG .WORD INPERR ERR3: JMP RUNOFF ; TTC4N - Read a line from the terminal ; (This is only used with PAUSE, so the actual data typed ; can be ignored.) TTC4N:: .TTYIN BIC #^C<177>,R0 CMP R0,#LF BNE TTC4N .PAGE .SBTTL Teletype Output Routines ; TTC3 - Send a line to the terminal (no CRLF) TTC3:: MOV @(SP),-(SP) ;Address of string 10$: MOVB @(SP),R0 BEQ 20$ .TTYOU INC (SP) BR 10$ 20$: TST (SP)+ ADD #2,(SP) ;Skip return RTS PC ; TTC33 - Send a to the terminal TTC33:: .TTYOU #CR .TTYOU #LF RTS PC ; TTC1 - Send one char to the terminal TTC1:: MOVB R1,R0 CMP R0,#37 ;Runoff sends out quoted spaces just to bugger BNE 10$ ; us up (fouls some terminals). INC R0 ;Make it a space 10$: .TTYOU RTS PC .PAGE .SBTTL Integer multiply & divide routines $MUL:: MOV R0,-(SP) ;Save multiplicand CLR -(SP) ;For single-precision result 10$: CLC ROR R1 ;Look at next bit in multiplier BCC 20$ ADD R0,(SP) ;If not zero, add in next to result CLC 20$: ROL R0 TST R1 BNE 10$ MOV (SP)+,R1 ;Result into R1 MOV (SP)+,R0 ;and restore multiplicand RTS PC ;$DIV - Inputs R0 dividend ; R1 divisor ; Outputs R0 quotient ; R1 remainder $DIV:: MOV #16.,-(SP) ;Iteration count - 16 bits MOV R1,-(SP) ;Save divisor for subtractions CLR R1 10$: ASL R0 ;Double left shift ROL R1 CMP R1,(SP) BLO 20$ SUB (SP),R1 ;Subtract if relevant, and INC R0 ; add in to quotient 20$: DEC 2(SP) BGT 10$ CMP (SP)+,(SP)+ RTS PC .END