Google
 

Trailing-Edge - PDP-10 Archives - BB-BL69C-SB_1986 - shift.mic
There are 5 other files named shift.mic in the archive. Click here to see a list.
.TOC	"ROTATES AND LOGICAL SHIFTS -- ROT, LSH, JFFO"

	.DCODE
240:	I,	B/0,	J/ASH
	I,	B/0,	J/ROT
	I,	B/2,	J/LSH
	I,		J/JFFO
	I,	B/1,	J/ASHC
	I,		J/ROTC
	I,		J/LSHC
	EA,		J/UUO
	.UCODE

;ENTER WITH 0,E IN AR
; NOTE THAT VALUES OF SC GREATER THAN 36
; CAUSE THE SHIFTER TO SELECT ARX.

=0****00***0
LSH:	AR_AC0,ARL/AD,ARX_0.M,SC_EA,
		SKP AR18,J/SHR1

JFFO:	AR_AC0,SKP AD NE,SC_#,#/6
=
=0	AC1_AR,I FETCH,J/NOP		;AC WAS ZERO, NO JUMP
	ARX+MQ_0.M,FE_P,SKP SCAD NE,	;TEST FIRST 6 BITS
		AR_SHIFT,ARL/SH		;DISCARD THEM
=0
JFFO1:	AR_SHIFT,FE_P,SKP SCAD NE,	;TEST NEXT 6 BITS
		ARX_ARX-1,J/JFFO1	;LOOP, COUNTING, TILL NE
	P_FE,ARR_0.S,			;RESTORE 6 NON-ZERO BITS
		ARX_ARX*-6		;GET POS GROUP COUNT*6
=0
JFFO2:	SKP AR0,AR_2(AR+1),		;LOOP TO FIND A 1
		ARX_ARX+1,J/JFFO2	;COUNTING AS WE GO
	AR_ARX-1,FETCH,J/STRAC1

=0****00***0
ASH:	SC_EA,SKP AR18,			;GET SHIFT AMOUNT
		AR_0S,J/ASHL		;SET LOW PART = 0
ROT:	AR_AC0,ARX_AC0,SC_EA,SKP AR18
=
;SINGLE-WORD LSH/ROT
; FOR ROT, B=0, AR AND ARX BOTH CONTAIN AC
; FOR LSH, B=2, AR HAS AC, ARX IS ZERO

=00
SHR1:	AR_SHIFT,SC_#+SC,#/-36.,	;DO POS (LEFT) SHIFT, CHK RANGE
		SKP SCAD0,J/SHR2
	ARX_AR (AD),AR_ARX (ADX),
		SC_#+SC,#/36.,
		B DISP,SKP SCAD0,J/SHR1	;MAKE NEG SHIFT TO EQUIV POS
SHR2:	AR_SHIFT,SC_#+SC,#/-36.,
		SKP SCAD0,J/SHR2	;BRING SC INTO RANGE
	AC0_AR,I FETCH,J/NOP		;DONE
.TOC	"ROTATE AND LOGICAL SHIFT COMBINED -- ROTC, LSHC"

=0****00***0
ASHC:	SC_EA,SKP AR18,			;SETUP SHIFT COUNT
		AR_AC1*2,J/ASHL		;GET LOW WORD
ROTC:	ARX_AC1
=	AR_AC0,SC_EA,SKP AR18		;SETUP BOTH AC'S
=0
ROT3:	MQ_SHIFT,ARX_AR (AD),
		AR_ARX (ADX),J/ROT4
	ARX_AR (AD),AR_ARX (ADX),
		SC_#+SC,#/36.,SKP SCAD0,J/ROT3

ROT4:	AR_MQ,ARX_SHIFT,
		SC_#+SC,#/-36.,SKP SCAD0
=0	MQ_SHIFT,ARX_AR (AD),
		AR_ARX (ADX),J/ROT4
STDAC:	AC0_AR,AR_ARX,I FETCH,J/STRAC1


1004:					;NEXT TO UUO
LSHC:	ARX_AC1,MQ_0.M
LSH1:	AR_AC0,SC_EA,FE_#,#/36.,SKP AR18
=0
LSH2:	MQ_SHIFT,AR_ARX (ADX),
		ARX/MQ,FE_#,#/-36.,J/LSH3
	ARX_AR (AD),AR_0.M,MQ_ARX,
		SC_FE+SC,SKP SCAD0,J/LSH2

LSH3:	AR_MQ,ARL/AD,ARX_SHIFT,MQ_0.M,
		SC_FE+SC,SKP SCAD0
=0	MQ_SHIFT,AR_ARX (ADX),ARX/MQ,J/LSH3
	AC0_AR,AR_ARX,I FETCH,J/STRAC1
.TOC	"ARITHMETIC SHIFTS -- ASH, ASHC"

;COMMON CODE FOR ARITHMETIC SHIFTS

=0
ASHL:	ARX_AR,AR_AC0,			;INPUT NOW IN AR LONG
		SKP SC NE,J/ASHL1	;CHECK FOR NULL SHIFT
	ARX_AR,AR_AC0,			;HERE IF RIGHT SHIFT
		SC_#+SC,#/36.,SKP SCAD0	;CHECK FOR LONG ONE
=0
ASHR1:	BR/AR,ARX_SHIFT,AR_SIGN,J/ASHR2	;LOW OUTPUT TO ARX
	ARX_AR,AR_SIGN,			;HERE IF SHIFT COUNT .GT. 36
		SC_#+SC,#/36.,		;BRING COUNT UP BY 36
		SKP SCAD0,J/ASHR1	;LOOP TILL COUNT REASONABLE

ASHR2:	BRX/ARX,ARX_BR,			;HIGH INPUT TO ARX
		B DISP,J/ASHX

;HERE FOR LEFT ARITHMETIC SHIFT

=0
ASHL1:	I FETCH,J/NOP			;SHIFT 0 IS A NOP
	BR_AR LONG,AR_SIGN		;SAVE INPUT, GEN SIGN WORD
	BR/AR,AR_BR*2 LONG		;SAVE SIGN, GET MAGNITUDE BITS
=0*
ASHL2:	BRX/ARX,ARX_AR,AR_BR,		;HI IN TO ARX, LOW TO BRX
		CALL,J/SHIFT		;CALL SHIFTER TO GET BITS LOST
	SKP AR NE BR			;ANY BITS DIFFERENT FROM SIGN?
=0
ASHL3:	AR_ARX,ARX_BRX,			;RESTORE HI TO AR, LOW TO ARX
		GEN #+SC,#/-36.,SKP SCAD0,J/ASHL4
	SET AROV,J/ASHL3		;BITS SHIFTED OUT NE SIGN
=0
ASHL4:	AR_ARX,ARX_0S,			;HERE IF E .GT. 36
		SC_#+SC,#/-36.,J/ASHL2	;SHIFT 36 PLACES, TRY AGAIN
	MQ_SHIFT,AR_BRX,CLR ARX,	;HIGH OUTPUT TO MQ,
		SC_#+SC,#/-1,B DISP	;COMPENSATE FOR EXTRA SHIFT
=0
ASHL5:	AR_BR,BRX/ARX,ARX/MQ,		;SIGN TO AR, HIGH OUT TO ARX
		SC_#,#/35.,		;READY TO COMBINE THEM
		B DISP,J/ASHX		;STORE AS APPROPRIATE
	ARX_SHIFT,J/ASHL5		;LOW OUTPUT TO ARX

;HERE TO GET FINAL RESULTS.

=0
ASHX:	AR_SHIFT,I FETCH,J/STORAC	;HERE AFTER ASH
	AR_SHIFT,ARX_BRX,		;HERE AFTER ASHC
		SC_#,#/35.,J/ST2AC