Google
 

Trailing-Edge - PDP-10 Archives - BB-H506E-SM - cobol/source/fix.mac
There are 7 other files named fix.mac in the archive. Click here to see a list.
; UPD ID= 3156 on 9/29/80 at 11:36 AM by NIXON                          
TITLE	FIX FOR LIBOL V12C
SUBTTL	CONVERT FLOATING-POINT TO 2-WORD COMPUTATIONAL	AL BLACKINGTON/CAM/DMN



	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.

	SEARCH	LBLPRM

	HISEG

	.COPYRIGHT		;Put COPYRIGHT statement in .REL file.

;	EDIT HISTORY
;NAME	DATE		COMMENTS
;V12A**************
;JEH	30-Jun-83	[1072] Don't turn on sign bit if value is zero
;JSM	5-Oct-81	[1004] FOR BIS TURN ON CORRECT SECOND WORD SIGN BIT
;V12**************
;DMN	29-SEP-80	[647] DON'T TURN ON LOW-WORD SIGN BIT IF RESULT IS ZERO.
;EHM	27-APR-78	[527] TEST FOR OVERFLOW AND UNDERFLOW

EXTERNAL OVFLO.

ENTRY FIX.,FIX.2

;CALLING SEQUENCE:
;	MOVE	AC,<FLOATING-POINT NUMBER>
;	MOVE	PA,[Z AC,<RESULT>]
;	PUSHJ	PP,FIX./FIX.2

FIX.:	LDB	IN,[POINT 4,PA,12]
	MOVE	IN,0(IN)

	TDNN	IN,[XWD 777,-1]	;IS IT ZERO?
	JRST	CC3C2D		;YES

	MOVM	TA,IN		;NO--GET
	CAMLE	TA,[DEC 9.9999999E+18]	;[527] IS IT TOO LARGE?
	JRST	FIXTL			;[527] YES
	CAMGE	TA,[DEC 1.0E-18]	;[527] IS IT TOO SMALL?
	JRST	FIXTS			;[527] YES
	MULI	TA,400		; GET	EXPONENT

	MOVEI	TC,0
	ASHC	TB,-306(TA)	;SHIFT TO GET INTEGER

CC3C2B:	JUMPGE	IN,CC3C2C	;WAS INPUT POSITIVE?

IFE BIS,<
	SETCA	TB,		;NO--NEGATE THE 2-WORD RESULT
	MOVNS	TC
	SKIPN	TC
	ADDI	TB,1
	SKIPGE	TB
	TLO	TC,1B18
CC3C2C:	MOVEM	TB,0(PA)	;STASH RESULT
	MOVEM	TC,1(PA)
	POPJ	PP,
>
IFN BIS,<
	DMOVN	TB,TB		;MAKE RESULT NEGATIVE
	SKIPN	TB		;[1072] UNLESS RESULT IS ZERO
	SKIPE	TC		;[1072]
	TLO	TC,(1B0)	;FIX 2ND WORD SIGN BIT ;[M1004]

CC3C2C:	DMOVEM	TB,0(PA)	;STASH RESULT
	POPJ	PP,
>

FIXTS:	SETOM	OVFLO.		;[527] TURN ON OVERFLOW
CC3C2D:	SETZM	0(PA)		;INPUT IS ZERO--ZERO THE RESULT
	SETZM	1(PA)
	POPJ	PP,

FIXTL2:	MOVE	IN,(IN)		;GET SIGN IN D.P. CASE 
FIXTL:	SETOM	OVFLO.		;[527] TURN ON OVERFLOW
	HRLOI	TB,377777	;[527] GIVE USER A LARGE NUMBER
	HRLOI	TC,377777	;[527] IN CASE NO ON SIZE ERROR
	JRST	CC3C2B		;[527] STASH RESULT & EXIT
;D.P. FLOATING POINT TO 2-WORD COMP

FIX.2:	LDB	IN,[POINT 4,PA,12]
	DMOVE	TA,(IN)		;GET SOURCE
	TDNN	TA,[777,,-1]	;IS IT ZERO?
	JUMPE	TB,CC3C2D	;YES
	SKIPGE	TA		;GET MAGNITUDE ONLY
	DMOVN	TA,TA		;FOR SIZE TESTS
	CAMN	TA,[307400,,0]	;1.1805916E+21
	CAIGE	TB,0		;WHICH IS MAX. POSSIBLE 2 WORD INTEGER
	CAML	TA,[307400,,0]
	JRST	FIXTL2		;TOO BIG
	CAMN	TA,[105477,,113564]	;1.0E-18
	CAML	TB,[164441,,653502]
	CAMG	TA,[105477,,113564]
	JRST	FIXTS		;TOO SMALL
	DMOVE	TA,(IN)		;GET SOURCE AGAIN
	HLRE	TC,TA		;ISOLATE EXPONENT
	ASH	TC,-9		;...
	JUMPGE	TA,.+3		;IF NEGATIVE
	DMOVN	TA,TA		;MAKE POSITIVE
	TRC	TC,-1		;BUT REMEMBER NEGATIVE SIGN
	TLZ	TA,777000	;CLEAR EXPONENT FIELD
	ASHC	TA,-276(TC)	;SHIFT INTEGER INTO POSITION
	JUMPGE	TC,FIX.2R	;IF ORIGINAL NUMBER WAS POSITIVE STORE RESULT
	SKIPN	TA		;[647] TEST FOR EXACTLY ZERO
	JUMPE	TB,FIX.2R	;[647] IN WHICH CASE DON'T TURN ON SIGN BIT
	DMOVN	TA,TA		;OTHERWISE MAKE RESULT NEGATIVE
	TLO	TB,(1B0)	;FIX 2ND WORD SIGN BIT
FIX.2R:	DMOVEM	TA,0(PA)	;AND STORE
	POPJ	PP,


IN=11	;INPUT ACCUMULATOR
TA=13	;SCRATCH
TB=TA+1	;SCRATCH
TC=TA+2	;SCRATCH
PA=16	;ADDRESS OF RESULT
PP=17	;PUSH-DOWN POINTER

	END