Apple II User Manual

Page of 257
mant1 and act as floating point registers.  On entry to
the subroutines these registers contain the numbers to
be operated upon and contain the result on return,  The
function of the registers is given before each entry point
in the source listing.  There are three error traps which
will cause a software interrupts.  ERROT (1D06) is
encountered if the argument in the log routine is less
than or equal to zero.  OVFLW (1E3B) will be executed if
the argument of EXP is too large.  Overflow detected by
the basic floating point routines will cause OVFL (1FE4)
to be executed.  The routines do not give underflow
errors, but set the number to zero if underflow occurs.
Readers of Dr. Dobbs's journal should note that when
these routines were published in that journal the math
function LOG contained an error which prevented the
correct result from being given if the argument was less
than 1.  This error has been correted in the present list-
ing and marked with "MOD 9/76."
   1                   *           SEPTEMBER 11, 1976
   2                   *     BASIC FLOATING POINT ROUTINES
   3                   *       FOR 6502 MICROPROCESSOR
   4                   *       BY R. RANKIN AND S. WOZNIAK
   5                   *
   6                   *     CONSISTING OF:
   7                   *        NATURAL LOG
   8                   *        COMMON LOG
   9                   *        EXPONENTIAL (E**X)
  10                   *        FLOAT      FIX
  11                   *        FADD       FSUB
  12                   *        FMUL       FDIV
  13                   *
  14                   *
  15                   *     FLOATING POINT REPRESENTATION (4-BYTES)
  16                   *                    EXPONENT BYTE 1
  17                   *                    MANTISSA BYTES 2-4
  18                   *
  19                   *     MANTISSA:    TWO'S COMPLIMENT REPRESENTATION WITH SIGN IN
  20                   *       MSB OF HIGH-ORDER BYTE.  MANTISSA IS NORMALIZED WITH AN
  21                   *       ASSUMED DECIMAL POINT BETWEEN BITS 5 AND 6 OF THE HIGH-ORDER
  22                   *       BYTE.  THUS THE MANTISSA IS IN THE RANGE 1. TO 2. EXCEPT
  23                   *       WHEN THE NUMBER IS LESS THAN 2**(-128).
  24                   *
  25                   *     EXPONENT:    THE EXPONENT REPRESENTS POWERS OF TWO.  THE
  26                   *       REPRESENTATION IS 2'S COMPLIMENT EXCEPT THAT THE SIGN
  27                   *       BIT (BIT 7) IS COMPLIMENTED.  THIS ALLOWS DIRECT COMPARISON
  28                   *       OF EXPONENTS FOR SIZE SINCE THEY ARE STORED IN INCREASING
  29                   *       NUMERICAL SEQUENCE RANGING FROM $00 (-128) TO $FF (+127)
  30                   *       ($ MEANS NUMBER IS HEXADECIMAL).
  31                   *
  32                   *     REPRESENTATION OF DECIMAL NUMBERS:    THE PRESENT FLOATING
  33                   *       POINT REPRESENTATION ALLOWS DECIMAL NUMBERS IN THE
APPROXIMATE
  34                   *       RANGE OF 10**(-38) THROUGH 10**(38) WITH 6 TO 7 SIGNIFICANT
  35                   *       DIGITS.
  36                   *
  37                   *
  38  0003                    ORG 3        SET BASE PAGE ADRESSES