Trailing-Edge
-
PDP-10 Archives
-
BB-H506D-SM_1983
-
cobol/source/float.mac
There are 8 other files named float.mac in the archive. Click here to see a list.
; UPD ID= 1828 on 4/13/79 at 1:03 PM by N:<NIXON>
TITLE FLOAT FOR LIBOL
SUBTTL CONVERT COMP TO FLOATING POINT AL BLACKINGTON/CAM/DMN
;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, 1981 BY DIGITAL EQUIPMENT CORPORATION
SEARCH LBLPRM
HISEG
ENTRY FLOT.1 ;1-WORD COMP TO COMP-1
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
HIPART==377776
TA=13
TB=TA+1
TC=TB+1
PA=16 ;INPUT PARAMETER
PP=17 ;PUSH-DOWN POINTER
SUBTTL FLOT.1 - ONE-WORD COMP TO COMP-1
;CALLING SEQUENCE:
; MOVE 16,<Z AC,OPERAND>
; PUSHJ 17,FLOT.1
;EXIT WITH RESULT IN ACCUMULATOR SPECIFIED BY AC-FIELD OF ACCUMULATOR 16.
FLOT.1: SKIPN TA,0(PA) ;IS INPUT ZERO?
JRST FLOT1A ;YES
IFN BIS,<
FLTR TA,TA
>
IFE BIS,<
IDIVI TA,1B18 ;NO--BREAK IT INTO TWO PIECES
CAIE TA,0 ;HIGH PART ZERO?
TLC TA,254000 ;NO--JAM EXPONENT
TLC TB,233000 ;JAM EXPONENT OF LOW PART
FADR TA,TB ;ADD TWO HALVES
>
FLOT1A: LDB TB,[POINT 4,PA,12]; GET AC-FIELD
MOVEM TA,0(TB) ;STORE RESULT
POPJ PP,
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
IFE BIS,<
MOVE TB,1(PA) ;GET LOW-ORDER PART
SKIPL TA,0(PA) ;GET HIGH-ORDER PART--NEGATIVE?
JRST FLOT2B ;NO
TLO TB,1B18 ;YES--BE SURE LOW-PART IS NEGATIVE
SETCA TA, ;NEGATE THE TWO-WORD VALUE
MOVMS TB
TLZ TB,1B18
JUMPN TB,FLOT2C
AOJA TA,FLOT2C
>
IFN BIS,<
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
JRST FLOT1A ;STORE RESULT
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?
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,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
END