Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-02 - 43,50301/star11.snb
There are 2 other files named star11.snb in the archive. Click here to see a list.
**
************************************
** MACHINE DEPENDENT* PDP11        *
************************************
**
INIT	BSIZE = 8
	WSIZE = 16
	HSIZE = 9999
	MAXSIZE = 2 ** 16 - 1
	ADDR.WORD = 2
	JUMPLOC = FILLTAB( TABLE(14,5) ,
.		'GOTO,GOTO"<-[,MOVA"<-,MOV"+,ADD"-,SUB"!,BIS"'
.		'/&/,BIC"&,BIC"X!,XOR"'
.		'/,DIV"*,MUL"MOD,MOD"<-<-,ASL"->->,ASR"'
.		'\,COM"'
.		)
	LOGOP = FILLTAB( TABLE(11) ,
.		'<=,LE"\>,LE">=,GE"\<,GE"<,LT"\>=,LT"'
.		'>,GT"\<=,GT"=,EQ"\=,NE"<>,R"'
.		)
	SC = '$'
	VER = VER '0  STAR11'
	MOV = 'MOV'
	SW.PIC = '+'
	BASE.REG = '%4'
	REENT.REG = '%5'
	MOVA.PARSE = POS(1) BREAK('(') . OFF
.		'(' BREAK(')') . LREG
	DEFINE('ASSCK(OP,L.ADDR)')
	DEFINE('GETROFF(LAB)')
	DEFINE('GENONE(OP)')
	DEFINE('GENTWO(OP)')
					:(RETURN)
**
BEGIN	STARTLAB =  LABEL
	ASSNL('.TITLE',LABEL)
	ASSNL('.GLOBL',LABEL)
	GENLAB(LABEL)
	( \( IDENT(SW.DEBUG) IDENT(SW.REENT) ) ASSNL(MOV,'%5,-(%6)') )
	DIFFER(SW.REENT)
.		ASSNL('SUB','$$REENT,%6')
.		ASSNL(MOV,'%6,' REENT.REG)
	IDENT(OPERAND)			:S(RETURN)
	OPERAND = DIFFER(SW.REENT)
.		GETROFF(OPERAND)
	ASSNL(MOV,'%5,' OPERAND)
	ASSNL('ADD','#2,' OPERAND)
					:(RETURN)
**
FINISH	( DIFFER(SW.REENT) ASSNL('ADD','$$REENT,%6') )
	( \( IDENT(SW.DEBUG) IDENT(SW.REENT) ) ASSNL(MOV,'(%6)+,%5') )
	ASSNL('RTS','%5')
	( DIFFER(SW.REENT) ASS('$$REENT','.WORD',RADIX(TOTSTORE)) )
DSLOOP	SAVEDS BREAK.TAB =
.	   GENLAB(T1) PUT('.=.+' RADIX(T2))	:S(DSLOOP)
DCLOOP	SAVEDC BREAK.TAB = ASS(T1,'.ASCIZ','"' T2 '"')	:S(DCLOOP)
	ASSNL('.END',STARTLAB)		:(RETURN)
**
COMMENT STATE LEN(69) . T1 = PUT(';' T1) :S(COMMENT)
	PUT(';' STATE)			:(RETURN)
**
RADIX	RADIX = DEC2OCT(RADIX)		:(RETURN)
**
STATSRT	DIFFER(SW.DEBUG) \(
.		DIFFER(OPCODE,'DO') DIFFER(OPCODE,'IF')
.		DIFFER(OPCODE,'IFANY') DIFFER(OPCODE,'CALLS')
.		) ASS(LABEL,MOV,'#' RADIX(STATENO) ',' REENT.REG)
.					:S(RETURN)
	( DIFFER(OPCODE,'BEGIN') GENLAB(LABEL) )	:(RETURN)
**
GENTWO	( DIFFER(OP,'CMP') OFFLOC(L.ADDR) )
	OP = IDENT(LR,'YY') OP 'B'
	ASSNL(OP,R.ADDR ',' L.ADDR)	:(RETURN)
**
ASSCK	L.ADDR POS(0) BREAK(',') . T1
	OFFLOC(T1)
GENONE	OP = IDENT(R.F,'Y') OP 'B'
	OFFLOC(L.ADDR)
	ASSNL(OP,L.ADDR)		:(RETURN)
**
CALLSRT DIFFER(SW.REENT)		:F(RETURN)
	BLOCK = GETLAB()
	DS(BLOCK,2)		:(RETURN)
**
GENCALL ASSNL('.GLOBL ',LOC)
	( NE(NARG) DIFFER(SW.REENT) )	:S(RENCALL)
	ASSNL('JSR','%5,' LOC)
	EQ(NARG,0)			:S(RETURN)
	NARG = NARG * 2
	ARGLAB = GETLAB()
	ASSNL('BR',ARGLAB)
	GENLAB(CALLLAB)
	PUT('.=.+' RADIX(NARG))
	GENLAB(ARGLAB)			:(RETURN)
RENCALL L1 = GETLAB() ; L2 = GETLAB()
	BLOCK = GETROFF(CALLLAB)
	BLOCK POS(0) BREAK('(') . OFF
	DS(CALLLAB,NARG * ADDR.WORD)
	ASSNL(MOV,'#' NARG ',' BLOCK)
	ASSNL('INCB','1+' BLOCK)
	( ASSNL(MOV,'#207,2+' (2 * NARG) '+' BLOCK) )
	ASSNL('JSR','%7,' L2)
	ASSNL('BR',L1)
	( ASS(L2,MOV,'%5,-(%6)') )
	ASSNL(MOV,'%3,%5')
	ASSNL('ADD','#' OFF ',%5')
	ASSNL('JMP',LOC)
	GENLAB(L1)			:(RETURN)
**
GENLOG	IDENT(OP,'R')			:S(GENLB)
	IDENT(L.F,'1')			:S(GENL1)
	( IDENT(R.ADDR,'#0') GENONE('TST') )	:S(GENLB)
	( FLIP() GENTWO('CMP') )
GENLB	ASSNL('B' OP,LOC)		:(RETURN)
GENL1	R.A = R.ADDR ; R.ADDR = '#' TAB.MASK(R.ENTRY)
	GENTWO('BIT')
	IDENT(R.A,'#0') 		:S(GENLB)
	OP = IDENT(R.A,'#1') IDENT(OP,'EQ') 'NE' :S(GENLB)
	OP = IDENT(R.A,'#1') IDENT(OP,'NE') 'EQ' :S(GENLB)
	( ERROR('BIT TESTS SUPPORT ONLY (EQ,NE) FOR (0,1)') ) :(RETURN)
**
ASS	T1 = IDENT(T2) DIFFER(T1) T1 '=.'	:S(ASS1)
	T1 = DIFFER(T1) T1 ':'
ASS1	T4 = T4 SAVECOM
	SAVECOM =
	T2 = GE(SIZE(T2),5) T2 ' '
	T3 = DIFFER(T4) RPAD(T3,20) ';' T4
	( PUT( RPAD(T1,10) RPAD(T2,5) T3) )	:(RETURN)
**
GENLOAD	ASSNL(MOV,ADDR ',' R)		:(RETURN)
**
GETREG	GETREG = '%' (WHEN + 1)		:(RETURN)
**
TABSTM	MASK = CKTYPE(LF,'1')  RADIX( 2 ** (WSIZE - LOW - 1) )
	IDENT(BASE,'REG') DIFFER(SW.REG) PUT('REG=' BASE.REG)
	CKTYPE(LF,'Y')			:F(RETURN)
	OFF = OFF + 1 - (LOW / BSIZE)	:(RETURN)
**
GETROFF GETROFF = REENT.OFF<LAB> '(' REENT.REG ')'	:(RETURN)
********
** OPTIMIZATION
********
CKREGD	DIFFER(SW.OPT2) 		:F(RETURN)
	ADDR POS(0) '@' 		:S(RETURN)
	BASELOC = EQ(OFF,0) '@' ADDR	:F(RETURN)
	LREG =				:(FRETURN)
********
** OPERATIONS
********
O.MOVA	OP = MOV
	CKTYPET(TF,'B',R.TYPE)		:F(O.TWO)
	R.ADDR = '#' R.ADDR
	R.ADDR POS(0) '#@' =		:S(O.TWO)
	R.ADDR MOVA.PARSE		:S(REGOFF)
	DIFFER(SW.PIC)			:F(O.TWO)
	R.ADDR POS(0) '#' REM . OFF	:F(O.TWO)
	OFF = OFF '-.'
	LREG = '%7'
REGOFF	LREG = '%0'
.		DIFFER(SW.REENT SW.PIC)
.		ASSNL(MOV,LREG ',%0')
	R.ADDR = LREG
	( DIFFER(OFF) OFFREG(R.ADDR)
.		ASSNL('ADD','#' OFF ',' R.ADDR) ) :(O.TWO)
**
O.ADD	OP = IDENT(R.ADDR,'#1') 'INC'	:S(O.ONE)F(O.TWOCK)
**
O.SUB	OP = IDENT(R.ADDR,'#1') 'DEC'	:S(O.ONE)F(O.TWOCK)
**
O.TWOCK	IDENT(R.F,'Y')			:S(O.40)F(O.TWO)
**
O.BIS					:(O.TWO)
**
O.MOV	IDENT(L.F,'1')			:S(MOV1)
	OP = IDENT(R.ADDR,'#0') 'CLR'	:S(O.ONE)F(O.TWO)
MOV1	R.A = R.ADDR ; R.ADDR = '#' TAB.MASK(L.ENTRY)
	OP = IDENT(R.A,'#0') 'BIC'	:S(O.TWO)
	OP = IDENT(R.A,'#1') 'BIS'	:S(O.TWO)
	GENTWO('BIC')
	( ASSNL('BIT','#' TAB.MASK(R.ENTRY) ',' R.A) )
	LAB = GETLAB()
	ASSNL('BEQ',LAB)
	( GENTWO('BIS') GENLAB(LAB) )	:(RETURN)
**
O.MUL	DIFFER(SW.M40)			:S(O.40)
	ASSNL(MOV,'#177304,%0')
	( ASSCK(MOV,L.ADDR ',(%0)+') )
	( ASSCK(MOV,R.ADDR ',(%0)') )
	R.ADDR = '-(%0)' ; OP = MOV	:(O.TWO)
**
O.MOD
O.DIV	DIFFER(SW.M40)			:S(O.40)
	ASSNL(MOV,'#177304,%0')
	( ASSCK(MOV,L.ADDR ',(%0)') )
	ASSCK(MOV,R.ADDR ',@#177300')
	R.ADDR = '(%0)'
	R.ADDR = IDENT(OP,'MOD') '-' R.ADDR
	OP = MOV			:(O.TWO)
**
O.ASR	IDENT(R.ADDR,'#1')		:S(O.ONE)
	R.ADDR '#' = '#-'		:S(O.ASH)
O.ASL	IDENT(R.ADDR,'#1')		:S(O.ONE)
O.ASH	OP = 'ASH'
	( IDENT(SW.M40) ERROR('SHIFTING OTHER THAN 1 NOT SUPPORTED')
.		)			:S(RETURN)F(O.40)
**
O.BIC	ASSCK(MOV,R.ADDR ',%0')
	ASSNL('COM','%0')
	R.ADDR = '%0'			:(O.TWO)
**
O.COM	IDENT(L.F,'1')			:F(O.ONE)
	OP = 'XOR'
	R.ADDR = '#' TAB.MASK(L.ENTRY)
	L.F = 'W' ; R.F = 'W'
O.XOR	DIFFER(SW.M40)			:S(O.X40)
	ASSCK(MOV,R.ADDR ',%0')
	ASSCK('BIC',L.ADDR ',%0')
	ASSCK('BIC',R.ADDR ',' L.ADDR)
	R.ADDR = '%0' ; OP = 'BIS'	:(O.TWO)
O.X40	ASSCK(MOV,R.ADDR ',%0')
	ASSCK(OP,'%0,' L.ADDR)		:(RETURN)
**
O.40	ASSCK(MOV,L.ADDR ',%0')
	R.ADDR = IDENT(R.F,'Y')  ASSNL('MOVB',R.ADDR ',%1')  '%1'
	( IDENT(OP,'MOD') ASSNL('DIV', R.ADDR ',%0')
.		ASSCK(MOV,'%1,' L.ADDR) )	:S(RETURN)
	ASSNL(OP,R.ADDR ',%0')
	ASSCK(MOV,'%0,' L.ADDR)		:(RETURN)
**
O.GOTO	ASSNL('JMP',LEFT)		:(RETURN)
**
O.ONE	GENONE(OP)			:(RETURN)
**
O.TWO	GENTWO(OP)				:(RETURN)
**
END