Apple II User Manual

Page of 257
+------------------------------------------------------------------------
|  TOPIC -- Apple II -- IA Floating point article
+------------------------------------------------------------------------
Interface Age, November 1976, pages 103-111.
Floating Point Routines for the 6502*
    by Roy Rankin
Department of Mechanical Engineering, Stanford University
    and Steve Wozniak
Apple Computer Company
*First appeared in Dr. DOBB's Journal of Computer Calisthenics &
Orthodontia, Box 310, Menlo Park, CA 94025
The following floating point routines represent a joint
effort between Steve Wozniak who wrote the basic float-
ing point routines of FADD, FSUB, FMUL, FDIV and
their support routines and myself, Roy Rankin, who
added FIX, FLOAT, LOG, LOG10, and EXP.  The basic
floating point routines are failry Machine dependent, but
the transcendental programs should be very easy to
transport from one machine to another.  The routines
consist of the following math functions
     * LOG         Natural log
     * LOG10       Base 10 log
     * EXP         Exponential
     * FADD        Floating add
     * FSUB        Floating subtraction
     * FMUL        Floating multiplication
     * FDIV        Floating division
     * FIX         Convert floating to fixed
     * FLOAT       Convert fixed to floating
Two additional routines exchange the contents of
exp/mant1 with exp/mant2 and compliments exp/
mant1.  These routines are
SWAP          Exchange the contents of exp/mant 1 with
              exp/mant 2
FCOMPL        Compliment exp/mant 1
Floating point numbers are represented by 4 bytes as
shown in the following
 +- SIGN BIT     +- SIGN BIT
 |  0 = +        |  0 = +
 |  1 = -        |  1 = -
 v               v
|S|             |S| +- PRESUMED DECIMAL POINT
|B|             |B| v
|_|_ _ _ _ _ _ _|_|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _