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 >
Wrap
Text File
|
1994-04-21
|
6KB
|
131 lines
FLOATING POINT MACRO DEFINITIONS
================================
For use with file FP_MACRO.S
Compiled by Peter Hibbs
List of MACRO definitions for use with the FP_STOS.S as described in
the FP_STOS.DOC document file. To use these MACROs first copy the file
FP_MACRO.S to your hard disk/working disk and then place the following
'include' pseudo-op at the start of the source file :-
include FP_MACRO.S
See the FP_STOS.DOC file for information on how to use the routines.
Note that the MACROs use the same sub-routine names used in this file
so don't change any of them or the MACROs may not work. See below for
more information on how to use the MACROs within a program.
fp_add ;add two numbers
fp_sub ;subtract two numbers
fp_mul ;multiply two numbers
fp_div ;divide two numbers
fp_sin ;fetch sin
fp_cos ;fetch cos
fp_tan ;fetch tan
fp_exp ;fetch exponential
fp_log ;fetch naperien log
fp_log10 ;fetch base10 log
fp_square ;fetch square root
ascii_fp buffer ;convert ASCII to fp
fp_ascii size,buffer ;convert fp_ASCII
fp_int ;convert fp to int
int_fp ;convert int to fp
fp_eq ;test if equal
fp_ne ;test if not equal
fp_gt ;test if greater than
fp_ge ;test if greater or equal
fp_lt ;test if less than
fp_le ;test if less or equal
fp_arcsin ;fetch arc sin
fp_arccos ;fetch arc cos
fp_arctan ;fetch arc tan
fp_sinh ;fetch hyperbolic sin
fp_cosh ;fetch hyperbolic cos
fp_tanh ;fetch hyperbolic tan
fp_intpart ;fetch int part of fp
fp_power ;fetch fp power
All these MACROs (except the ascii_fp) assume that the floating point
number will already be held in registers d0/d1 (and in registers d2/d3
where two values are required). The results are always returned in
registers d0/d1. The following examples show how they can be used in a
program. Note that only registers d0/d1 and d4 are changed by any of
the MACROs.
1. Multiply two floating point numbers and display result.
ascii_fp #first ;convert string into fp in d0/d1
move.l d0,d2 ;and copy to d2/d3
move.l d1,d3
ascii_fp #second ;convert 2nd No to fp in d0/d1
fp_mul ;multiply numbers, result in d0/d1
fp_ascii #'3',#fp_buffer ;convert to ASCII in fp_buffer
bsr display ;user S/R to display fp_buffer
.
.
first dc.b '123.456',0 ;first number
second dc.b '987.654',0 ;second number
.
fp_buffer ds.b 50 ;output buffer
.
2. Calculate the square root of a floating point number and display.
lea number,a0 ;set a0 to number string
lea fp_buffer,a1
ascii_fp a0 ;convert string to fp in d0/d1
fp_square ;fetch square root
fp_ascii #'6',a1 ;convert to ASCII with 6 digits
bsr display ;user S/R to display fp_buffer
.
number dc.b '1234567.89',0 ;number value
.
fp_buffer ds.b 50 ;output buffer
Note that in the first example the address of the number strings were
passed to the MACRO as constants and in the second example as a
variable in register a0. Similarly the output buffer was defined as a
constant in the first example and as a variable in register a1 in the
second. The ASCII digit in the fp_ascii MACRO defines the number of
digits following the decimal point which are returned. The 'display'
sub-routine is not defined here and would be a simple routine to
display the contents of the output buffer on screen, if required. All
strings returned by the floating point routines are NUL terminated as
should be any strings passed to the MACROs. Note also that the fp_ascii
MACRO returns the length of the string (excluding the NUL code) in
register d0, this could be used to find the end of the string if any
extra characters need to be appended to the string.