Registers

Mail me with a quote to go here...

by Ciaran McCreesh
Created: 13th September 1999
Last Modified: 27th November 1999

This page will explain what registers are and will list the basic registers on the ti86.

What are Registers?

Using the built-in language if you want to store a number you would put it in a variable. Using Assembly there are three options - you can save the number in a temporary memory location within the program, you can save the number in a variable that can be read by any program (or calculation) at any time on the calculator (as you do in the built-in language) or you can put the number in a register. Registers are temporary storage locations within the processor. They are not memory (for the technically minded I have been told that in the ti86 they are J-K flip-flops built into the processor).

Registers are more than just storage locations, however. If you want to perform an operation on one or more numbers then you must put the numbers in registers before performing the operation. If you have two numbers in memory that you want to add together then you could do the following (this is not a complete program):

Start_Of_Code_Example:
  ld a,(location_of_first_number)  ; Load a register with first number
  ld b,a                           ; Load b with a (you can't do ld b,(location))
  ld a,(location_of_second_number) ; Load a register with second number
  add a,b                          ; a = (a + b)
  ld (place_to_put_the_result),a   ; Load result memory location with a register
End_Of_Code_Example:

But the following would not work because you can't add the contents of two memory locations together directly:

  add (location_of_first_number),(location_of_second_number) ;This is not allowed.

Available Registers

Registers have names, not very descriptive names but still names. On the ti86 they are called a, b, c, d, e, f, h and l (I've coloured register names because register a can be confused with the letter 'a' - if your browser doesn't support CSS then you won't see this). There are also some other registers but they will be explained later. Some of the above registers have special uses, but they all have one thing in common - they are 8 bit registers. This means that they can hold any number made with 8 binary digits (bits), ie %00000000 = 0 to %11111111 = 255.

But what if you want to hold larger numbers? Some registers can be paired together to make 16 bit registers (they can hold up to %1111111111111111 = 65535). However, only certain registers can be paired with certain others. The table below will show which pairs can be used and what they can be used for.

Pair Usage
af By itself the a register is also called the accumulator - it is used to 'accumulate' the results of instructions. It is the only register that some logical and arithmetical operations can be performed on.
The f register on its own is the flags register - it is used to store the flags when two values are compared, for example.
The af register pair is rarely used.
bc By itself the b register is often used as a counter (eg in loops).
The c register has no real special purpose. The bc register pair is used as a counter in the 'block' (copy / compare a lot of stuff) instructions.
de The d and e registers on their own have no special purposes. The de register pair is used to store the destination in block copy instructions.
hl The h and l registers on their own have no special purpose. The hl register pair is often used as a pointer to a memory location (explained later).