.TITLE REW .IDENT /01/ ;For History Comments .ENABLE LC ; ; This is a tiny program to rewind a magtape ; ; History: ; 01 P.A. Stephensen-Payne 23-Oct-80 ; .PAGE .SBTTL Macros .MACRO FERR,X,P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14 .IIF NB , MOV P1,ARGBLK ;Arguments for insertion .IIF NB , MOV P2,ARGBLK+2 .IIF NB , MOV P3,ARGBLK+4 .IIF NB , MOV P4,ARGBLK+6 .IIF NB , MOV P5,ARGBLK+8. .IIF NB , MOV P6,ARGBLK+10. .IIF NB , MOV P7,ARGBLK+12. .IIF NB , MOV P8,ARGBLK+14. .IIF NB , MOV P9,ARGBLK+16. .IIF NB , MOV P10,ARGBLK+18. .IIF NB , MOV P11,ARGBLK+20. .IIF NB , MOV P12,ARGBLK+22. .IIF NB , MOV P13,ARGBLK+24. .IIF NB , MOV P14,ARGBLK+26. MOV #I.'X,R1 ;Address of Error String JMP FERR .ENDM .MACRO DIAG,X,P1,P2,P3,P4 .IIF NB , MOV P1,ARGBLK .IIF NB , MOV P2,ARGBLK+2 .IIF NB , MOV P3,ARGBLK+4 .IIF NB , MOV P4,ARGBLK+6 MOV #I.'X,R1 CALL DIAG .ENDM ; .MCALL CSI$,CSI$1,CSI$2,CSI$SW,CSI$SV,CSI$ND ; for CSI .MCALL GCMLB$,GCMLD$,GCML$,SPWN$,DIR$ ; for GCML .MCALL QIOW$S,EXIT$S,ALUN$S,WTSE$S,SVTK$S ;general use .MCALL FSRSZ$,FINIT$ .PAGE .SBTTL Offset Definitions ; ; If you are going to use symbolic offsets of your own, ; define them here ; ; It is often a good idea to use symbolic names for your luns ; CMDLUN=1 OUTLUN=2 ERRLUN=5 .PAGE .SBTTL Data - Error Messages .NLIST BEX OUTBLK: .BLKB 80. ; To build error message in ARGBLK: .BLKW 15. ; Argument block for $EDMSG I.SST: .ASCII /REW - SST Trap = %D at PC %P/<7><7> .ASCII /%N R0=%P, R1=%P, R2=%P, R3=%P/ .ASCIZ /%N R4=%P, R5=%P, R6=%P, (SP)=%P/ I.GIND: .ASCIZ /REW - Invalid Indirect Command File/<7> I.GCME: .ASCIZ /REW - Command Read Error = %D/<7> I.CSYN: .ASCIZ /REW - Command Syntax Error/<7> I.CSI1: .ASCIZ /REW - Command Line Parse Failure at Offset %D/<7> I.CS2O: .ASCIZ /REW - Invalid Syntax in Output Filespec/<7> I.MORO: .ASCIZ /REW - Too Many Output Files Specified/<7> I.TERR: .ASCIZ /REW - Error = %D Rewinding Tape/<7> I.AERR: .ASCIZ /REW - Error = %D Assigning LUN to Tape/<7> I.SELE: .ASCIZ /REW - Select Error on Unit/<7> .EVEN .PAGE .SBTTL Data - CSI & GCML Tables ; ; First we define the system buffers for CSI and GCML ; ; ; The GCMLB$ macro must be modified for user requirements. The ; format is:- ; GCMLB$ command-file depth,prompt,lun GCMBLK: GCMLB$ 1,REW,,CMDLUN CSI$ CSIBLK: .BLKB C.SIZE ; CSI control block .EVEN ; HESW=1 OSWTAB: ; Output switches CSI$SW HE,HESW,SWMSK$,SET ; Help CSI$ND ; SWMSK$: .WORD ; Default mask word HLSPWN: SPWN$ MCR...,,,,,1,,,HELCMD,HELCML HELCMD: .ASCII /HELP REW/ HELCML=.-HELCMD .EVEN ; .PAGE .SBTTL Data - File Definitions FSRSZ$ 1 ; For Command File ; .PAGE .SBTTL Data - User's Areas .LIST BEX SSTTAB: .WORD SSTOD ; Odd Address Trap .WORD SSTMP ; Memory Protect .WORD SSTBE ; BPT .WORD SSTIO ; IOT .WORD SSTIL ; Reserved Instruction .WORD SSTEM ; Non-RSX EMT .WORD SSTTE ; TRAP .WORD SSTFP ; Floating Point SSTNUM: .WORD 0 ; Store for SST Number IOSB: .BLKW 2 ; I/O Status Block ; .PAGE .SBTTL Mainline Code ; ; This section of code governs the mainline operation of the program. ; START: SVTK$S #SSTTAB,#8. ; Specify SST Table ALUN$S #CMDLUN,#"TI,#0 ; Assign prompt lun to TI: FINIT$ ; Initialise the file section ; GETCMD: CLR SWMSK$ ; Clear Options Mask GCML$ #GCMBLK ; Get Command Line BCC 20$ ; If CC OK - carry on CMPB #GE.EOF,G.ERR(R0) ; Was it an end-of-file? BEQ 10$ ; If EQ yes - terminate program CMPB #GE.OPR,G.ERR(R0) ; Invalid command file? BNE 5$ ; If NE no - carry on DIAG GIND ; yes - log the message BR GETCMD ; and try again ; 5$: MOVB G.ERR(R0),R0 ; Sign-extend the error FERR GCME,R0 ; Else log error ; 10$: EXIT$S ; That's all ; 20$: MOV G.CMLD+2(R0),R1 ; Command start MOV G.CMLD(R0),R2 ; And length BEQ GETCMD ; If not there, Re-Prompt ; ; Now parse the command ; PARSE: CSI$1 #CSIBLK,R1,R2 ; Check the syntax BCC 10$ ; If CC OK - carry on MOV CSIBLK+C.FILD+2,R0 ; Get Address of Error SUB R1,R0 ; And hence offset INC R0 ; Starting at 1 DIAG CSI1,R0 ; Log the error BR GETCMD ; And get another command line ; 10$: BIT #CS.EQU*400,(R0) ; Was an "=" specified? BEQ 20$ ; If EQ no - OK carry on DIAG CSYN ; Yes - log error BR GETCMD ; And try again ; 20$: CSI$2 #CSIBLK,OUTPUT,#OSWTAB ; Parse real output name BCC 30$ ; If CC OK - carry on DIAG CS2O ; Output error message BR GETCMD ; And get next command line ; 30$: BITB #CS.MOR,C.STAT(R0) ; See if more output files BEQ 40$ ; If EQ OK - carry on DIAG MORO ; Else log error BR GETCMD ; And get next line ; 40$: BIT #HESW,SWMSK$ ; Help switch? BEQ 50$ ; If EQ no - process normally DIR$ #HLSPWN ; Yes - ask for help WTSE$S #1 ; Wait for it to finish BR 90$ ; Get next line ; 50$: CALL PROCESS ; Now process the command ; 90$: JMP GETCMD ; Get the next line .PAGE .SBTTL Process Routines PROCESS: CMP CSIBLK+C.DSDS,#2 ; At least two characters in device? BGE 10$ ; If GE yes - carry on DIAG CSYN ; No - syntax error BR 90$ ; Get next command ; 10$: MOV CSIBLK+C.DSDS+2,R0 ; Get address of string MOV R0,R1 ; Save it ADD CSIBLK+C.DSDS,R1 ; Offset to end of string CLRB (R1) ; Insert terminator, just in case ADD #2,R0 ; Skip over device mnemonic CALL $COTB ; Convert the number ALUN$S #OUTLUN,@CSIBLK+C.DSDS+2,R1 ; Assign a LUN CMP $DSW,#IS.SUC ; OK? BEQ 20$ ; If EQ yes - carry on DIAG AERR,$DSW ; No - log error BR 90$ ; And exit ; 20$: QIOW$S #IO.SEC,#OUTLUN,#1,,#IOSB ; Sense characteristics BIT #400,IOSB+2 ; Select error? BEQ 30$ ; If EQ no - carry on DIAG SELE ; Yes - say so BR 90$ ; and get next ; 30$: QIOW$S #IO.RWD,#OUTLUN,#1,,#IOSB ; Rewind the tape MOVB IOSB,R0 ; Successful? BPL 90$ ; If PL yes - exit DIAG TERR,R0 ; No - log the error ; 90$: RETURN .PAGE .SBTTL SST SST Handling Routines ; ; This routine handles any SSTs by logging an error, closing the file ; and exiting. This should make it easy to track down the error. ; SSTFP: INC SSTNUM ; Floating Point SSTTE: INC SSTNUM ; TRAP SSTEM: INC SSTNUM ; Non-RSX EMT SSTIL: INC SSTNUM ; Reserved Instruction SSTIO: INC SSTNUM ; IOT SSTBE: INC SSTNUM ; BPT SSTMP: INC SSTNUM ; Memory Protect SSTOD: ; Odd Address Trap TST SSTNUM ; Have we been here before? BGE 20$ ; If GE no - carry on CMP SSTNUM,#-1000. ; Yes - twice? BLE 10$ ; If LE yes - don't even try to close the file MOV #-2000.,SSTNUM ; Stop second level of recursion ; 10$: EXIT$S ; Exit ; 20$: CMP SSTNUM,#1 ; Memory Protect? BNE 30$ ; If NE no - carry on ADD #6,SP ; Yes - chuck three words off the stack ; 30$: CMP SSTNUM,#5 ; TRAP or EMT? (ignore FP as impossible) BLT 40$ ; If LT no - carry on TST (SP)+ ; Yes - chuck a word off the stack ; 40$: MOV (SP)+,ARGBLK+28. ; Save the old PC TST (SP)+ ; Ignore the PS MOV SSTNUM,ARGBLK+26. ; Save the SST number MOV #-100.,SSTNUM ; And stop recursion FERR SST,ARGBLK+26.,ARGBLK+28.,R0,R1,R2,R3,R4,R5,SP,(SP) .PAGE .SBTTL Output Routines ; FERR: CALL DIAG ; Output the Message EXIT$S ; Terminate the program ; DIAG: CALL OUT ; Output QIOW$S #IO.WLB,#ERRLUN,#1,,,,<#OUTBLK,R1,#40> ; Output to TI: RETURN ; Return ; OUT: MOV #OUTBLK,R0 ; Get Buffer for Output MOV #ARGBLK,R2 ; Get Address of any Parameters CALL $EDMSG ; Edit the Message RETURN .END START