This entry is part [part not set] of 8 in the series Microprocessor Architecture Basics

A microprocessor instruction is a description of an operation that has to be performed on a data. The data is called operand. An instruction may have one or more operands. The microprocessor executes instructions in a process called instruction cycle. Each microprocessor is designed to operate on a specific set of instructions defined in its instruction set architecture. Instructions (represented as hexadecimal or binary values) are also called machine code.

An instruction has a certain size (length) in number of bits. These bits are grouped into bit fields and they form the structure of the instruction (aka instruction format) . A typical instruction format has the following bit fields in its structure:

  • Opcode (Operation Code) – Identification of the operation that the instruction should perform.
  • Operands – Source and/or destination operands of the instruction.
  • Mode (optional) – Addressing mode of the operation.
  • Condition (optional) – Specific condition for executing the instruction. Usually the condition is based on the status flags of the CPU (see our article Microprocessor Arithmetic Logic Unit for additional information regarding the status flags).

Example:

Fig.1 Instruction format example

In the example instruction format shown in Fig. 1 we have the following bit fields:

  • M – This is the addressing mode selection bit for Operand 3 (Op3). If M is 0 then Op3 is a register, if it is 1 then Op3 is an immediate value.
  • Opcode – 4 bit value specifying the operation that the instruction will perform:

  • Op1 – First operand field. It specifies which general purpose register contains the actual first operand value.

  • Op2 – Second operand field. This is the destination operand and it specifies in which general purpose register the result of the operation will be stored.
  • Op3 – Third operand field. Depending on the value of bit field M it can either be the actual operand (immediate value) or a pointer to a general purpose register containing the operand value.

Using the instruction format shown in Fig.1 we will present two examples showing specific operations using the assembly language and its equivalent machine code. Keep in mind that the machine code binary representation is in fact the instruction format with its bit fields.

In the operation shown below we want to add the contents of register r1 with the decimal value of 5, and store the result in register r3. Here the M bit field is set to 1 indicating that the Op3 bit field contains the actual operand value (decimal 5 in this case). The addition operation is selected by setting the Opcode bit field value to 0000.

 

In the operation shown below we want to subtract the contents of register r1 with the contents of register r4, and store the result in register r2. Here the M bit field is set to 0 indicating that the Op3 bit field points to a register containing the actual operand value. The subtraction operation is selected by setting the Opcode bit field value to 0001.

Instruction Classification

Microprocessor instructions can be divided into the following classes:

  • Data processing instructions –  these instructions perform arithmetic operations, logical operations, comparisons.
  • Memory access instructions – these instruction move data between memory and CPU  registers
  • Jump and Branch instructions – these instructions change the flow of the program using the program counter.
  • Special instructions – breakpoint instructions that can stop the execution of the program, no operation instruction etc.
  • Co-processor instructions – some architectures allows adding a co-processor to the main microprocessor for execution of specific instructions like floating point arithmetic, graphics, signal processing etc.
Series Navigation

Was this article helpful?