Introduction


A test enables a program to skip the execution of an instruction, depending on some condition in the program. For example, you can design a program to execute a particular instruction only if the result of a calculation is greater than 100.


Types of Tests

You can use four types of tests in your program. These tests are accessed through the [ TESTS ] and [ FLAGS ] keys.
  • Comparison Test - Compares the value in the numeric display register with the value in a data register.
  • DSZ Test - Decrements (or increments) the value in a data register and then tests if the value is zero.
  • Flag Test - Tests the status of a flag to determine if it is set or reset.
  • YES/NO Test - Lets you control the execution of a program by responding to a yes/no question.

How a Test Affects Program Execution

When using a test, you specify a condition to test. The program tests that condition and determines if the result of the test is true or false.
If the result is true, program execution continues in normal sequential order.
If the result is false, the program skips the first instruction that follows the test.

This rule is summarized as "Do If True, Skip If False".
testinstruct
Because a test determines whether the next program instruction is executed, you can perform tests only in a program- not from the keyboard.

Using a Test

For example, you may want to use a test to determine whether to execute a memory operation such as RCL A. This case is illustrated below. If the result of the test is true, the RCL A instruction is executed. If the result is false, the RCL A instruction is skipped.
testrcla
Although a test skips only one instruction, you can make a program skip or execute entire segments by using a transfer instruction following the test.

For example, you may want a program to transfer to a segment labeled BB if a certain condition is true. This case is illustrated below. If the result of the test is true, the GTL BB instruction is executed. If the result is false, the GTL BB instruction is skipped.
gtl
If the instruction following a test is an inverse function, such as INV SIN, only INV is skipped.

Back