Part Two:
The Z80 Microprocessor and Assembly Language Rudiments

    The TI-86 uses a 6 megahertz Z80 processor made by Zilog (www.zilog.com).  The 6 megahertz means that the processor is capable of executing six million menial instructions per second.  Yes, this is sluggish by modern comparison, but you must realize that this processor hasn’t changed since Zilog first introduced it in 1972.  You must give it credit for its durability, for the Z80 is still widely used and programmed for today, a good example being in that of Nintendo’s Gameboy.

    The Z80 can address up to 64k of memory.  This means that at any given moment, the Z80 will have 64k available to it, each byte having a specific address that is represented by a word, or a 16-bit number.  16-bits will hold a range of values from 0-$ffff, a range of 64k. $c000, for example, is an address within our 64k, different than the byte it addresses at $c000; $c000 is the pointer to the byte stored there.  When referencing the value at $c000 and not the pointer $c000 itself, parenthesis are put around the address: ($c000) is the byte addressed by $c000.  This method of referring to bytes is known as indirect addressing.  The byte ($c000) can be data, such as strings, tables and graphics, but it is most likely an executable instruction.

    Executable bytes of information are called instructions, and the range of instructions for a given microprocessor is called its instruction set.  Like characters or numbers, this is just a byteor more of addressable memory, but it’s unique in that an instruction has the special ability of giving commands to the microprocessor.  Assembly instructions are lexical words which, for simplicity, are modeled after words from the English language.  Each instruction has a corresponding hex value called an opcode (short for operation code).  The instruction <call $d748> has the opcode of CD48D7.  When an assembly language program is compiled, all instructions are made into opcodes so that they can be identified and then executed by the CPU.
    The calculator can also be programmed to run machine language, the language of hexadecimal opcodes that are fed directly to the microprocessor.  Assembly language instructions and machine language instruction parallels perform the same operations; the only difference between these two languages is in how these instructions are portrayed.  Assembly instructions are more meaningful and much easier to remember, giving you good cause to program in assembly over machine level.  See your 86 manual for instructions on programming in machine language.

    Microprocessors store data internally as well as externally (in addressed memory).  A byte of internal memory is called a register.  The Z80 has many registers, but only the registers that can be accessed through instructions are important to the assembly programmer, and are consequently the only registers touched on by this tutorial.  Each register also has a sister register, so that when put together they form a register pair.  These pairs are: AF, BC, DE, HL, IX, IY, PC, SP, and IR.  Some of these pairs have instructions that allow you to manipulate them as a pair, and not just as a single register.  Each register has unique capabilities, as you will see, which is part of the reason why the Z80 instruction set is so powerful.