# Calc65

## Demo Application for a 6502 Floating Point Math
Package

[ Home ] [ Tools ] [ Toolkit ] [ TIA ] [ SoftVCS ] [ Soft6502 ] [ calc65 ] [Up]

**Screen Shot of Calc65**

This may represent the epitome of dragging obsolete technology
into the 21st century, but better late than never!

Here you will find source code for a full-featured, 6502 floating point
scientific math package. The routines
are coded for assembly with the cba65 assembler
described elsewhere on this website. Available
routines include add, subtract, multiply, divide, square root, and all the
trigonometric and inverse trigonometric functions. Natural log, exponential, and
all hyperbolic and inverse hyperbolic functions are also included, as well as a
few utility functions.

The calculator which demonstrates the math package consists of a
Windows user interface, a 6502 emulator, and the assembled object code in *.h6x
file format. Rounding has not been consistently implemented as yet, so there
will sometimes be an unnecessarily large loss in precision when complex
functions or multiple operations are involved. *Caveat emptor.*

Internally, the math routines use Cordic algorithms and similar
strategies involving pseudo-multiplication and pseudo-division. The square root routine
employs non-restoring pseudo-division as described in this
paper. The BCD number format occupies 8 bytes and is described in the source
code, a fragment of which is displayed here. Note that there are 12 mantissa
digits and 3 exponent digits supporting a maximum value of **+9.999999999
E+999**.

**Floating Point Number Format for ***fltpt65.cba*

This internal format can be represented in printed form as:

D.DDDDDDDDDDD EDDD

where the 'D's represent mantissa or exponent digits.

This package is not production quality code. It is still at *beta*
testing level, so be prepared to encounter bugs. There are unused functions and
tables which have not been purged from the package, so it requires more RAM
space than necessary. I will investigate any problems reported by users, but at
the moment I am focusing my attention on an extended precision version of the
routines which I will post later.

NOTE: This code could motivate a homebrew project to build a
simple calculator using an LCD or LED display, a 6502, a keypad, and suitable
memory.