Google
 

Trailing-Edge - PDP-10 Archives - klad_sources - klad.sources/ifix.mac
There are no other files named ifix.mac in the archive.
SUBTTL	IFIX	36 BIT FIX FUNCTION

;*FOR KI10 SIMULATION/DIAGNOSTICS  13-OCT-71, J.R.KIRCHOFF
;*	15-MAY-70 /JRK
;*	FROM VERSION, 18 FEBRUARY 1966	ED YOURDON
;*36 BIT FIX FUNCTION
;*AN INTERGER RESULT IS OBTAINED BY SEPARATING FRACTION AND
;*EXPONENT.  THE FRACTION IS SHIFTED N PLACES RIGHT, WHERE
;*N= 43 - (EXPONENT-200) (OCTAL)

;*THE CALLING SEQUENCE FOR THE ROUTINE IS AS FOLLOWS:
;*	MOVEI	Q,ARG
;*	PUSHJ	17,FIX.0
;*THE ANSWER IS RETURNED IN ACCUMULATOR A

	A==	0
	B==	1
	Q==	16

FIXR.0:	SETOM	IFIXC		;SET TO ROUND
	JRST .+2

FIX.0:	SETZM	IFIXC
	MOVEM	A,IFIXA		;SAVE AC A
	MOVEM	B,IFIXB		;SAVE AC B
	MOVM	A,(Q)		;PICK UP ARG
	MULI	A,400		;SEPARATE FRACTION AND EXPONENT
	EXCH	A,B		;PUT PARTIAL RESULTS IN A
	CAILE	B,243
	JRST	FIX1C		;OVERFLOW ERROR
	ASHC	A,-243(B)	;USE EXPONENT AS INDEX REGISTER
	SKIPN	IFIXC		;ROUND RESULT ?
	JRST	.+3		;NO
	TLNE	B,200000	;NEED ROUNDING ?
	ADDI	A,1		;YES
	SKIPGE	(Q)		;SET THE CORRECT SIGN
	MOVNS	A,A
	MOVE	B,IFIXB		;RESTORE AC B
	JRST	2,@[.+1]	;CLEAR FLAGS
	POPJ	17,		;EXIT

FIX1C:	MOVE	B,IFIXB
	MOVE	A,IFIXA
	JRST	2,@[XWD 400200,.+1]	;OVERFLOW
	POPJ	17,

IFIXA:!	0
IFIXB:!	0
IFIXC:!	0