MCODE Multi-Precision Library for HP-41

A little while ago I decided to learn a bit of MCODE programming and hence I was looking for a project. Guided by the helpful hints from Valentin during his SSMC #4 and SSMC #20 - scroll down to very last post I started to build a MCODE based multi-precision library for the HP41.

Many hours later and thanks to the help of many here on the forum (in particular Egan Ford) I was able to show a somewhat acceptable 4k module providing some multi-precision functionality during the Allschwill meeting. While by no means complete and perfect, I think it might be a decent starting point to breath some, albeit limited, multi-precision life into the HP-41.

In its current state, the MPL provides

- ~1000 digits, exponents up to +/-2048 for each MPN (Multi-Precision-Number)

- a complete set of basic floating point arithmetic (+,-,*,/)

- some special floating point arithmetic (x
^{2}, y^{x}, 1/x)

- an (almost) complete set of basic arithmetic between MPN and normal numbers (+,-,*).
- MPN/NN is missing but can be easily accomplished by MPN* (1/NN).

- Harder to replicate is N/MPN, which is also missing. It can be accomplished by converting the NN into a MPN via MPN2M, followed by MP* (which is not nearly as elegant as a separate MPN/M function would be)

- MPN/NN is missing but can be easily accomplished by MPN* (1/NN).
- special functions for fast division and multiplication by 10

- a complete set of MPN handling and I/O functions (create, set, view, get MPN, convert between MPN and NN, Copy MPN, CHS, CLX MPN, etc)

- some comparison functions (MP=0?, MP=1?)

- custom MPL error messages

- entirely in MCODE

Naturally there is an even longer list of things the MPL does not do as of today, for example

- MPN comparison functions (MPNX>MPNY, etc)

- sqrt(x), e
^{x}, ln(x), fact(x)

- constants pi and e to many digits

- direct division instead of the simple, yet slow Newton iteration

- more effective use of storage by storing a full 14 digits in each register. This would also speed up MP*, MPY^X and MP/ by at least 100%

- much more testing

- etc

One idea to tackle these was to create a little Open Source project. Maybe there are others that enjoy programming in MCODE and enjoy the challenge.

In the meantime, for those that are interested, please find below links to

- a short presentation and user guide I gave in Allschwil about the features, structure of the MPL, some high level algorithm overview, execution times, a quick reference guide and an introductory step-by-step example

- QRG, Error Msgs and Step-by-Step as separate pdf pages for readability

- .ROM and .MOD files for your emulators (including the iPhone), Ramboxes and Clonix/NoV

If you do play around and discover bugs, it would be great if you can send me an email via the forum (please with steps to replicate it).

Cheers,

Peter

QRG, Error Msgs and Step-by-Step

*Edited: 6 Nov 2008, 9:50 p.m. after one or more responses were posted*