Documentation for calc-pi-arm64-asm
Command Input Output Description
+ Xreg, Yreg Xreg Addition Xreg = Yreg + Xreg
Rotate stack Zreg → Yreg
Rotate stack Treg → Zreg
Set 0.0 → Treg
- Xreg, Yreg Xreg Subtract Xreg = Yreg - Xreg
Rotate stack Zreg → Yreg
Rotate stack Treg → Zreg
Set 0.0 → Treg
* Xreg, Yreg Xreg Multiply Xreg = Yreg * Xreg
Rotate stack Zreg → Yreg
Rotate stack Treg → Zreg
Set 0.0 → Treg
/ Xreg, Yreg Xreg Divide Xreg = Yreg / Xreg
Rotate stack Zreg → Yreg
Rotate stack Treg → Zreg
Set 0.0 → Treg
The value of Xreg must be non-zero.
chs Xreg Xreg Change sign of number in Xreg by performing a
2's Compliment subraction from zero.
clrstk Clear Stack
Sets 0.0 into Xreg, Yreg, Zreg, Treg
clrx Clear X Register
Sets 0.0 into Xreg
The stack is not rotated.
enter XReg Yreg RPN Enter command
Move Zreg → Treg
Move Yreg → Zreg
Copy Xreg → Yreg

This is included for compatibility with scientific pocket calculators. The "Enter" text command duplicates Xreg into Yreg. This is different from the keyboard [Enter] key used to terminate number input.
log
logoff
The command 'log' starts a terminal log session. The filenames are sequential as follows: out/out001.txt, out/out002.txt, out/out003.txt ... the folder 'out' must exist in the working directory. Logging is stopped with the 'logoff' command.
print
print f

.
. f
Print Xreg to console output without formatting. The base-10 conversion mode is set independently using commands: fix, int, or sci. The period character "." is synonymous to "print".

Adding "f" to print command will format the text output stream in groups of 10 digits, with 100 digits per line, in blocks of 1000 digits. Formatting is independent of the base-10 conversion mode set with: fix, int, or sci. Use "help print" to see more options.
rcl <reg> XReg Recall value from Register Reg0 to Reg7
Move Zreg → Treg
Move Yreg → Zreg
Move Xreg → Yreg
Copy Register to Xreg
Valid input: 0,1,2,3,4,5,6,7
rdown Rotate stack down R↓ (circular rotation)
Move Yreg → Xreg
Move Zreg → Yreg
Move Treg → Zreg
(Circular) Move previous Xreg → Treg
recip Xreg Xreg Compute Xreg = 1/Xreg reciprocal value
rup Rotate stack up R↑ (circular rotation)
Move Zreg → Treg
Move Yreg → Zreg
Move Xreg → Yreg
(circuar) Move previous Treg → Xreg
sigfigs
sigfigs v
sigfigs <a>

sf
sf v
sf <a>
Show or set number of significant digits. The command "sf" is synonymous to "sigfigs" Adding "v" to sigfigs or sf will show accuracy verbose mode, showing bytes and words. Adding an integer argument to sigfigs or sf will set the variable size. Example: "sf 1000" will set accuracy to 1000 digits. Use "help sf" to get more options to set variable size.
sto <reg> XReg Store value from Xreg to Reg0 to Reg7
Valid input: 0,1,2,3,4,5,6,7
Stack is not rotated.
xy Exchange Xreg and Yreg
RPN registers

RPN calculators can be recognized because RPN calculators do not have an equals sign [=] button. In place of the equals sign key is a large [Enter] key. You can read about RPN on Wikipedia here This type of calculator will add 1 + 2 + 3 to obtain the sum 6 with the following keystrokes:

"1 Enter 2 Enter 3 + +"

Scientific calculators like the HP-11C or HP-15C have always been my favorite. Anyone who has used such a scientific calculator should feel right at home with this type of calculator. This program works with a 4 register stack, X, Y, Z, and T. Similar to a scientific calculator, there are 8 storage registers number 0 to 7. There is a simple demonstration of these registers at the start of this program's tutorial here.

Numeric Input

The program will accept floating point input. At the "Op Code:" prompt, enter a numeric text string. Use the keyboard [Enter] key to terminate the input. The input be converted to a binary fixed point. White space is ignored within the number.

Example syntax:
0
0.0
123
+123
-123
123.456
-123.456
For example:

Op Code: 123
Op Code: 456
Op Code; +

XREG  +579.000000000000000000000000000000000000000000000000
YREG   0.0
ZREG   0.0
TREG   0.0
Printing Numbers

Printing involves 3 concepts: base-10 conversion, text formatting, and significant digits.

Base-10 conversion:

All numbers are stored binary fixed point format. In order to view the numbers in human understandable output, it is necessary to convert the binary numbers (base-2) to recognizable (base-10) format. For example, the number "123.0" would be stored as binary fixed point as (integer part).(fraction part) with values "07B.0000000000000000"

hex  0000000000000000 000000000000007B 0000000000000000 0000000000000000 0000000000000000 0000000000000000
dec +123.000000000000000000000000000000000000000000000000000000000000

Text formatting:

The process of the base-10 conversion produces a continuous stream of ascii characters. Unformatted text will "wrap" to the next line when the screen width of the console terminal is reached. It is very difficult to work with unformatted numbers. Formatting requires adding ascii space characters and end of line characters. Formatting is configured by adding the "f" modifier character to the end of the "print" or "." commands to request that text be formatted in group of 10 digits, 100 digits per line, in blocks of 1000 digits.

print     +3.141592653589793238462643383279502884197169399375105820974944
print f   +3.
          1415926535 8979323846 2643383279 5028841971 6939937510 5820974944

.         +3.141592653589793238462643383279502884197169399375105820974944
. f       +3.
           1415926535 8979323846 2643383279 5028841971 6939937510 5820974944

Significant digits:

In the case of any repetitive calculation that runs in a loop, each operation in the loop may experience round off errors. Over many loops, these cumulative errors can add up. Additionally, the variables are allocated in 64 bit words. The intended number of decimal digits may not match up to an even number of 64 bit words. To avoid this problem, extra bytes (or 64 bit words) are added to each variable to absorb these precision errors.

To illustrate, take the example of dividing 1/3 to produce and endless text string of 3's looking like "0.3333...". However at some point the number may inherit various accuracy errors and look something like "0.33333328342". In this case 6 digits were accurate followed by 5 random digits. The sigfigs or sf command will set the intended accuracy variable size and number of base-10 digits to print. Extra 64 bit words are allocated, called "guard words". Adding "e" followed by an integer to the sigfigs or sf command will allow extended digits to be included in the "print" or "." commands. Extended digits beyond the specified accuracy are shown in parentheses.

Example:
"sf 100" will set accuracy to 100 digits.
"sf e 100" will tell the program to print 100 "extended" digits.

Let's do the this and divide 1/3, then print 100 digits and 100 extra digits, 200 total. You can see the last 37 digits are random. Although the requested accuracy is 100 digits, in fact this calculation of 1/3 has an internal calculation accuracy of about 163 digits.

+0.333333333333333333333333333333333333333333333333333333333333333333333333333333
3333333333333333333333(3333333333333333333333333333333333333333333333333333333333
333335069863606368550117241574023322014605)

A normal calculation to 100 digits would print 1/3 to the specified accuracy.

+0.333333333333333333333333333333333333333333333333333333333333333333333333333333
3333333333333333333333

To calculate and print pi to 1000 digits with 10 extended digits and print in formatted output (note period command to print), you would do the following:

Op Code: sf 1000
Op Code: sf e 10
Op Code: c.pi
Op Code: . f
Capturing output to a file

To capture text output to a disk file, first create a folder called "out" in the current working directory. Next use the "log" and "logoff" commands to start and stop a logging session. The output text capture files will be automatically named out/out001.txt, out/out002.txt, out/out003.txt ...

Display intermediate results on the stack

Each time a numeric command is requested from the keyboard, the program will show the stack registers, Xreg, Yreg, Zreg, and Treg. The number is shown unformatted, truncated to 50 digits.