Google
 

Trailing-Edge - PDP-10 Archives - SRI_NIC_PERM_SRC_3_19910112 - utilities/ra10.fai
There are no other files named ra10.fai in the archive.
	title	ra10 - read A10 files.  Build EXE file.

	search monsym
	EXTERN	.JBFF,.JBREL,.JBSYM,.JB41,.JBUUO

a=1
b=2
c=3
d=4
w=5
x=6
y=7
z=10

p=17

OPDEF	CALL	[PUSHJ P,]
OPDEF	RET	[POPJ P,]
OPDEF	ERROR	[1B8]
OPDEF	ESTOP	[2B8]
opdef	outstr	[3b8]
opdef	errmsg	[4b8]

PDLEN==100
LBFLN==40

PDLIST:	Block	pdlen
IJFN:	0
LINBUF:	BLOCK	LBFLN
LINPTR:	0
TENWRD:	0
TENADR:	0
maxtad:	0
WC:	0
CHECKS:	0
OCTLIN:	0


TENSAD:	0		;starting address of program
TENORG:	0		;phys addr corresp. to physical 0

UUOH:	0
	JRST	UUOHAN
CRLF:	BYTE(7)15,12
GTJFTB:	BLOCK	.GJBFP+1		;bblock for long GTJFN
;	;DDRPI.A10   VER 0.4   03-MAY-77
;	Z A,C@@,EOR,Gpm
;	T C,AN,HIX,OhX,O,HLp
;	T I,AP,C@@,=H,B,HOR,,,,FH@,E,MjF
;	T R,HOK,A,,,GE,,A,F,,,C|c,Hq,,A`,Om`,O,Du=,NOi,,oM
;	T C,HOQ,A`,O?x,O,GoE
;	T ,C@@,M@@
;	;EOF

;A10 format:

;	;semicolon means line is a comment
;	each field represents 16 bits.  Each character represents
;	six bits.  generally, subtract octal 100 from the character,
;	except, if the character is already less than 100, leave it
;	alone.

;	lines are checksummed, except Octal patch lines.  Checksum
;	is such that if you add every field (count, address, data,
;	and checksum), the result should be zero (mod 2^16)

;	T means line is to be loaded in the PDP-10
;	 Space following means normal format, "O" following signifies
;	 the Octal format for patches.
;	 First field is the count of data bytes that follow.
;	 High order byte of WC is the high order PDP-10 address.
;	 The second field is the PDP-10 address (0 to 177777)
;	 The address field is NOT included in the data byte count
;	Z defines area to zero
;	Address is first address to zero.  WC is usually 1.
;	data item is the count of words to zero.
;	checksum as usual.
;	If WC>1 then other items are additional counts

GETAFD:	MOVEI	B,0		;collect ASCII-ized field
GETAF1:	CALL	GETBYT		;get a byte of input from file.
	CAIE	A,","		;comma or eol ends field
	CAIN	A,12
	JRST	[ADDM B,CHECKS	;end of field. collect checksum
		RET]		;return
	SKIPE	OCTLIN		;is this a patch line?
	JRST	GETAF2		;yes. reading octal numbers.
	CALL	CNVASC		;convert ascii character to number
	IMULI	B,100		;shift B
	ADD	B,A
	JRST	GETAF1		;loop

GETAF2:	CAIL	A,"0"
	CAILE	A,"7"
	ERROR	[ASCIZ/error in Octal line/]
	IMULI	B,10
	ADDI	B,-"0"(A)
	JRST	GETAF1

CNVASC:	CAIGE	A,175		;convert character to 6 bit number
	CAIGE	A,75
	ERROR	[ASCIZ/Illegal ASCII-ized character/]
	CAILE	A,77
	SUBI	A,100
	RET

GETTWD:	SETZM	TENWRD		;collect 3 fields to form a word.
	CALL	GETAFD
	DPB	B,[POINT 16,TENWRD,35]
	CALL	GETAFD
	DPB	B,[POINT 16,TENWRD,19]
	CALL	GETAFD
	CAILE	B,17		;first field is 4 bits.
	ERROR	[ASCIZ/illegal field in GETTWD/]
	DPB	B,[POINT 4,TENWRD,3]
	MOVE	B,TENWRD
	RET

SOCTLN:	SETZM	OCTLIN		;assume line is not OCTAL
	ILDB	B,LINPTR	;second character of line.
	CAIN	B," "		;blank?
	RET
	CAIE	B,"O"
	ERROR	[ASCIZ/Unknown second character/]
	SETOM	OCTLIN		;flag this is octal.
	RET

PNTCMT:	CALL	PNTLIN		;print a comment or a blank line
DOLINE:	CALL	RDLINE		;read a line
	RET			;end of file.
	ILDB	A,LINPTR	;first byte of line
	CAIE	A,15
	CAIN	A,";"
	JRST	PNTCMT		;print a comment.
	CAIN	A,"Z"
	JRST	DOZLIN		;do a zero line
	CAIN	A,"T"	
	JRST	DOTLIN		;do load ten line
	ERROR	[ASCIZ/Unknown function/]

GTWCAD:	CALL	GETAFD		;get WC field
	MOVEM	B,WC		;save it.
	CALL	GETAFD
	MOVEM	B,TENADR	;save PDP-10 address
	LDB	B,[POINT 8,WC,27]	;high-order PDP-10 addr.
	DPB	B,[POINT 2,TENADR,19]
	MOVEI	B,0
	DPB	B,[POINT 8,WC,27]	;clear high byte of WC.
	MOVE	B,TENADR
	CAMGE	B,MAXTAD
	MOVEM	B,MAXTAD	;save latest maximum
	RET

DOTLIN:	CALL	SOCTLN		;decide if line is octal
	CALL	GTWCAD		;get WC and ADDRESS
	SKIPN	WC		;is there a WC at all?
	JRST	DOTSL		;no.  we just saw the start address.
DOTLN1:	CALL	GETTWD		;get a ten word
	MOVE	A,TENADR	;get the current tenaddress
	CAMGE	A,MAXTAD
	MOVEM	A,MAXTAD	;maximum ten address
	ADD	A,TENORG	;plus phys org of 10 pseudo mem.
	MOVEM	B,(A)		;stuff word
	AOS	TENADR		;next word into next word
	MOVNI	B,3
	ADDB	B,WC
	JUMPG	B,DOTLN1
	SKIPE	WC
	ERROR	[ASCIZ/bad WC on T line/]
CHKCHK:	SKIPE	OCTLIN		;is this an octal patch?
	JRST	DOLINE		;yes, no checksum.  do next line
	CALL	GETAFD		;get last field
	MOVE	B,CHECKS
	TRNE	B,177777
	ERROR	[ASCIZ/Checksum error/]
	JRST	DOLINE		;do next line.

DOTSL:	MOVE	A,TENADR
	MOVEM	A,TENSAD		;save ten start address
	JRST	CHKCHK

DOZLIN:	CALL	SOCTLN
	CALL	GTWCAD		;get wc and address
	SKIPN	WC
	JRST	CHKCHK		;end if WC is zero.
DOZLI1:	CALL	GETAFD		;get the count field
	MOVE	A,TENADR
	ADDM	B,TENADR	;update in case of second count.
	ADD	A,TENORG
	SETZM	(A)
	ADDI	A,1
	SOJG	B,.-2
	SOSG	WC
	JRST	[MOVE B,TENADR
		SUBI B,1
		CAMGE B,MAXTAD
		MOVEM B,MAXTAD
		JRST CHKCHK]
	JRST	DOZLI1


GETBYT:	ILDB	A,LINPTR	;get next byte from line
	jumpe	a,[error [asciz/unexpected end of line/]]
	cain	a,15		;ignore cr
	jrst	getbyt
	CAIN	A,12		;but LF is end of line
	SETZM	LINPTR		;see above test.
	RET

RDLINE:	HRRZ	A,IJFN
	HRROI	B,LINBUF
	MOVEI	C,LBFLN*5-4
	MOVEI	D,12
	SIN
	ERJMP	TSTEOF
	MOVEI	A,0
	IDPB	A,B		;make sure line ends with null.
;	CALL	PNTLIN		;debugging - print line
	MOVE	A,[POINT 7,LINBUF]
	MOVEM	A,LINPTR
CPOPJ1:	AOS	(P)
CPOPJ:	RET

TSTEOF:	HRRZ	A,IJFN
	GTSTS
	TLNE	B,(GS%EOF)
	RET
	HRROI	A,[ASCIZ/?Input error: /]
	PSOUT
	ESTOP

PNTLIN:	HRROI	A,LINBUF
	PSOUT
	RET
START:	RESET
	MOVE	P,[IOWD PDLEN,PDLIST]
	MOVE	A,[JSR UUOH]
	MOVEM	A,.JB41
	CALL	INICOD		;initialize.
NXTFIL:	CALL	DOFILE
	HRRZ	A,IJFN
	CLOSF
	 ERJMP	.+1
	HRROI	A,[ASCIZ/Any more files? /]
	CALL	YESNO
	JRST	FINUP
	JRST	NXTFIL

FINUP:
	MOVS	0,tenorg		;origin of psuedo mem.
	ADD	0,[20,,20]		;don't blt into acs.
	MOVE	1,MAXTAD		;end address of blt.
	MOVE	2,[BLT 0,(1)]
	MOVE	3,[HALTF]
break:	jrst	2

INICOD:	Hrrz	a,.jbsym
	hlre	b,.jbsym
	sub	a,b
	ADDI	A,2000
	TRZ	A,777
	MOVEM	A,TENORG
	RET

YESNO:	PUSH	P,A
YESNO1:	MOVE	A,(P)
	PSOUT
	HRROI	A,LINBUF
	MOVEI	B,LBFLN*5-4
	MOVE	C,(P)
	RDTTY
	 ERJMP	YESNO1
	LDB	A,[POINT 7,LINBUF,6]
	CAIE	A,"Y"
	CAIN	A,"Y"+40
	AOS	-1(P)
	SUB	P,[1,,1]
	RET

DOFILE:	CALL	OPISTR		;open file for input
	CALL	DOLINE
	RET
UUOHAN:	PUSH	P,UUOH
	PUSH	P,A
	LDB	A,[POINT 9,.JBuuo,8]
	CAIL	A,NUUOS
	MOVEI	A,0
	CALL	@UUOTAB(A)
	JRST	.+2
	AOS	-1(P)
	POP	P,A
	SUB	P,[1,,1]
	JRST	2,@1(P)

UUOTAB:	ILLUUO
	ERRUUO
	ESTPUU
	OUTSUU
	ERMSUU
NUUOS==.-UUOTAB

ILLUUO:	HRROI	A,[ASCIZ/?Illegal UUO
/]
	PSOUT
DIE:	HALTF
	JRST	DIE

ERRUUO:	HRROI	A,[ASCIZ/?ERROR:   /]
	PSOUT
	HRRO	A,.JBUUO
	PSOUT
	HRROI	A,CRLF
	PSOUT
	JRST	DIE

ESTPUU:	HRROI	A,[ASCIZ/?JSYS error:   /]
	PSOUT
	CALL	JSERR
	JRST	DIE

OUTSUU:	HRRO	A,.JBUUO
	PSOUT
	RET

ERMSUU:	hrroi	a,[asciz/%Error: /]
	PSOUT
	HRRO	A,.JBUUO
	PSOUT
	HRROI	A,CRLF
	PSOUT
JSERR:	MOVEI	A,.PRIOU
	PUSH	P,B
	PUSH	P,C
	HRLOI	B,.FHSLF		;SELF,,MOST RECENT ERROR
	MOVEI	C,0
	ERSTR
	erjmp	.+1
	ERJMP	.+1
	HRROI	A,CRLF
	PSOUT
	POP	P,C
	POP	P,B
	RET
	SUBTTL	OPEN FILES FOR INPUT/OUTPUT

OPMSG:	[ASCIZ/Name of the A10 file:  /]
	[ASCIZ/Name of the accounting data file: /]
	[ASCIZ/Name of the binary accounting data file(s): /]
	[ASCIZ/Output raw accounting data to: /]

OPJFN:	IJFN
;	DJFN
;	BJFN
;	DOJFN

OPGBIT:	GJ%OLD!GJ%XTN!GJ%CFM
	GJ%OLD!GJ%XTN!GJ%CFM
	GJ%OLD!GJ%XTN!GJ%CFM!GJ%IFG!GJ%FLG	;* ok on binary data file
	GJ%XTN!GJ%CFM!GJ%FOU			;Output file

OPNBIT:	070000,,OF%RD		;Read 7 bit bytes
	070000,,OF%RD
	440000,,OF%RD
	070000,,OF%WR

OPENBI:	SKIPA	Z,[2]
OPENDO:	MOVEI	Z,3
	JRST	GETIJF

OPISTR:	TDZA	Z,Z
OPDATA:	MOVEI	Z,1
GETIJF:	OUTSTR	@OPMSG(Z)
	MOVEI	B,0
	MOVEI	A,GTJFTB		;GTJFN TABLE
	MOVE	C,OPGBIT(Z)		;bits for GTJFN
	MOVEM	C,.GJGEN(A)
	MOVE	C,[.PRIIN,,.PRIOU]
	MOVEM	C,.GJSRC(A)
	SETZM	.GJDEV(A)
	SETZM	.GJDIR(A)
	SETZM	.GJNAM(A)
	SETZM	.GJEXT(A)
	SETZM	.GJPRO(A)
	SETZM	.GJACT(A)
	SETZM	.GJJFN(A)
	MOVE	C,[g1%rnd+.GJBFP-.GJF2]
	MOVEM	C,.GJF2(A)		;size of extra area
	SETZM	.GJCPP(A)
	SETZM	.GJCPC(A)
	HRRO	C,OPMSG(Z)
	MOVEM	C,.GJRTY(A)
	SETZM	.GJBFP(A)
	GTJFN
	ERJMP	[caie a,gjfx37		;skip message if merely ^u
		ERRMSG	1,[ASCIZ/Cannot get JFN/]
		JRST GETIJF]
	MOVEM	A,@OPJFN(Z)		;SAVE FLAGS
	HRRZ	A,A			;CONTINUE HERE FROM OPNXXX
GETIOF:	MOVE	B,OPNBIT(Z)
	OPENF
	ERJMP	[ERRMSG	[ASCIZ/Cannot OPENF input file/]
		MOVE A,@OPJFN(Z)
		JRST GETIOF]
	RET
	END	START