Lesson 1Let's start our exploration of microprocessor programming with a simple program. We're going to flash some LEDs that are connected to ports A and B. We have seen this example on the programs page, but there we used the program to explain what an assembler will do for you. Now we are going to explain how the program actually works, and why it works the way it does. But before we begin, let me explain two basic instruments of the Sitcom computer that we're going to use. |
Software dashboardEvery microprocessor has a certain internal architecture. Our 8085 has a number of internal registers to work with. You can consider these registers to be the software dashboard, the controls and dials of the microprocessor. All programs use these, or at least some of these registers. The most important registers are the Accumulator (Short A or Accu), and the program counter (PC). Let me start with explaining the program counter: The program counter is a 16-bit register, and holds a pointer to the memory location of the next instruction that will be executed. During reset this program counter is reset to a value of 0, which means that all our programs will start at address 0000H. After execution of an instruction the program counter will be incremented to point to the next instruction in memory. This incrementing will continue indefinitely, unless a special instruction alters the PC. Jump and Call instructions are typical instructions that can alter the program counter's value, and cause the program to continue from a totally different location in memory. We'll see lots of examples of these Jump and Call instructions in this and subsequent lessons.
The Accumulator is the most important working register in the 8085.
All calculations are done with the Accumulator as origin and destination of the data.
Being an 8-bit processor, the 8085's Accumulator can hold only 8 bits of data, restricting its math capabilities to numbers ranging from 0 to 255.
Special tricks are required to perform more complex arithmetic.
Apart from the Accu and PC the 8085 has some more registers.
The registers B, C, D, E, H and L are typically used as scratch pad registers.
They are all 8 bits wide, and each of them can thus hold the same kind of values as the Accu.
Typically one of these registers hold the second operand during dual operand operations, like addition and subtraction.
The registers H and L can be concatenated to a 16-bit register to hold a pointer to point to some data in memory.
|
Input & OutputEvery computer needs some form of Input and Output (in short I/O). Input signals affect the behaviour of the program, while output signals are used to indicate the internal status of your program or control some actions based on the input status.
The basic form of Sitcom has one device for input and output, the 8255 chip (not counting the optional DL1414 displays).
This chip has a total of 24 lines, that can be used as digital input or output.
All of these lines are at our disposal on the I/O connector.
All 3 ports can be written to and read from using the 8085 I/O instructions.
Each port has its own I/O address.
Port A has I/O address 000H, port B has I/O address 001H, and port C has I/O address 002H.
A 4th I/O address on the 8255 is reserved as control register. This register mainly determines the direction of each of the I/O ports. It is also used to select special tricks, but these will not be covered (yet). You can consult the 8255 data sheet to learn about the special features of the 8255 if you like. The table above shows you the 8255 control register, which is addressed by the I/O address 003H on the basic Sitcom.
Please note that after reset all ports are switched to input mode.
Warning:
No document I have seen describing the 8255 mentions the fact that all outputs are initialized to "0" when the mode register is written to.
So no matter what the output latches contained previously, their contents are cleared to "0" once the control port is written to.
I had to learn the hard way, when smoke came out of my EPROM programmer because a low signal shorted the 25V programming voltage each time the direction of one of the I/O ports was changed. |
Continue Lesson 1 - A first attempt to flash some LEDs |
[Home] [Latest News] [Essentials] [Hardware] [The Build] [Programs] [Projects] [Downloads] | |||