본문 바로가기

Computer Architecture/Lecture Review

Instruction Processing

What is the instruction?

It is made up of two parts, the opcode (what the instruction does) and the operands (who it does it to).

Fundamentally, there are three kinds of instructions : 

  • Operate : operate on data (arithmetic, logical)
  • Data-movement : move information from / to memory to / from the processing unit
  • Control : altering the sequential process of instructions

 

Let me give you some examples in LC-3.

ADD instruction in LC-3

These are the LC-3's ADD instructions. The first four bits [15:12] are the opcode, which determines the action of the instruction. Other bits [11:0] are the operands. 

First instruction means, "add the value of register 2 and register 6, and store the result into register 6."

Second instruction means, "add the value of register 2 to the positive integer 6, and store the result into register 6."

The difference between to instructions occur in bit 5 : 0 means the source operand is stored in the register [2:0], 1 means [4:0] is the immediate operand, represented in the form of sign-extended integer.

 

Instruction Cycle

Instructions are processed in a very systematic, step-by-step manner. 

The following steps are called the Instruction Cycle, which means the entire sequence of steps required to process an instruction.

 

Step 1. Fetch

  1. Load the MAR with the contents of the PC, and simultaneously increment the PC. (Takes one clock cycle)
  2. Interrogate memory, resulting in the instruction being placed in the MDR. (one or more than one clock cycle)
  3. Load the IR(Instruction Register) with the content of the MDR. (one clock cycle)

 

Step 2. Decode

Decode phase examines the instruction in order to figure out what the michroarchitecture is being asked to do. 

In the LC-3, 4-to-16 decoder identifies which of the 16 opcodes is to be processed. 

 

Step 3. Evaluate Address

Computes the address of the memory location, which is needed to process the instruction.

 

Step 4. Fetch Operands

This phase obtain the source operands needed to process the instruction.

ex) In the ADD instruction, this phase consisted of obtaining the source operands from R2 and R6.

 

Step 5. Execute

This phase carries out the execution of the instruction.

ex) In the ADD instruction, this phase includes the step of performing the addition in the ALU.

 

Step 6. Store Result

The result is written into its designated destination. 

'Computer Architecture > Lecture Review' 카테고리의 다른 글

Von Neumann Model  (1) 2024.01.14