Unity 1.1

Unity is an assembly program loader for the Texas Instruments TI-81 graphing calculator. It serves as an extension to the TI-81's operating system, allowing you to run your own Z80 assembly programs on the calculator.

Assembly programs can be considerably faster than those written in the calculator's built-in, BASIC-like language. Assembly programs can also do many things that are impossible or extremely difficult in BASIC. Unfortunately, this power also means that assembly programs can easily crash the calculator, destroying any data and programs you have saved, and often requiring a full reset of the calculator. Unity has been tested a fair amount, but bugs do creep in, and there is, of course, no warranty of any kind for this software.

The latest version of this program can be found on ticalc.org.

Supported hardware

Unity is intended to work on any version of the TI-81, either the "old" or "new" style hardware. While Unity has not been tested on every ROM version in existence, it is likely that it will work on all of them.

Most assembly programs, however, use ROM subroutines (e.g., for printing text or scanning the keypad), and these routines need to be catalogued separately for each ROM version. The example programs in this package currently support ROM versions 1.1K, 1.6K, 1.8K, and 2.0V. To find your ROM version, press 2nd MATH ALPHA LN. (Then press CLEAR to exit the screen.)

Information about other ROM versions is always welcome; you can contact me at floppusmaximus@users.sourceforge.net.

Note about emulators

Unity will work on any true TI-81 emulator (one that emulates the "ghost RAM" space.) I'm aware that some folks have tried running a TI-81 ROM image with a TI-85, TI-86, or TI-82 emulator; although Unity itself would work fine on such an emulator, the installation procedure described below will not. A special (and somewhat more complex) installation procedure would have to be developed in order to support those emulators.

Unity will not work on TI's PC-81 emulator, since that program does not emulate the calculator's Z80 CPU at all.

Installing Unity

Read the following instructions carefully and follow the steps in the order shown. If you type something incorrectly, the calculator may or may not crash, but it almost certainly won't work right.

Note: Installing Unity will replace any existing assembly loader or shell on your calculator.

Creating the installer programs

To begin, enter the following three programs into the calculator. The first program must be entered as Prgm0; the other two can use different program slots if you prefer. The left column shows the program as it appears on the calculator screen; the right column shows the individual keys to press.

Don't forget the blank line at the end of Prgm0; it's important.

Prgm0: UDATA
:JRTVWIHIWTUKHRS 2nd ALPHA EE; ×; 4; 6; -; ; ^; ; -; 4; 5; (; ^; ×; LN
VTHJKHTJHWQVSJIH 6; 4; ^; EE; (; ^; 4; EE; ^; -; 9; 6; LN; EE; ; ^
OHHTUQSUKUPTHPOJ 7; ^; ^; 4; 5; 9; LN; 5; (; 5; 8; 4; ^; 8; 7; EE
PWPVUNRKHWQJJPWU 8; -; 8; 6; 5; LOG; ×; (; ^; -; 9; EE; EE; 8; -; 5
KHNHRKNHITUQSUKK (; ^; LOG; ^; ×; (; LOG; ^; ; 4; 5; 9; LN; 5; (; (
PIPJHIIPOJPWNTSI 8; ; 8; EE; ^; ; ; 8; 7; EE; 8; -; LOG; 4; LN;
NKHWQJKKNHIIHWLJ LOG; (; ^; -; 9; EE; (; (; LOG; ^; ; ; ^; -; ); EE
SOVSUJPVLKVUKJWV LN; 7; 6; LN; 5; EE; 8; 6; ); (; 6; 5; (; EE; -; 6
OTQOQVNWPJHWNWST 7; 4; 9; 7; 9; 6; LOG; -; 8; EE; ^; -; LOG; -; LN; 4
UTUUKWWKVHQKJHPV 5; 4; 5; 5; (; -; -; (; 6; ^; 9; (; EE; ^; 8; 6
KKJHTVKTQVMJRUHW (; (; EE; ^; 4; 6; (; 4; 9; 6; ÷; EE; ×; 5; ^; -
IKOVUMJVIUPIRTNI ; (; 7; 6; 5; ÷; EE; 6; ; 5; 8; ; ×; 4; LOG;
LTPTNQKWVISKPIHT ); 4; 8; 4; LOG; 9; (; -; 6; ; LN; (; 8; ; ^; 4
MVMJIWOUKHIHMHHV ÷; 6; ÷; EE; ; -; 7; 5; (; ^; ; ^; ÷; ^; ^; 6
USIOQVITITHTNISV 5; LN; ; 7; 9; 6; ; 4; ; 4; ^; 4; LOG; ; LN; 6
UMKTVWIIKRQHOHOH 5; ÷; (; 4; 6; -; ; ; (; ×; 9; ^; 7; ^; 7; ^
OLWVNWPWNHLSWTQH 7; ); -; 6; LOG; -; 8; -; LOG; ^; ); LN; -; 4; 9; ^
HHHHHHHHHWMTMUMV ^; ^; ^; ^; ^; ^; ^; ^; ^; -; ÷; 4; ÷; 5; ÷; 6
MKVSWUKHIUSHIVVV ÷; (; 6; LN; -; 5; (; ^; ; 5; LN; ^; ; 6; 6; 6
VJHHLWUTSHIUVJIT 6; EE; ^; ^; ); -; 5; 4; LN; ^; ; 5; 6; EE; ; 4
UUKWUTSHHMNTLLOU 5; 5; (; -; 5; 4; LN; ^; ^; ÷; LOG; 4; ); ); 7; 5
KVIUITIWITKKPHHH (; 6; ; 5; ; 4; ; -; ; 4; (; (; 8; ^; ^; ^
HVTTMWULHUKSQVTJ ^; 6; 4; 4; ÷; -; 5; ); ^; 5; (; LN; 9; 6; 4; EE
NJNOU LOG; EE; LOG; 7; 5; ENTER
:SXUGBTYICV"UNV? 2nd ALPHA LN; STO▸; 5; TAN; MATRX; 4; 1; ; PRGM; 6; +; 5; LOG; 6; (-)
FHLEMCJ θYYAAθPH COS; ^; ); SIN; ÷; PRGM; EE; 0; 3; 1; 1; MATH; MATH; 3; 8; ^
UQMGNFWCLHU  LCT 5; 9; ÷; TAN; LOG; COS; -; PRGM; ); ^; 5; 0; 0; ); PRGM; 4
CWBLBMZIAXPOBIRA PRGM; -; MATRX; ); MATRX; ÷; 2; ; MATH; STO▸; 8; 7; MATRX; ; ×; MATH
J,? AFY  NHD"AAB EE; .; (-); 0; MATH; COS; 1; 0; 0; LOG; ^; x⁻¹; +; MATH; MATH; MATRX
AAFJJD,LAXPOBMRE MATH; MATH; COS; EE; EE; x⁻¹; .; ); MATH; STO▸; 8; 7; MATRX; ÷; ×; SIN
"PYHTGBNθ"QLXθZθ +; 8; 1; ^; 4; TAN; MATRX; LOG; 3; +; 9; ); STO▸; 3; 2; 3
WRT YELI ERINSUθ -; ×; 4; 0; 1; SIN; ); ; 0; SIN; ×; ; LOG; LN; 5; 3
?XZTFAGOAJJAIRNθ (-); STO▸; 2; 4; COS; MATH; TAN; 7; MATH; EE; EE; MATH; ; ×; LOG; 3
 V"VNZVSTI"XCUNA 0; 6; +; 6; LOG; 2; 6; LN; 4; ; +; STO▸; PRGM; 5; LOG; MATH
HKBπPTPPRJθE ^; (; MATRX; 2nd ^; 2nd ALPHA 8; 4; 8; 8; ×; EE; 3; SIN; ENTER
:
Prgm1: USETUP
:"Y3OffH0Wtan-1  ALPHA +; 2nd VARS 4; ALPHA ^; 0; ALPHA -; 2nd TAN
* nCr tan = nPr  ×; MATH 3; TAN; 2nd MATH 1; MATH 2
XmaxSci8(ClrHo VARS 2; 2nd MATH 6; MODE 2; 8; (; 2nd MATH 2; PRGM 5
mePTOn(XmaxFPar 2nd PRGM 3; VARS 2; MATH 3
t Bcol2 Y4OnPT VARS 4; 2; ALPHA 0; 2nd ; 2nd VARS 5; 2nd PRGM 3
On(2DispHomeAl 2nd MATH 2; 2; PRGM 3; 2nd VARS 1
lOnScatterlog 8 2nd MATRX 2; LOG; 8
aY1T+W+X3TOnF  VARS 1; 2nd VARS 6; +; ALPHA -; +; 2nd VARS 8; ALPHA COS; 2nd MATH 6; ALPHA 0
 DispHomeConnec 2nd MATH 2; ALPHA 0; PRGM 3; MODE 3
tedRP(log 0.38A MATH 1; LOG; 0; .; 3; 8; 2nd VARS 1
llOnXminY3Off0 VARS 1; 2nd VARS 4; 0
SequenceY25PTOf MODE 5; 2nd VARS 2; 5; 2nd PRGM 4
f(Y2OffY2OnPT 2nd VARS 3; 2nd VARS 3; 2nd MATH 2; 2nd PRGM 4
Off(!ClrDrawY2 MATH 5; 2nd PRGM 1; 2nd VARS 3
On*Row+(AllOffY MATRX 4; 2nd VARS 1; 2nd VARS 3
2OnPTOff(sinh 2nd MATH 2; 2nd PRGM 4; MATH 1
 "PTOff(AllO ALPHA +; 2nd MATH 2; STO▸; 2nd PRGM 4; 2nd VARS 1
nY3OffDispHomeB 2nd VARS 4; PRGM 3; VARS 3
rowY3)PTOff( D 2nd VARS 3; ); 2nd PRGM 4; 2nd MATH 2; ALPHA 0; PRGM 3
ispHome1-1AllOff 1; x⁻¹; 2nd VARS 1
Round(.BcolCcol2 MATH 1; .; VARS 4; VARS 6; 2
Y2PTOff(X3T" 2nd MATH 6; STO▸; 2nd VARS 2; -; 2nd PRGM 4; 2nd VARS 9; ALPHA +
Y2 STO▸; 2nd VARS 2; ENTER
:"PTOn("Y3T ALPHA +; 2nd PRGM 3; ALPHA +; STO▸; 2nd VARS 0; ENTER
:"(1)^π"Y1 ALPHA +; (; (-); 1; ); ^; 2nd ^; ALPHA +; STO▸; 2nd VARS 1; ENTER
:0X 0; STO▸; ALPHA STO▸
Prgm2: ULAUNCH
:"PTOn(PTOn(PT ALPHA +; 2nd PRGM 3; 2nd PRGM 3; 2nd PRGM 3
On(PTOn(PTOn( 2nd PRGM 3; 2nd PRGM 3
PTOn(PTOn(PTO 2nd PRGM 3; 2nd PRGM 3; 2nd PRGM 3
n(PTOn(PTOn(PT 2nd PRGM 3; 2nd PRGM 3; 2nd PRGM 3
On(PTOn(PTOn( 2nd PRGM 3; 2nd PRGM 3
PTOn(PTOn(PTO 2nd PRGM 3; 2nd PRGM 3; 2nd PRGM 3
n("X3T ALPHA +; STO▸; 2nd VARS 9; ENTER
:X+1X ALPHA STO▸; +; 1; STO▸; ALPHA STO▸; ENTER
:If X<9 PRGM 3; ALPHA STO▸; 2nd MATH 5; 9; ENTER
:Prgm2 PRGM 2; ENTER
:0X 0; STO▸; ALPHA STO▸; ENTER
:Input X PRGM 2; ALPHA STO▸

Running the installer

Once you've entered the programs above (and double-checked Prgm1 to be sure it's correct), do the following:

  1. Turn the calculator off and back on.
  2. Be sure the calculator is in Function mode.
  3. Run Prgm1.
  4. Run Prgm2. It will run for a little while and then display a question mark (?). Press 2nd CLEAR to exit the program.
  5. Press Y= to open the equation editor. Press ENTER twice to move down to Y3.
  6. Type lots and lots of garbage into Y3, until the calculator won't let you type any more. It's important that the equations be completely full.
  7. Return to the home screen and run Prgm2 again. This time, when it displays a ?, type Y1 (2nd VARS 1 ENTER.)
  8. The calculator will display an error message. Press ENTER again ("Goto Error") which should take you to the equation editor. Press 2nd CLEAR to return to the home screen. (Note: if you accidentally press CLEAR before pressing 2nd, thus deleting the contents of Y1, then immediately turn the calculator off, and start over with step 1.)
  9. Repeat steps 7 and 8 four more times. The fifth time you run Prgm2, rather than displaying a ?, it will launch the installer.

After a few seconds, one of the following will be displayed:

E
Something was typed incorrectly, probably in the first section of Prgm0. Press ON to turn the calculator off, then turn it back on, check the programs for errors, and try again.
EE
Something was typed incorrectly, probably in the second section of Prgm0. Press ON to turn the calculator off, then turn it back on, check the programs for errors, and try again.
:)
Unity has been successfully installed! Press ON to turn the calculator off, then turn it back on. You can erase Prgm0 and Prgm1 at this point – you won't need them again. You may want to keep Prgm2 for re-installation purposes (see below.)

Note: after erasing the installer programs, you may notice that you have 442 fewer bytes of free memory than you had before (unless you previously had a different assembly loader or shell installed.) This is normal and expected.

Using

To run an assembly program, just type it in and run it as you would a normal BASIC program. (If you want, you can call an assembly program as a subroutine from a BASIC program, or even embed assembly code in the middle of a BASIC program.) Assembly programs begin with a Pause command (PRGM 6), followed by ++ and a long line of text.

If you type something incorrectly in an assembly program, you will receive the message ERROR 53 INVALID. Press ENTER to view the location where the error was detected (the actual incorrect character is probably either immediately after the cursor or somewhere in the line above it.)

Here is an example program you can try:

Program: HELLO
:Pause PRGM 6; ENTER
:++RπθRCF?VIMYEN +; +; ALPHA ×; 2nd ^; 2nd ALPHA 3; ×; PRGM; COS; (-); 6; ; ÷; 1; SIN; LOG
XWθRRJ?"FXK NOEE STO▸; -; 3; ×; ×; EE; (-); +; COS; STO▸; (; 0; LOG; 7; SIN; SIN
NEBL",GBQLπPI ,G LOG; SIN; MATRX; ); +; .; TAN; MATRX; 9; ); 2nd ^; 2nd ALPHA 8; ; 0; .; TAN
A MATH

If a program crashes

When a BASIC program crashes, you can always halt it by pressing ON. This is not true for most assembly programs, because by their nature they take full control of the CPU. If an assembly program freezes, you can force the calculator to power off by pressing and holding the Y= and GRAPH keys, then pressing ON. This will work so long as the assembly program does not disable interrupts; I highly recommend that, in writing assembly programs, you leave interrupts enabled whenever possible.

Writing assembly programs

You can use the asm81 assembler, included with this package, to assemble programs. The ti81.inc header file defines a large collection of ROM routines, RAM areas, and constants that you can use. Many of the ROM routines are similar to their counterparts on later TI calculators, but there are some important differences. See program.txt for more information.

Re-installing

When you change the calculator's batteries, the CPU is reset, thus disabling Unity (or any other IM 2 hook.) The RAM contents, however, are retained (you are using a backup battery, right?) Assuming Unity was properly installed prior to removing the batteries, you can use the following program to re-enable it, rather than having to retype the full installer code.

If Unity was not previously installed correctly, running this program will crash the calculator completely.

Enter the following program, as well as Prgm2 from above.

Prgm3: URELOAD
:"log 8sinh Y1O ALPHA +; LOG; 8; MATH 1; 2nd VARS 2
ff2-12Fsinh 0Disp 2; x⁻¹; 2; ALPHA COS; MATH 1; 0; PRGM 3
HomeBrowY3X1TOf VARS 3; 2nd VARS 3; 2nd VARS 6
fPTOn(X2TOnPT 2nd PRGM 3; 2nd MATH 2; 2nd VARS 7; 2nd PRGM 3
On(XmaxFPart Bc VARS 2; MATH 3; VARS 4
olAllOffPTOn( 2nd ; 2nd VARS 1; 2nd PRGM 3
Y4OffPTOn(All 2nd MATH 2; 2nd VARS 5; 2nd PRGM 3; 2nd VARS 1
OnY3Off2DispH 2nd VARS 4; 2nd MATH 2; 2; PRGM 3
omeAllOnScatter 2nd VARS 1; 2nd MATRX 2
8PTOn("Y2 8; 2nd PRGM 3; ALPHA +; STO▸; 2nd VARS 2; ENTER
:"PTOn("Y3T ALPHA +; 2nd PRGM 3; ALPHA +; STO▸; 2nd VARS 0; ENTER
:"(1)^π"Y1 ALPHA +; (; (-); 1; ); ^; 2nd ^; ALPHA +; STO▸; 2nd VARS 1; ENTER
:0X 0; STO▸; ALPHA STO▸

To run this program, use basically the same procedure as for the original installation:

  1. Turn the calculator off and back on.
  2. Be sure the calculator is in Function mode.
  3. Run Prgm3.
  4. Run Prgm2. It will run for a little while and then display a question mark (?). Press 2nd CLEAR to exit the program.
  5. Press Y= to open the equation editor. Press ENTER twice to move down to Y3.
  6. Type lots and lots of garbage into Y3, until the calculator won't let you type any more. It's important that the equations be completely full.
  7. Return to the home screen and run Prgm2 again. This time, when it displays a ?, type Y1 (2nd VARS 1 ENTER.)
  8. The calculator will display an error message. Press ENTER again ("Goto Error") which should take you to the equation editor. Press 2nd CLEAR to return to the home screen. (Note: if you accidentally press CLEAR before pressing 2nd, thus deleting the contents of Y1, then immediately turn the calculator off, and start over with step 1.)
  9. Repeat steps 7 and 8 four more times. The fifth time you run Prgm2, rather than displaying a ?, it will display a *. Press ON to turn the calculator off, then turn it back on; Unity should now be reinstalled.

About this program

The programs in this package are free software, and you are permitted (and encouraged) to modify and/or redistribute them, under the terms of the GNU General Public License.

There is no warranty of any kind for this software; please see the GNU General Public License for more information.

Thanks

A few people deserve a lot of credit for helping to make this program possible:

Joerg Woerner has published a lot of great information about the hardware internals of the TI-81 (and lots of other devices besides.)

Xavier Andreani (aka critor) has been extremely helpful in finding information about the less common early versions of the TI-81.

And Randy Compton (aka Mr. Z) discovered the OS bug that is used to launch the Unity installation, not to mention publishing some very helpful documentation of ROM 1.8K.

Finally, thanks to the entire calculator programming community for being so awesome!