Computer Instruction Explained: Format, Instruction Cycle and a 16-Bit Worked Example

Decode an illustrative 16-bit load instruction, calculate its effective address, trace fetch through write-back, and learn the errors that change answers.

KnowledgeGate Team

Exam prep & CS education

Updated 25 Aug 20265 min read

Many students can identify an opcode in isolation but lose the question when instruction encoding, address calculation, PC movement and execution are combined. A single instruction can be traced from its 16-bit word to the final value written into a register by checking each field and state change in order. Each result depends on the stated ISA: field widths, address units, PC increments and side effects can differ between architectures.

Computer instruction meaning: the ISA contract

A computer instruction is an encoded command. Its fields tell the processor which operation to perform and where the operands come from or go.

The instruction set architecture, or ISA, defines this programmer-visible contract. It includes opcodes, registers, data types, addressing rules and instruction formats. The microarchitecture is different: it is the internal design that implements the ISA, perhaps with a particular pipeline, cache arrangement or control unit.

Our toy machine has fixed-length 16-bit instructions and word-addressed memory. It has eight registers, R0 to R7. Its program counter, PC, advances by one word after a normal fetch, and signed displacements use two's complement. Keep these rules visible while solving. The broader GATE CS Exam hub can help you place this concept within subject preparation.

Computer instruction types: operation, data and control

Instructions can move data, transform it or change control flow. Mnemonic syntax and side effects are ISA-specific, so LD, ADD, AND and BEQ must be interpreted under this toy ISA.

Class

Illustrative instruction

What changes

Data transfer

LD R3, 12(R5)

Loads one memory word into R3

Arithmetic

ADD R1, R2, R4

With R2 = 11 and R4 = 7, writes 18 to R1

Logical

AND R6, R1, R7

With R1 = 0xB6 and R7 = 0x5A, writes 0x12 to R6

Control transfer

BEQ R1, R0, -3

May replace the sequential PC when the comparison is true

An instruction usually combines an operation with zero or more explicit operands. Other inputs can be implicit, such as the PC or a condition-code register. Do not assume that every instruction reads memory or writes a general-purpose register.

Computer instruction format: decode the 16-bit word

For LD R3, 12(R5), bits 15 down to 0 are divided as follows: opcode[15:12] has 4 bits, destination[11:9] has 3 bits, base[8:6] has 3 bits, and signed displacement[5:0] has 6 bits.

The capacities follow directly from the widths. Four opcode bits provide 2^4 = 16 bit patterns. Each 3-bit register field selects one of 2^3 = 8 registers. A 6-bit signed two's-complement displacement ranges from -2^5 = -32 to 2^5 - 1 = +31.

Now encode LD R3, 12(R5):

  1. LD = 0011.

  2. R3 = 011 and R5 = 101.

  3. +12 = 001100 in 6 bits.

  4. Concatenation gives 0011 011 101 001100.

  5. Regrouping into 4-bit nibbles gives 0011 0111 0100 1100.

  6. Those nibbles are hexadecimal 3, 7, 4, C, so the stored word is 0x374C.

The 16-bit LD instruction split into opcode 0011, destination R3, base R5 and displacement +12, forming the word 0x374C.

Computer instruction cycle: trace fetch to write-back

Set the complete starting state first. PC = 200, M[200] = 0x374C, R5 = 1000, M[1012] = 37, and the old value of R3 = 9. Unless an address has a 0x prefix, memory addresses here are decimal word addresses.

The state changes in this order:

  1. Fetch: IR <- M[200] = 0x374C, then PC <- 201 because a normal fetch advances one word.

  2. Decode: the control unit extracts LD, destination R3, base R5 and displacement +12.

  3. Effective address: EA = R5 + 12 = 1000 + 12 = 1012.

  4. Operand fetch: the processor reads M[1012] = 37.

  5. Execute and write-back: R3 <- 37.

The final architectural state is PC = 201, R3 = 37 and R5 = 1000. The base register has not changed. A fault or a control-transfer instruction could alter this normal path, but neither occurs in this trace.

A five-stage trace of the LD instruction from fetch to write-back, ending with PC 201 and R3 changed from 9 to 37.

Computer instruction addressing: positive and negative displacement checks

The same 6-bit field can hold a negative displacement. The positive encoding is +12 = 001100. For -5, calculate 2^6 - 5 = 64 - 5 = 59. The 6-bit representation of 59 is 111011, so -5 is 111011 in 6-bit two's complement. Sign extension preserves the negative value, and R5 = 1000 gives EA = 1000 - 5 = 995.

If you read 111011 as unsigned 59, you will incorrectly calculate 1000 + 59 = 1059. The field width and signedness are part of the instruction format, not optional details.

Register addressing names a register. Immediate addressing carries a value in the instruction. Direct addressing carries an address, indirect addressing points to a location that holds an address, and base-plus-displacement addressing adds an encoded offset to a base register. Practise selecting and calculating these in Addressing modes and instruction formats in computer architecture explained.

Computer instruction mistakes that change the answer

Use this checklist before committing to a numerical answer.

Mistake

Wrong result

Correction

Counting this word-addressed PC in bytes

PC 200 becomes 202

One normal fetch advances one word, so it becomes 201

Forgetting sign extension

111011 is read as 59

As a signed 6-bit value, it is -5

Returning the effective address

The answer is reported as 1012

1012 is the address; the loaded operand is 37

Assuming LD changes every status flag

Unstated flag changes are added

Apply only the side effects defined by the toy ISA

Instruction length must also be interpreted under the stated addressing convention. On a different byte-addressed ISA, a fixed 4-byte instruction at address 0x0040 makes the sequential PC become 0x0044, not 0x0041.

Computer instruction exam patterns: what to calculate under pressure

Most instruction questions reduce to a small set of calculations:

  1. Allocate field widths and count available encodings.

  2. Decode a binary or hexadecimal instruction.

  3. Sign-extend an offset and calculate an effective address.

  4. Trace PC, IR, registers and memory through the micro-operations.

  5. Distinguish an address from the operand stored at that address.

  6. Connect instruction dependencies to pipeline hazards and performance.

For a short performance check, suppose a workload executes 800,000 instructions at an average CPI = 1.25. It needs 800,000 x 1.25 = 1,000,000 cycles. At 1 GHz, the execution time is 1,000,000 / 1,000,000,000 s = 0.001 s = 1 ms. CPI here is an average for the stated workload, not a property of one opcode.

After practising dependencies and timing, use Pipelining in Computer Architecture: the 5-stage pipeline, speedup, and hazards to connect them to stalls and forwarding. The GATE Test Series provides mixed practice across instruction formats, addressing and performance.

Computer instruction short version and next step

  • Identify every field and its width.

  • Decode signed values using the stated representation.

  • State whether memory is word-addressed or byte-addressed.

  • Trace the PC and data path in order.

  • Report the final architectural state, not an intermediate address.

In the main example, 0x374C at PC 200 leaves PC = 201 and changes R3 from 9 to 37. If you want a structured path across GATE CS subjects, continue with GATE Guidance by Sanchit Sir.