Using Comparison Tests
You can use one of six comparison tests to compare the value in the numeric display register with the contents of a data register. (The value in the numeric display register is the 13-digit number use internally, not neccesarily the rounded value shown in the display.)
Available Comparisons
When you press [ TESTS ] the following menus is displayed.This menu enables you to select from the following comparison tests. (In this table, the word "display" means the value in the numeric display register.)
{ IF> } - Display greater than the data register contents?
[ INV ] { IF> } - Display less than or equal to the data register contents?
{ IF< } - Display less than the data register contents?
[ INV ] { IF< } - Display greater than or equal to the data register contents?
{ IF= } - Display equal to the data register contents?
[ INV ] { IF= } - Display not equal to the data register contents?
Note:
The { DSZ } and { Y/N } selections are described in later sections of this chapter.A comparison test compares the 13-digit numbers stored internally in the numeric display register and the specified data register. If you want the test to compare the numbers as they would be displayed, use { RND } to round them to the current display format.
Performing a Comparison Test
To include a comparison test in a program, use one of the following key sequences:- [ TESTS ] { IF> } nnn or X
- [ TESTS ] [ INV ] { IF> } nnn or X
- [ TESTS ] { IF< } nnn or X
- [ TESTS ] [ INV ] { IF< } nnn or X
- [ TESTS ] { IF= } nnn or X
- [ TESTS ] [ INV ] { IF= } nnn or X
For example, suppose you want to add 2 to the contents of the numeric display register and then determine if the result is equal to the contents of data register A. If the result is equal to the value in register A, you want the program to stop.
The key sequence to enter this test in a program is:
[ + ] 2 [ = ] [ TESTS ] { IF= } A [ HALT ]
- If the result of the addition is equal to the value in register A, the test result is true and the HLT instruction is executed.
- If the result of the addition is not equal to the value in register A, the test result is false and the HLT instruction is skipped.
Example
Program loops provide a good example of the advantages of using tests in a program. Write a program that counts by twos, like the example shown here, but uses a test to stop the loop when the count reaches 20.PC = | Program Mnemonics | Comments |
---|---|---|
0000 | 20 STO A | Stores comparison value |
0004 | CLR | Clears calculator |
0005 | LBL LL | Begins loop |
0008 | + 2= | Adds 2 |
0011 | PAU | Pauses to show result |
0012 | IF= A | Does count = 20? |
0014 | HLT | Yes - stop the program |
0015 | GTL LL | No - repeat loop |
Running the Example
Run the program and observe the result.Procedure | Press | Display |
---|---|---|
Run the program | [ RUN ] { PGM } | |
... | ... | |
☚ Back