Representative System (Part 3) - Executing a Program

Microprocessors

Representative System (Part 3) - Executing a Program

Video Lectures created by Tim Feiegenbaum at North Seattle Community College.

We are continuing in our discussion of a representative system and we're in the portion where we're going to be executing the program.  The program we're going to be executing is this program right here.  In this particular section, we're going to execute these first two addresses and we're going to do an input and we're going to tell what device we want to have an input come from.  Now what I'm going to do is read directly from your textbook. I don't like doing this, but it's extremely detailed and it isn't the easiest text to understand in this section.  I'm just going to read the text and then as I read I'm going to give some explanation of what is it actually talking about?

 

Executing the Program

I'll begin reading here under executing the program.  Let's go inside the microprocessor and watch the action.  Ready?  Power on.  As power is supplied we see all the registers flip flops and even the program counter coming up in what appears to be a random state.  The microprocessor is outputting addresses and reading back memory and desperately trying to execute the program.  However, since the PC program counter came up in random state the address that is being output is wrong and the information being returned is of no value.  Therefore when the microprocessor attempts to execute the retrieved instruction no one knows what will happen.  As you can see the microprocessor is running uncontrollably and serving no useful purpose so let's get its attention.

We press the reset button and the release it.  This is the reset button right here.  This is automatic on most home computers.  In fact, in most computers built in the last few years, this is an automatic function, you turn it on and it automatically resets.  The instant we press the button the wildly uncontrollable activity ceases and the program counter goes to 0, 0, 0 and this is our hex address and it stays there.  When we release the reset button the desired controlled program execution begins.  It will progress as outlined in the following paragraphs.  We have a program that's stored in ROM and we're going to begin executing it starting at memory location 0, 0, 0, 0.  First, the microprocessor needs an instruction.  It outputs the program counter which is currently set to this number right here.  Program counter which is internal tot eh processor to the address bus.  This address goes out on the address bus.

It also activates a control bus signal called memory read.  That is right here, control bus memory read.  That would be going over here.  The address goes to the memory and identifies the desired byte.  The memory read signal goes to the enabled input of the ROM and causes it to enter the active state and place its selected date; this is our first instruction, on the data bus.  With the pressing of the reset button the counter outputs this address with the reset also the control bus activates a read here in ROM.  The piece of data that's stored in ROM I placed on the data bus.  After a short delay of a few nanoseconds, the microprocessor latches the information currently on the data bus into its instruction register.  That data is latched and now the data at this location is in the microprocessor.  It then deactivates the control bus, right here, and the address bus lines, and begins to decode the instruction to find out what it is expected to do next.

Our first instruction was in and remember were over here this is our first instruction was in, the instruction register now contains and it's one, one, 0, one, one, 0, one, one or DB and hex.  Upon decoding the instruction the microprocessor learns that it is an input instruction.  The instruction is being given is that we're going to input data.  However, to execute an input instruction requires an address of the input device. The microprocessor has been told we're going to input data, but it does not know where the data is coming from.  This information is part of a program and is stored in the next sequential memory location.  In our program, this is the second byte of information.  The processor knows we're going to have an input, but where is the input coming from?  This is indicating the device number.  This is the device number that is going to contain the input.

The microprocessor then increments the program counter and fetches the next byte by sending the program counter to the address bus and again activating enable on the control bus.  Down the data bus from ROM comes 0, 0, 0, 0, 0, 1 since that is what we pout there when we wrote the program.  The microprocessor takes this byte and stores it in a temporary latch, internal to the microprocessor.  It now knows what to do.  What it's going to do is input data and where to do it and this is going to be device number one.  This happens to be device number one right here.  It accomplishes this task by outputting 0, 1, now that is the port number.  Out on the address bus we send out this port number 0, 0, 0, 0, 1 because that's … the address bus is saying … Actually it doesn't mention this in your text, but actually the address goes to every device on the computer, but only the one that has the correct number will actually respond.  On the address bus, it says device number one which happens to be this device.

It also causes IO read on the control bus to go low.  We have the address going over here saying device number one and then there is an IO read going to the eight-bit buffer. This combination causes the eight-bit buffer to come out of its tristate mode.  It places the logic level of the switches onto the data bus.  Here are the logic levels of the switches and they are placed on the data bus.  Again, after a few nanoseconds of delay, the microprocessor latches the data bus information into the accumulator.  Now the execution of the first instruction is complete.  The buses are deactivated.

Okay, the buses being address bus and control bus.  The program counter is incremented and we begin to fetch the next instruction.  Notice what has happened so far.  The eight bits of data representing the current state of the switches and that over here are now being held in the accumulator. In addition, the program counter has been incremented twice so we are now ready to add RISC location to which contains our next instruction.

What we have done, we have completed instruction 0 and 1.  Now we are at instruction two.  

We're going to stop here and we're going to pick up on the next presentation what we will pick up instruction number two.

Video Lectures created by Tim Fiegenbaum at North Seattle Community College.