Mathematical operations

The four math operations are made between the A and the M registers: A holds the first operand, M holds the second operand, and after the operation the result is in A, with the number of decimal digits required by the decimal knob setting. M is unchanged. The R register, after the operation, has the result with all the decimal places, regardless of the decimal knob. for division only, if contains the remainder of the division. (if this is not clear, see this page)

The symbols for the four math operations are + - :

Before the symbol you can place the name of the register you want to do the operation with:

B+ Adds B to the accumulator
 C/: Divides the accumulator by the value contained in the first half of C

If no register is specified, the operation is made with the M register: + and M+ are synonimous.

Another mathematical operation available is the square root, that takes the operand from the specified register and leaves the result in A:


 D leaves in A the square root of D
 A leaves in A the square root of A
  leaves in A the square root of M
 F/ leaves in A the square root of F/

The last mathematical operation is absolute value. Absolute value is only possible within A itself (i.e., the absolute value of A is left into A) and is coded thus:

A

Literally, this notation would mean Exchange A with A (see Transfer functions), but as this has no meaning, the opcode is re-used for this operation.

Other operations that affect the value of the registers are the Transfer decimal part operation, classed as a transfer function, and the Clear register operation, classed in service functions).

More complex mathematical functions (like logs, sine, exponential etc.) have to be programmed. This is an example of a program that calulates the cosine of a number.

This page is part of the Programma 101 Web