2. The Z80 Microprocessor

by Cassady Roop

Computers often seem intelligent; they can do math, remember information, and follow instructions. Some can even speak to you and understand your replies, or read your handwriting, and find things for you stored in other computers on the other side of the planet! But they really are not intelligent (not yet at least). Thus the long-standing analogy of comparing the processor of a computer to a 'brain' may be a little misleading. It does perform brain-like functions, but this is only because the millions of switches inside it just happen to output a four when you add two and two.

THE PROCESSOR- A microprocessor does just what its name implies- it processes. But what does it process? How?

The processor is an integrated circuit, which is a small slice of silicon with thousands or millions of tiny transistor switches etched onto it, encased in a much larger chunk of plastic with little metal leads sticking out. When supplied with power and given an instruction, in binary, it performs that operation. Depending on the operation, it may or may not send data to or recieve data from memory, send data out to things connected to it, such as an LCD screen in the case of a TI86, or recieve data from another device, such as the TI-86 keyboard or the linkport.

A processor doesn't really understand that much. Some are limited to just a few instructions, like a microchip you would expect to find in a microwave oven or similar appliance; some understand quite a few instructions as in computer processors. The TI-86 definitely is a computer; it is far more similar to a desktop computer than a little pocket calculator.

Z80- The TI-86 is built around a fairly popular microprocessor chip called the Z80, manufactured by Zilog Corporation. It has found use in older home computers, the Nintendo Gameboy, the TI-8x series of graphing calculators, and many custom-built systems. This is kind of surprising, as it is actually a very old chip; it has been in use many years. Most other chips of its age have disappeared from general use, replaced by more powerful devices. But the Z80 is powerful, although maybe not quite as fast as its big brothers. And above all, the Z80 instruction set is relatively easy to learn.

The instruction set is all the instructions a processor can understand. Each instruction is sent to the chip as a code called an opcode, for 'operation code.' An opcode is written in hex, but at the processor level it is binary, of course, so it can understand it. Opcodes are numerous and unmemorable, so it is hard to remember the individual codes. For this reason, programmers use 'mnemonics' instead of actual opcodes. When the program is assembled, the mnemonics are replaced with the opcodes by an assembler program. Example:

mnemonicopcodemeans
call $4101CD0141call location $4101 in memory

Registers- Inside the microprocessor chip, there are several small but extremely fast pieces of memory. These are registers. A register is only one byte long, but some registers can be paired together to provide a two-byte register. Assembly programs use registers far more often than actual memory, which is outside the microprocessor. Registers are used to temporarily store a number, to perform operations on a number, or to load a memory address or its contents. The Z80 registers used by the TI-86 are shown below:

register purpose
A
B
C
D
E
F
H
L
accumulator, operations can be performed on numbers loaded in A
general purpose, loop counter
general purpose
general purpose
general purpose
flag register, not normally used in programs
general purpose
general purpose

And many can be paired together. Also, some registers can be used in pairs:
AF
BC
DE
HL
IX
IY
PC
SP
rarely used together because F is the flag register
general purpose, counter register, block moves
general purpose, addressing, block moves
general purpose, addressing, block moves
Index Register, rarely used
Index Register that points to system flags memory, not used often
program counter. points to next address to execute in a program
stack pointer. points to top of stack. don't mess with this!