Trailing-Edge
-
PDP-10 Archives
-
decus_20tap5_198111
-
decus/20-0138/dmptap.mac
There are 2 other files named dmptap.mac in the archive. Click here to see a list.
TITLE DMPTAP
SUBTTL BINARY DUMP FOR MAGTAPE P. ALCIERE
SEARCH MACTEN,UUOSYM
SALL
TWOSEG
VMAJOR==2
VMINOR==4
VEDIT==11
VWHO==0
.JBVER==137
LOC .JBVER
BYTE (3)VWHO(9)VMAJOR(6)VMINOR(18)VEDIT
RELOC 400000
PDLSIZ=20 ;PUSHDOWN LIST SIZE
;REGISTERS:
T0==0
T1==1
WORDS==2
LEFT==3
RIGHT==4
BYTES==5
PNT==6
SP==7
FROM==10
BITS==11
LF==12
CMP==13
FF==14
CR==15
STATUS==16
P==17
;CHANNELS:
TTY==0
INN==1
OUT==2
;INITIALIZATION:
START: JFCL
RESET
MOVEI 0,EOF
MOVEM 0,.JBREN ;SET UP REENTRY ADDRESS FOR HUNG DEVICE
MOVE P,[IOWD PDLSIZ,STACK]
SETZM RECNO#
SETZM LOWZRO ;ZERO BUFFERS, ETC.
MOVE T1,[XWD LOWZRO,LOWZRO+1]
BLT T1,LOWTOP
SKIPE T1,SVJBFF# ;RESTORE .JBFF FOR RESTART
MOVEM T1,.JBFF##
MOVE T1,.JBFF
MOVEM T1,SVJBFF
OPEN TTY,TTYBLK
HALT
;SET UP LOGICAL NAME OF INPUT MAGTAPE
ASKIN: OUTSTR[ASCIZ"
Logical/physical device name of MAGtape: "]
INPUT TTY, ;READ NAME OF MAGTAPE
MOVE PNT,[POINT 6,INNBLK+1]
PUSHJ P,SIXBIT
;OPEN INPUT MAGTAPE
OPNINN: OPEN INN,INNBLK
JRST [OUTSTR [ASCIZ/
?Cannot open a device by that name./]
JRST ASKIN]
MOVE 0,INNBLK+1
MOVEM 0,LOC# ;SET UP DEVICE NAME FOR MTCHR.
MOVEI 0,INN
DEVCHR 0,
TLNN 0,(DV.MTA) ;TEST FOR MAGTAPE
JRST NOTMTA ;NOT A MAGTAPE
MOVE 0,[XWD 2,[EXP .TFTRK,INN]]
TAPOP. 0, ;7-TRACK?
HALT
JUMPN 0,ASK7 ;YES
MOVEI 0,8 ;DISPLAY 8 BITS PER CHARACTER IF 9-TRACK TAPE
SA10: MOVEM 0,BYTSIZ#
MOVEI 0,4 ;4 BYTES PER WORD
MOVEM 0,BPERW#
MOVE 0,[XWD 3,[EXP .TFMOD+1000,INN,.TFM8B]]
TAPOP. ;SET INDUSTRY-COMPATIBLE MODE
HALT
JRST ASKOUT
;ASK 7-TRACK QUESTIONS
ASK7: MOVEI 0,6 ;DISPLAY 6 BITS PER CHARACTER IF 7-TRACK TAPE
MOVEM 0,BYTSIZ
MOVEM 0,BPERW ;6 BYTES PER WORD
OUTSTR [ASCIZ"Parity (ODD/EVEN): "]
INPUT TTY,
MOVEI BITS,.IODMP
ILDB CMP,TINP+1 ;PICK UP O/E
CAIL CMP,140 ;TEST FOR LOWER CASE
SUBI CMP,40 ;CONVERT TO UPPER CASE
CAIE CMP,"E"
JRST ASKOUT
IORI BITS,IO.PAR ;SET EVEN PARITY BIT IF "E"
SETSTS INN,(BITS) ;MODIFY STATUS BITS OF OPENED INPUT FILE
MOVE 0,[XWD 2,[EXP .TFKTP,INN]]
TAPOP. 0, ;TEST KONTROLLER TYPE
HALT
CAIE 0,7 ;SA-10?
JRST ASKOUT ;NO
MOVE 0,[XWD 1,6] ;YES
JRST SA10
;ASK OUTPUT QUESTIONS
ASKOUT: OUTSTR [ASCIZ/
Output device name: /]
INPUT TTY,
MOVE PNT,[POINT 6,OUTBLK+1]
PUSHJ P,SIXBIT
;OPEN OUTPUT DEVICE
OPNOUT: MOVE 0,LOC+.MTSRE ;SAVE INITIAL ERROR COUNTS
MOVEM 0,OLDSRE#
MOVE 0,LOC+.MTHRE
MOVEM 0,OLDHRE#
OPEN OUT,OUTBLK
JRST [OUTSTR [ASCIZ/
?Cannot open a device by that name./]
JRST ASKOUT]
MOVEI 0,OUT ;TEST WHETHER DIRECTORY DEVICE
DEVCHR 0,
TLNN 0,(DV.DIR) ;SKIP IF DIRECTORY DEVICE
JRST DUMMY ;ELSE JUMP
;ASK FILENAME.EXT IF DIRECTORY DEVICE
ASKFIL: OUTSTR [ASCIZ/
Output filename.ext: /]
INPUT TTY,
MOVE PNT,[POINT 6,OUTNAM]
PUSHJ P,SIXBIT
MOVE PNT,[POINT 6,OUTNAM+1]
PUSHJ P,SIXBIT
HLLZS OUTNAM+1
ENTER OUT,OUTNAM
JRST [OUTSTR [ASCIZ/
?Cannot open a file by that name./]
JRST ASKFIL]
DUMMY: OUTPUT OUT,
;PUT CONTROL CHARACTERS IN THEIR OWN AC'S
NONDIR: MOVEI FF,14
MOVEI SP,40
MOVEI CR,15
MOVEI LF,12
;SET LIMIT TO PRINTABLE OUTPUT
OUTSTR [ASCIZ "Max. lines printout: "]
PUSHJ P,TIDEC
CAIGE 0,0 ;DEFAULT OUTPUT: 20 LINES
MOVEI 0,^D20
MOVEM 0,LINES
READ: MOVE 0,.JBFF## ;MAKE INPUT LIST
SUB 0,.JBREL##
HRLZS 0
HRR 0,.JBFF
SOJ 0,
MOVEM 0,INLIST#
INPUT INN,INLIST ;READ ONE RECORD (UNBUFFERED)
GETSTS INN,STATUS ;GET FILE STATUS FROM MONITOR
TRNE STATUS,IO.EOF ;TEST FOR EOF
JRST EOF
TRNE STATUS,IO.BKT ;TEST FOR BLOCK TOO LARGE
JRST MORCOR ;YES. GET MORE CORE AND TRY AGAIN.
MOVE PNT,[POINT 7,[ASCIZ/
Record number: /]]
PUSHJ P,STRING
AOS LEFT,RECNO
MOVSI PNT,(POINT 7,0)
SETZB 0,1
PUSHJ P,DECMAL
MOVSI PNT,(POINT 7,0)
PUSHJ P,STRING
MOVE PNT,[POINT 7,[ASCIZ/ Record length: /]]
PUSHJ P,STRING
MOVE LEFT,[XWD 21,LOC]
MTCHR. LEFT,
HALT
MOVE LEFT,LOC+.MTCCR ;GET NUMBER OF CHARACTERS READ
MOVEM LEFT,LIMIT#
MOVSI PNT,(POINT 7,0)
SETZB 0,1
PUSHJ P,DECMAL
MOVSI PNT,(POINT 7,0)
PUSHJ P,STRING
MOVE PNT,[POINT 7,[ASCIZ/ bytes
/]]
PUSHJ P,STRING
MOVE FROM,.JBFF##
LINE: MOVE PNT,[POINT 7,LINBUF]
SETZM LINBUF ;CLEAR OUTPUT LINE
MOVE 0,[XWD LINBUF,LINBUF+1]
BLT 0,LINBUF+^D26
MOVEI WORDS,3
WORD: MOVE BYTES,BPERW
MOVE RIGHT,(FROM) ;GET NEXT WORD OF INPUT
BYTE: MOVE BITS,BYTSIZ
IDPB SP,PNT
TLZE BITS,1 ;SA-10 FLAG ON?
LSH RIGHT,2 ;YES. IGNORE HIGH-ORDER 2 BITS
BIT: MOVEI LEFT,30 ;CONVERT EACH 0 OR 1 TO ASCII
LSHC LEFT,1
IDPB LEFT,PNT
SOJG BITS,BIT
SOSG LIMIT
JRST ENDREC
SOJG BYTES,BYTE
AOJ FROM,
SOJG WORDS,WORD ;TEST FOR END OF LINE
IDPB CR,PNT ;END OF LINE
IDPB LF,PNT
IDPB LF,PNT
MOVE PNT,[POINT 7,LINBUF]
PUSHJ P,STRING ;PRINT IT OUT
SOSLE LINES ;CHECK VS. MAX. NO. LINES
JRST LINE
MOVE PNT,[POINT 7,[ASCIZ/
Output limit reached.
/]]
MOVS CMP,OUTBLK+1 ;OUTPUT DEVICE NAME
CAIE CMP,'TTY'
OUTSTR (PNT)
PUSHJ P,STRING
JRST EOF
ENDREC: IDPB CR,PNT ;END OF RECORD
IDPB LF,PNT
MOVE PNT,[POINT 7,LINBUF]
PUSHJ P,STRING ;PRINT LAST LINE
TRNN STATUS,IO.ERR ;TEST FOR ERROR ON INPUT
JRST READ
PUSHJ P,MTSTAT ;INTERPRET STATUS BITS
JRST READ
EOF: PUSHJ P,MTSTAT ;INTERPRET STATUS BITS
MOVS CMP,OUTBLK+1
MOVE PNT,[POINT 7,[ASCIZ/Soft read errors: /]]
CAIE CMP,'TTY'
OUTSTR (PNT)
PUSHJ P,STRING
MOVE LEFT,LOC+.MTSRE ;SOFT READ ERRORS
SUB LEFT,OLDSRE
MOVSI PNT,(POINT 7,0)
SETZB 0,1
PUSHJ P,DECMAL
CAIE CMP,'TTY'
OUTSTR 0,
MOVSI PNT,(POINT 7,0)
PUSHJ P,STRING
MOVE PNT,[POINT 7,[ASCIZ/ Hard read errors: /]]
CAIE CMP,'TTY'
OUTSTR (PNT)
PUSHJ P,STRING
MOVE LEFT,LOC+.MTHRE ;HARD READ ERRORS
SUB LEFT,OLDHRE
MOVSI PNT,(POINT 7,0)
SETZB 0,1
PUSHJ P,DECMAL
CAIE CMP,'TTY'
OUTSTR 0
MOVSI PNT,(POINT 7,0)
PUSHJ P,STRING
MOVE PNT,[POINT 7,[ASCIZ/
/]]
CAIE CMP,'TTY'
OUTSTR (PNT)
PUSHJ P,STRING
EXIT
;SUBROUTINES
DEFINE TESTAT(B,M)
<
TRNE STATUS,B ;TEST BIT
OUTSTR M ;TYPE OUT MESSAGE
>
;INTERPRET MAGTAPE STATUS BITS
MTSTAT: TESTAT IO.IMP,IMPMSG
TESTAT IO.DER,DERMSG
TESTAT IO.DTE,DTEMSG
TESTAT IO.EOF,EOFMSG
TESTAT IO.ACT,ACTMSG
TESTAT IO.BOT,BOTMSG
TESTAT IO.EOT,EOTMSG
TRNN STATUS,IO.PAR ;TEST BIT
OUTSTR ODDMSG
TESTAT IO.PAR,EVNMSG
TESTAT IO.NRC,NRCMSG
;FINAL <CR>,<LF>
OUTSTR [ASCIZ /
/]
POPJ P,
IMPMSG: ASCIZ /
[Tried to write while write-locked, or other illegal operation.]/
DERMSG: ASCIZ /
[Data was missed, tape is bad, or transport is hung.]/
DTEMSG: ASCIZ /
[Parity error.]/
EOFMSG: ASCIZ /
[End of file (or hung device).]/
ACTMSG: ASCIZ /
[Device was active.]/
BOTMSG: ASCIZ /
[Unit is at beginning of tape.]/
EOTMSG: ASCIZ /
[Unit is at end of tape.]/
EVNMSG: ASCIZ /
[Even parity is set.]/
ODDMSG: ASCIZ /
[Odd parity is set.]/
NRCMSG: ASCIZ /
[Automatic error correction is suppressed.]/
;GET MORE CORE AND TRY READING TAPE AGAIN
MORCOR: MTBSR. INN, ;BACKSPACE RECORD
MOVE 0,.JBREL
ADDI 0,2000
CORE 0,
JRST [OUTSTR [ASCIZ/
? Could not get enough core to read tape block.
/]
EXIT]
OUTSTR [ASCIZ/
[/]
MOVE LEFT,.JBREL
ADDI LEFT,1001 ;ALLOW FOR WORD 0 AND UPMP
ASH LEFT,-^D9
MOVSI PNT,(POINT 7,0)
SETZ 0,
PUSHJ P,DECMAL
OUTSTR 0
OUTCHR ["+"]
MOVEI LEFT,HITOP
TRZ LEFT,400000
LSHC LEFT,-^D9
SKIPE RIGHT
AOJ LEFT, ;ROUND UP
MOVSI PNT,(POINT 7,0)
SETZ 0,
PUSHJ P,DECMAL
OUTSTR 0
OUTSTR [ASCIZ/P Core.]
/]
JRST READ
SIXBIT: HRRZ 0,PNT ;GET ADDRESS FROM POINTER
SETZM @0 ;CLEAR DESTINATION WORD INITIALLY
MOVEI BYTES,6 ;MAX. 6 CHARACTERS IN DEVICE NAME
GET: ILDB 0,TINP+1 ;PICK UP A LETTER
CAILE 0,140 ;TEST FOR LOWER-CASE
SUBI 0,40 ;IF SO, CONVERT TO UPPER-CASE
CAIN 0,":" ;QUIT ON COLON
POPJ P,
CAIN 0,"." ;TEST FOR PERIOD
JRST DOT ;IGNORE PERIOD IF FIRST CHARACTER
SUBI 0,40 ;CONVERT TO SIXBIT
JUMPLE 0,GOT ;QUIT ON ANY CONTROL CHARACTER OR BLANK
IDPB 0,PNT ;PUT SIXBIT CHARACTER INTO DEVICE NAME
SKIP: SOJG BYTES,GET ;LOOP
GOT: POPJ P,
DOT: CAIL BYTES,6 ;SEE IF IT WAS THE FIRST CHARACTER
JRST SKIP ;YES. IGNORE IT
POPJ P, ;NO. GO HOME
TIDEC: INPUT TTY, ;DECIMAL INPUT FROM TTY
SETZ 0,
TIDEC1: ILDB CMP,TINP+1 ;GET CHARACTER FROM TTY
SUBI CMP,"0" ;SUBTRACT ASCII "0"
JUMPL CMP,TIDEC2 ;QUIT IF <0
CAILE CMP,"9" ;QUIT IF >9
TIDEC2: POPJ P,
IMULI 0,^D10
ADD 0,CMP
JRST TIDEC1
;DECIMAL TYPOUT ROUTINE FROM SYSTEM REFERENCE MANUAL:
DECMAL: IDIVI LEFT,^D10 ;DIVIDE BY 10
HRLM RIGHT,(P) ;SAVE REMAINDER
SKIPE LEFT ;ALL DIGITS FORMED?
PUSHJ P,DECMAL ;NO. CALL SELF RECURSIVELY
HLRZ LEFT,(P) ;YES. TAKE OUT IN OPPOSITE ORDER
ADDI LEFT,"0" ;CONVERT TO ASCII
IDPB LEFT,PNT ;PUT ONE DIGIT INTO OUTPUT AREA
POPJ P,
;OUTPUT STRING. BYTE POINTER IN PNT POINTS TO ASCIZ STRING.
STRING: MOVE BITS,OUTBLK+1
CAME BITS,[SIXBIT /TTY/] ;OUTPUT DEVICE = TTY?
JRST NOTTTY ;NO
OUTSTR (PNT) ;YES. USE TTCALL
POPJ P,
NOTTTY: ILDB BITS,PNT ;NOT TTY. GET FIRST BYTE
JUMPE BITS,ENDSTR
PUT: SOSGE OBUF+2
JRST PUTBF
IDPB BITS,OBUF+1
JRST STRING
PUTBF: OUTPUT OUT,
JRST PUT
ENDSTR: POPJ P,
NOTMTA: OUTSTR [ASCIZ "
? Not a MAGtape.
"]
JRST ASKIN
LIT
HITOP==.
RELOC
;NON-ZEROED LOW CORE:
LINES: DEC 1000 ;MAX. LINES PER RUN
TTYBLK: 0
SIXBIT/TTY/
XWD TOUT,TINP
INNBLK: OCT IO.NRC+17,0,0
OUTBLK: 0
SIXBIT/DSK/
XWD OBUF,0
;ZEROED LOW CORE:
LOWZRO==.
OUTNAM: BLOCK 4
0
LOC: BLOCK 22
TINP: BLOCK 3
TOUT: BLOCK 3
OBUF: BLOCK 3
LINBUF: BLOCK ^D27
STACK: BLOCK PDLSIZ ;PUSHDOWN LIST
LOWTOP==.
END START