.MCALL .MODULE .MODULE JFIX,VERSION=04,COMMENT=,IDENT=NO,LIB=YES ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. .SBTTL Module Declaration .NLIST .ENABL LC .DSABL GBL .NLIST CND .LIST ; ++ ; FACILITY: ; ; RT-11 System Subroutine Library ; ; CALLABLE ENTRIES: ; ; JAFIX, JDFIX ; ; ENVIRONMENT: ; ; These routines can be used by any job running in a single-job or ; multi-job environment . It uses "TRAP" to provide error processing. ; ; ; INCLUDE FILES: ; ; SYSMAC.SML ; RT-11 system macro library. ; ; EXTERNAL REFERENCES: ; .GLOBL $SYSLB ; Include system library work area. .GLOBL $SETR0 ; Entry point to SET R0 routine .SBTTL JFIX - Fortran-callable Routine ; ; ++ ; FUNCTIONAL DESCRIPTION: ; ; JAFIX - converts a REAL*4 value to INTEGER*4 ; JDFIX - converts a REAL*8 (DOUBLE PRECISION) value to INTEGER*4 ; ; CALLING SEQUENCE: ; ; i = JAFIX (asrc, jres ) ; i = JDFIX (dsrc, jres ) ; ; INPUT PARAMETERS: ; ; R5 - address of argument block ; ; 0(R5) - argument count of JAFIX,JDFIX call ; 2(R5) - address of a variable to be converted ; 4(R5) - address of a variable that is to receive the result ; ; RETURNED FUNCTION VALUE: ; ; i = -1 normal return; the result is negative ; = 0 normal return; the result is zero ; = 1 normal return; the result is positive ; = -2 an overflow occured while computing the result ; ;-- .SBTTL JFIX - Fortran-callable Routine .PSECT SYS$I JDFIX:: TST (PC)+ ; set c=0 JAFIX:: SEC ; set c=1 BIC R3,R3 ; 0 reg without changing c MOV (R5)+,R4 ; skip arg count MOV (R5)+,R4 ; get addr of floating number MOV (R4)+,R1 ; get high order floating MOV (R4)+,R0 ; next part BCS 10$ ; if jafix don't want any more MOV @R4,R3 ; get last needed 8 bits 10$: ASL R1 ; c=sign ROR -(SP) ; save for later SEC RORB R1 ; insert implied normalize bit SWAB R1 ; switch exp and high mantissa MOV R1,R4 ; make copy for exp CLRB R1 ; remove exp from high word mantissa BIC R1,R4 ; remove high word mantissa from exp SWAB R0 ; set up to move next byte of mantissa BISB R0,R1 ; insert next byte mantissa CLRB R0 ; remove it SWAB R3 ; get lowest byte BISB R3,R0 ; put it in CLR R3 ; init low word of result CLR R2 ; init high word of result SUB #200,R4 ; remove bias from exp BLE 40$ ; branch if result will be zero CMP #20,R4 ; will result be only 1 word long BHIS 30$ ; branch if only need 1 word SUB #20,R4 ; well, we need 2 words CMP #20,R4 ; make sure result will fit in 2 words BHI 20$ ; branch if o.k. MOV #-2,R0 ; set overflow indicatore BR 50$ ; go finish up 20$: MOV R1,R3 ; perform a word shift MOV R0,R1 30$: ROL R1 ; shift in a bit ROL R3 ; into low order result ROL R2 ; now into high order result DEC R4 ; are we done? BGT 30$ ; branch for more bits 40$: CLR R0 ; set for $setr0 routine 50$: TST (SP)+ ; test final sign BPL 60$ ; branch if positive NEG R2 ; negate result NEG R3 SBC R2 60$: MOV @R5,R1 ; get address of result MOV R3,(R1)+ ; store low result MOV R2,@R1 ; store high result CALLR $SETR0 ; exit via $setr0 routine .END