Google
 

Trailing-Edge - PDP-10 Archives - BB-Z759A-SM - cobol-source/float.mac
There are 8 other files named float.mac in the archive. Click here to see a list.
; UPD ID= 1010 on 4/26/83 at 5:22 PM by NIXON                           
TITLE	FLOAT FOR LIBOL
SUBTTL	CONVERT COMP TO FLOATING POINT	AL BLACKINGTON/CAM/DMN

	SEARCH COPYRT
	SALL

;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.

COPYRIGHT (C) 1974, 1983, 1984 BY DIGITAL EQUIPMENT CORPORATION


	SEARCH	LBLPRM
	HISEG
	.COPYRIGHT		;Put standard copyright statement in REL file

ENTRY	FLOT.2		;2-WORD COMP TO COMP-2
ENTRY	FLT.12		;1-WORD COMP TO COMP-2
ENTRY	FLT.22		;2-WORD COMP TO COMP-2
ENTRY	FLT.42		;4-WORD COMP TO COMP-2

HIPART==377776
TA=13
TB=TA+1
TC=TB+1
PA=16	;INPUT PARAMETER
PP=17	;PUSH-DOWN POINTER
SUBTTL	CONVERT TWO-WORD COMP TO COMP-1



;CALLING SEQUENCE:
;	MOVE PA,<Z AC,ADDRESS OF HIGH-ORDER HALF OF DOUBLE-PRECISION NUMBER>
;	PUSHJ PP,FLOT.2
;EXIT WITH FLOATING POINT NUMBER IN ACCUMULATOR SPECIFIED BY
;		AC-FIELD OF AC16.
.

FLOT.2:	MOVSI	TC,(1.0)	;SET SCALING FACTOR
	DMOVE	TA,0(PA)	;GET BOTH WORDS
	JUMPGE	TA,FLOT2B	;POSITIVE?
	DMOVN	TA,TA		;NEGATE IT

FLOT2B:	TLZ	TB,1B18		;BE SURE LOW-HALF IS POSITIVE

FLOT2C:	TLNE	TA,HIPART	;IS VALUE > 2**54?
	JRST	FLOT2E		;YES

	ASHC	TA,10		;NO--SHIFT OVER 8 BITS
	ASH	TB,-10		;RESTORE LOW PART

	SKIPE	TA		;SET EXPONENT IN HIGH-PART UNLESS
	TLC	TA,266000	;	IT IS ZERO
	SKIPE	TB		;SET EXPONENT IN LOW PART UNLESS
	TLC	TB,233000	;IT IS NEGATIVE

	FADR	TA,TB		;ADD TWO-HALVES
	FMP	TA,TC		;MULTIPLY BY SCALING FACTOR

	SKIPGE	0(PA)		;WAS INPUT NEGATIVE?
	MOVNS	TA		;YES--NEGATE RESULT
	LDB	TB,[POINT 4,PA,12]; GET AC-FIELD
	MOVEM	TA,0(TB)	;STORE RESULT
	POPJ	PP,

FLOT2E:	ADD	TC,[1B8]	;NUMBER > 2**54--INCREASE SCALING FACTOR
	ASHC	TA,-1		;REDUCE TA
	JRST	FLOT2C		;TRY AGAIN
SUBTTL	FLT.12 - ONE-WORD COMP TO COMP-2

;CALLING SEQUENCE:
;	MOVE 16,<Z AC,OPERAND>
;	PUSHJ 17,FLT.12

;EXIT WITH RESULT IN ACCUMULATOR SPECIFIED BY AC-FIELD OF ACCUMULATOR 16.

FLT.12:	SETZ	TB,		;CLEAR SECOND WORD
	SKIPN	TA,0(PA)	;GET INPUT
	JRST	FLOT2R		;ZERO, RETURN
	ASHC	TA,-10		;MAKE ROOM FOR EXPONENT
	TLC	TA,243000	;SET EXP TO 27+8 DECIMAL
	DFAD	TA,[EXP 0,0]	;NORMALIZE
FLOT2R:	LDB	TC,[POINT 4,PA,12]	;GET AC FIELD
	DMOVEM	TA,0(TC)	;STORE RESULT
	POPJ	PP,
SUBTTL	FLT.22 - TWO-WORD COMP TO COMP-2

;CALLING SEQUENCE:
;	MOVE 16,<Z AC,OPERAND>
;	PUSHJ 17,FLT.22

;EXIT WITH RESULT IN ACCUMULATOR SPECIFIED BY AC-FIELD OF ACCUMULATOR 16.

FLT.22:	DMOVE	TA,0(PA)	;GET INPUT
	SKIPGE	TA		;INPUT NEGATIVE?
FLT22N:	DMOVN	TA,TA		;YES, MAKE IT POSITIVE
FLT22P:	PUSH	PP,TC+1		;NEED 4 AC'S
	MOVE	TC,TB		;MOVE LOW WORD
	SETZB	TB,TC+1		;ZERO SECOND WORD OF EACH PAIR
	JUMPE	TA,FLT22A	;LEAVE ALONE IF ZERO
	ASHC	TA,-10		;MAKE ROOM FOR EXPONENT
	TLC	TA,306000	;SET EXPONENT TO 2*<27+8>
	DFAD	TA,[EXP 0,0]	;NORMALIZE
FLT22A:	JUMPE	TC,FLT22B	;LEAVE ALONE IF ZERO
	ASHC	TC,-10		;MAKE ROOM FOR EXPONENT
	TLC	TC,243000	;SET EXPONENT TO 27+8
	DFAD	TC,[EXP 0,0]	;NORMALIZE
	DFAD	TA,TC		;ADD AND NORMALIZE
FLT22B:	POP	PP,TC+1		;RESTORE AC
	SKIPGE	0(PA)		;WAS INPUT NEGATIVE?
	DMOVN	TA,TA		;YES, NEGATE OUTPUT
	JRST	FLOT2R		;RETURN
SUBTTL	FLT.42 - FOUR-WORD COMP TO COMP-2

;CALLING SEQUENCE:
;	MOVE 16,<Z AC,OPERAND>
;	PUSHJ 17,FLT.42

;EXIT WITH RESULT IN ACCUMULATOR SPECIFIED BY AC-FIELD OF ACCUMULATOR 16.

FLT.42:	DMOVE	TA,0(PA)	;GET HIGH PAIR OF INPUT
	SKIPN	TA		;SEE IF BOTH ZERO
	JUMPE	TB,[DMOVE TA,2(PA)	;GET LOWER PAIR
		JRST	FLT22P]		;TREAT AS JUST 2 WORDS
	CAIN	TA,[-1]		;SEE IF BOTH -1
	CAIE	TB,[-1]
	JRST	FLT42A		;NO
	DMOVN	TA,2(PA)	;YES, GET LOWER PAIR
	JRST	FLT22N		;TREAT AS JUST 2 WORDS

FLT42A:	DMOVE	TA,2(PA)	;GET LOWER PAIR OF INPUT
	SKIPGE	0(PA)		;INPUT NEGATIVE?
	DMOVN	TA,TA		;YES, MAKE IT POSITIVE
	PUSH	PP,TC+1		;NEED 4 AC'S
	MOVE	TC,TB		;MOVE LOW WORD
	SETZB	TB,TC+1		;ZERO SECOND WORD OF EACH PAIR
	JUMPE	TA,FLT42B	;LEAVE ALONE IF ZERO
	ASHC	TA,-10		;MAKE ROOM FOR EXPONENT
	TLC	TA,306000	;SET EXPONENT TO 2*<27+8>
	DFAD	TA,[EXP 0,0]	;NORMALIZE
FLT42B:	JUMPE	TC,FLT42C	;LEAVE ALONE IF ZERO
	ASHC	TC,-10		;MAKE ROOM FOR EXPONENT
	TLC	TC,243000	;SET EXPONENT TO 27+8
	DFAD	TC,[EXP 0,0]	;NORMALIZE
	DFAD	TA,TC		;ADD AND NORMALIZE
FLT42C:	MOVE	TC+1,(PP)	;RESTORE AC
	PUSH	PP,TA		;STORE RESULT FOR NOW
	PUSH	PP,TB

	DMOVE	TA,0(PA)	;GET HIGH PAIR INPUT
	SKIPGE	TA		;INPUT NEGATIVE?
	DMOVN	TA,TA		;YES, MAKE IT POSITIVE
	MOVE	TC,TB		;MOVE LOW WORD
	SETZB	TB,TC+1		;ZERO SECOND WORD OF EACH PAIR
	JUMPE	TA,FLT42D	;LEAVE ALONE IF ZERO
	ASH	TA,5		;MAKE ROOM FOR EXPONENT (NEVER GETS TOO BIG)
	TLC	TA,377000	;SET EXPONENT TO 4*<27+8>-13
	DFAD	TA,[EXP 0,0]	;NORMALIZE
FLT42D:	JUMPE	TC,FLT42E	;LEAVE ALONE IF ZERO
	ASHC	TC,-10		;MAKE ROOM FOR EXPONENT
	TLC	TC,351000	;SET EXPONENT TO 3*<27+8>
	DFAD	TC,[EXP 0,0]	;NORMALIZE
	DFAD	TA,TC		;ADD AND NORMALIZE
FLT42E:	POP	PP,TC+1		;RESTORE LOW ORDER PAIR
	POP	PP,TC
	DFAD	TA,TC		;FORM COMPLETE NUMBER
	POP	PP,TC+1		;FINALLY RESTORE PA
	SKIPGE	0(PA)		;WAS INPUT NEGATIVE?
	DMOVN	TA,TA		;YES, NEGATE OUTPUT
	JRST	FLOT2R		;RETURN

END