We left off in our discussion of executing the program. In the first section, we had executed command 0 and 1 and now we were picking up at counter executing 0002. In addition, the program counter has been incremented twice, so we were now ready to access location 002, which contains our next instruction.
The microprocessor now begins to access memory by outputting the program counter to the address bus and activating the control bus signal memory-read. It outputs the address and again, accesses the memory-read. The ROM places the information, and this is going to be D3, which means we're going to have an output.
The ROM places the information D3 on the data bus and the microprocessor latches it into the instruction register. It's latched into the instruction register within the processor and this is the information saying “output”.
Upon decoding the instruction, the microprocessor must obtain another byte to determine which device should receive the data. Therefore, we increment the program counter and again gain access to memory. This time, two comes down from the data bus and we hold it in a temporary latch. Here we said we want to have an output and then this specifies the device number.
The microprocessor now has everything required to execute the instruction and proceeds to do so. Recall this was device #1 and this is device #2.
The device #2 is sent from the temporary latch to the address bus. Device number 02 is sent on the address bus from the temporary latch here to the address bus. The signal I/O write this is a write command is activated on the control bus and the contents of the accumulator are sent down the databus. The address bus calls to the #2 device, at that same moment the control bus comes over here, enables it, and then the data is sent out to the output.
The coincidence of I/O write on the control bus and 02 on the address bus causes the 8-bit output latch to be enabled. This was, in fact, enabled. This means that the information now on the data bus will be latched and presented to the LED. The information that we had originally inputted in our input device, which was stored here, is now outputted to the latch and it will be displayed on the LEDs.
With the second instruction complete, the busses are deactivated, the program counter is incremented and we're ready for another instruction fetch. Notice the processes so far has resulted in the states of the switches being displayed on the LEDs. There were, of course, a few nanoseconds or microseconds of delay in the accumulator.
The microprocessor now outputs the program counter to the address bus and memory-read to the control bus. This is the same thing we've done before as we read the contents of ROM. Down the data bus from ROM comes C3, which is our next instruction. Our next command here, instruction here and that is going to be C3.
This byte is loaded into the instruction registry, it comes from ROM into the instruction register and it is decoded. Upon decoding, the microprocessor determines that this is a 3-byte instruction, so it must access two more memory addresses. The program counter is incremented. The memory is addressed and down the data bus comes 00. That's our next byte.
The microprocessor holds this in a temporary storage register, and that is this one right here. The program counter is incremented and sent to the address bus with 006 on the address bus and memory-read on the control bus, the memory kicks out again, 00 to the data bus. The microprocessor accepts this byte and is now ready to complete the execution phase of the instruction.
Instruction execution, in this case, is a matter of transferring the last two bytes received and being held in temporary storage into the program counter. Remember, the program counter always points to the address of the next instruction. Since we are now forcing it to 0000, and that's the hex value, that will be the address of our next instruction, which happens to be where we began.
The process will continue from there in an exact loop replay of our proceeding discussion. A structure of this type is called a program loop, more specifically an infinite loop. Each time through the loop, we will put the status of the switches and transfer those data to the indicators. Although this is a trivial application of a microprocessor, it should serve as an adequate example of the sequential instruction of any microprocessor.
All communications are carried out via the three buses which identify what, where and when, all data are transferred.
Video Lectures created by Tim Fiegenbaum at North Seattle Community College.
by Gary Elinoff
In Partnership with Future Electronics
In Partnership with NXP Semiconductors
by Gary Elinoff