Section 12: Subroutines181
The program with a subroutine would look like this:
  01 LBLTQROOT          
  02Ta?          
  03 PROMPT          
  04 STO 01       26 LBL 01  
  05Tb?       27 RCL 02  
  06 PROMPT       28 CHS  
  07 STO 02       29 RCL 02  
  08Tc?       30 X 2  
  09 PROMPT       31 RCL 02  
  10 STO 03       32 RCL 03  
  11 XEQ 01       33 *  
  12 â€“       34 4  
  13 RCL 01       35 *  
  14 2       36 â€“  
  15 *       37 SQRT  
  16 /       38 END  
  17 PSE          
  18 XEQ 01          
  19 +          
  20 RCL 01          
  21 2          
  22 *          
  23 /          
  24 PSE          
  25 RTN          
With this version of the program, execution begins with the label in line 1 and continues until the XEQ 01 in line 11. At this point, execution is transferred to the LBL 01 in line 26; this is the beginning of the subroutine. When the END in line 38 is encountered, execution is transferred back to line 12, the  â€“  instruction. Root r1 is displayed and the program continues.
When the XEQ 01 in line 18 is encountered, execution is transferred back to line 19 and root r2 is displayed.
The use of the subroutine saved you seven lines of program memory!
Before you key in the program, you may wish to clear other programs from program memory. Do so by executing CLP and specifying the name of the program you wish to clear. Remember, if you are in doubt as to what is in program memory, simply list CATALOG 1.