.TITLE MTH_QUAD_FLOAT Quadword integer to floating conversions .IDENT /V01.02/ ;++MTHQFLOAT.MAR ; ; FACILITY: ; Quadword Mathematics subroutines. ; ; ABSTRACT: ; This module contains the routines to convert from quadword integers ; to single or double precision floating point values. ; ; ENVIRONMENT: ; Called from high-level language (FORTRAN or PASCAL) programs. ; User mode. ; ;-- ; ; MODIFICATION HISTORY: ; ; Gotten from Spring 1982 DECUS VAX/VMS SIG tape from the submission ; from the Institute for Cancer Research. ; ; V01.00 03-Oct-82 FJN Editted to fit into the MTHQ... package ; V01.01 25-Feb-83 FJN Correct name to MTH_QUAD_DOUBLE ; V01.02 15-Apr-83 FJN Standardize help comments ; ; ; EQUATED SYMBOLS: ; LOW = 0 ;Offset to low-order longword HIGH = 4 ;Offset to high-ordr longword ; ; Argument offsets ; qint = 4 ;Offset to address of quadword integer ; ; Program section for code ; .PSECT _MTH_CODE,PIC,USR,CON,REL,LCL,SHR,EXE,NOWRT,RD .SHOW BINARY .PAGE .SBTTL MTH_QUAD_FLOAT Convert quadword integer to floating ;+ MTH_QUAD_FLOAT ; Convert quadword integer to floating point. ; ; result.wl.v = MTH_QUAD_FLOAT( quad.rq.r ) ; result.wq.v = MTH_QUAD_DOUBLE( quad.rq.r ) ; ; quad quadword to be converted to floating point. Passed by ; reference. ; ; result returned floating point result (either single or double ; precision). Passed by value. ;- ;+0MTH_QUAD_FLOAT ; ; FUNCTIONAL DESCRIPTION: ; Convert quadword integer to floating point ; ; CALLING SEQUENCE: ; result = MTH_QUAD_FLOAT/DOUBLE(quad) ; ; INPUT PARAMETERS: ; quad(AP) address of quadword integer to be floated ; ; OUTPUT PARAMETERS: ; result single precision (in register R0) or double precision ; (in registers R0 and R1) floating point result. ; ;- MTH_QUAD_DOUBLE:: .ENTRY MTH_QUAD_FLOAT,^M MOVQ @qint(AP),R0 ;Get the quadword integer CVTLD R1,R2 ;Convert high order longword TSTL R2 ;Was high order longword non-zero? BEQL 5$ ;If not skip fixup. EXTV #7,#8,R2,R1 ;Get exponent of floating point result ADDL #32,R1 ;Add 32 to exponent to represent the INSV R1,#7,#8,R2 ; high order longword piece. 5$: BBCC #31,R0,10$ ;Was quadword negative? ADDD #^F2147483648,R2 ;Yes, add peculiar floating value 10$: CVTLD R0,R0 ;Convert low order integer longword ADDD R2,R0 ; and add to high order result RET .END