Google
 

Trailing-Edge - PDP-10 Archives - SRI_NIC_PERM_SRC_3_19910112 - utilities/typbin.mac
There are no other files named typbin.mac in the archive.
	TITLE TYPBIN
	SUBTTL J. BURCHFIEL JUNE 9, 1971

	;DOES AN OCTAL DUMP OF A PACKED FILE.

	A=1
	B=2
	C=3
	D=4
	F=6
	G=7
	AA=10
	BB=11
	P=17

	SEARCH STENEX

START:	RESET
	MOVE P,[IOWD 10,STK]
	SETZM BYTCNT
	SETZM EOF
	HRROI A,[ASCIZ/
BINARY FILE INTERPRETER.
INPUT FILE = /]
	PSOUT
	MOVSI A,120003
	MOVE B,[XWD 100,101]
	GTJFN
	JRST ERR
	MOVEM A,INJFN
Q1:	HRROI A,[ASCIZ/
BYTE LENGTH (DECIMAL BITS) = /]
	PSOUT
	MOVEI A,100
	MOVEI C,^D10
	NIN
	JRST ERR
	CAIL B,1
	CAILE B,^D36
	JRST Q1
	MOVEM B,BYTSIZ
	ADDI B,2
	IDIVI B,3
	ADDI B,1
	MOVEM B,COLWID
	HRLZI B,-1(B)
	IOR B,[1B0+1B2+1B3+10]
	MOVEM B,NOUTWD
	MOVEI A,^D72-7
	IDIV A,COLWID
	MOVEM A,NCOLS
	MOVE B,[XWD 440000,200000]
	MOVE A,INJFN
	OPENF
	JRST ERR
	HRROI A,[ASCIZ/
OUTPUT FILE = /]
	PSOUT
	MOVSI A,460003
	MOVE B,[XWD 100,101]
	GTJFN
	JRST ERR
	MOVEM A,OUTJFN
	MOVE B,[XWD 070000,100000]
	OPENF
	JRST ERR
	MOVE D,NCOLS
	SETZ AA,
	JRST LUPEOL

LUP:	MOVE BB,BYTSIZ
	SETZ F,
	CAIGE AA,(BB)
	PUSHJ P,NEWWD
	SKIPE EOF	;NO MORE INPUT?
	CAME BB,BYTSIZ	;AND NOTHING LEFT FROM LAST WORD?
	SKIPA		;NO
	JRST FIN	;YES- ALL DONE.
	LSHC F,(BB)
	SUBI AA,(BB)
	MOVE B,F
	MOVE A,OUTJFN
	MOVE C,NOUTWD
	AOS BYTCNT
	NOUT
	JRST ERR
	MOVEI B,40
	BOUT
	SKIPE EOF
	JRST FIN
	SOJG D,LUP
LUPEOL:	MOVE A,OUTJFN
	MOVEI B,15
	BOUT
	MOVEI B,12
	BOUT
	MOVE B,BYTCNT
	MOVE C,[540006,,10]
	NOUT
	  JFCL
	MOVEI B,40
	BOUT

	MOVE D,NCOLS
	JRST LUP

NEWWD:	LSHC F,(AA)
	SUBI BB,(AA)
	MOVE A,INJFN
	BIN
	MOVE G,B
	GTSTS
	TLNE B,(1B8)	;EOF?
	SETOM EOF
	MOVEI AA,^D36
	POPJ P,

FIN:	MOVE A,INJFN
	CLOSF
	JRST ERR
	MOVE A,OUTJFN
	CLOSF
	JRST ERR
	HRROI A,[ASCIZ /DONE.
TOTAL BYTES (DEC) = /]
	PSOUT
	MOVEI A,101
	MOVE B,BYTCNT
	MOVEI C,^D10
	NOUT
	JRST ERR
	MOVEI B,37
	BOUT
	HRROI A,[ASCIZ /
EXIT.
^C
/]
	PSOUT
	HALTF

ERR:	MOVEI A,100
	MOVE B,[XWD 400000,-1]
	SETZ C,
	ERSTR
	HALTF
	HALTF
	HALTF

	LIT

INJFN:	BLOCK 1
BYTSIZ:	BLOCK 1
NOUTWD:	BLOCK 1
OUTJFN:	BLOCK 1
BYTCNT:	BLOCK 1
EOF:	BLOCK 1
COLWID:	BLOCK 1
NCOLS:	BLOCK 1
PATCH:	BLOCK 20
STK:	BLOCK 10

	END START