Trailing-Edge
-
PDP-10 Archives
-
BB-Z759A-SM
-
cobol-source/fix.mac
There are 7 other files named fix.mac in the archive. Click here to see a list.
; UPD ID= 1317 on 7/11/83 at 4:33 PM by HOFFMAN
TITLE FIX FOR LIBOL
SUBTTL CONVERT FLOATING-POINT TO 2-WORD COMPUTATIONAL 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
; EDIT HISTORY
;NAME DATE COMMENTS
;V12B*************
;JEH 27-Jun-83 [1072] Don't turn on sign bit if result if zero
;JSM 5-Oct-81 [1004] [676] For BIS turn on the 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?
DMOVN TB,TB ;MAKE RESULT NEGATIVE
SKIPN TB ;[1072] UNLESS ITS ZERO
SKIPE TC ;[1072]
TLO TC,(1B0) ;[1004] [676] FIX 2ND WORD SIGN BIT
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