Section 12: Subroutines180
Here is a complete program for calculating the two roots of a quadratic square:
  00          
  01 LBLTQROOT          
  02Ta?          
  03 PROMPT          
  04 STO 01          
  05Tb?          
  06 PROMPT          
  07 STO 02          
  08Tc?          
  09 PROMPT          
  10 STO 03      
  11 RCL 02   28 RCL 02  
  12 CHS   29 CHS  
  13 RCL 02   30 RCL 02  
  14 X 2 These sections of program memory are identical. 31 X 2  
  15 RCL 01 32 RCL 01  
  16 RCL 03 33 RCL 03  
  17 * 34 *  
  18 4 35 4  
  19 *   36 *  
  20 â€“   37 â€“  
  21 SQRT   38 SQRT  
  22 â€“   39 +  
  23 RCL 01       40 RCL 01  
  24 2       41 2  
  25 *       42 *  
  26 /       43 /  
  27 PSE       44 PSE  
          45 END  
Since the routine for calculating r1 contains a large section that is identical to a large section in the routine for calculating r2, you can simply create a subroutine out of the duplicated instructions. The subroutine is then executed in both the solutions for r1 and r2. This subroutine is inside the program file. Since it occurs at the end of the program file, the END for the program file also acts as the end of the subroutine.