home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 150_01 / aft8087.mac < prev    next >
Text File  |  1985-03-10  |  3KB  |  125 lines

  1.     PAGE    66,132
  2.     SUBTTL     AFT8087.LIB - Macros Library P.C. FORTRAN INTERFACING
  3.     PAGE
  4.     COMMENT &
  5.     ---------------------------------------------------------------
  6.  
  7.             * * *  A F T 8 0 8 7 . L I B  * * *
  8.  
  9.                   Version 1.0
  10.  
  11.     This Library of Macros enables a FORTRAN Programmer to use the
  12.     8087 N.D.P. by adjusting the Floating Point representation of
  13.     REAL numbers (as used in FORTRAN or BASIC) to the 8087 format.
  14.     It also allows adjusting results from the 8087 back into the
  15.     FORTRAN/BASIC format.
  16.  
  17.         This library was written by
  18.             Jean-Marc Belisle
  19.             GEOSTAT SYSTEMS INC.
  20.             10403 W. Colfax Av.  Suite 450
  21.             Lakewood, Colorado   80215
  22.             U.S.A.
  23.  
  24.         REVISIONS ----------------------------
  25.  
  26.  
  27.         --------------------------------------
  28.  
  29.  
  30.         This software is PUBLIC DOMAIN
  31.         However Please leave the mention of
  32.         The author's name ... just to set the record straight
  33.  
  34.         This library was contributed to 
  35.         The Denver Amateur Computer Society
  36.         by Jean-Marc Belisle 
  37.                     January 1983
  38.  
  39.     ---------------------------------------------------------------
  40.         &
  41.  
  42. ;
  43. ;---- -------------
  44. ;     Macro AT8087 is used to transform a REAL number to the 8087 format
  45. ;     Macro AF8087 is used to transform a REAL number from 8087 format
  46. ;
  47. ;    They are used as follows
  48. ;    
  49. ;    AT8087  <Ptr to 2 most significant bytes of number> [,<A>]
  50. ;                                [,<B>]
  51. ;                                [,<C>]
  52. ;                                [,<D>]
  53. ;    The Ptr. addresses the exponent byte and the sign byte
  54. ;    If the first parameter is absent then it is assumed (but not
  55. ;    checked) that the exponent and sign are kept in the register
  56. ;    specified by the second operand.
  57. ;
  58. ;    The optional second parameter is the first letter of 
  59. ;    an "X" register (AX,BX,CX,DX). If used, the macros assume
  60. ;    that the exponent and sign bytes are already loaded in that
  61. ;    register. If left blank, then register AX is used.
  62. ;
  63. ;    ONE of the 2 parameters MUST be specified.
  64. ;
  65. ;    example :
  66. ;
  67. ;    Number    dd    83200000R    ;define 5.0 in FORTRAN/BASIC
  68. ;                    ;format
  69. ;    ...
  70. ;    AT8087    Number+2        ;will adjust Number to the 8087
  71. ;                    ;format using AX
  72. ;    mov    cx,word ptr number+2    ;get the exponent & sign in CX
  73. ;    AF8087    Number+2,C        ;will adjust Number from the
  74. ;                    ;8087 format to the FORTRAN one
  75. ;                    ;using register CX
  76. ;    AT8087    ,C            ;Adjust CX content to 8087
  77. ;                    ;format
  78. ;
  79. ;---- -------------
  80. ;
  81. AT8087    MACRO    SREAL,R
  82.     IFB    <R>
  83.     MOV    AX,WORD PTR SREAL    ;GET EXPONENT
  84.     ATGEN7    SREAL,A
  85.     ELSE
  86.     ATGEN7    SREAL,R
  87.     ENDIF
  88.     ENDM
  89. ATGEN7    MACRO    SREAL,R
  90.     LOCAL    ZERO
  91. ;;--- PERFORM EXPONENT ADJUST
  92.     OR    R&H,R&H        ;TEST FOR ZERO
  93.     JZ    ZERO        ;BYPASS ADJUST IF SO
  94.     SUB    R&H,2        ;DECREMENT E FOR BIAS DIFFERENCE
  95.     SHL    R&L,1        ;SIGN INTO CARRY
  96.     RCR    R&X,1        ;SIGN INTO REG. HIGH
  97.     IFNB    <SREAL>
  98.     MOV    WORD PTR SREAL,R&X    ;BACK IN PLACE
  99.     ENDIF
  100. ZERO:
  101.     ENDM
  102. ;
  103. AF8087    MACRO    SREAL,R
  104.     IFB    <R>
  105.     MOV    AX,WORD PTR SREAL    ;GET EXPONENT
  106.     AFGEN7    SREAL,A
  107.     ELSE
  108.     AFGEN7    SREAL,R
  109.     ENDIF
  110.     ENDM
  111. AFGEN7    MACRO    SREAL,R
  112.     LOCAL    ZERO
  113. ;;--- PERFORM EXPONENT ADJUST
  114.     OR    R&X,R&X        ;TEST FOR ZERO
  115.     JZ    ZERO        ;BYPASS ADJUST IF SO
  116.     SHL    R&L,1        ;E0 INTO CARRY
  117.     RCL    R&H,1        ;E0 INTO REG. HIGH. SIGN INTO CARRY
  118.     RCR    R&L,1        ;SIGN INTO REG. LOW
  119.     ADD    R&H,2        ;INCREMENT E FOR BIAS DIFFERENCE
  120.     IFNB    <SREAL>
  121.     MOV    WORD PTR SREAL,R&X    ;BACK IN PLACE
  122.     ENDIF
  123. ZERO:
  124.     ENDM
  125.