Our WEB page:
http://www.6502.org/source/floats/wozfp1.txt
contains floating point software from:
Dr. Dobb's Journal, August 1976, pages 17-19.
Floating Point Routines for the 6502
by Roy Rankin, Department of Mechanical Engineering,
Stanford University, Stanford, CA 94305
(415) 497-1822
and
Steve Wozniak, Apple Computer Company
770 Welch Road, Suite 154
Palo Alto, CA 94304
(415) 326-4248
It is said:
All routines are called and exited in a uniform manner:
The arguments(s) are placed in the specified floating point
storage locations (for specifics, see the documentation preceeding
each routine in the listing), then a JSR is used to
enter the desired routine. Upon normal completion, the
called routine is exited via a subroutine return instruction (RTS).
I tested FADD and FSUB, both work perfectly. But not Floating Multiply - FMUL!!!
Putting floating point 1.5 which is $00600000 both in $04,$05,$06,$07 and in $08,$09,$0A,$0B and then calling FMUL
I get an unchanged $00600000 in $04,$05,$06,$07 and a value $00000000 in $08,$09,$0A,$0B. Not the expected 2.25 which is $01480000 in either place!
Checking the code one finds that one comes to the statement:
1F 0D 06 03 MD1 ASL SIGN CLEAR LSB OF SIGN
without having set variable "SIGN" anywhere previously! The value $EA ("NOP") is given to variable "SIGN" initially when assembled
0003 EA SIGN NOP
and this is the value I had:
But the ASL changes this to $D4 for the next call!
Then comes statements:
1F12 24 09 ABSWAP BIT M1 MANT1 NEG?
1F14 10 05 BPL ABSWP1 NO,SWAP WITH MANT2 AND RETURN
without previously having set the accumulator to any special value! If "MANT1" is negative the branch taken then depends on the random contents of the accumulator! Is a statement "LDA #$FF" missing?
Anyway, the software does not give the correct result!
Can anybody explain what is wrong? Maybe Steve Wozniak himself should be asked! But APPLE BASIC sure worked correctly!!!![/list]