Google
 

Trailing-Edge - PDP-10 Archives - BB-H580E-SB_1985 - dspfp.mac
There are 7 other files named dspfp.mac in the archive. Click here to see a list.
TITLE	DSPFP FOR LIBOL V12C
SUBTTL	DISPLAY A FLOATING-POINT NUMBER		AL BLACKINGTON/CAM

	SEARCH	COPYRT
	SALL

;COPYRIGHT (C) DIGITAL EQUIPMENT CORPORATION 1974, 1985
;ALL RIGHTS RESERVED.
;
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
;ONLY  IN  ACCORDANCE  WITH  THE  TERMS  OF  SUCH LICENSE.

	HISEG

	.COPYRIGHT		;Put standard copyright statement in REL file

ENTRY DSP.FP

;ENTER WITH FLOATING-POINT NUMBER IN "NM".

DSP.FP:	MOVEI	TX,7		;SET TEN'S EXPONENT TO 7

	TDNN	NM,[XWD 777,-1]	;IS IT ZERO?
	JRST	DSP.Z		;YES--SPECIAL PROCESSING

	JUMPGE	NM,DSP.1
	MOVMS	NM
	OUTSTR	[ASCIZ "-"]
DSP.1:	FAD	NM,[0]		;NORMALIZE

DSP.A:	CAMG	NM,FPP20	;IS NUMBER > 10**20?
	JRST	DSP.B		;NO
	FDVR	NM,FPP20	;YES--BRING IT DOWN
	ADDI	TX,^D20		;ADD TO EXPONENT
	JRST	DSP.A		;LOOP UNTIL IN RANGE

DSP.B:	CAML	NM,FPM12	;IS NUMBER < 10**-12?
	JRST	DSP.C		;NO
	FMPR	NM,FPP12	;YES--BRING IT UP
	SUBI	TX,^D12		;DECREMENT TEN'S EXPONENT
	JRST	DSP.B		;LOOP UNTIL WITHIN RANGE

DSP.C:	MOVE	TA,NM		;SPLIT THE NUMBER INTO EXPONENT AND MANTISSA
	MULI	TA,400

	CAMLE	NM,FPP10	;IS NUMBER GREATER THAN 10**10?
	JRST	DSP.H		;YES
	CAILE	TA,200		;NO--IS IT LESS THAN 1?
	JRST	DSP.L		;NO
;NUMBER IS LESS THAN 1, BUT GREATER THAN 10**-12

	MOVE	AC0,TA+1	;GET DECIMAL POINT TO LEFT OF AC0
	MOVEI	AC1,0

	SUBI	TA,200
	ASHC	AC0,(TA)

DSP.E:	CAML	AC0,DP9		;AT LEAST 8 PLACES IN AC0?
	JRST	DSP.F		;YES
	MOVEI	PA,DP1		;NO--MULTIPLY BY 10
	PUSHJ	PP,MUL.21
	SOJA	TX,DSP.E	;DECREMENT TEN'S EXPONENT AND LOOP

DSP.F:	ADDI	AC0,5		;ROUND
	MOVE	AC1,AC0		;NOW PUT DECIMAL POINT BETWEEN AC0&AC1
	MOVEI	AC0,0
	JRST	DSP.N

;THE NUMBER IS GREATER THAN 10**10, BUT LESS THAN 10**20

DSP.H:	MOVE	AC0,TA+1
	MOVEI	AC1,0
	ASHC	AC0,-306(TA)	;DECIMAL POINT IS NOW TO RIGHT OF AC1
	JUMPE	AC0,DSP.J	;IS IT < 2**35?

DSP.I:	MOVEI	PA,DP3		;NO--DIVIDE BY 1000
	PUSHJ	PP,DIV.21
	ADDI	TX,3		;KICK UP TEN'S EXPONENT
	JUMPN	AC0,DSP.I	;LOOP

DSP.J:	MOVE	AC0,AC1
	MOVEI	AC1,0
	JRST	DSP.N

;THE NUMBER IS GREATER THAN 1 BUT LESS THAN 10**10

DSP.L:	MOVE	AC0,TA+1
	MOVEI	AC1,0
	ASHC	AC0,-243(TA)
;THE NUMBER NOW IS FIXED, AND HAS DECIMAL POINT BETWEEN AC0&AC1

DSP.N:	CAMGE	AC0,DP8		;IS IT GREATER THAN 10**8?
	JRST	DSP.O		;NO
	IDIVI	AC0,^D10	;REDUCE IT
	CAIGE	AC1,5		;IS REMAINDER < 5?
	TDCA	AC1,AC1		;YES
	MOVSI	AC1,200000	;NO
	AOJA	TX,DSP.N	;BUMP TEN'S EXPONENT AND LOOP

DSP.O:	CAML	AC0,DP7		;IS NUMBER LESS THAN 10**7?
	JRST	DSP.P		;NO
	MOVEI	PA,DP1		;YES--INCREASE IT
	PUSHJ	PP,MUL.21
	SOJA	TX,DSP.O

DSP.P:	TLZE	AC1,200000	;ANY NEED TO ROUND?
	AOJA	AC0,DSP.N	;YES--BUMP IT AND LOOP

	IDIV	AC0,DP7
	ADDI	AC0,"0"
	ROT	AC0,-7
	TLO	AC0,1340
	OUTSTR	AC0

	MOVEI	TA,DP6

DSP.Q:	MOVE	AC0,AC1
	IDIV	AC0,(TA)
	ADDI	AC0,"0"
	OUTCHR	AC0
	SKIPE	AC1
	AOJA	TA,DSP.Q

	OUTSTR	[ASCIZ "E"]
	JUMPGE	TX,DSP.R
	OUTSTR	[ASCIZ "-"]
	MOVMS	TX

DSP.R:	IDIVI	TX,^D10
	HRLM	TX+1,0(PP)
	SKIPE	TX
	PUSHJ	PP,DSP.R

	HLRZ	TA,(PP)
	ADDI	TA,"0"
	OUTCHR	TA

	POPJ	PP,
;THE NUMBER WAS ZERO

DSP.Z:	OUTSTR	[ASCIZ "0.0E0"]
	POPJ	PP,


AC0=0
AC1=AC0+1
TA=2

NM=5
TX=12	;(2 AC'S)
PA=16
PP=17

FPP20:	1.0E20
FPP12:	1.0E12
FPM12:	1.0E-12
FPP10:	1.0E10

DP9:	DEC	1000000000
DP8:	DEC	100000000
DP7:	DEC	10000000
DP6:	DEC	1000000
	DEC	100000
	DEC	10000
DP3:	DEC	1000
	DEC	100
DP1:	DEC	10
	DEC	1

EXTERNAL MUL.21,DIV.21

	END