Floating Point: Apple vs. Acorn

Discuss all aspects of programming here. From 8-bit through to modern architectures.
Post Reply
Coeus
Posts: 951
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Floating Point: Apple vs. Acorn

Post by Coeus » Mon May 14, 2018 7:29 pm

I was browsing the 6502.org site and came across the floating point routines for the Apple II by Steve Wozniak and Roy Rankin - http://6502.org/source/floats/wozfp1.txt so I thought I'd compare with the routines in BASIC 2, presumably by Sophie Wilson.

There is an interesting difference of approach. The Wozniak routines are very compact and have, perhaps been optimised for small footprint at the expense of speed. The Wilson routines are almost the exact opposite with, for example, most of the loops unrolled. As another example in order to add two numbers the mantissa need to be aligned. The Wozniak routines shift the mantissa one bit at a time, rotating three bytes of mantissa in a loop. The Wilson routines first check if the difference in exponent is enough to shift by at least one whole byte. If so a separate loop shifts whole bytes at a time and then a second loop shift however many remaining bits are required.

Post Reply