Version française

Armpi 4 - Calculating Pi

Armpi 4 is a program that calculates π in decimal for the ARM processors (in particular for the Acorn Risc PC). It is the successor of Armpi 3. Most explanations are given in the document relative to the version 3; only the changes are given here.

Like with the version 3, the assembly source is given in a separate file. Perl scripts enable to extract the assembly source from the given file in accordance with the standard syntax or the source for extASM. Another Perl script creates a BASIC program (for the Risc PC) from the assembly source returned by the first script.

Only the conversion into base 10 has been modified. There are two main changes:

The division by 4 is performed a little like the division by 2, except the backcarries (so called because they correspond to carries in the multiplication by 4). When a digit (between 0 and 27) is divided by 4, a quotient between 0 and 6 and a remainder between 0 and 3 are obtained. A remainder equal to r generates two backcarries respectively equal to 2r and to 5r for the next two digits. Thus a value up to 21 is added to each digit, so one verifies that the digits can't be higher than 27. Concerning the implementation, the backcarries are added sometimes before, sometimes after the division of the digit by 4 (in the former case, the backcarries are obviously multiplied by 4), and the code is particularly optimised; the best way to see how it works is to take examples and to run the code on them...

Results and Comparisons

200,000 decimals have been calculated in 6 hours 54 minutes 4 seconds: the binary calculation has lasted 3 hours 47 minutes 12 seconds and the conversion into base 10 has lasted 3 hours 6 minutes 52 seconds.

The comparisons with other computers and other π calculation programs I've written are given in a separate file; all the programs up to Armpi 4 use the same formula, but the algorithms are quite different.

Valid XHTML 1.0!
Last updated: