Logical functions

These instructions are basically jump instructions. There are unconditional jumps, that are always done, and conditional jumps, that are done only if A > 0.

The logic of a jump is the following:

There is a destination instruction (today we would call it a label) in the middle of the program, that serves only as a placeholder to specify the destination of the jump.

The origin instruction is the proper jump instruction. The program is scanned until the destination instruction is found, and program execution is transferred.

The codes for the jump instructions are not very mnemonical, and make use of the special keys V, W, Y and Z. Please note that register names here have no relation to registers, and are used only to differentiate jumps.

For example, when the program finds a jump instuction C V, it will scan all the instructions searching for the label B V, and jump there.

These are the available jump instructions:

 Origin instruction  Destination instruction
V  A V
W  A W
Y  A Y
 Z  A Z
 C V  B V
 C W  B W
 C Y  B Y
 C Z  B Z
 D V  E V
 D W  E W
 D Y  W Y
 D Z  E Z
 R V  F V
 R W  F W
 R Y  F Y
 R Z  F Z

There are thus 16 possible jumps that can be implemented in programs. In reality, there are more, as several origin instructions may point to the same destination instruction.

The first four jumps are used for special purposes: as their code is composed of a single character, they are very commonly used to let the user specify actions to perform. For example, to have a very simple program that lets the user enter several numbers and then print their sum, one would have the user enter each number followed by the pressing of key S, and when the numbers are finished the user should press Z to know the results. Pressing Z would cause the program to jump to the label A Z, where the sum would be done.

This would be the program:

 A V Program start. Conventionally, an A V instruction (destination instruction for jump) is placed at the beginning of the program, so that the user can run the program pressing the V key.
 A * Clear register A, where we will calculate the sum.
 B V Destination instruction. This is the label for jump instruction C V below, that implements the loop that keeps asking user input.
 S Stop and wait for user input. If the user presses S after the number, execution proceeds with the following instruction. If the user presses Z, we proceed to A Z, where the result is printed.
 + The user has input its number, that will be found in M. Add M into A.
C V  Jump instruction. Jump back to B V, and ask another number..
 A Z  Destination instruction for jump Z. Note that the program does not contain the Z jump instruction, it will be the user that will press the Z key when the numbers are finished, therefore causing the program to jump here.
 A  Print the value stored into A
 V  Go back to the beginning of program

Conditional jumps are very similar in structure, except that they use the split operator to distinguish them from the unconditional ones:

 Origin instruction  Destination instruction
/V  A/V
/W  A/W
/Y  A/Y
/Z  A/Z
 C/V  B/V
 C/W  B/W
 C/Y  B/Y
 C/Z  B/Z
 D/V  E/V
 D/W  E/W
 D/Y  W/Y
 D/Z  E/Z
 R/V  F/V
 R/W  F/W
 R/Y  F/Y
 R/Z  F/Z

This page is part of the Programma 101 Web