home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI10.ARJ / ictari.10 / ASSEMBLY / FLOAT_PT / FP_MACRO.DOC next >
Text File  |  1994-04-21  |  6KB  |  131 lines

  1.  
  2.                        FLOATING POINT MACRO DEFINITIONS
  3.                        ================================
  4.  
  5.                          For use with file FP_MACRO.S
  6.                             Compiled by Peter Hibbs
  7.  
  8.     List of MACRO definitions for  use  with  the FP_STOS.S as described in
  9.     the FP_STOS.DOC document file. To use  these MACROs first copy the file
  10.     FP_MACRO.S to your hard disk/working disk  and then place the following
  11.     'include' pseudo-op at the start of the source file :-
  12.  
  13.          include             FP_MACRO.S
  14.  
  15.     See the FP_STOS.DOC file for  information  on  how to use the routines.
  16.     Note that the MACROs use the  same  sub-routine names used in this file
  17.     so don't change any of them or  the  MACROs may not work. See below for
  18.     more information on how to use the MACROs within a program.
  19.  
  20.          fp_add                                  ;add two numbers
  21.  
  22.          fp_sub                                  ;subtract two numbers
  23.  
  24.          fp_mul                                  ;multiply two numbers
  25.  
  26.          fp_div                                  ;divide two numbers
  27.  
  28.          fp_sin                                  ;fetch sin
  29.  
  30.          fp_cos                                  ;fetch cos
  31.  
  32.          fp_tan                                  ;fetch tan
  33.  
  34.          fp_exp                                  ;fetch exponential
  35.  
  36.          fp_log                                  ;fetch naperien log
  37.  
  38.          fp_log10                                ;fetch base10 log
  39.  
  40.          fp_square                               ;fetch square root
  41.  
  42.          ascii_fp            buffer              ;convert ASCII to fp
  43.  
  44.          fp_ascii            size,buffer         ;convert fp_ASCII
  45.  
  46.          fp_int                                  ;convert fp to int
  47.  
  48.          int_fp                                  ;convert int to fp
  49.  
  50.          fp_eq                                   ;test if equal
  51.  
  52.          fp_ne                                   ;test if not equal
  53.  
  54.          fp_gt                                   ;test if greater than
  55.  
  56.          fp_ge                                   ;test if greater or equal
  57.  
  58.          fp_lt                                   ;test if less than
  59.  
  60.          fp_le                                   ;test if less or equal
  61.  
  62.          fp_arcsin                               ;fetch arc sin
  63.  
  64.          fp_arccos                               ;fetch arc cos
  65.  
  66.          fp_arctan                               ;fetch arc tan
  67.  
  68.          fp_sinh                                 ;fetch hyperbolic sin
  69.  
  70.          fp_cosh                                 ;fetch hyperbolic cos
  71.  
  72.          fp_tanh                                 ;fetch hyperbolic tan
  73.  
  74.          fp_intpart                              ;fetch int part of fp
  75.  
  76.          fp_power                                ;fetch fp power
  77.  
  78.     All these MACROs (except the  ascii_fp)  assume that the floating point
  79.     number will already be held in  registers d0/d1 (and in registers d2/d3
  80.     where two values are  required).  The  results  are  always returned in
  81.     registers d0/d1. The following examples show how  they can be used in a
  82.     program. Note that only registers d0/d1  and  d4  are changed by any of
  83.     the MACROs.
  84.  
  85.     1. Multiply two floating point numbers and display result.
  86.  
  87.          ascii_fp  #first              ;convert string into fp in d0/d1
  88.          move.l    d0,d2               ;and copy to d2/d3
  89.          move.l    d1,d3
  90.          ascii_fp  #second             ;convert 2nd No to fp in d0/d1
  91.          fp_mul                        ;multiply numbers, result in d0/d1
  92.          fp_ascii  #'3',#fp_buffer     ;convert to ASCII in fp_buffer
  93.          bsr       display             ;user S/R to display fp_buffer
  94.          .
  95.          .
  96.  
  97.     first          dc.b      '123.456',0         ;first number
  98.     second         dc.b      '987.654',0         ;second number
  99.                    .
  100.     fp_buffer      ds.b      50                  ;output buffer
  101.                    .
  102.  
  103.     2. Calculate the square root of a floating point number and display.
  104.  
  105.          lea       number,a0           ;set a0 to number string
  106.          lea       fp_buffer,a1
  107.          ascii_fp  a0                  ;convert string to fp in d0/d1
  108.          fp_square                     ;fetch square root
  109.          fp_ascii  #'6',a1             ;convert to ASCII with 6 digits
  110.          bsr       display             ;user S/R to display fp_buffer
  111.          .
  112.  
  113.     number         dc.b      '1234567.89',0      ;number value
  114.                    .
  115.     fp_buffer      ds.b      50                  ;output buffer
  116.  
  117.     Note that in the first example  the  address of the number strings were
  118.     passed to the  MACRO  as  constants  and  in  the  second  example as a
  119.     variable in register a0. Similarly the  output  buffer was defined as a
  120.     constant in the first example and as  a  variable in register a1 in the
  121.     second. The ASCII digit in  the  fp_ascii  MACRO  defines the number of
  122.     digits following the decimal  point  which  are returned. The 'display'
  123.     sub-routine is not  defined  here  and  would  be  a  simple routine to
  124.     display the contents of the output  buffer  on screen, if required. All
  125.     strings returned by the floating  point  routines are NUL terminated as
  126.     should be any strings passed to the MACROs. Note also that the fp_ascii
  127.     MACRO returns the length  of  the  string  (excluding  the NUL code) in
  128.     register d0, this could be used to  find  the  end of the string if any
  129.     extra characters need to be appended to the string.
  130.  
  131.