All things in all posts will help you visualize about the way that computers work generally. Note that it is not the real structure of modern computers, but the way that modern computers work is nearly the same as in my posts. I am sure that if you understand about the way that computers work in my posts, you will easy to learn about all fields of computer afterward. Thank you !!!
In a previous post, we learned about the arithmetic and logic instructions and the way that those instructions work in CPU. The arithmetic and logic instructions are more complicated than load and store instructions that we will learn in this post. The load instruction will help load one byte from a RAM address (in a register) to another register. The store instruction will help store one byte from a register to a RAM address (in another register).
To understand about the load and store instructions, let’s look at the diagram below first:
The diagram above depicts 4 first bits of load and store instructions in IR (instruction register). In arithmetic and logic instructions, the first bit will be “1” and the remaining 3 bits will represent 8 arithmetic and logic operations. But now, the first bit of load and store instructions is “0” and the remaining 3 bits will be “000” for load instruction and “001” for store instruction.
The first bit of “0” in these instructions will go through a NOT gate and become “1” for the inputs of all AND gates that locate next to the right of the decoder 3x8 in the diagram. The remaining 3 bits will go into a 3X8 decoder. If those 3 bits are “000” or “001”, the first or second output of the 3X8 decoder will be “1” and become the second input of the corresponding AND gate. Now, we have the output of the first or the second AND gate of “1”. This “1” (on) signal will perform the corresponding function by cooperating with stepper for enabling and setting register A, register B, MAR and RAM.
All things that I demonstrate above, you can find out in the diagram. Now, let’s spend some time understanding everything…OK. Conclusion, we have the output of the first AND gate for signal of load instruction and the output of the second AND gate for signal of store instruction. If the signal of load instruction is “1”, loading a byte from a RAM address to a register. If the signal of store instruction is “1”, storing a byte from register to a RAM address.
Maybe you wonder about the remaining instructions that have the first four bits not “0000” or “0001”. Yeah. The answer is simple. Those instructions will be spent for other functions in the CPU that we will learn later, you should not worry about that.
The last four bits will be the places for declaring 2 registers that the instructions will manipulate with. Let’s look at the diagram below:
Similar to arithmetic and logic instructions, the first 2 bits in the last 4 bits will be for the first register and the last 2 bits in the last 4 bits will be for the second register. Details about registers, you can find out in the diagram. The first 4 bits, we have just mentioned above.
Now, all 8 bits of load and store instructions were understood. Returning to the first diagram in this post, we will discover the way that load and store instructions work. First, we come to the load instruction. When the signal of load instruction (from the first AND gate) is “1”, one input of two AND gates that connect to it will be “1”. The other inputs of this AND gate connect to step 4 bit and step bit 5, so the output of this AND gate will be “1” if the stepper goes in fourth step and fifth step.
Of course, the output of the AND gate that connects to the step 4 bit will be “1” first. So, it will enable register A, the byte in register A on the bus and set that byte for MAR. Now, the byte in the register A will be the address that RAM will return a byte from there. Next, the output of the AND gate that connects to step 5 will be “1”. So, it will enable RAM and set register B. Now, the byte in RAM (at the address of register A) will be set in register B.
Note that the first three steps of stepper will help fetch the next instruction to the IR and the remaining steps will execute instruction.
Similar for store instruction, the output of the AND gate that connects to the step 4 bit will be “1” first. So, it will enable register A and set it for MAR. Now, the byte in the register A will be the address that RAM will receive a byte into there. Next, the output of the AND gate that connects to step 5 will be “1”. So, it will enable register B and set RAM. Now, the byte in RAM (at the address of register A) will receive the byte in register B.
Below is the way that these load and store instructions are represented in computer language:
The remaining step 6 will do nothing, stepper will go to step 7 for resetting the stepper and another cycle from step 1 to step 6 starts again. You may understand the load and store instructions and the interesting function of stepper. That’s a marvelous device. Thank you for your reading and see you again in my next posts !!!
0 Nhận xét