Contributed by Claus Buchholz
Like its sibling, the TI-55, the MBA was given limited programmability with 32 steps and no conditional branching. That program memory is shared with four of the memory registers: 8, 9, [.] and [+/-]. If you enter a program and then look at those registers, you see that the program keycodes don't match the digits in the memories. The translation between keycodes and internal codes is the same as for the TI-55. See my article, "Hidden Opcodes on the TI-55," for the details.
Notice that the opcode (internal code) for RST is 13, which contains valid decimal digits. That means they can be stored in a memory register (the TI-55's RST code, 2F, cannot). So, a program entered into the MBA could alter the memory register containing the RST code to create a conditional branch.This factorial program demonstrates the technique:
00 51 STO Loop entry 01 01 1 Save current multiplier 02 55 × Multiply by previous product 03 01 1 04 84 +/- Negative one 05 71 SUM 06 01 1 Decrement multiplier 07 71 SUM 08 83 . Decrement loop counter 09 01 1 Most significant digit of register [.] 10 61 RCL 11 01 1 Recall current multiplier 12 41 RST Loop back unless loop counter has gone below zero 13 00 0 Loop counter stored here 14 00 0 Least significant digits of register [.] 15 08 8 Exponent digits of register [.] 16 81 CE Clear junk 17 01 1 Final multiplier 18 44 ) Close factorial calculation 19 42 R/S Start and stop here 20 43 ( Open factorial calculation 21 71 SUM 22 83 . Add in loop counter 23 41 RST Go to loop
After entering the program, the user presses RST and R/S to initialize. Thereafter, the user enters an integer from 1 to 69 and presses R/S to see the factorial of that number.
Program steps 09 through 15 make up the contents of memory register [.] containing the number 115011300 which has the mantissa digits 1.1501130000 and exponent digits 08. Notice the digits 13. They are the opcode for the RST in step 12. The next two zero digits will contain the loop counter. When the user enters a number and presses R/S, step 22 adds the loop count to the register and step 23 branches to the loop at step 00. Step 08 decrements the loop counter and step 12 loops back. When the loop counter decrements beyond zero, the number in register [.] becomes 115011299 and the RST code changes to the code for %. So the program does not loop back and step 16 clears the junk entered by the modified steps 12 through 15. Step 17 enters a one and step 18 finishes the multiplication.
It is a highly contrived program. Nine steps are dedicated to implementing the loop counter. But it does show that is is possible to program the MBA in a way that exceeds TI's intentions.
Using this techniqe, the MBA can do trig! This program calculates the Maclaurin series expansion for the sine or cosine of an angle in radians, accurate to all 10 displayed digits. It takes advantage of the fact that the ratio of consecutive terms is -x²/(2n(2n+1)) and that the difference of the differences of consecutive denominators of those ratios is 8. Still it is a bit too large for the MBA's program memory, so the user must initialize some memories each time. The entered program is the same for sine or cosine; only the initialization changes.
Enter the program: 2nd LRN RCL 3 +/- ÷ RCL 2 × SUM 4 8 SUM 1 SUM 9 RCL 1 SUM 2 RST × 0 = RCL 4 R/S x² STO 3 RCL 4 × RST
Initialize the program: 2 STO 2 R/S
Calculate the sine: 6 STO 2 STO 1 64 +/- SUM 9 angle STO 4 R/S
Calculate the cosine: 2 STO 2 STO 1 64 +/- SUM 9 1 STO 4 angle R/S
The loop counter steps by 8, so summing -64 into memory 9 causes the program to sum 64/8 or 8 terms. That is adequate for angles up to π/2. For angles up to π, use 80 +/- SUM 9 instead.
If you prefer degrees to radians and only need 3 digits' accuracy, try this simple program for angles up to 45°: 2nd LRN ( CE ÷ 57.3 - CE × x² × .162 ) STO 0 ( 1 - RCL 0 x² ) 2nd √x R/S RST 2nd LRN RST 2nd FIX 3
Enter the angle and press R/S to see the cosine, then press RCL 0 to see the sine.
And you thought the MBA wasn't a real calculator!