Reputation: 133
I am working on a Forth implementation where I have come across the need for double-cell arithmetic (the Forth implementation is 32-bit) including double-cell multiplication and division/remainder. However, the architecture I am developing this for, ARM Cortex-M4, lacks 64x64 multiplication or 64/64 division/remainder instructions (it only has 32x32 multiplication and 32/32 division and 32x32+64 multiply/accumulate instructions).
While I would be fine with 32x64 multiplication (as 64x64 multiplication can be emulated with it for cases that would not overflow anyways), and for some things 64/32 division/remainder would be sufficient, I would like to at least have a full 64/64 division/remainder in addition to 32x64 multiplication so I can do a full implementation of double-cell arithmetic.
Upvotes: 2
Views: 760
Reputation: 8544
You can take as an example the bigmath.f library (or another variant) — Double Number Arithmetic by Wil Baden.
There are defined D*
and DU/MOD
words.
Regarding a license. I think this code is in public domain. It was published in Forth Dimensions1 as a reference implementation, and the author said there: "For a copy of the source for this article send e-mail requesting Stretching Forth #19: Double Number Arithmetic".
For DU/MOD
word, Wil Baden also noted: "The algorithm is based on Knuth's algorithm in volume 2 of his Art of Computer Programming, simplified for two-cell dividend and two-cell divisor".
1 Wil Baden (1998). Stretching standard Forth #19: Double Number Arithmetic. Forth Dimensions XIX.6 March-April 1998, pp. 33-34
On the page 4 we can also read:
The material contained in this periodical (but not the code) is copyrighted by the individual authors of the articles and by Forth Interest Group, Inc., [...] Any code bearing a copyright notice, however, can be used only with permission of the copyright holder.
And it seems neither the code nor the article bears any copyright notice.
Upvotes: 3