home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l320 / 2.img / EXAMPLES / SETNDP.F < prev    next >
Encoding:
Text File  |  1988-04-06  |  3.6 KB  |  167 lines

  1. c    Examples of the use of the MicroWay programs:
  2. c        enab_ex, dsab_ex, inf_ctl, round and precis,
  3. c    which provide an easy method for the Fortran or C
  4. c    programmer to set up and to alter the state of the NDP.
  5. c    Exceptions can be enabled (unmasked) and disabled (masked)
  6. c    in groups or individually, the infinity mode may be set
  7. c    (on 80287 only), and the rounding and /or precision control
  8. c    modes may be set to any possible value.
  9.  
  10.     integer stndpcw, ldndpcw
  11.     integer type, cw_arg, save_cw
  12.  
  13. c    Function declarations:
  14. c        enab_ex        - enable (unmask) exceptions.
  15. c        dsab_ex        - disable (mask) exceptions.
  16. c        round        - rounding control.
  17. c        inf_ctl        - 80287 infinity control.
  18. c        precis        - precision control.
  19.  
  20.     integer enab_ex, dsab_ex
  21.     integer round, inf_ctl, precis
  22.  
  23. c    Argument definitions:
  24. c        Exceptions:
  25. c        IM    - invalid operation.
  26. c        DM    - denormalized operand (80x87 only).
  27. c        ZM    - zero divide.
  28. c        OM    - overflow.
  29. c        UM    - underflow.
  30. c        PM    - precision.
  31. c        UOM    - undefined opcode (Weitek only).
  32. c        DCM    - data chain (Weitek only).
  33. c        80287 infinity control:
  34. c        AFFINE    - affine closure.
  35. c        PROJ    - projective closure.
  36. c        Rounding control:
  37. c        EVEN    - round to nearest or even.
  38. c        DOWN    - round toward - infinity.
  39. c        UP    - round toward + infinity.
  40. c        CHOP    - round toward zero.
  41. c        IRND    - round integers like reals (Weitek only).
  42. c        IZ    - round integers toward 0 (Weitek only).
  43. c        Precision control:
  44. c        SINGLE    - single precision (24 bits) (80x87 only).
  45. c        DOUBLE    - double precision (53 bits) (80x87 only).
  46. c        EXTEND    - extended precision (64 bits) (80x87 only).
  47.  
  48.     integer IM, DM, ZM, OM, UM, PM, UOM, DCM
  49.     integer AFFINE, PROJ
  50.     integer EVEN, DOWN, UP, CHOP, IRND, IZ
  51.     integer SINGLE, DOUBLE, EXTEND
  52.  
  53.     parameter (IM = 1, DM = 2, ZM = 4, OM = 8, UM = 16, PM = 32)
  54.     parameter (UOM = 64, DCM = 128)
  55.     parameter (AFFINE = 1, PROJ = 0)
  56.     parameter (EVEN = 0, DOWN = 1, UP = 2, CHOP = 3, IRND = 4, IZ = 5)
  57.     parameter (SINGLE = 0, DOUBLE = 2, EXTEND = 3)
  58.  
  59.  
  60. c    Initialize the NDP.
  61.  
  62.     call init_ndp
  63.  
  64. c    Save the control word as the base line value.
  65.  
  66.     save_cw = stndpcw()
  67.     write(*,1) save_cw
  68. 1    format(/' Control word = ',8z,'.'/)
  69.  
  70. c    Enable various exceptions.
  71.  
  72.     cw_arg = enab_ex(IM)
  73.     type = stndpcw()
  74.     write(*,1) type
  75.  
  76.     cw_arg = enab_ex(DM)
  77.     type = stndpcw()
  78.     write(*,1) type
  79.  
  80.     cw_arg = enab_ex(ZM)
  81.     type = stndpcw()
  82.     write(*,1) type
  83.  
  84.     cw_arg = enab_ex(OM)
  85.     type = stndpcw()
  86.     write(*,1) type
  87.  
  88.     cw_arg = enab_ex(UM)
  89.     type = stndpcw()
  90.     write(*,1) type
  91.  
  92.     cw_arg = enab_ex(PM)
  93.     type = stndpcw()
  94.     write(*,1) type
  95.  
  96. c    Disable them.
  97.  
  98.     cw_arg = dsab_ex(IM)
  99.     type = stndpcw()
  100.     write(*,1) type
  101.  
  102.     cw_arg = dsab_ex(DM)
  103.     type = stndpcw()
  104.     write(*,1) type
  105.  
  106.     cw_arg = dsab_ex(ZM)
  107.     type = stndpcw()
  108.     write(*,1) type
  109.  
  110.     cw_arg = dsab_ex(OM)
  111.     type = stndpcw()
  112.     write(*,1) type
  113.  
  114.     cw_arg = dsab_ex(UM)
  115.     type = stndpcw()
  116.     write(*,1) type
  117.  
  118.     cw_arg = dsab_ex(PM)
  119.     type = stndpcw()
  120.     write(*,1) type
  121.  
  122. c    Set the infinity control.
  123.  
  124.     cw_arg = inf_ctl(AFFINE)
  125.     type = stndpcw()
  126.     write(*,1) type
  127.  
  128. c    Set various rounding control modes.
  129.  
  130.     cw_arg = round(EVEN)
  131.     type = stndpcw()
  132.     write(*,1) type
  133.     
  134.     cw_arg = round(DOWN)
  135.     type = stndpcw()
  136.     write(*,1) type
  137.     
  138.     cw_arg = round(UP)
  139.     type = stndpcw()
  140.     write(*,1) type
  141.     
  142.     cw_arg = round(CHOP)
  143.     type = stndpcw()
  144.     write(*,1) type
  145.  
  146. c    Set various precision control modes.
  147.     
  148.     cw_arg = precis(SINGLE)
  149.     type = stndpcw()
  150.     write(*,1) type
  151.     
  152.     cw_arg = precis(DOUBLE)
  153.     type = stndpcw()
  154.     write(*,1) type
  155.     
  156.     cw_arg = precis(EXTEND)
  157.     type = stndpcw()
  158.     write(*,1) type
  159.  
  160. c    Restore the base line control word state.
  161.  
  162.     type = ldndpcw(save_cw)
  163.     type = stndpcw()
  164.     write(*,1) type
  165.  
  166.     end
  167.