The Ultimate TI Calculator FAQ - Programming

by Patrick Davidson ( pad@ocf.berkeley.edu) - Return to FAQ index - Return to my main page
  1. How can I program in the calculator's built-in Basic language?
  2. How do I develop assembly programs?
  3. What programs do I need to build assembly programs?
  4. What DOS programs can I use to build assembly programs?
  5. What Windows programs can I use to build assembly programs?
  6. What Linux programs can I use to build calculator assembly programs?
  7. What Macintosh programs can I use to build calculator assembly programs?
  8. What is the best way to learn to program the calculators in assembly language?
  9. Where can I find good documentation and tutorials on calculator assembly programming?
  10. How can I program the TI-89 or TI-92+ in C?
  11. What about languages not mentioned above?

How can I program in the calculator's built-in Basic language?

The built-in Basic language of the calculator is explained in thorough detail in the calculator's manual. I see no point in repeating any of the manual's detailed explanations here.


How do I develop assembly programs?

Assembly programs are almost always written on computers. Programs are normally created first as text files on a computer, which are then assembled to produce executable files that can be sent to the calculator and run. It is possible to develop assembly programs on the calculator, but this presents many additional problems.

Since assembly source files are nothing but text files with the assembly program written in them, they can be created and edited with any program that can edit text files: MS-DOS Edit, UltraEdit, PFE, emacs, vi, Windows Notepad, etc. There are various programs that will assemble these files and produce calculator executables. There are also some Windows programs specifically designed for calculator assembly programming which have built-in editors and also allow you to assemble from inside of them.

Note that for the TI-89, TI-89 Titanium, TI-92 Plus, and Voyage 200, high quality C compilers are available, so you can get good results without using assembly language if you know (or learn) C. See the C section for more.

Of course, you can't just write a program once and expect it to work perfectly; it's also necessary to debug the programs. Programs are often tested on computers with emulators before being tried on the calculator. Emulators are programs that simulate the functioning of the calculator on the computer. Since a new, untested assembly program has a much higher chance of failing, testing things on the calculator first is likely to cause your memory to be erased requiring you to re-send everything. However, for emulators on the computer, you can reload a previous copy of the simulated calculator's memory almost instantly. Using emulators also avoids wearing out your link cable by plugging in your link cable every time you want to send a slightly changed version of your program. Finally, most emulators include debuggers, which allow you to simulate each instruction of your program step-by-step to help you understand what is going on. The most up to date emulators are \ TiEmu (for the TI-89 and above) and TilEm (for the TI-86 and below). The most popular emulator is still the somewhat older Virtual TI. You can find information about even more emulators from ticalc.org's page on emulators.

The TI-82 through TI-86 all use the Z80 processor (or a compatible one), so they all have essentially the same assembly language. The only difference between them is the interface you have to use to the operating system and the keyboard and display. Likewise, the TI-89, TI-92, and TI-92+ all have a 68000 processor (or a compatible one) so they have the same level of similarity.

Also, note that assembly programs use so-called "include files" which give definitions of the memory addresses to use to access system variables and functions. These files should be "included" in your program, which means that when the assembly assembles your program, it will act as if the text of the include file were inserted where the include command is, so all the addresses will be defined and you can use them in your program. The include files are different for each calculator (except TI-89 and TI-92+), and standard ones usually are included with the development tools, so you can just use those without worrying about them (the development tools section will have some specific information on this).

The next sections of this document describe which programs are needed for development, how to learn assembly programming, and what documentation you can learn from.


What programs do I need to build assembly programs?

As mentioned above, the first program you will need is a text editor. If you already have a favorite text editor, you should probably continue using it. If not, it doesn't really matter what editor you use, but you might want to consider one of the editors specifically designed for calculator assembly programming.

It is usually not necessary to understand the details of how the building process works; the building tools almost always include one simple program which automates the process.

To actually build assembly programs, you will usually need both an assembler and a linker. The assembler is the program which reads in your assembly source file and outputs binary machine code (and sometimes some other information as well). The linker is a program which converts the binary machine code for a particular program into an executable file usable on the calculator.

Note: the next two paragraphs explain details of the building process which beginning programmers don't need to understand at all. They are only here to explain some inner workings, and the feasibility of using or creating non- standard development tools.

When programming on Z80 calculators, programs are normally written to run at a constant address in memory. The output of an assembler is usually just the raw binary image, which must be copied to that address to work. The linker used in this case does nothing other than adding the header for TI Graph-Link files to this so they can be sent to the calculator. For this reason, you can use any Z80 assembler you want, as long as it outputs a raw binary image. However, it is probably a good idea to stick with the standard assemblers used by the TI community, as others expect slightly different source code formats. When building Usgard programs for the TI-85, the situation is slightly more complex as the programs don't have constant addresses; in this case, relocations must be marked in the source file, and the assembler outputs a list of these which the linker uses to build a relocation table.

For the 68K calculators, assemblers normally produce object modules, which contain not only the binary machine code image, but also relocation and symbol information. This is a more flexible system (allowing programs to be relocated and make a variety of external references), but requries you to use an assembler that supports the right output format, and makes the linkers more complicated.


What command line (DOS/Windows) programs can I use to build assembly programs?

Note that many of these building tools involve multiple programs, which will need to be able to locate each other. For this reason, you should make sure that all executables are somewhere in your path. Also, the TASM assembler (used in all Z80 calculators) needs a 'TASM80.TAB' file; you should set the TASMTABS environment variable to its location. Finally, it's a very good idea to always enter the directory your source file is in before you try to compile it.


What Windows programs can I use to build assembly programs?

Windows users can use all of the programs programs mentioned above. However, for many calculators, there are special Windows development tools as well, which usually have integrated editors from which you can assemble programs with just a few clicks. Here is a brief list of some of the more useful ones, certainly not complete:


What Linux programs can I use to build calculator assembly programs?

  • TI-GCC SDK. Note that the IDE of TIGCC is for Windows only but the rest of it will work on Linux. This is certainly the best system for developing programs for the TI-89 and TI-92+. You can use it to develop programs in assembly or C. It includes the TI-GCC library which has numerous functions and thorough documentation of using the system for both assembly and C programmers.
  • GCC4TI is a fork of TIGCC which works similarly.

    If you are developing for Fargo II for the TI-92, then you can simply get the Fargo II Unix toolkit which includes everything you need to build programs for Fargo II.

    There are many other Unix programs you can use. Beware that some of these development tools use assemblers with somewhat different syntaxes than are standard in the TI community, and may also be rather user-unfriendly. In my experience, if you want to assemble Z80 calculator programs under Linux, the easiest solution is probably to run the standard DOS tools with DOSEmu.


    What Macintosh programs can I use to build calculator assembly programs?

    Since I don't use a Mac, I can't really say too much here. However, you can look in ticalc.org's Mac archives for some programs. Unfortunately, it doesn't seem as if they have a complete set of development tools for every calculator.


    What is the best way to learn to program the calculators in assembly language?

    This section is intended to give general advice on how to learn assembly programming. It is not intended to teach you how to program, but only to explain the best way to learn. This is a subject on which different people have very different opinions, so no doubt some people will think this advice is all wrong. However, if you see any "advice" from someone saying stuff like the following:

    Hello, my name is [insert something or other] and I have been trying to learn to program assembly for several months. I'd like a little help with programming. Please don't tell me to do [insert something recommended in this FAQ] because I know it's better to [insert some ideas that this FAQ tells you to avoid]. Anyway I have been working on a [insert description of relatively simply program] and I think I've almost got it but I was wondering [insert a few questions which show the user lacks even a rudimentary understanding of programmin] ...

    you probably should trust this FAQ more, unless you really want to have to spend several months learning only the fundamentals of assembly programming. Keep in mind that I'm actually an experienced assembly programmer, and am advising you to do the things that worked best for me, and telling you to avoid the things that seem to cause the many problems I see beginners complaining about. Of course, even people who actually do know what they are talking about would probably disagree with me on some of these points.

    And now onto my list of ideas, in no particular order:


    Where can I find good documentation and tutorials on calculator assembly programming?

    There is a great deal of documentation on ticalc.org of varying quality. For the TI-89, TI-92 Plus, and Voyage 200, the TIGCC documentation is farily thorough.


    How can I program the calculator in C?

    The TI-GCC SDK (for Windows) is a complete development environment for the TI-89 and TI-92+ in both C and assembly. There is also a Linux version which lacks the graphical IDE but has everything else. It includes both the GCC compiler (a highly optimizing C compiler that is the standard compiler on Linux, and also is the core of DJGPP, which was used to build the DOS versions of Doom and Quake) and GNU assembler, as well as the A68K assembler (which was historically the assembler of choice for most calcuatlor assembly programmers). It also includes an extensive library (including most of the functions of the standard C library as well as many calculator-specific functions and interfaces to system routines), thorough documentation of the library (and the use of TI-GCC for C and assembly programming), and an editor. This is clearly the system of choice for programming for these calculators.

    TI-GCC 0.95 is the most recent C compiler for the calcuator that is marked as a release vesrion, but it is quite out of date. The "beta" version of TI-GCC (available on the TIGCC site) is more up-to-date, as is GCC4TI which is a fork of TIGCC.

    There is also a Linux version of TI-GCC which also has the same compiler and library available.


    What about languages not mentioned above?

    There are some programming languages you can use for the calculators that I haven't mentioned here. If you want to try them, you can find the compilers on ticalc.org. However, I recommend against using them.

    There are currently several C compilers for the Z80 calculators which are available from ticalc.org. They all have the common feature that they generate extremely inefficient code and most also don't come close to supporting all of the C language correctly.

    There is also a Pascal compiler called UltraPascal for the 68K calculators. The code generated is usually of tolerable quality, but not nearly as good as you get from TI-GCC.