Digit keys are never stored into programs, and when pressed they only serve to compose numbers into the M register.

This means that to use a constant within a program, for example if you need to multiply A times 5, you cannot enter the "5" digit into the program. There are mainly two ways of overcoming this problem.

1) Have constants pre-loaded into registers and recorded on card

For example, one might specify that register D holds the constant, and record the contents of D register on the magnetic card. When the user runs the program, it will find the needed constant already there. The problem is, there are vrey few registers in the P101, and wasting memory like this is not a very good idea.

This solution is only acceptable if the constants that are used are composed of many digits (see the example program to calculate cosine) or if they are used very very often in the program

2) Encode the constants as instructions

Otherwise, one would embed the constant into the program, encoding it in its native binary form, that gets displayed (and entered) as instructions. There is a special instruction (namely, A  /) that is used to specify that the following instructions are not to be intended as instuctions, but as a binary encoding of a constant. For example, in a program the following instructions encode a constant with the value of -10:

A  /   Mark the beginning of a constant
 F/S The least significant digit is a 0, is negative and has the decimal point (i.e. is the units digit)
 E  The next digit is a 1, and is the last digit.

To encode these constants, one builds the numbers a digit at the time, by having an istruction whose left part specifies the digit and left part specifies whether the number is positive or negative, wether the digit has the decimal point (i.e., identifies the units) and also marks the last digit of the constant. These codes can be worked out from two tables.

A simpler way to encode a number would be to turn on the machine, type the number on the keyboard and then press the commands A  . The number will be printed, followed by the equivalent instructions

This page is part of the Programma 101 Web