Instruction Formats and Addressing Modes Formula Sheet: COA Revision Notes with Worked Examples

Revise COA instruction formats with one compact sheet covering field widths, address-count sequences, effective-address formulas, expanding opcodes and memory-reference checks.

KnowledgeGate Team

Exam prep & CS education

Updated 29 Nov 20265 min read
Instruction Formats and Addressing Modes Formula Sheet: COA Revision Notes with Worked Examples

Instruction-format problems mix bit allocation, opcode counts, effective-address arithmetic and memory-reference counts. Solve them with three checks: identify the field budget, apply the addressing rule and verify the memory accesses. The worked checks here produce 6 opcode bits, 18 remaining bits, X = 72, effective addresses 200, 800, 1000, 224, 4296, 1160, 3000 and 2996, 32 one-address opcodes, and the PC-relative range 0x0800 to 0x17FF. Each result follows declared instruction length, addressability, register width and PC convention.

Instruction format anatomy and bit-budget rules

An instruction format fixes how word bits represent the opcode and operand specifiers.

Item

Rule

When to use

Opcode capacity

2^k patterns

k is known

Opcode width

ceil(log2 M) bits

M operations

Register width

ceil(log2 R) bits per field

R registers

Remaining bits

length minus opcode, register, mode and fixed bits

Immediate or displacement

Unsigned range

0 to 2^n - 1

Unsigned field

Two's-complement range

-2^(n-1) to 2^(n-1) - 1

Signed field

A 32-bit word with 64 operations and two 16-register fields needs ceil(log2 64)=6 opcode bits and ceil(log2 16)=4 per register. Eight register bits leave 32-6-8=18 without mode or function fields. Unsigned range: 0 to 2^18-1=262,143. Two's-complement range: -2^17 to 2^17-1, or -131,072 to 131,071. Width does not establish signedness, scaling or addressability. See Instruction Formats & Addressing Modes in COA: Worked Guide owns the full concept-first walkthrough; this page keeps the formula-sheet and revision angle.

Zero-, one-, two- and three-address instruction formats

Address count means explicit specifiers, not memory accesses. Three-address names a destination and two sources; two-address overwrites one operand; one-address implies an accumulator; zero-address implies the stack top.

For A = 7, B = 5, C = 10, D = 4, compile X = (A + B) x (C - D) = 12 x 6 = 72:

Format

Sequence

Count

Three-address

ADD R1,A,B; SUB R2,C,D; MUL X,R1,R2

3

Two-address

MOV R1,A; ADD R1,B; MOV R2,C; SUB R2,D; MUL R1,R2; MOV X,R1

6

One-address accumulator

LOAD A; ADD B; STORE T; LOAD C; SUB D; MUL T; STORE X

7

Zero-address stack

PUSH A; PUSH B; ADD; PUSH C; PUSH D; SUB; MUL; POP X

8

Stack notation is bottom to top; binary operators take left from next-to-top and right from top. Trace: [7,5] -> [12] -> [12,10,4] -> [12,6] -> [72]. Code-size and traffic comparisons require instruction widths and operand locations.

Addressing-mode formula sheet: operand, EA and update order

Let A be the address or displacement, R register contents, M[x] memory, and PC_next the post-fetch PC.

Mode

Operand or EA rule

Extra state change

Question cue

Immediate

operand=A; no EA

None

Literal

Register

operand=R; no memory EA

None

Value in register

Direct

EA=A; operand=M[A]

None

Address field

Memory indirect

EA=M[A]; operand=M[M[A]]

None

Memory pointer

Register indirect

EA=R; operand=M[R]

None

Register pointer

Indexed

EA=A+IX

None

Index

Base register

EA=A+BR

None

Base

PC-relative

EA=PC_next+sign_extend(A)

None

Signed offset

Auto-increment

EA=R; use M[R]

Then R<-R+d

Old R

Auto-decrement

First R<-R-d; then EA=R, use M[R]

Before access

New R

Implied

No explicit field

Defined by architecture

Implicit

Here d is operand size in addressable units, not automatically a byte or word. Indexed, base and relative modes add different reference values; relative displacement is signed.

Addressing modes worked from one machine state

Use a byte-addressed machine with A=200, R1=1000, IX=24, BR=4096, PC_next=1200, relative displacement -40, R2=R3=3000, and d=4 for a 4-byte operand. Memory has M[200]=800, M[800]=34, M[1000]=55, M[224]=66, M[4296]=88, M[1160]=99, M[3000]=111, M[2996]=222.

  • Immediate gives operand 200; direct gives EA=200, operand 800.

  • Memory indirect reads pointer M[200]=800, then EA=800, operand M[800]=34.

  • Register indirect gives EA=R1=1000, operand 55.

  • Indexed gives EA=200+24=224, operand 66; base gives EA=200+4096=4296, operand 88.

  • PC-relative gives EA=1200+(-40)=1160, operand 99.

  • Auto-increment uses old R2: EA=3000, operand 111, then R2=3004. Auto-decrement acts first: R3=3000-4=2996, EA=2996, operand 222.

Effective-address map showing immediate, direct, indirect, indexed, base, PC-relative, auto-increment and auto-decrement paths.

Expanding opcode formula and worked allocation

A fixed k-bit opcode allows at most 2^k operations. An expanding opcode uses prefix allocation, reclaiming missing operand fields as extensions. At each stage, next-format capacity = unused prefixes x 2^(reclaimed field width); only unused prefixes continue.

For a 16-bit instruction and 16 registers, each register field needs 4 bits. Layout [opcode 4][R1 4][R2 4][R3 4] has 16 primary patterns. Assign 15 three-address operations and reserve 1111.

Reclaim one field for [1111][extension 4][R1 4][R2 4]. Its capacity is 1 x 2^4 = 16; assign 14, leaving 1110 and 1111. Reclaim another for [1111][1110 or 1111][extension 4][R1 4]: 2 x 2^4 = 32 one-address operations. Checksum: 15 three-address, 14 two-address, at most 32 one-address. 16 - 15 - 14 is invalid because extension depths are unequal opcode spaces.

Expanding-opcode tree showing primary and extension patterns and 32 one-address operations.

Addressability, displacement range and memory-reference checks

Capacity rules: n address bits select 2^n units; byte capacity is units times bytes per unit; an n-bit signed displacement spans -2^(n-1) to 2^(n-1)-1 units. Thus 24 bits select 2^24 bytes, or 16 MiB, with byte addressing; 4-byte word addressing gives 64 MiB.

For PC_next=0x1000, a 12-bit signed byte displacement is -2^11 to 2^11-1, or -2048 to +2047. The range is 0x1000-0x0800=0x0800 through 0x1000+0x07FF=0x17FF. Scale only if supplied.

For a single-word load, assuming no cache or extra translation accesses:

Modes

Memory references

Immediate, register

1 fetch + 0 data reads = 1

Direct, register-indirect, indexed, base, relative, auto-update

1 fetch + 1 operand read = 2

Memory indirect

1 fetch + 1 pointer read + 1 operand read = 3

Stores, multiword instructions and multi-level indirection change these counts.

How instruction formats and addressing modes are tested

Start with the right scratch action: draw bit fields; compile one expression; write EA = ... before substitution; mark PC_next; preserve signed units; draw a prefix tree; separate fetch, pointer and operand accesses.

Avoid floor(log2) in place of ceil(log2), counting implicit operands, confusing immediate A with direct M[A], stopping at an indirect pointer, reversing auto-update order, assuming every address field is signed, and subtracting counts across opcode depths.

For effective-address practice, use Addressing Modes MCQs: 12 Solved COA Questions. This page owns the formula sheet and worked checks; the earlier Instruction Formats and Addressing Modes: Mistakes and How to Avoid Them is the error-diagnosis and 60-second-audit companion.

Instruction formats and addressing modes: the two-minute checksum

Closed book, reproduce ceil(log2 M), ceil(log2 R), remaining bits, 0/1/2/3-address meanings, EA rules, auto-update order, prefix expansion, 2^n units, signed range and memory-reference counts. Checksum: 6 + 8 + 18 = 32 bits, X = 72, indirect EA = 800, indexed EA = 224, base EA = 4296, relative EA = 1160, auto registers 3004 and 2996, 32 one-address opcodes, and 0x0800 to 0x17FF. For full COA, use Computer Architecture and Organisation; for adjacent notes, use CS Fundamentals for Exams & Placements.