Creating a Function-Key Menu
When using a menu, you must design the program so that each function key transfers control to a specific program segment. Typically, you place a HLT instruction at the end of each segment to prevent the calculator from executing past the segment.
Building a Menu
To create a menu in a program, use a separate DFN instruction for each function key you want to define. After the final function key is defined, put a HLT instruction at the point in the program where you want the definitions displayed.The following illustration shows how you structure a program for a three function menu. Pressing [ F1 ], [ F2 ], or [ F3 ] transfers program execution to label AA, BB, or CC, respectively.
These instructions define the menu shown below:
DFN F1:1st@AA
DFN F2:2nd@BB
DFN F3:3rd@CC
HLT
LBL AA <--- [ F1 ]
...
HLT
LBL BB <--- [ F2 ]
...
HLT
LBL CC <--- [ F3 ]
...
HLT
Example Program 1
Write a program that creates a menu with options to calculate the third, fourth, or fifth root of a number.PC = | Program Mnemonics | Comments |
---|---|---|
0000 | `ROOTS` | Create a menu title |
0005 | DFN F1:3RD@AA | Defines F1 |
0012 | DFN F2:4TH@BB | Defines F2 |
0019 | DFN F3:5TH@CC | Defines F3 |
0026 | HLT | Stops program and displays menu |
0027 | LBL AA | Labels segment |
0030 | (INV y^x 3) | Calculates third root |
0035 | HLT | Stops program |
0036 | LBL BB | Labels segment |
0039 | (INV y^x 4) | Calculates fourth root |
0044 | HLT</td> | Stops program |
0045 | LBL CC | Labels segment |
0048 | (INV y^x 5) | Calculates fifth root |
0053 | HLT | Stops program |
Running Example 1
Test the program by calculating the third and fifth roots of a number.Procedure | Press | Display |
---|---|---|
Activate the menu | [ RUN ] { PGM } | |
Enter a number | 8 | |
Calculate 3rd root | { 3RD } | |
Enter a number | 3125 | |
Calculate 5th root | { 5TH } |
Example Program 2
This example lets you use the function keys to enter sides a and b of a right triangle. When you press { CAL }, the program calculates the length of the hypotenuse. (If the keyboard is not in lowercase lock, use [ 2nd ] A and [ 2nd ] B to enter the lowercase letters a and b.)
PC = | Program Mnemonics | Comments |
---|---|---|
0000 | `ENTER SIDES` | Creates menu title |
0011 | DFN F1:a @SA | Defines F1 |
0018 | DFN F2:b @SB | Defines F2 |
0025 | DFN F5:CAL@CH | Defines F5 |
0032 | HLT | Stops program and displays menu |
0033 | LBL SA | Labels segment |
0036 | STO A HLT | Stores side a in register A |
0039 | LBL SB | Labels segment |
0042 | STO B HLT | Stores side b in register B |
0045 | LBL CH | Labels segment |
0048 | (RCL A x^2 | Calculates hypotenuse |
0052 | + RCL B x^2) SQR | |
0058 | `HYP=` | Creates alpha message |
0062 | COL 16 MRG = | Merges result |
0066 | HLT | Stops program |
Running Example 2
Test the program by entering values that describe a "3-4-5" triangle.Procedure | Press | Display |
---|---|---|
Activate the menu | [ RUN ] { PGM } | |
Enter side a | 30 { a } | |
Enter side b | 40 { b } | |
Calculate hypotenuse | { CAL } |
☚ Back