UBa
University of Bamenda — Faculty of Engineering & Technology

Computer Architecture
Complete CA Exam Guide

COME 3XXX  |  Unit 1 & Unit 2 — Memory, Addressing Modes, ISA & Assembly Programming

Unit 1: Memory Location, Access & Addressing Modes
Unit 2: ISA & Assembly Language Programming
Format: Structural Q&A + Theory Recap
2025/2026 Academic Year
✦ Prepared by:  [ Nyoh Leoanard K]
Unit 1 Theory Addressing Modes Unit 1 Questions Unit 2 Theory Assembly Unit 2 Questions Mixed Questions Quick Reference
Unit 1

Memory Location, Access & Addressing Modes — Theory Recap

💾
1 Bit
0 or 1
📦
1 Byte
8 bits
🗂️
1 Word
16–64 bits
📐
Address bits
log₂(M)
1.1 — Memory Fundamentals

Memory as an Array

Main memory = array of adjacent cells. Each cell stores 1 bit (0 or 1). Cells are grouped into words — the smallest addressable entity (16–64 bits). Memory size is expressed in bytes.

Example: 256 MB = 256 × 2²⁰ = 2²⁸ bytes.

Address bits required for M words: l = log₂(M) Maximum addressable words with l bits: M = 2^l Example: Memory = 64M words → l = log₂(64 × 2²⁰) = log₂(2²⁶) = 26 bits

Memory Write Operation — 3 Steps

  1. CPU loads the word to be stored into the Memory Data Register (MDR).
  2. CPU loads the destination address into the Memory Address Register (MAR).
  3. CPU issues a WRITE signal → word in MDR is stored at address in MAR.

Note: MDR and MAR are CPU-internal registers, not accessible to the programmer.

Memory Read Operation — 3 Steps

  1. CPU loads the source address into the MAR.
  2. CPU issues a READ signal → memory will place the word at that address into MDR.
  3. After memory access delay, the word is loaded into MDR, ready for CPU use.
1.2 — Instruction Classification (by Operand Count)
ClassFormExampleMeaning
Three-addressOP src1, src2, dstADD R1,R2,R3R3 ← R1 + R2
Two-addressOP src, dstADD R1,R2R2 ← R1 + R2
One-and-half-addressOP mem, regADD B,R1R1 ← M[B] + R1
One-addressOP srcADD R1Racc ← Racc + R1
Zero-addressUses stackADD (SP)+,(SP)Pop two, push sum
⚠ Exam Trap: One-and-half address It is called "one-and-half" because it uses TWO types of addressing (register + memory), and register addressing uses FEWER bits than memory addressing — hence "half" address less than a full two-address.
1.3 — Addressing Modes
1. Immediate
Operand VALUE is embedded directly in the instruction. Prefix: #
LOAD #1000, Ri
Ri ← 1000 (the constant itself)
2. Direct / Absolute
Instruction contains the MEMORY ADDRESS of the operand. No prefix.
LOAD 1000, Ri
Ri ← M[1000]
3a. Register Indirect
A REGISTER holds the effective address of the operand. Notation: (Rj)
LOAD (Rj), Ri
Ri ← M[Rj]
3b. Memory Indirect
A MEMORY LOCATION holds the effective address of the operand.
LOAD (1000), Ri
Ri ← M[M[1000]]
4. Indexed
Effective address = constant X + content of index register Rind.
LOAD X(Rind), Ri
Ri ← M[Rind + X]
5. Relative
Same as indexed but uses the Program Counter (PC) instead of Rind.
LOAD X(PC), Ri
Ri ← M[PC + X]
Unit 1 — Exam Questions

Memory, Instruction Classification & Addressing Modes

1
Define the terms: bit, byte, and word. A computer has a memory of 512 MB. How many address bits are required? If the address bus has 32 bits, what is the maximum memory capacity in bytes?
Memory Fundamentals  |  [8 marks]
✔ Model Answer

Definitions:

  • Bit: The smallest unit of information in a computer, capable of storing a binary value of 0 or 1. [1 mark]
  • Byte: A group of 8 bits that can be treated as an atomic unit. It is the standard unit for expressing memory size. [1 mark]
  • Word: The smallest addressable entity in memory, consisting of n bits that can be stored or retrieved in a single memory operation. Typical sizes range from 16 to 64 bits. [1 mark]

Address bits for 512 MB:

512 MB = 512 × 2²⁰ = 2⁹ × 2²⁰ = 2²⁹ bytes

l = log₂(M) = log₂(2²⁹) = 29 bits required [2 marks]

Maximum capacity with 32-bit address bus:

M = 2^l = 2^32 bytes = 4,294,967,296 bytes = 4 GB [2 marks]
Exam Note: Always show the formula l = log₂(M) before substituting. The examiner awards method marks separately from the final answer.
2
With the aid of a diagram or clearly labelled steps, describe the sequence of operations performed by the CPU to carry out a MEMORY WRITE operation. Name the key registers involved and state their roles.
Memory Access  |  [8 marks]
✔ Model Answer

A memory write operation stores a word from the CPU into a specified memory location. The two key registers involved are the Memory Data Register (MDR) and the Memory Address Register (MAR).

Three Steps of a Memory Write:

  1. Load MDR: The word to be written is loaded by the CPU into the Memory Data Register (MDR). The MDR acts as a temporary buffer holding the data to be stored. [2 marks]
  2. Load MAR: The address of the memory location where the word is to be stored is loaded into the Memory Address Register (MAR). The MAR holds the destination address. [2 marks]
  3. Issue WRITE Signal: The CPU issues a WRITE control signal. This triggers the memory system to store the word currently in the MDR into the memory location whose address is held in the MAR. [2 marks]

Register Roles (Table):

RegisterFull NameRole in Write Operation
MDRMemory Data RegisterHolds the data word to be written to memory
MARMemory Address RegisterHolds the address of the target memory location
Key Point: Both MDR and MAR are internal CPU registers. They are NOT accessible to the programmer — they operate transparently during instruction execution.
3
Describe the sequence of operations for a MEMORY READ operation. How does it differ from a memory write operation?
Memory Access  |  [6 marks]
✔ Model Answer

Three Steps of a Memory Read:

  1. Load MAR: The address of the memory location from which the word is to be read is loaded into the MAR. [1 mark]
  2. Issue READ Signal: The CPU issues a READ control signal, indicating that the word at the address held in MAR should be transferred into the MDR. [1 mark]
  3. Data Available in MDR: After a period equal to the memory access delay, the memory system places the requested word into the MDR, where it is ready for CPU processing. [2 marks]

Key Difference between READ and WRITE:

AspectWrite OperationRead Operation
DirectionCPU → MemoryMemory → CPU
MDR RoleHolds data to BE storedReceives data READ from memory
Signal IssuedWRITE signalREAD signal
MDR loaded byCPU (before operation)Memory (after access delay)
4
Explain with examples the five classes of instructions based on number of operands. For each class, show the equivalent representation in terms of a three-address instruction.
Instruction Classification  |  [10 marks]
✔ Model Answer
ClassExampleMeaningEquivalent 3-address
Three-addressADD R1,R2,R3R3 ← R1 + R2; R1, R2 unchangedItself
Two-addressADD R1,R2R2 ← R1 + R2; R2 is overwrittenADD R1,R2,R2
One-and-halfADD B,R1R1 ← M[B] + R1ADD B,R1,R1
One-addressADD R1Racc ← Racc + R1 (accumulator is implicit)ADD R1,Racc,Racc
Zero-addressADD (SP)+,(SP)Pop two values from stack, push their sumUses stack mechanism

Why "One-and-half" Address?

The instruction uses a memory location (full address bits needed) AND a register (fewer bits needed). Since the memory operand requires a full address while the register needs only a small field, the combined addressing requirement is described as "one-and-a-half" addresses.

Stack Operation (Zero-address) — Push & Pop:

  • PUSH: Store a value at address pointed to by Stack Pointer (SP), then increment SP.
  • POP: Decrement SP first, then retrieve the value at that address. LIFO — last in, first out.
5
Define "addressing mode." Describe, with examples and diagrams, ALL six addressing modes covered in this unit. For each, state the effective address calculation.
Addressing Modes — CORE QUESTION  |  [15 marks]
✔ Model Answer

Addressing mode: The method by which the address of an operand is specified in an instruction. Different modes offer trade-offs between instruction size, flexibility, and speed.

#ModeDefinitionExampleEffective Address / Operation
1ImmediateOperand value IS the instruction field. No memory access needed.LOAD #1000, RiRi ← 1000 (no EA, value is direct)
2Direct (Absolute)Instruction field contains the memory address of the operand.LOAD 1000, RiEA = 1000; Ri ← M[1000]
3aRegister IndirectA named register holds the effective address. Notation: (Rj)LOAD (Rj), RiEA = Rj; Ri ← M[Rj]
3bMemory IndirectA memory location holds the effective address. Two memory accesses.LOAD (1000), RiEA = M[1000]; Ri ← M[M[1000]]
4IndexedEA = constant X added to content of index register Rind.LOAD X(Rind), RiEA = Rind + X; Ri ← M[Rind+X]
5RelativeSame as indexed but the Program Counter (PC) is used as the base.LOAD X(PC), RiEA = PC + X; Ri ← M[PC+X]

Key Comparison — Indirect vs. Indexed:

  • Indirect: One extra memory access to get the address. Flexible for dynamic pointer-like access.
  • Indexed: Uses arithmetic (addition) to compute the address. Ideal for array traversal — increment X to access successive elements.
Exam Tip: The # symbol uniquely identifies immediate mode. Parentheses () identify indirect mode. A register next to a constant in parentheses like X(Rind) identifies indexed mode.
6
Identify the addressing mode used in each instruction and compute the effective address or final result where possible: (a) LOAD #500, R3   (b) LOAD 500, R3   (c) LOAD (R5), R3 where R5=2000   (d) LOAD (500), R3 where M[500]=3000   (e) LOAD 20(R6), R3 where R6=1000
Applied Addressing Modes  |  [10 marks]
✔ Model Answer
InstructionModeEffective AddressResult
LOAD #500, R3ImmediateNo EA — value is #500R3 ← 500 (constant)
LOAD 500, R3Direct/AbsoluteEA = 500R3 ← M[500]
LOAD (R5), R3Register IndirectEA = R5 = 2000R3 ← M[2000]
LOAD (500), R3Memory IndirectEA = M[500] = 3000R3 ← M[3000]
LOAD 20(R6), R3IndexedEA = R6 + 20 = 1020R3 ← M[1020]
Critical distinction: LOAD 500 vs LOAD #500 — the presence of # makes all the difference between loading a constant (immediate) vs loading from an address (direct).
7
Differentiate between register indirect addressing and memory indirect addressing. State ONE advantage and ONE disadvantage of memory indirect addressing compared to register indirect.
Addressing Modes Comparison  |  [6 marks]
✔ Model Answer
AspectRegister IndirectMemory Indirect
Address stored inA CPU register (e.g. Rj)A memory location (e.g. address 1000)
Memory accesses1 (to get operand)2 (to get address, then operand)
NotationLOAD (Rj), RiLOAD (1000), Ri
SpeedFaster (register access is fast)Slower (extra memory access)

Advantage of Memory Indirect:

Allows access to a larger address space — the pointer can be stored anywhere in memory, unlike register indirect which is limited by the number of registers available.

Disadvantage of Memory Indirect:

Requires an extra memory read cycle to fetch the effective address, making it significantly slower than register indirect addressing.

Unit 2

Instruction Set Architecture & Assembly Programming — Theory Recap

2.1 — Instruction Types (ISA)
TypePurposeExamples
Data MovementTransfer data between registers, memory, stackMOV Ri,Rj LOAD STORE PUSH POP
Arithmetic & LogicalComputation on register/memory contentsADD R1,R2,R0 SUB AND OR SHIFT ROTATE
Sequencing (Control)Alter the program counter — change execution flowJUMP addr BRANCH-IF-Z CALL RETURN
Input/OutputTransfer data between CPU and peripheral devicesINPUT 1000 OUTPUT 2000 or memory-mapped
2.2 — Condition Code (CC) Flags
FlagNameSet to 1 when...
NNegativeResult of most recent operation is negative
ZZeroResult of most recent operation is zero
VOverflowMost recent operation caused arithmetic overflow
CCarryMost recent operation generated a carry out
2.3 — JUMP vs. CALL: Critical Distinction

JUMP (Unconditional Branch)

Loads PC with a new address. The previous PC value is LOST. Execution continues at the new address with no way to return automatically.

CALL (Subroutine Call)

Same as JUMP but FIRST pushes the incremented PC (return address) onto the stack. When the subroutine executes RETURN, it pops the return address from the stack back into PC — resuming at the instruction after the CALL.

2.4 — Assembly Language Basics

Simple Processor Registers

RegisterFull NameFunction
PCProgram CounterAddress of the NEXT instruction to execute
IRInstruction RegisterHolds the OPCODE of the current instruction
ARAddress RegisterHolds the ADDRESS portion of current instruction
ACAccumulatorImplicit source and destination for data operations
DRData RegisterTemporary data holder

Intel x86 Registers (as covered in course)

RegisterFunction
AX / AL / AHAccumulator — main data register (AL = low byte, AH = high byte)
BXBase register — used for memory addressing
CXCounter register — used for loop counting
DXData register — data operations and I/O

Assembly Program Structure (8086 DOS)

.MODEL SMALL ; Memory model (1 code seg + 1 data seg) .STACK 100H ; Reserve 256 bytes (100H) for stack .DATA ; Data segment — declare variables NUM1 DB 5 ; DB = Define Byte; NUM1 = 5 NUM2 DB 3 ; NUM2 = 3 .CODE ; Code segment — program instructions MAIN PROC ; Begin main procedure ; ... instructions here ... MOV AH, 4CH ; DOS function: terminate program INT 21H ; Call DOS interrupt 21H MAIN ENDP ; End main procedure END MAIN ; End of program
⚠ MOV AH, 4CH + INT 21H — Always required to end a DOS assembly program 4CH = terminate function code. INT 21H = DOS service interrupt. Without this, the program does not exit cleanly.
Unit 2 — Exam Questions

ISA, Instruction Types & Assembly Programming

8
Classify and explain the four types of instructions in an Instruction Set Architecture (ISA). Give TWO examples for each type.
Instruction Types  |  [12 marks]
✔ Model Answer

1. Data Movement Instructions [3 marks]

Transfer data between registers, between registers and memory, or to/from the stack. They do NOT modify the data.

  • MOV Ri, Rj — Copies content of Ri into Rj. Rj is overwritten; Ri unchanged.
  • LOAD 25838, Rj — Loads content of memory address 25838 into register Rj. Memory unchanged.
  • STORE Ri, 1024 — Stores content of Ri into memory location 1024. Ri unchanged.

2. Arithmetic & Logical Instructions [3 marks]

Perform computation or logical manipulation on register/memory contents.

  • ADD R1,R2,R0 — R0 ← R1 + R2. Source registers unchanged.
  • SHIFT R1 — Performs logical left or right shift on R1.
  • AND R1,R2 — Bitwise AND of R1 and R2, stored in R2.

3. Sequencing / Control Instructions [3 marks]

Change the order of instruction execution by modifying the Program Counter (PC).

  • JUMP NEW-ADDRESS — Unconditional: PC ← NEW-ADDRESS. Previous PC value is lost.
  • BRANCH-IF-ZERO Loop — Conditional: if Z flag = 1, PC ← Loop address.
  • CALL SubroutineX — Pushes return address, PC ← SubroutineX.

4. Input/Output Instructions [3 marks]

Transfer data between the processor and external peripheral devices through dedicated ports.

  • INPUT 1000 — Reads data from the input device at port address 1000 into the accumulator.
  • OUTPUT 2000 — Sends data from the accumulator to the output device at port address 2000.
9
What is the Condition Code (CC) Register? Name and describe the four flags it contains. Show how conditional branching uses these flags with an example assembly loop.
CC Flags & Branching  |  [8 marks]
✔ Model Answer

The Condition Code (CC) Register is a special-purpose register whose individual bits (flags) are set or cleared based on the results of executing various instructions. It is used by conditional branch instructions to decide whether to take a branch.

FlagMeaningSet to 1 when
NNegativeMost recent operation result is negative
ZZeroMost recent operation result is zero
VOverflowMost recent operation caused an arithmetic overflow
CCarryMost recent operation generated a carry-out

Example: Assembly Loop Using Conditional Branching

LOAD #100, R1 ; R1 ← 100 (loop counter) Loop: ADD (R2), R0 ; R0 ← R0 + M[R2] (accumulate sum) DECREMENT R1 ; R1 ← R1 - 1 (sets Z flag if R1 becomes 0) BRANCH-IF-GREATER-THAN Loop ; If Z=0 (R1 > 0), jump back to Loop ; After loop: R0 holds sum of 100 values from memory starting at R2

The DECREMENT instruction updates the Z flag. If R1 is not yet zero (Z=0, meaning result > 0), the branch is taken and the loop continues. When R1 reaches 0, Z=1, the branch is NOT taken, and execution falls through.

10
Explain the difference between a JUMP instruction and a CALL instruction. Why is the RETURN instruction necessary when using CALL?
Control Flow  |  [6 marks]
✔ Model Answer
FeatureJUMPCALL
Effect on PCPC ← NEW-ADDRESSPC ← Subroutine address
Saves return address?NO — previous PC lostYES — pushes (PC+1) onto stack
Can return?No automatic returnYes — via RETURN instruction
Use caseOne-way unconditional branchSubroutine / function call

Why RETURN is needed after CALL:

When CALL executes, the incremented PC value (pointing to the instruction AFTER the CALL) is pushed onto the stack. The RETURN instruction pops this saved address from the stack back into the PC, thereby resuming execution exactly where the program left off before the subroutine was called.

Without RETURN, execution would continue inside the subroutine indefinitely or fall into incorrect memory. CALL + RETURN together implement the function call mechanism.

11
What is memory-mapped I/O? How does it differ from the use of dedicated I/O instructions? State ONE advantage of memory-mapped I/O.
I/O  |  [5 marks]
✔ Model Answer

Dedicated I/O: The CPU uses special I/O instructions (INPUT, OUTPUT) with dedicated port addresses that are separate from the memory address space.

INPUT 1000 ; Read from keyboard at port 1000 → accumulator OUTPUT 2000 ; Write from accumulator → output device at port 2000

Memory-mapped I/O: I/O device registers are mapped into the same address space as regular memory. The CPU interacts with I/O devices using standard data movement instructions (MOVE, LOAD, STORE) — no separate INPUT/OUTPUT instructions needed.

MOVE Rin, R0 ; Input: moves data from input device register Rin into R0 MOVE R0, Rout ; Output: moves data from R0 to output device register Rout
FeatureDedicated I/OMemory-Mapped I/O
Special instructions?Yes (INPUT, OUTPUT)No — uses MOVE/LOAD/STORE
Address spaceSeparate I/O address spaceShared with memory
ComplexitySimpler hardwareSimpler instruction set

Advantage of memory-mapped I/O: Any instruction that can reference memory can be used to access I/O devices, giving the programmer the full power of the instruction set for I/O operations without needing special I/O instructions.

12
Describe the basic structure of an assembly language program for the 8086 processor. Explain what each directive (.MODEL, .STACK, .DATA, .CODE) does. Include and explain the instructions used to terminate the program.
Assembly Structure  |  [8 marks]
✔ Model Answer
.MODEL SMALL ; Directive: defines memory model .STACK 100H ; Directive: allocates stack space .DATA ; Directive: begins data segment NUM1 DB 5 ; Declare variable NUM1 as byte = 5 NUM2 DB 3 ; Declare variable NUM2 as byte = 3 .CODE ; Directive: begins code segment MAIN PROC ; Procedure declaration MOV AL, NUM1 ; Load NUM1 into AL register ADD AL, NUM2 ; AL ← AL + NUM2 MOV AH, 4CH ; Load termination code into AH INT 21H ; Call DOS to terminate program MAIN ENDP ; End of procedure END MAIN ; End of assembly file
DirectiveMeaning
.MODEL SMALLUses "Small" memory model: 1 code segment + 1 data segment (max 64KB each). Other models: TINY, MEDIUM, LARGE.
.STACK 100HReserves 256 bytes (100 hex) for the stack. Stores temporary data, function return addresses.
.DATAMarks the beginning of the data segment. Variables declared here with DB (Define Byte), DW (Define Word), etc.
.CODEMarks the beginning of the code segment where executable instructions are written.
PROC / ENDPMarks the start and end of a procedure (subroutine / function).
MOV AH, 4CH + INT 21HTerminates the program. 4CH = DOS terminate function. INT 21H = invokes DOS interrupt handler which checks AH and exits cleanly.
13
Write a complete assembly language program to: (a) Add two numbers stored in memory. (b) Subtract two numbers (9 - 4). Annotate each instruction with a comment explaining its purpose.
Assembly Programming  |  [10 marks]
✔ Model Answer

(a) Addition — Two numbers from memory [5 marks]

.MODEL SMALL .STACK 100H .DATA NUM1 DB 5 ; First operand: 5 NUM2 DB 3 ; Second operand: 3 .CODE MAIN PROC MOV AL, NUM1 ; AL ← 5 (load first number into AL) ADD AL, NUM2 ; AL ← AL + NUM2 = 5 + 3 = 8 (add second number) ; Result (8) is now stored in AL register MOV AH, 4CH ; Prepare to terminate: load DOS exit code INT 21H ; Execute DOS interrupt to terminate program MAIN ENDP END MAIN

(b) Subtraction — 9 minus 4 [5 marks]

.MODEL SMALL .STACK 100H .CODE MAIN PROC MOV AL, 9 ; AL ← 9 (load minuend — the number being subtracted from) MOV BL, 4 ; BL ← 4 (load subtrahend — the number to subtract) SUB AL, BL ; AL ← AL - BL = 9 - 4 = 5 (perform subtraction) ; Result (5) is now in AL MOV AH, 4CH ; Load DOS terminate function code INT 21H ; Terminate the program via DOS interrupt MAIN ENDP END MAIN
Note: SUB modifies the destination operand (AL). BL remains unchanged after SUB AL, BL. This mirrors the behaviour of ADD and other two-address arithmetic instructions.
14
Write assembly code to compare two numbers (5 and 3) using the CMP instruction. Explain what CMP does internally and how the result could be used in a conditional branch.
Assembly — CMP & Branching  |  [6 marks]
✔ Model Answer
MOV AL, 5 ; AL ← 5 MOV BL, 3 ; BL ← 3 CMP AL, BL ; Compares AL and BL (internally: AL - BL = 5 - 3 = 2) ; Sets flags: N=0 (positive), Z=0 (not zero) ; NEITHER operand is changed by CMP ; Example conditional branch based on CMP result: JG Greater_Label ; Jump if Greater (N=0 and Z=0) JE Equal_Label ; Jump if Equal (Z=1) JL Less_Label ; Jump if Less (N=1)

How CMP works internally:

CMP performs a subtraction (AL − BL) but does NOT store the result. It ONLY updates the Condition Code flags (N, Z, V, C) based on the outcome. These flags are then examined by a subsequent conditional jump instruction.

CMP ResultFlags SetBranch to use
AL > BLZ=0, N=0JG (Jump if Greater)
AL = BLZ=1JE (Jump if Equal)
AL < BLN=1JL (Jump if Less)
15
What is assembly language? State THREE advantages and TWO disadvantages of assembly language programming compared to high-level languages.
Assembly Overview  |  [7 marks]
✔ Model Answer

Assembly language is a low-level programming language that uses mnemonic instructions (e.g., MOV, ADD, SUB) that map directly to machine code instructions. An assembler translates assembly code into binary machine code.

Advantages [3 marks]:

  1. Efficiency: Programs run faster and use less memory since the programmer has direct control over hardware resources with no abstraction overhead.
  2. Direct hardware control: Allows precise manipulation of registers, memory addresses, and I/O ports — essential for OS kernels, device drivers, and embedded systems.
  3. Size optimisation: Code can be tuned for minimal footprint, critical in microcontrollers and ROM-based systems.

Disadvantages [2 marks]:

  1. Low portability: Code written for one CPU architecture (e.g., x86) must be completely rewritten for another (e.g., ARM).
  2. Harder to maintain: Programs are longer, more complex, and harder to read/debug compared to equivalent high-level language code.

Common Use Cases:

Operating systems, embedded systems, device drivers, microcontrollers, and game engines (performance-critical sections).

Mixed / Comprehensive

Cross-Unit Exam Questions & Calculation Problems

16
CALCULATION: A memory system uses 24-bit addresses and each word is 4 bytes. (a) How many words can be addressed? (b) What is the total memory capacity in bytes? (c) Express the capacity in MB.
Memory Calculation  |  [6 marks]
✔ Model Answer

(a) Number of addressable words:

M = 2^l = 2^24 = 16,777,216 words = 16M words [2 marks]

(b) Total capacity in bytes:

Each word = 4 bytes Total bytes = 2^24 × 4 = 2^24 × 2^2 = 2^26 bytes = 67,108,864 bytes [2 marks]

(c) Capacity in MB:

2^26 bytes ÷ 2^20 bytes/MB = 2^6 MB = 64 MB [2 marks]
17
Consider the instruction: ADD B, R1. (a) Identify the instruction class. (b) Identify the addressing modes used for each operand. (c) Rewrite this instruction as an equivalent three-address instruction. (d) Explain what happens to the original contents of B and R1.
Combined Application  |  [8 marks]
✔ Model Answer

(a) Instruction class: One-and-half-address instruction. [2 marks]
It is called "one-and-half" because it uses a memory operand (B — requires full address bits) and a register operand (R1 — requires fewer bits for a register field).

(b) Addressing modes: [2 marks]

  • Operand B: Direct (Absolute) addressing — B is the address of a memory location.
  • Operand R1: Register addressing — R1 is a CPU register.

(c) Equivalent three-address instruction: [2 marks]

ADD B, R1, R1 (adds M[B] to R1, stores result back in R1)

(d) Effect on operands: [2 marks]

  • Contents of memory location B: UNCHANGED — B is only read, not written to.
  • Contents of register R1: OVERWRITTEN — R1 receives the result (M[B] + R1). The original value of R1 is lost.
18
A simple processor has mnemonics: LD x (load from memory x to AC), ST x (store AC to memory x), ADD (add DR to AC), MOVAC (copy AC to DR). Write assembly code for this processor to compute: Result = A + B + C, where A, B, C are memory locations.
Simple Processor Assembly  |  [8 marks]
✔ Model Answer

Strategy: The simple processor uses AC as accumulator and DR as data register. ADD always does: AC ← AC + DR.

LD A ; AC ← M[A] (load A into accumulator) MOVAC ; DR ← AC (copy A from AC into DR) LD B ; AC ← M[B] (load B into accumulator, overwriting A) ADD ; AC ← AC + DR = B + A (add DR (=A) to AC (=B)) MOVAC ; DR ← AC (save B+A into DR) LD C ; AC ← M[C] (load C) ADD ; AC ← AC + DR = C + (A+B) (add DR (=A+B) to AC (=C)) ST Result ; M[Result] ← AC (store final sum A+B+C)

The result A+B+C is stored in memory location "Result". This demonstrates why one-address (accumulator-based) architectures require more instructions than three-address architectures for the same computation.

19
Explain the stack push and pop operations with a concrete example. Show the state of the stack and the Stack Pointer (SP) before and after each operation.
Stack Operations  |  [7 marks]
✔ Model Answer

A stack is a LIFO (Last-In, First-Out) data structure. The Stack Pointer (SP) always points to the top of the stack — the next usable location.

PUSH Operation (storing value 5A):

StepActionSP valueMemory
Before PUSHSP points to location 102310231023: empty
During PUSHStore 5A at address SP (1023)10231023: 5A
After PUSHIncrement SP10241023: 5A ✓

POP Operation (retrieving value DD from 1021):

StepActionSP valueResult
Before POPSP = 10221022
Step 1DECREMENT SP first1021
Step 2Read value at M[1021] = DD1021Register ← DD
Key Rule: PUSH → store THEN increment SP. POP → decrement SP THEN retrieve. The order matters — getting it backwards is a common exam mistake.
20
ESSAY: Compare RISC and CISC philosophy as it relates to instruction classification and addressing modes. Which approach do you think best matches what is described in this course material, and why?
Critical Analysis / Higher-Order  |  [10 marks]
✔ Model Answer

CISC — Complex Instruction Set Computer:

CISC architectures support many instruction classes (including one-and-half and three-address forms) and rich addressing modes (including memory indirect). A single instruction can perform multiple memory accesses. This reduces the number of instructions per program but each instruction may take multiple clock cycles.

RISC — Reduced Instruction Set Computer:

RISC architectures limit instructions to simple, single-cycle operations. Only LOAD and STORE access memory; all arithmetic uses register operands only (three-address register-to-register). Addressing modes are minimal (typically immediate and register indirect only).

FeatureCISCRISC
Addressing modesMany (all 6 in this course)Few (immediate + register indirect)
Instruction classesAll 5 (0 to 3 address)Primarily 3-address (register)
Memory accessMany instructions access memoryOnly LOAD/STORE touch memory
Code densityCompact (fewer instructions)More instructions, but simpler each

Relevance to Course Material:

The course material covers a range of addressing modes and instruction classes consistent with a CISC-like instructional model (especially memory indirect, indexed, and one-and-half address formats). However, the simple processor mnemonics (LD, ST, ADD) and the emphasis on the accumulator model lean toward an early RISC/simple processor philosophy. Understanding both is essential because modern CPUs blend both approaches.

Quick Reference

Master Summary Tables — Bring This to Mind During the Exam

All Addressing Modes at a Glance
ModeInstruction FormEffective AddressOperation
ImmediateLOAD #K, RiNo EARi ← K
DirectLOAD A, RiEA = ARi ← M[A]
Register IndirectLOAD (Rj), RiEA = RjRi ← M[Rj]
Memory IndirectLOAD (A), RiEA = M[A]Ri ← M[M[A]]
IndexedLOAD X(Rind), RiEA = Rind + XRi ← M[Rind+X]
RelativeLOAD X(PC), RiEA = PC + XRi ← M[PC+X]
Simple Processor Instruction Set
MnemonicOperandMeaning
STOPStop execution
LDxAC ← M[x] (load from memory)
STxM[x] ← AC (store AC to memory)
MOVACDR ← AC
MOVAC ← DR
ADDAC ← AC + DR
SUBAC ← AC − DR
ANDAC ← AC AND DR
NOTAC ← complement of AC
BRAadrJump to address adr (unconditional)
BZadrJump to adr if AC = 0 (conditional)
Transfer of Control Instructions
InstructionMeaning
BRANCH-IF-CONDITIONTransfer to new address if condition flag is true
JUMPUnconditional transfer — old PC is lost
CALLTransfer to subroutine — return address saved on stack
RETURNPop return address from stack back into PC
🎯 Last-Minute Exam Checklist ✔ Know l = log₂(M) and M = 2^l by heart  |  ✔ Write 3 steps for READ, 3 steps for WRITE  |  ✔ Know # = immediate, () = indirect, X(R) = indexed  |  ✔ Remember ONE-AND-HALF = register + memory addressing  |  ✔ CALL saves return address on stack; JUMP does not  |  ✔ CMP subtracts but does NOT store result — only sets flags  |  ✔ Always end DOS assembly with MOV AH,4CH + INT 21H