Make your own free website on

The Absolute Basics

Table of Contents

The Chip Itself
Number Systems
The Stack
Back to the lesson index

The Chip Itself

The processor that runs the TI-82 (and 80, 81, 85, 83?, 86?) is a Zilog Z80 microprocessor. This is the same chip that ran the TRS-80 computer from Radio Shack. A modified version of this is what runs Nintendo's Game Boy. It runs at approximately 6 MHz, but because of how the timer works this varies based on the temperature, humidity, battery power, and whether Perot is running for president this week. The TI-82 uses an A RC (Resistor-Capaciter, not Radio Controlled) timing circuit. Although the chip in the TI-92 (which uses a crystal for timing) runs at a steady 10 MHz, your 82 is not the worst calc on the block... The HP48 G and GX run at only 4 MHz, and the HP S and SX run at only 2MHz. Graphing is so slow I once wrote a program to turn one on at some time late at night (usually 3AM) make graphs and save them, then turn off again. However, when I looked at assembler programs for them, they ran much faster than TI-82 BASIC programs. However, now that the 82 has assembly language, it is now the faster of the two calculators again! Another Game Boy note, supposedly the Game Boy only runs at 4MHz (but with a crystal) and with only 16K of RAM! Half of this RAM is Video RAM leaving only 8K for data! The catch is that it can use add in ROM cartridges of up to 512K in size.

Back to top


Now to business, like any other processor, the Z80 has registers. These are pieces of memory inside the chip that are faster than your RAM. For those who don't know, RAM stands for Random Access Memory, because you can access parts of it in any order you want to. ROM is Read Only Memory, that you can read, but not write over. ROM is used to store programs used by the TI to control it, so that if the batteries die, these programs are still intact. RAM, on the other hand is called "volitile" because if it doesn't recieve a "Memory Refresh Signal" every so often, it loses everything stored in it. The TI-82 has 32K of RAM, K is a kilobyte, or 1024 bytes. It also has the following registers: A, B, C, D, E, F, H, L, IX, IY, SP, A', B', C', D', E', F', H', L', PC, and I. You can't directly store to SP, PC, or I. (I may be wrong, but even if you can, it's a very bad idea) Here are a few things you need to know about these registers:
The registers A-E, H, and L are the general purpose registers, you can use them for almost anything.
A is the "accumulator" register, and is used for addition and subtraction.
F is the "flags" register. It is a very useful register, but it should not be used to store data because the data would soon be lost, and because you need this register for other things.
Sometimes registers are doubled up, for instance, B and C can be treated like a single 16 bit register called BC. The complete list of these is AF, BC, DE, and HL.
There is also an alternate register set that is almost invisible to the chip. The only way to use it is to use a command that switches a register with its alternate twin. For instance, you can swap A with A' or B with B'. The reason you do this instead of storing more values to memory is because compared with the speed of the registers, memory is slow! (Something they never tell you in computer stores...) Usually, it is better to store a value in a register than in memory. Even C++ for computers lets you do this.
The PC register is the Program Counter register. It tells the chip where to look for the next command. This is handled automatically so you don't have to worry about it.
The registers IX and IY are the Index registers. These are used by the 82 as signposts to tell it where to look for certain pieces of information, like whether to display a message normally or in reverse video. You may need to use these in your programs, but you should not change them.
The SP register is the Stack Pointer. Unless you are an advanced programmer you should never store to this variable. (It may even be locked up so that you can't store to it.) More info on the stack
The I register is the Interrupt mode register. Interrupts will be discussed a little farther down.

Back to top

Number Systems

The first thing you need to know to program assembler is the basic terms. A bit is short for BInary digiT, this is either a 1 or a 0. If a bit is 1 it is on or set. If it is zero it is off, or clear. 4 bits form a nibble. 8 bits form a byte. 2 bytes form a word. The Z80's commands mostly use bytes and words. Some affect only bits, but not many. A byte, having 8 bits can hold numbers from 0 to 255 (unsigned) or -128 to 127 (signed). I said earlier that there are 4 bits in a nibble, and 8 in a byte, but that the Z80 was concerned with bytes. Why worry about nibbles? You use them to represent any byte with symbols, rather than 1 to 3 (1 to 4 if unsigned). If you had to type every byte in either your hand would grow into your numeric keypad (PC users only, I think) or you would need a 256 key (at least) keyboard. Since the nibbles are composed of 4 bits they can have any of 16 values as shown below:
Number Nibble
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 A
11 B
12 C
13 D
14 E
15 F

When use in this way the nibble is called a hexit, for HEXadecimal digIT. Just remember that we count in decimal / base 10, nibbles are hexadecimal / base 16 and bits are binary / base 2. To tell which you're looking at in an assembler program look before, after, and at the number. Decimal numbers sit there looking normal or are followed by a "d" or "D". Hexadecimal numbers start with a "$" or end with a "h" or "H". Binary numbers end in "b" or "B" and are almost in groups of 8 or 16. Some languages let you specify a number as hexadecimal by putting "0x" in front of it, but most people get along fine with "d", "h" or "$", and "b".

Back to top

The Stack

The stack is used to temporarily store info that isn't worth devoting memory to or is used during interrupts. The stack is like placing coins in a spring loaded coin holder from a car. The first coin you put in is the last one that comes out. You access the stack with the Push and Pop commands. If you if you push a penny into the holder and then push a dime in, you have to pop the dime off before you can pop off the penny. Any program can use the stack, but it does have a maximum size.

Back to top


Every time you press a button on your calculator, an interrupt occurs. This makes the processor stop what it's doing, handle what just happened, then go back to doing what you told it to do. This is invisible to your program, so if your program doesn't use the keyboard, hitting ENTER fast enough will technically slow the calc down, but your program will never know that you hit the keyboard unless it checks. Your programs can use a trick with these. Anytime an interrupt occurs the processor checks to see which it was and looks up where the code that handles this interrupt is. The table that tells it where the interrupt handlers are is in RAM, meaning you can write your own routine that handles the interrupt, then make the table point to it. You might write a better routine to read he keyborad, or you might just make your handler leave a message for your program and then run the normal interrupt handler. This way your program would get a message every time a key was hit. In PC's this was taken even further and a small program would be written that makes the table of interrupts point to a piece of code, then the small program would end without changing the interrupt table back to allow normal operation. As a result, whenever (lets use the keyboard interupt as an example) the keyboard is hit, the new code might check to see if it was Esc or Ctrl-E or some other key. On TIs this would be set to a key you don't use much. Perhaps DEL, or for beginning users X, T, Theta. If not your handler would pass control to the normal handler, if it was DEL it might bring up a notepad or a password program.

Back to top

Questions, comments, flames? Send them in!
If you need help (more simple or more technical) tell me and I'll send it to you by e-mail. Also, is there anything in specific you want to see examples of? Let me know!