Computer Science

NRB Assistant Director (IT) Notes: Computer Architecture and Microprocessors

Complete Unit 1 notes for Paper I, Section (A) of the Nepal Rastra Bank Assistant Director (IT) exam: all seven sub-topics, solved numericals and 70 practice MCQs.

By Updated 70 min read

NRB Assistant Director IT Paper I Unit 1 notes on computer architecture and microprocessors
Unit 1 of Paper I, Section (A) of the Nepal Rastra Bank Assistant Director (IT) syllabus.
On this page

Quick answer: what Unit 1 is worth, and what it covers

Unit 1 of Paper I, Section (A) of the Nepal Rastra Bank Assistant Director (Information Technology) written examination is Computer Architecture & Organization and Microprocessors. Paper I carries 100 marks with a pass mark of 40: twenty-five multiple-choice questions worth 1 mark each (30 minutes, 0.2 marks deducted for every wrong answer), nine short-answer questions worth 5 marks each, and three long-answer questions worth 10 marks each (2 hours 30 minutes for the subjective part). Questions are asked in English and answers must be written in English.

This page is a complete, worked set of notes for all seven sub-topics of that unit — 1.1 Basic Structures through 1.7 the 808X and Intel microprocessors — written against the official syllabus approved on 2080/05/07. It includes solved numericals for Booth’s algorithm, IEEE 754 conversion and cache mapping, seventy practice multiple-choice questions with answers, and answer plans for the ten long questions most likely to appear.

The same unit heading, “Computer Architecture & Organization and Microprocessors”, appears in the Nepal Rastra Bank Assistant Director (Cyber Security) syllabus for 2080, and closely related computer-architecture topics appear in the Nepal Bank and Public Service Commission IT syllabi — so these notes serve those examinations too.

A note on language. Complex ideas are explained in Nepali so that the concept actually lands, but every definition is also given as an “Exam line” — the exact English sentence to reproduce in the answer sheet. The syllabus is explicit: “Examinee should use English language to answer.”

Key facts at a glance

ItemValue
PostAssistant Director (Information Technology), Officer Third Class, Technical Service
OrganisationNepal Rastra Bank (the central bank of Nepal)
PaperPaper I — Information Technology – I
Full marks / pass marks100 / 40
Objective section25 MCQ × 1 = 25 marks, 30 minutes, −0.2 per wrong answer, no calculator
Subjective section9 short × 5 = 45 and 3 long × 10 = 30, in 2 hours 30 minutes
Units in Section (A)1. Computer Architecture & Microprocessors, 2. Digital Logic Design, 3. Operating Systems, 4. Database Management System and Design
Written stage total300 marks across Papers I, II and III
Later stagesPractical examination 50 marks (pass 25), interview 40 marks
Syllabus approved2080/05/07
Official syllabus11-Assistant-Director-IT-Open-2080.pdf, nrb.org.np

How to use this page

The unit is large, so read it in the order the marks fall rather than front to back. The six highest-scoring areas, judged by how this syllabus is usually set, are cache memory and its mapping arithmetic, the 8086 BIU/EU architecture and segmentation, Booth’s algorithm, IEEE 754 conversion, DMA, and hardwired versus microprogrammed control. Each has a solved numerical below. Everything else is comparison tables, which is exactly the form a 5-mark answer should take.

For 10-mark answers, the structure that earns full marks is: definition, then a labelled diagram, then the step-by-step working, then a worked example with real numbers, then one line on advantages or limitations. A 10-mark answer without a diagram does not score full marks.

Contents

The ten sections below follow the official syllabus numbering exactly, so you can tick off sub-topics against the NRB document as you revise. Part 2 is the revision material: a formula sheet, a 70-question practice set, and answer plans for the long questions.

Part 1 — the syllabus, section by section

Part 2 — revision toolkit

1.1 Basic Structures

1.1.1 Sequential Circuits (क्रमिक परिपथ)

Definition / Exam line:

A sequential circuit is a logic circuit whose output depends not only on the present inputs but also on the past history of inputs, which is held in memory elements (flip-flops). It is therefore described by Output = f(present input, present state).

नेपालीमा: Combinational circuit ले अहिलेको input मात्र देखेर output दिन्छ (जस्तै adder)। Sequential circuit सँग memory (flip-flop) हुन्छ, त्यसैले उसले “पहिले के भएको थियो” सम्झन्छ — यही सम्झनालाई state भनिन्छ। Counter, shift register, traffic-light controller सबै sequential हुन्।

Synchronous vs Asynchronous

FeatureSynchronousAsynchronous
State changeOnly at clock edgeAs soon as input changes
ClockCommon clock to all FFsNo common clock
SpeedSlower (limited by clock)Faster
DesignEasy, predictableHard — race condition, hazards
ExampleSynchronous counter, registersRipple counter, SR latch

Mealy vs Moore (हरेक वर्ष MCQ आउने विषय)

MooreMealy
Output depends onPresent state onlyPresent state AND present input
Output written onState circle in diagramTransition arrow in diagram
States neededMoreFewer
Output timingSynchronous with clock, delayed by 1 cycleReacts immediately, can glitch
NotationZ = f(Q)Z = f(Q, X)

सम्झने तरिका: Moore = Memory(state) मात्र। Mealy = state + also input.

1.1.2 Design Procedure of a Synchronous Sequential Circuit

Exam line — the seven steps (यो क्रम रटनु, 5-mark प्रश्न यहीँबाट आउँछ):

  1. Word statement → State Diagram (problem बुझेर state चित्र बनाउने)
  2. State Diagram → State Table (present state, input, next state, output)
  3. State Reduction / Minimisation (equivalent states मिलाउने — optional)
  4. State Assignment (प्रत्येक state लाई binary code दिने; n states → ⌈log₂n⌉ FFs)
  5. Transition Table → Excitation Table (चुनिएको flip-flop को excitation table प्रयोग गरी प्रत्येक FF को input चाहिने मान निकाल्ने)
  6. K-Map simplification (प्रत्येक FF input र output का लागि minimal Boolean expression)
  7. Draw the logic diagram and verify.

Flip-flop Characteristic Equations (रटनु)

Flip-flopCharacteristic equation Q(t+1) =
SRS + R′Q (with SR = 0)
DD
JKJQ′ + K′Q
TT ⊕ Q = TQ′ + T′Q

Excitation Tables (step 5 मा यही चाहिन्छ — X = don’t care)

Q(t) → Q(t+1)S RJ KDT
0 → 00 X0 X00
0 → 11 01 X11
1 → 00 1X 101
1 → 1X 0X 010

सम्झने तरिका (T flip-flop): T = 1 जब state बदलिन्छ (toggle), T = 0 जब same रहन्छ। D: D sadhai next state बराबर। JK: सबैभन्दा धेरै don’t-care → सबैभन्दा सजिलो K-map.

1.1.3 State Diagram and State Table

  • State Diagram: circles = states, directed arrows = transitions, arrow label = input / output (Mealy) or circle label = state / output (Moore).
  • State Table: tabular form of the same information.

Worked micro-example — 2-bit up counter with JK flip-flops:

Present Q₁Q₀Next Q₁Q₀J₁K₁J₀K₀
00010X1X
01101XX1
1011X01X
1100X1X1

From K-maps: J₀ = K₀ = 1, J₁ = K₁ = Q₀ → this is the standard synchronous up-counter where each higher FF toggles when all lower bits are 1.

1.1.4 Von Neumann vs Harvard Architecture (निश्चित प्रश्न)

FeatureVon Neumann (Princeton)Harvard
MemoryOne memory for instruction + dataSeparate instruction & data memory
BusesSingle shared busSeparate buses for each
FetchInstruction and data cannot be fetched togetherCan be fetched simultaneously
SpeedSlower — Von Neumann bottleneckFaster
Cost / complexityCheap, simpleCostly, more pins & wires
Instruction/data widthMust be sameCan differ
Self-modifying codePossibleNot possible (data memory ≠ code memory)
Used inGeneral-purpose PCs (x86), most CPUsDSPs, microcontrollers (AVR, PIC, ARM Cortex-M), cache level of modern CPUs

Von Neumann bottleneck (नेपालीमा): CPU धेरै छिटो भयो, तर instruction र data दुवै एउटै bus हुँदै आउनुपर्छ। त्यो bus साँघुरो पुल जस्तै भयो — CPU कुरेर बस्नुपर्छ। यही “CPU भन्दा memory/bus ढिलो हुने समस्या” Von Neumann bottleneck हो।

Modified Harvard (आजका CPU): Main memory एउटै (Von Neumann) छ तर L1 cache छुट्टै छ — L1-I (instruction) र L1-D (data)। त्यसैले आजका x86 “modified Harvard” भनिन्छ।

Von Neumann’s stored-program concept (1945, EDVAC report): program पनि data सरह memory मा binary रूपमा राखिन्छ। यही कारण computer “general purpose” भयो।

1.1.5 RISC vs CISC (हरेक वर्ष आउँछ — table रटनु)

FeatureRISCCISC
Full formReduced Instruction Set ComputerComplex Instruction Set Computer
No. of instructionsFew (~50–150)Many (~200–400+)
Instruction lengthFixed (e.g. 32-bit)Variable (1–15 bytes in x86)
Clock cycles / instructionMostly 1 (pipelined)Many (2–15)
Addressing modesFew (3–5)Many (8–20+)
RegistersMany (32–192)Few (8–16)
Memory accessOnly LOAD / STOREAlmost any instruction can touch memory
Control unitHardwiredMicroprogrammed
PipeliningEasy & deepDifficult
Code sizeLargerSmaller
Compiler workHigh (compiler optimises)Low (hardware does the work)
PowerLowHigher
ExamplesARM, MIPS, SPARC, PowerPC, RISC-V, Atmel AVRIntel x86, 8086, Motorola 68000, IBM 370, VAX

नेपालीमा फरक: CISC ले एउटै instruction मा धेरै काम गर्छ (जस्तै x86 को MUL सीधै memory मा) — त्यसैले program छोटो, तर hardware जटिल। RISC ले सानो-सानो, एकनासको instruction मात्र राख्छ — hardware सजिलो, pipeline छिटो, तर program लामो। Trade-off: hardware complexity vs code size.

Exam line: “RISC shifts complexity from hardware to the compiler, whereas CISC shifts complexity from the compiler to the hardware (microcode).”

1.1.6 Flynn’s Classification — SISD, SIMD, MISD, MIMD (1966)

आधार: instruction stream को संख्या × data stream को संख्या।

TypeStreamsMeaningExample
SISD1 instr, 1 dataTraditional uniprocessor, sequentialClassic Von Neumann machine, single-core 8086, early PCs
SIMD1 instr, many dataOne instruction applied to many data items at once (data parallelism)GPU, vector/array processors, Intel MMX/SSE/AVX, ILLIAC-IV, CM-2
MISDmany instr, 1 dataMany instructions on the same data — mostly theoreticalSystolic arrays; fault-tolerant redundant systems (e.g. Space Shuttle flight computers)
MIMDmany instr, many dataIndependent processors on independent data (task parallelism)Multicore CPUs, clusters, Intel Core i7, IBM BlueGene, distributed systems

MIMD की दुई उप-किसिम:

  • Shared memory (tightly coupled) → SMP (Symmetric Multiprocessing), NUMA
  • Distributed memory (loosely coupled) → Clusters, MPP, grid

सम्झने तरिका: SI = एउटै order सबैलाई; MI = सबैलाई आफ्नै order। SD = एउटै data; MD = छुट्टाछुट्टै data. SIMD = “एउटै हुकुम, सयौं सिपाही” (GPU) — MCQ मा GPU सोध्यो भने SIMD। MISD सबैभन्दा दुर्लभ/अव्यावहारिक — यो MCQ मा सधैँ आउँछ।

1.1.7 Representation of Data (डाटा प्रतिनिधित्व)

Signed integer representations — 4-bit comparison

DecimalSign-Magnitude1’s Complement2’s ComplementExcess-8 (bias)
+50101010101011101
−51101101010110011
00000 / 1000 (two zeros)0000 / 1111 (two zeros)0000 only1000
Range (n=4)−7 … +7−7 … +7−8 … +7−8 … +7

General range formulas (रटनु):

  • Unsigned n-bit: 0 to 2ⁿ − 1
  • Sign-magnitude / 1’s complement: −(2ⁿ⁻¹ − 1) to +(2ⁿ⁻¹ − 1)
  • 2’s complement: −2ⁿ⁻¹ to +2ⁿ⁻¹ − 1

2’s complement किन सबैभन्दा प्रयोग हुन्छ (Exam line):

2’s complement has a unique representation of zero, needs no end-around carry, and allows subtraction to be performed by the same adder hardware used for addition — therefore no separate subtractor circuit is required.

2’s complement निकाल्ने २ तरिका:

  1. सबै bit उल्टाउने (1’s complement) + 1 जोड्ने.
  2. दायाँबाट पहिलो 1 सम्म जस्तै सार्ने, त्यसपछिका सबै bit उल्टाउने. उदाहरण: 0110**1000** → 1001**1000**

Other data codes

CodePurpose / Note
BCD (8421)Each decimal digit in 4 bits. 1010–1111 invalid. Used in calculators, financial/banking displays
Packed BCDTwo digits per byte
Excess-3BCD + 0011. Self-complementing, no 0000 code
Gray codeOnly one bit changes between consecutive values → used in shaft encoders, K-maps. Binary→Gray: G = B XOR (B>>1)
ASCII7-bit, 128 chars (+1 parity)
Extended ASCII8-bit, 256 chars
EBCDIC8-bit, IBM mainframes
Unicode16/32-bit, UTF-8/16/32, multilingual (Devanagari included)

Endianness: Little-endian = LSB at lowest address (Intel x86, 8086). Big-endian = MSB at lowest address (Motorola 68k, PowerPC default, network byte order). 0x12345678 at address 100 → little: 78 56 34 12; big: 12 34 56 78.

1.1.8 Arithmetic Operations (basic rules)

OperationRule
2’s comp additionAdd normally; discard final carry out
2’s comp subtractionA − B = A + (2's complement of B)
Overflow detectionOverflow if Cin ≠ Cout of the sign bit, i.e. V = C_n ⊕ C_{n−1}. Also: adding two same-sign numbers giving the opposite sign = overflow
1’s comp additionAdd; if carry out, add it back (end-around carry)
Carry vs OverflowCarry matters for unsigned; Overflow matters for signed

Worked example (4-bit 2’s complement): 5 + 4 0101 + 0100 = 1001. Both operands positive, result sign bit = 1 (negative) → overflow, because +9 is outside −8…+7.

1.1.9 Basic Operational Concepts

Essential CPU registers (Exam line सहित)

RegisterFull formFunction
PCProgram CounterHolds the address of the next instruction
IRInstruction RegisterHolds the instruction currently being executed
MARMemory Address RegisterHolds the address being sent to memory
MDR / MBRMemory Data/Buffer RegisterHolds data being read from or written to memory
ACAccumulatorHolds the ALU operand/result (in 1-address machines)
R0…R(n−1)General Purpose RegistersFast local operand storage
SPStack PointerPoints to the top of the stack
PSW / FlagsProgram Status WordCondition codes: Z, C, S/N, V/O, P, AC
TRTemporary RegisterInternal scratch, not programmer-visible

Register Transfer Notation — “Add the contents of memory location LOC to R1”

Step 1:  MAR ← PC
Step 2:  MDR ← M[MAR],  PC ← PC + 1        (fetch)
Step 3:  IR  ← MDR                          (instruction now in IR)
Step 4:  decode IR
Step 5:  MAR ← address field of IR (LOC)
Step 6:  MDR ← M[MAR]                       (operand fetch)
Step 7:  R1  ← R1 + MDR                     (execute in ALU)

नेपालीमा: CPU ले हरेक instruction यसै क्रममा चलाउँछ — पहिले कहाँ छ भन्ने address पठाउनु (MAR), त्यसपछि के छ भन्ने data लिनु (MDR), त्यसपछि काम गर्नु। MAR address मात्र बोक्छ, MDR data मात्र बोक्छ — यो भेद MCQ मा सोध्छ।

1.1.10 Bus Structures

Definition / Exam line:

A bus is a shared set of parallel electrical conductors (plus a protocol) that carries information between two or more functional units of a computer.

Three functional buses

BusDirectionCarriesWidth decides
Address busUnidirectional (CPU → memory/IO)Address of location/portMemory capacity = 2^(width). 8086: 20 lines → 1 MB
Data busBidirectionalActual dataWord size / throughput. 8086: 16 lines; 8088: 8 lines
Control busMixedRD, WR, CLK, RESET, INTR, ALE, M/IO, HOLD, HLDA, READYCoordination/timing

महत्वपूर्ण MCQ: Address bus unidirectional, data bus bidirectional. n address lines → 2ⁿ addressable locations.

Bus organisation types

TypeStructureSpeedCost
Single-busAll units share one busSlowest (one transfer at a time)Cheapest, fewest pins
Two-busSeparate CPU↔memory and CPU↔I/OMediumMedium
Three-busDedicated paths (+ DMA/IOP path)FastestMost expensive

Bus arbitration (कसले bus चलाउने भन्ने निर्णय):

MethodHowPriorityNote
Daisy chainingGrant signal passes serially device to deviceFixed by physical positionSimple, few lines; nearest device starves the rest; one failure blocks all downstream
Polling / RotatingArbiter asks each device in turnCan be rotated (fair)More lines, programmable
Independent requestEach device has its own BR/BG line pairFully flexibleFastest, most lines (2n)

Synchronous bus = common clock, fixed-length transfer, simple but limited by slowest device. Asynchronous bus = handshaking (MSYN/SSYN), each device at own speed, more flexible but needs extra control lines.

1.1.11 Instruction Cycle, Machine Cycle, Execution Cycle

Note on the syllabus wording: the syllabus prints “Instruction, Cycle and Excitation Cycle.” In the standard textbooks (Mano, Stallings, Hamacher) the examinable topics here are the instruction cycle, the machine cycle, the execute cycle, and — from sequential-circuit design — the excitation table/cycle. All four are covered so you are safe whichever way it is asked.

Hierarchy (सम्झनु: ठूलोबाट सानो)

Program  ⊃  Instruction Cycle  ⊃  Machine Cycle  ⊃  T-state (clock cycle)
TermDefinition
T-state / Clock cycleOne period of the CPU clock — the smallest timing unit
Machine cycleTime to complete one bus operation (one memory read, memory write, I/O read, I/O write, or opcode fetch). 8086 machine cycle = 4 T-states (T1–T4) + wait states
Instruction cycleTime to fetch and completely execute one instruction = 1 to 6 machine cycles
Fetch cycleSub-cycle that brings the instruction into the IR
Execute cycleSub-cycle that actually performs the operation

The instruction cycle — five phases (Exam answer)

  1. Fetch — MAR ← PC; MDR ← M[MAR]; IR ← MDR; PC ← PC + 1
  2. Decode — control unit interprets the opcode, identifies operands
  3. Operand fetch (Effective Address calculation) — resolve the addressing mode, read operand from memory/register; may be indirect cycle if indirect mode
  4. Execute — ALU performs the operation
  5. Store result / Write-back, then Interrupt check — if an interrupt is pending and enabled, save PC and branch to the ISR; otherwise fetch next instruction

8086 T-state breakdown of one machine cycle:

  • T1 — address placed on bus, ALE pulsed high to latch it
  • T2 — address removed, bus turns around; RD/WR asserted; status lines set
  • T3 — data actually transferred (memory/IO places data on bus); READY sampled
  • T4 — data latched, control signals deactivated, cycle ends
  • Tw (wait state) — inserted between T3 and T4 if READY is low (slow memory)

Excitation Cycle / Excitation Table

In sequential-circuit design the excitation table answers: “What input must I apply to this flip-flop to drive it from its present state to the required next state?” It is the reverse of the characteristic table. The excitation cycle is therefore the design step (step 5 of §1.1.2) in which every required state transition is converted into the flip-flop input values — and from there, via K-maps, into the actual gate network. (The full excitation table is given in §1.1.2 above.)

1.2 Processing Unit

1.2.1 Instruction Formats

An instruction = opcode + operand/address field(s) (+ addressing-mode field).

┌──────────┬──────────┬──────────┬──────────┐
│  Opcode  │  Mode    │ Operand1 │ Operand2 │
└──────────┴──────────┴──────────┴──────────┘

Opcode width rule: with an n-bit opcode field you can encode at most 2ⁿ distinct operations. With m bits of address field and word size w: w = opcode bits + mode bits + address bits.

Classification by number of addresses — compute X = (A + B) × (C + D)

यो उदाहरण परीक्षामा सबैभन्दा धेरै सोधिन्छ। चारै रूप रटनु।

(a) Three-address instruction — OP dest, src1, src2

ADD  R1, A, B        ; R1 ← M[A] + M[B]
ADD  R2, C, D        ; R2 ← M[C] + M[D]
MUL  X,  R1, R2      ; M[X] ← R1 × R2

3 instructions — shortest program, longest instruction. Used by: IBM 370, RISC.

(b) Two-address instruction — OP dest, src (dest is also a source)

MOV  R1, A           ; R1 ← M[A]
ADD  R1, B           ; R1 ← R1 + M[B]
MOV  R2, C
ADD  R2, D
MUL  R1, R2
MOV  X,  R1

6 instructions. Used by: Intel x86/8086, Motorola 68000. Most common commercially.

(c) One-address instruction (Accumulator machine)

LOAD  A              ; AC ← M[A]
ADD   B              ; AC ← AC + M[B]
STORE T              ; M[T] ← AC     (temporary needed!)
LOAD  C
ADD   D              ; AC ← M[C] + M[D]
MUL   T              ; AC ← AC × M[T]
STORE X

7 instructions. Used by: early machines, Intel 8085, PDP-8.

(d) Zero-address instruction (Stack machine — Reverse Polish / Postfix) Expression becomes AB+CD+*

PUSH A
PUSH B
ADD                  ; pops 2, pushes sum
PUSH C
PUSH D
ADD
MUL
POP  X

8 instructions — shortest instructions, longest program. Used by: JVM, x87 FPU, Burroughs B5000.

(e) RISC / Load-Store (three-address, register-only ALU)

LOAD  R1, A
LOAD  R2, B
ADD   R3, R1, R2
LOAD  R4, C
LOAD  R5, D
ADD   R6, R4, R5
MUL   R7, R3, R6
STORE X, R7

ALU operates only on registers; memory is touched only by LOAD/STORE.

निष्कर्ष (Exam line):

As the number of address fields decreases, the instruction length decreases but the number of instructions required to express the same computation increases — a direct trade-off between instruction size and program size.

Fixed vs Variable length, and Expanding Opcode

  • Fixed length (RISC, 32-bit): easy decode, easy pipeline, wastes space.
  • Variable length (x86, 1–15 bytes): compact, but decoding is sequential and hard.
  • Expanding opcode: rarely-used operations get a longer opcode so that the frequently-used ones stay short — Huffman-like encoding of the opcode space.

1.2.2 Arithmetic and Logical Instructions

ClassInstructions
Data transferMOV, LOAD, STORE, XCHG, PUSH, POP, IN, OUT, LEA, LDS/LES
ArithmeticADD, ADC (add with carry), SUB, SBB, INC, DEC, MUL, IMUL, DIV, IDIV, NEG, CMP, CBW, CWD, AAA/DAA (BCD adjust)
LogicalAND, OR, XOR, NOT, TEST
ShiftSHL/SAL, SHR (logical, fills 0), SAR (arithmetic, preserves sign)
RotateROL, ROR, RCL, RCR (through carry)
Transfer of controlJMP, CALL, RET, conditional jumps (JZ, JNZ, JC, JNC, JE, JNE, JG, JL, JA, JB), LOOP, INT, IRET
StringMOVS, CMPS, SCAS, LODS, STOS (+ REP prefix)
Processor controlCLC, STC, CLI, STI, CLD, STD, NOP, HLT, WAIT, LOCK, ESC

Key distinctions MCQ loves:

  • CMP A,B = SUB that sets flags but does not store the result.
  • TEST A,B = AND that sets flags but does not store the result.
  • SHR fills with 0 → for unsigned division by 2. SAR replicates the sign bit → for signed division by 2.
  • MUL = unsigned multiply, IMUL = signed multiply.
  • Logical shift left by 1 = ×2; right by 1 = ÷2 (unsigned).

1.2.3 Addressing Modes (10-mark प्रश्नको पक्का विषय)

Definition / Exam line:

An addressing mode is the rule by which the operand of an instruction is specified — i.e. how the effective address (EA), the actual address of the operand, is computed from the address field of the instruction.

#ModeEffective AddressExample (8086)Use case
1Implied / ImplicitOperand is implicit in the opcodeCLC, NOP, HLT, CMCShortest instruction
2ImmediateOperand is in the instruction; EA not usedMOV AX, 1234HInitialising constants — fastest, no memory access
3RegisterOperand in a register; EA = RMOV AX, BXFast, no memory cycle
4Direct / AbsoluteEA = address fieldMOV AX, [2000H]Simple global variables
5IndirectEA = M[address field] — two memory accessesMOV AX, [[2000H]] (conceptual)Pointers; large address space with small field
6Register IndirectEA = contents of registerMOV AX, [BX]Pointers, loops — most used
7Auto-increment / decrementEA = R, then R ← R ± dLODSB (SI auto-increments)Array/string traversal, stack
8Displacement / BasedEA = R + displacementMOV AX, [BX+4]Structure/record fields
9IndexedEA = base address + index registerMOV AX, [SI+2000H]Array elements
10Base-Index (+ displacement)EA = Base + Index (+ disp)MOV AX, [BX+SI+4]2-D arrays, array inside a record
11Relative / PC-relativeEA = PC + signed displacementJMP SHORT LABELPosition-independent / relocatable code, branches
12StackOperand at top of stack, implicitPUSH AX, POP BX, ADD (0-addr)Expression evaluation, subroutine linkage
13Base RegisterEA = Base register + displacementsegment:offset in 8086Relocation, segmentation

Worked numerical question (यो ढाँचामा आउँछ):

A two-word instruction is stored at addresses 200 and 201, so after the fetch PC = 202. The address field of the instruction = 500. R1 = 400, XR (index register) = 100. Memory: M[500] = 800, M[600] = 900, M[702] = 325, M[400] = 700.

ModeEAOperand fetched
Direct500M[500] = 800
Immediate— (operand = 500)500
IndirectM[500] = 800M[800]
Relative (PC-relative)PC + 500 = 202 + 500 = 702M[702] = 325
IndexedXR + 500 = 100 + 500 = 600M[600] = 900
Register—R1 = 400
Register indirectR1 = 400M[400] = 700

सावधानी: Relative mode मा PC already incremented मान्नुपर्छ — fetch सकिएपछि PC अर्को instruction तिर सरिसकेको हुन्छ। माथि instruction दुई word लामो भएकाले PC = 202, त्यसैले EA = 702। यदि instruction एक word को भए PC = 201, EA = 701 हुन्थ्यो। परीक्षामा यो assumption लेखिदिनु: “assuming PC has already been incremented past the current instruction during the fetch phase.” यही एक वाक्यले examiner सँग तर्क गुम्न दिँदैन।

Why so many modes? (Exam line)

Addressing modes reduce instruction length, allow a small address field to reach a large memory, and give direct hardware support for high-level language constructs such as arrays (indexed), records (displacement), pointers (indirect), recursion/subroutines (stack) and relocatable code (PC-relative).

1.3 Input/Output Organization

1.3.1 Why I/O needs special organisation

नेपालीमा: CPU nanosecond मा काम गर्छ, keyboard millisecond मा, printer second मा। साथै हरेक device को data format, word length, error rate फरक। यो speed र format को खाडल पुर्न I/O module (interface) चाहिन्छ।

I/O Module (Interface) functions — Exam answer:

  1. CPU and device communication / control (command decoding)
  2. Data buffering (speed matching — device र memory बीच)
  3. Error detection (parity, checksum, timeout)
  4. Address recognition (कुन port मेरो हो भन्ने चिन्नु)
  5. Timing and synchronisation
  6. Data format conversion (serial↔parallel, voltage levels)

1.3.2 Three techniques of I/O (मुख्य comparison table)

Programmed I/OInterrupt-driven I/ODMA
Who transfers dataCPUCPUDMA controller
CPU waits?Yes — busy-wait / polling loopNo — does other work until interruptedNo — fully free
Data pathDevice → CPU → MemoryDevice → CPU → MemoryDevice ↔ Memory directly
Transfer unitWord/byteWord/byteBlock
CPU overheadHighestMedium (ISR per word)Lowest (only setup + completion)
SpeedSlowestMediumFastest
Hardware costCheapestMediumMost expensive
Suitable forSlow devices, few bytes, simple systemsModerate-speed, unpredictable timing (keyboard)High-speed bulk — disk, network card, graphics, sound

Programmed I/O (Polling)

CPU repeatedly reads the status register until the “ready” flag is set, then transfers one word. Busy-waiting wastes the whole CPU.

LOOP:  IN   AL, STATUS_PORT
       TEST AL, READY_BIT
       JZ   LOOP              ; busy-wait — CPU चक्कर मारिरहन्छ
       IN   AL, DATA_PORT

Interrupt-driven I/O

Device raises INTR when ready. CPU finishes the current instruction, then:

  1. Completes current instruction (interrupts are checked at instruction boundaries)
  2. Pushes PC (and flags, and registers) onto the stack — context saving
  3. Loads the ISR address from the interrupt vector table
  4. Executes the ISR (Interrupt Service Routine / handler)
  5. IRET → pops flags and PC → resumes the interrupted program

1.3.3 Memory-Mapped I/O vs I/O-Mapped (Isolated) I/O — निश्चित प्रश्न

FeatureMemory-Mapped I/OI/O-Mapped / Isolated I/O
Address spaceI/O ports share the memory address spaceSeparate I/O address space
8086 address lines usedAll 20 linesOnly 16 lines (A0–A15)
8086 port capacityPart of the 1 MB memory64 K ports (2¹⁶)
Instructions usedAny memory instruction — MOV, ADD, AND, CMP, INC…Only IN and OUT
Control signalMEMR / MEMW (M/IO = 1)IOR / IOW (M/IO = 0)
Memory lost to I/OYes — I/O eats memory addressesNo
Decoding hardwareMore complex (20-bit decode)Simpler (16-bit decode)
FlexibilityHigh — full instruction set on portsLow — only IN/OUT
Used inMotorola 68000, ARM, most RISC, PowerPCIntel x86/8086 supports both

सम्झने तरिका: Memory-mapped = “I/O ले memory को ठेगाना चोर्छ, तर बदलामा सबै instruction प्रयोग गर्न पाउँछ”। Isolated = “आफ्नै छुट्टै ठेगाना, तर IN/OUT मात्र”।

1.3.4 Basic Interrupt System

Types of interrupts

ClassificationTypes
By sourceHardware (external device) vs Software (INT n instruction)
By maskabilityMaskable (can be disabled by CLI) vs Non-maskable (NMI)
By vectoringVectored (device supplies the address) vs Non-vectored (fixed address)
By causeExternal (I/O), Internal/Trap/Exception (divide-by-zero, overflow, page fault), Software

8086 interrupt structure (रटनु)

  • 256 interrupt types, numbered 00H–FFH
  • Interrupt Vector Table (IVT) occupies 00000H – 003FFH = first 1 KB
  • Each entry is 4 bytes: 2 bytes IP (offset) then 2 bytes CS (segment)
  • Vector address = interrupt type number × 4
  • On interrupt the 8086 pushes FLAGS, CS, IP (6 bytes) and clears IF and TF
TypeNameCause
0Divide by zeroDIV/IDIV quotient overflow
1Single step / TrapTF = 1 — used by debuggers
2NMINon-maskable hardware interrupt pin — cannot be disabled
3Breakpoint1-byte INT 3 instruction
4OverflowINTO when OF = 1
5–31Reserved by Intel
32–255Available to the usere.g. INT 21H = DOS services

Priority (highest → lowest): Divide-by-zero / INT n / INTO → NMI → INTR → Single-step (lowest).

Interrupt priority resolution methods

MethodHow it worksPros / Cons
Software pollingISR checks each device’s flag in a fixed orderCheap hardware, slow
Daisy chaining (serial)INTA ripples through devices; nearest one with a pending request grabs it and puts its vector on the busFew lines; priority fixed by physical position
Parallel priority interruptRegister + priority encoder + mask registerFast, programmable priority; more hardware
8259 PICDedicated chip: 8 inputs, cascadable to 64 levels, programmable fixed/rotating priority, maskingIndustry standard with 8086

1.3.5 Direct Memory Access (DMA) — 10-mark प्रश्न

Definition / Exam line:

DMA is an I/O technique in which a dedicated DMA controller takes control of the system buses and transfers a block of data directly between an I/O device and main memory, without passing the data through the CPU, thereby freeing the CPU for other computation.

DMA transfer sequence (steps रटनु)

  1. CPU programs the DMA controller: starting memory address, word count, direction (read/write), and mode.
  2. Device requests service → DMA controller asserts HOLD (bus request) to CPU.
  3. CPU completes the current bus cycle, floats (tri-states) its address, data and control buses, and replies with HLDA (hold acknowledge).
  4. DMA controller becomes bus master and transfers data device ↔ memory, incrementing the address register and decrementing the word count after each word.
  5. When the word count reaches zero, DMA releases HOLD and raises an interrupt (EOP — End of Process) to tell the CPU the block is complete.
  6. CPU regains the buses and resumes.

DMA controller registers

Address register (current memory address), Word-count register (bytes remaining), Control/Mode register, Status register, DMA request/acknowledge lines.

Three DMA transfer modes

ModeBehaviourEffect on CPU
Burst / Block transferWhole block transferred in one go; CPU halted until doneFastest transfer, CPU starved longest
Cycle stealingOne word per bus acquisition, then bus returnedCPU slowed slightly; good compromise — most common
Transparent / HiddenTransfers only when CPU is not using the bus (internal operations)No CPU slowdown at all, but slowest transfer

DMA and cache — a classic exam point: because DMA writes to memory without the CPU knowing, the cache can hold stale data (cache coherence problem). Solutions: mark DMA buffers non-cacheable, bus snooping, or explicit cache flush/invalidate before and after the transfer.

Cycle stealing vs Interrupt — MCQ: DMA “steals” a bus cycle without saving any CPU context; an interrupt forces a full context save/restore. That is why DMA is far cheaper per word.

Common 8086-family DMA controller: Intel 8257 (4 channels) and 8237 (4 channels, cascadable). PC-AT cascaded two 8237s → 7 usable channels.

I/O Processor / Channel (IOP)

A step beyond DMA: a separate specialised processor that executes its own channel program out of main memory, handling complete I/O sequences (seek, read, error retry) and interrupting the CPU only at the end. Used in IBM mainframes — selector channel (one fast device) and multiplexer channel (many slow devices).

1.4 Computer Arithmetic

1.4.1 Arithmetic and Logic Unit (ALU)

Exam line:

The ALU is the combinational digital circuit inside the CPU that performs all arithmetic operations (add, subtract, increment, decrement, multiply, divide) and all logical operations (AND, OR, XOR, NOT, shift, rotate, compare) on the data supplied by the registers, and sets the condition-code flags according to the result.

ALU का भागहरू: arithmetic unit (adder/subtractor), logic unit (gate array), shifter, status/flag register, and the multiplexer that selects which functional output goes to the result bus (selected by the control unit’s function-select lines).

Flags set by the ALU:

FlagSet when
Z (Zero)Result = 0
C (Carry)Carry/borrow out of the MSB — unsigned out-of-range
S/N (Sign)MSB of result = 1 (negative in 2’s complement)
V/O (Overflow)Signed result out of range: V = C_n ⊕ C_{n−1}
P (Parity)Result has even number of 1s (8086: even parity → PF = 1)
AC/AF (Auxiliary Carry)Carry from bit 3 to bit 4 — used by BCD adjust (DAA, AAA)

Adders — speed hierarchy

AdderPrincipleDelayNote
Half adderS = A⊕B, C = AB—No carry-in
Full adderS = A⊕B⊕Cin, Cout = AB + Cin(A⊕B)—Building block
Ripple-carry addern full adders chainedO(n) — slow, carry must propagateSimple, cheapest
Carry-look-ahead adder (CLA)Generate Gi = AiBi, Propagate Pi = Ai⊕Bi; Ci+1 = Gi + PiCiO(log n)Fastest practical, more gates
Carry-save adderThree operands → sum + carry vectorsUsed inside multipliers
Carry-select adderCompute both carry-in cases, selectBetween ripple and CLA

Exam line for CLA: “A carry-look-ahead adder computes all carries in parallel directly from the generate and propagate terms, eliminating the sequential carry propagation delay of the ripple-carry adder.”

1.4.2 Integer Arithmetic

Addition and subtraction in 2’s complement

A − B is computed as A + B̄ + 1. The same adder does both: the control line SUB is XORed with every bit of B and fed as carry-in. Overflow: V = C_n ⊕ C_{n−1}.

Multiplication — Booth’s Algorithm (धेरै सोधिन्छ)

किन Booth? सामान्य shift-add मा हरेक bit का लागि एउटा addition चाहिन्छ। Booth ले लगातार 1 को string (जस्तै 0111) लाई एक subtraction + एक addition मा बदल्छ, र signed numbers सीधै handle गर्छ। त्यसैले operations घट्छ।

Booth recoding rule — examine Q₀ Q₋₁:

Q₀ Q₋₁MeaningAction
0 0middle of a run of 0sASR only (arithmetic shift right)
0 1end of a run of 1sA ← A + M, then ASR
1 0beginning of a run of 1sA ← A − M, then ASR
1 1middle of a run of 1sASR only

Registers: A (initially 0), Q (multiplier), Q₋₁ (initially 0), M (multiplicand), counter = n. ASR shifts A, Q, Q₋₁ right together, preserving the sign bit of A. Result = A Q (2n bits).

Worked example: (−5) × 2, n = 4. M = 2 = 0010, Q = −5 = 1011, A = 0000, Q₋₁ = 0.

StepQ₀Q₋₁ActionAQQ₋₁
init——000010110
11 0A ← A − M = 1110; ASR111101011
21 1ASR only111110101
30 1A ← A + M = 0001; ASR000011010
41 0A ← A − M = 1110; ASR111101101

Result A Q = 1111 0110 = −10 in 8-bit 2’s complement. ✔ (−5 × 2 = −10)

Other multipliers: Array multiplier (fully combinational, n² AND gates + adders — fast, large), Wallace tree (carry-save tree, O(log n)), Modified Booth / radix-4 (examines 3 bits, halves the number of partial products).

Division — Restoring vs Non-Restoring

Restoring division steps (unsigned, n-bit):

  1. A ← 0, Q ← dividend, M ← divisor, count = n
  2. Shift left A, Q by 1
  3. A ← A − M
  4. If A < 0 (sign bit = 1): Q₀ ← 0 and restore A ← A + M else: Q₀ ← 1
  5. Decrement count; repeat from 2 until count = 0
  6. Q = quotient, A = remainder

Non-restoring skips the restore step: if A is negative it shifts and adds M next time instead of subtracting (A ← 2A + M), only correcting at the very end (if A < 0 then A ← A + M). → Faster, one operation per cycle instead of possibly two, same hardware.

Divide overflow: if the divisor is zero, or if the high-order half of the dividend ≥ divisor, the quotient will not fit → the 8086 raises interrupt type 0.

1.4.3 Floating-Point Arithmetic — IEEE 754 (पक्का प्रश्न)

Format

┌───┬──────────────┬───────────────────────────────┐
│ S │   Exponent   │    Mantissa / Significand     │
└───┴──────────────┴───────────────────────────────┘
FormatTotal bitsSignExponentMantissaBiasApprox. decimal digits
Single precision (float)321823127~7
Double precision (double)64111521023~16
Extended (x87)801156416383~19
Half16151015~3

Value = (−1)^S × 1.M × 2^(E − bias) The leading 1. is the hidden / implicit bit — it is not stored, which buys one extra bit of precision. Stored exponent E = actual exponent + bias.

Special values (MCQ मा सधैँ आउँछ)

E (all bits)MMeaning
all 0s0±Zero
all 0s≠ 0Denormalised / subnormal number (no hidden bit, value = 0.M × 2^(1−bias))
all 1s0±Infinity
all 1s≠ 0NaN (Not a Number) — e.g. 0/0, √(−1)

Worked conversion: represent −12.75 in IEEE 754 single precision

  1. Sign: negative → S = 1
  2. 12.75 in binary: 12 = 1100, 0.75 = .11 → 1100.11
  3. Normalise: 1100.11 = 1.10011 × 2³ → actual exponent = 3
  4. Biased exponent E = 3 + 127 = 130 = 10000010
  5. Mantissa = fraction after the leading 1, padded to 23 bits: 10011 0000 0000 0000 0000 00
  6. Assemble: 1 | 10000010 | 10011000000000000000000 = C14C0000H

Reverse: what is 41C80000H?

0100 0001 1100 1000 … → S = 0 (+), E = 10000011 = 131 → exp = 131 − 127 = 4, M = 1001000… → 1.1001 × 2⁴ = 11001.0 = 25.0

Floating-point ADDITION / SUBTRACTION algorithm (steps रटनु)

  1. Check for zeros — if either operand is 0, return the other.
  2. Align the exponents — shift the mantissa of the smaller exponent right by the difference, incrementing its exponent until both match. (यही step मा precision गुम्छ — यो नै exam मा सोधिने “why error?” को उत्तर)
  3. Add or subtract the aligned mantissas (with sign handling).
  4. Normalise the result — shift left and decrement the exponent, or shift right and increment, until the form 1.xxx is restored.
  5. Round the mantissa to the available bits; check for overflow/underflow of the exponent.

Worked example: (1.5 × 2³) + (1.25 × 2¹) Align: 1.25 × 2¹ = 0.3125 × 2³. Add: 1.5 + 0.3125 = 1.8125 → 1.8125 × 2³ = 14.5 ✔

Multiplication / Division

  • Multiply: sign = S₁ ⊕ S₂; add exponents and subtract one bias (E = E₁ + E₂ − bias); multiply mantissas; normalise; round.
  • Divide: sign = S₁ ⊕ S₂; subtract exponents and add bias (E = E₁ − E₂ + bias); divide mantissas; normalise; round.

किन bias घटाउने/जोड्ने? दुवै exponent मा bias भित्र छ, जोड्दा bias दुईपटक आइहाल्छ — त्यसैले एकपटक घटाउनुपर्छ। Division मा उल्टो, bias काटिन्छ त्यसैले फेरि जोड्नुपर्छ।

Rounding modes (IEEE 754 defines four)

  1. Round to nearest, ties to even — the default
  2. Round toward zero (truncate / chop)
  3. Round toward +∞ (ceiling)
  4. Round toward −∞ (floor)

Guard, round and sticky bits are the three extra low-order bits kept during the computation so that the final rounding is correct.

Exceptions

Overflow (exponent too large → ±∞), Underflow (too small → denormal or 0), Division by zero (→ ±∞), Invalid operation (→ NaN), Inexact (rounding occurred).

Fixed-point vs Floating-point (Exam line):

Fixed-point representation has a constant number of fractional digits, giving uniform absolute precision over a narrow range with fast, simple hardware. Floating-point representation stores an exponent as well, giving a very wide dynamic range with uniform relative precision, at the cost of more complex hardware and of rounding error.

1.5 Memory Systems

1.5.1 The Memory Hierarchy

        ┌──────────────┐   ↑ faster, smaller, costlier per byte
        │  Registers   │   | ~0.25–1 ns,  bytes–KB
        ├──────────────┤   |
        │  L1 Cache    │   | ~1–2 ns,  32–64 KB  (split I/D — Harvard)
        ├──────────────┤   |
        │  L2 Cache    │   | ~5–10 ns, 256 KB–1 MB
        ├──────────────┤   |
        │  L3 Cache    │   | ~10–30 ns, 2–32 MB (shared between cores)
        ├──────────────┤   |
        │ Main Memory  │   | ~50–100 ns, GBs (DRAM)
        ├──────────────┤   |
        │  SSD / Disk  │   | 0.1 ms / 5–10 ms, TBs
        ├──────────────┤   |
        │ Tape / Cloud │   ↓ slower, larger, cheaper per byte
        └──────────────┘

Principle of Locality — यो hierarchy काम गर्ने कारण (Exam line):

Temporal locality: a memory location that has just been referenced is likely to be referenced again soon (loops, subroutines, counters). Spatial locality: locations whose addresses are near a referenced location are likely to be referenced soon (arrays, sequential instruction fetch). Caching exploits temporal locality by retaining recent data and spatial locality by fetching a whole block rather than a single word.

1.5.2 Internal (Semiconductor) Memory

SRAM vs DRAM (पक्का MCQ)

FeatureSRAMDRAM
Storage elementFlip-flop (6 transistors)Capacitor + 1 transistor
Refresh needed?NoYes — every few ms, else charge leaks
SpeedFastSlower
DensityLow (big cell)High (tiny cell)
Cost per bitHighLow
PowerHigh static, low dynamicLower overall
Used asCache, registersMain memory
Volatile?YesYes

DRAM किन refresh चाहिन्छ (नेपालीमा): DRAM मा bit capacitor को charge हो। Capacitor बाट charge चुहिन्छ (leakage), त्यसैले हरेक केही millisecond मा पढेर फेरि लेख्नुपर्छ — यही refresh cycle हो। SRAM मा flip-flop छ, power भएसम्म state आफैँ थामिन्छ, refresh चाहिँदैन।

DRAM variants: FPM, EDO, SDRAM (clock-synchronous), DDR / DDR2 / DDR3 / DDR4 / DDR5 (transfers on both clock edges — double data rate), RDRAM, GDDR (graphics).

ROM family

TypeWritten byErasable byReusable
Mask ROMManufacturer (at fabrication)Not erasableNo
PROMUser, once, by blowing fusesNot erasableNo
EPROMUser, electricallyUV light (quartz window), whole chipYes (~1000×)
EEPROMUser, electricallyElectrically, byte-wiseYes
FlashUser, electricallyElectrically, block-wiseYes — SSD, BIOS, pen-drive

Non-volatile सबै ROM. NOR flash = random read, used for BIOS/firmware. NAND flash = block access, high density, used in SSD/USB/SD cards.

Memory capacity / chip-count calculations (संख्यात्मक प्रश्न)

Formulas:

  • Address lines n → 2ⁿ locations. Capacity = 2ⁿ × word size.
  • Number of chips = required capacity ÷ chip capacity
  • Chips in parallel → increases word size (data lines)
  • Chips in series/banks → increases number of locations (address lines)

Example: How many 256 × 4 RAM chips are needed to build a 2 K × 8 memory?

  • Word size: need 8 bits, chip gives 4 → 2 chips in parallel
  • Locations: need 2048, chip gives 256 → 2048 / 256 = 8 banks
  • Total = 2 × 8 = 16 chips
  • Address lines: 2048 = 2¹¹ → 11 lines (8 to the chips, 3 to the bank decoder)

1.5.3 Cache Memory — सबैभन्दा महत्वपूर्ण उपविषय

Exam line:

Cache memory is a small, fast SRAM placed between the CPU and main memory that holds copies of the most recently and most frequently used blocks of main memory, so that the average memory access time seen by the processor approaches the cache access time rather than the main-memory access time.

Address breakdown

With an n-bit main-memory address and a block (line) size of 2^b bytes:

MappingAddress fieldsTag width
DirectTag ∣ Line ∣ Wordn − l − b (where cache has 2^l lines)
Fully associativeTag ∣ Wordn − b
k-way set associativeTag ∣ Set ∣ Wordn − s − b (where 2^s sets = lines/k)

The three mapping techniques

FeatureDirect MappingFully AssociativeSet Associative (k-way)
RuleBlock j → line j mod LBlock can go anywhereBlock j → set j mod S, any of k lines in that set
Tag comparators1L (all, in parallel)k
Hardware costCheapestMost expensive (CAM)Middle — practical compromise
Replacement algorithmNot needed (only one choice)Needed (LRU etc.)Needed, within the set
Conflict missesHighest — thrashing if two hot blocks map to the same lineNoneLow
Tag sizeSmallestLargestMiddle
Search timeFastestSlowestMiddle
Used in practiceRare / simple L1Small TLBs, victim cachesAlmost all real caches (4-way, 8-way, 16-way)

नेपालीमा सम्झने तरिका: Direct = “हरेक block को एउटै तोकिएको सिट” — सस्तो तर दुई हट block एउटै सिटमा परे झगडा (thrashing)। Fully associative = “जहाँ खाली छ त्यहीँ बस” — उत्तम तर सबै सिट एकैचोटि जाँच्नुपर्छ, धेरै महँगो। Set-associative = “तोकिएको पंक्ति (set), पंक्ति भित्र जहाँ पनि” — यही व्यावहारिक।

Worked numerical — हरेक वर्ष यो ढाँचा आउँछ

A computer has 16 MB main memory, a 64 KB cache and a block size of 16 bytes. Find the address format for direct, fully associative, and 4-way set associative mapping.

  • Main memory 16 MB = 2²⁴ → 24-bit address
  • Block size 16 = 2⁴ → Word/offset = 4 bits
  • Number of cache lines = 64 KB / 16 B = 4096 = 2¹²
MappingWordLine / SetTagTotal
Direct4Line = 1224 − 12 − 4 = 824 ✔
Fully associative4—24 − 4 = 2024 ✔
4-way set assoc.4Sets = 4096/4 = 1024 = 2¹⁰ → 1024 − 10 − 4 = 1024 ✔

Cache performance formulas (रटनु)

  • Hit ratio h = hits / (hits + misses); Miss ratio = 1 − h
  • AMAT (Average Memory Access Time) = Hit time + (Miss ratio × Miss penalty)
  • Simultaneous (parallel) lookup: T_avg = h·Tc + (1 − h)·Tm
  • Hierarchical (sequential) lookup: T_avg = h·Tc + (1 − h)·(Tc + Tm)
  • Two-level: T = h₁T₁ + (1−h₁)h₂T₂ + (1−h₁)(1−h₂)Tm
  • Speed-up = Tm / T_avg

Example: Tc = 10 ns, Tm = 100 ns, h = 0.95.

  • Simultaneous access: 0.95(10) + 0.05(100) = 9.5 + 5 = 14.5 ns
  • Hierarchical access: 0.95(10) + 0.05(110) = 9.5 + 5.5 = 15 ns

परीक्षामा कुन मान्ने? Question मा “cache miss भएपछि memory जाने” लेखेको भए hierarchical; नलेखेको भए assumption स्पष्ट लेखिदिनु।

Replacement algorithms

AlgorithmRuleNote
FIFOReplace the oldest loaded blockSimple; may evict a hot block
LRU (Least Recently Used)Replace the block unused for the longest timeBest practical performance, exploits temporal locality; costly to track exactly (pseudo-LRU used)
LFU (Least Frequently Used)Replace the least-referenced blockNeeds counters; old hot blocks stick
RandomPick anyCheapest hardware, surprisingly decent
Optimal (OPT/MIN)Replace the block needed furthest in the futureTheoretical benchmark only — needs future knowledge

Write policies

PolicyMechanismProsCons
Write-throughWrite to cache and memory at the same timeMemory always consistent; simple; safe for DMA/multiprocessorHigh bus traffic, slow writes
Write-back (copy-back)Write only to cache; set a dirty bit; write to memory only on evictionFast, far less bus trafficMemory temporarily stale → coherence problem with DMA/other cores
Write bufferQueue in front of memoryHides write-through latencyExtra hardware
Write-allocateOn a write miss, first load the block into cacheGood with write-backExtra read
No-write-allocate (write-around)On a write miss, write straight to memoryGood with write-throughNo benefit on rewrite

The three C’s — types of cache miss

MissCauseReduced by
Compulsory / Cold-startFirst-ever reference to a blockLarger blocks, prefetching
CapacityCache too small to hold the working setLarger cache
Conflict / CollisionToo many blocks map to the same setMore associativity, victim cache

Cache coherence (multiprocessor / DMA)

When several caches hold the same block, a write by one must not leave the others stale. Solutions: write-through + bus snooping, MESI protocol (Modified, Exclusive, Shared, Invalid), directory-based coherence, or marking shared pages non-cacheable.

1.5.4 Virtual Memory (closely linked; also Paper I Unit 3)

  • Virtual (logical) address generated by the CPU → translated by the MMU into a physical address.
  • Paging: fixed-size pages ↔ frames; page table per process; page fault → OS loads the page from disk.
  • TLB (Translation Lookaside Buffer): a small fully-associative cache of recent page-table entries — without it every access would need an extra memory read.
  • Segmentation: variable-size logical segments; suffers external fragmentation. Paging suffers internal fragmentation.
  • Effective access time = h·(TLB + mem) + (1−h)·(TLB + 2·mem) (single-level page table)
  • Cache vs Virtual memory: cache is managed by hardware between CPU and memory; virtual memory is managed by the OS between memory and disk.

1.5.5 External (Secondary) Memory

Magnetic disk geometry & performance

Terms: Platter, Track, Sector, Cylinder (same track on all platters), Head, Spindle, Actuator arm. Capacity = heads × cylinders × sectors/track × bytes/sector

Disk access time (Exam formula — रटनु):

Access time = Seek time + Rotational latency + Transfer time (+ Controller/queuing delay)
  • Seek time — move the head to the right track (the largest component, ~4–10 ms)
  • Rotational latency — wait for the sector to come under the head; average = half a revolution = 30000 / RPM (in ms)
  • Transfer time = bytes to transfer / transfer rate

Example: 7200 RPM disk, average seek 5 ms, transfer rate 100 MB/s, read 4 KB.

  • Rotational latency (avg) = 30000 / 7200 = 4.17 ms
  • Transfer = 4 KB ÷ 100 MB/s = 0.04 ms
  • Total ≈ 5 + 4.17 + 0.04 = 9.21 ms

Disk scheduling algorithms (one-liners)

FCFS (fair, poor), SSTF (shortest seek first — starvation), SCAN (elevator — sweeps to the end and reverses), C-SCAN (returns to the start without serving — more uniform wait), LOOK / C-LOOK (reverses at the last request, not the physical end).

RAID — Redundant Array of Independent Disks (table रटनु)

LevelTechniqueMin disksUsable capacityFault toleranceNote
RAID 0Striping, no redundancy2N (100%)NoneBest performance & capacity, highest risk
RAID 1Mirroring2N/2 (50%)1 disk per mirrorBest read, costly, simple recovery
RAID 2Bit-level striping + Hamming ECC3—1 diskObsolete
RAID 3Byte-level striping + dedicated parity disk3N−11 diskParity disk is a bottleneck
RAID 4Block-level striping + dedicated parity disk3N−11 diskParity disk is a bottleneck
RAID 5Block striping + distributed parity3N−11 diskMost popular — good read, write penalty
RAID 6Block striping + dual distributed parity4N−22 disksSafer, higher write cost
RAID 10 (1+0)Mirror then stripe4N/21 per mirror setBest performance + redundancy; used for databases

बैंकिङ सन्दर्भ (NRB परीक्षामा उपयोगी): core banking database सर्भरमा सामान्यतया RAID 10 (performance + redundancy) र archival/file storage मा RAID 5/6 प्रयोग हुन्छ। RAID backup को विकल्प होइन — यो केवल availability दिन्छ, logical corruption वा ransomware बाट बचाउँदैन। यो वाक्य exam मा लेख्नु।

SSD vs HDD

HDDSSD
TechnologyRotating magnetic plattersNAND flash, no moving parts
Access time5–10 ms0.05–0.1 ms
Seek penaltyLarge (mechanical)None — true random access
Shock resistance / noise / powerPoor / noisy / higherGood / silent / lower
Cost per GBLowerHigher
WearMechanical failureLimited P/E cycles — needs wear levelling, TRIM, over-provisioning

Optical and tape

CD ~700 MB (780 nm laser), DVD 4.7 GB single-layer (650 nm), Blu-ray 25 GB/layer (405 nm blue-violet). Shorter wavelength → smaller pits → more capacity. Magnetic tape = sequential access only, cheapest per GB, still used for long-term archival/offsite backup (LTO).

1.6 CPU Structure and Function

1.6.1 Processor Organisation

What a CPU must do: fetch instruction → interpret it → fetch data → process data → write data.

Main components:

  • Control Unit (CU) — generates the timing and control signals
  • ALU — arithmetic and logic
  • Registers — fast internal storage
  • Internal CPU interconnection (internal bus) — links CU, ALU and registers

1.6.2 Register Organisation

(a) User-visible registers (programmer can name them)

ClassPurpose
General purposeAny use — operands, addresses (AX, BX…, R0–R31)
Data registersData only (accumulator)
Address registersIndex register, segment pointer, stack pointer, base register
Condition code / flagsPartly visible — readable, set by hardware, usually not directly writable

Design issues (exam point): how many registers? (RISC: 32+; CISC: 8–16; too few → more memory traffic, too many → longer instruction fields and slower context switch). How wide? Enough to hold the largest address and the largest data word.

(b) Control and status registers (mostly invisible)

PC, IR, MAR, MDR, PSW (Program Status Word: Sign, Zero, Carry, Overflow, Equal, Interrupt-enable, Supervisor/user mode), interrupt vector register, page-table base register, interrupt-stack pointer.

Supervisor (kernel) vs User mode: privileged instructions (I/O, halt, changing the page table) execute only in supervisor mode. यो bit PSW मा हुन्छ — OS security को आधार यही हो।

(c) Register file / windows

Register file = the physical array of GPRs. RISC machines use large register files plus register windows (SPARC) or register renaming (superscalar) to cut memory traffic and remove false dependences.

1.6.3 Instruction Pipelining (10-mark प्रश्नको प्रमुख विषय)

Exam line:

Pipelining is a technique of overlapping the execution of several instructions by dividing the datapath into independent stages, each of which works on a different instruction simultaneously — analogous to an assembly line. It increases instruction throughput without reducing the latency of any single instruction.

Classic 5-stage RISC pipeline

IF (Instruction Fetch) → ID (Instruction Decode / register read) → EX (Execute / address calculation) → MEM (Memory access) → WB (Write Back)

        1    2    3    4    5    6    7    8    9
I1 :   IF   ID   EX  MEM   WB
I2 :        IF   ID   EX  MEM   WB
I3 :             IF   ID   EX  MEM   WB
I4 :                  IF   ID   EX  MEM   WB
I5 :                       IF   ID   EX  MEM   WB

Pipeline formulas (रटनु)

For n instructions, k stages, cycle time t:

  • Non-pipelined time = n × k × t
  • Pipelined time = (k + n − 1) × t
  • Speed-up S = (n × k) / (k + n − 1); as n → ∞, S → k
  • Maximum theoretical speed-up = k (number of stages)
  • Efficiency = S / k; Throughput = n / [(k + n − 1) t]

Example: 4-stage pipeline, 100 instructions, 1 ns per stage. Non-pipelined = 100 × 4 = 400 ns. Pipelined = (4 + 100 − 1) = 103 ns. Speed-up = 400/103 ≈ 3.88 (approaching the ideal 4).

Pipeline hazards (तीन किसिम — रटनु)

HazardCauseSolution
Structural (resource)Two instructions need the same hardware unit in the same cycle (e.g. one memory port)Duplicate the resource, split I/D cache (Harvard), stall
DataAn instruction needs a result not yet producedOperand forwarding / bypassing, register renaming, compiler scheduling, stall (bubble)
Control (branch)The next address is unknown until the branch resolvesBranch prediction, branch target buffer, delayed branch (delay slot), speculative execution, loop unrolling

Data dependence types: RAW (Read After Write — true dependence, the real problem), WAR (Write After Read — anti-dependence), WAW (Write After Write — output dependence). WAR and WAW are name dependences, removable by register renaming.

Beyond simple pipelining

TechniqueIdea
SuperscalarMultiple pipelines issue several instructions per cycle; hardware finds the parallelism. IPC > 1
SuperpipelinedMore, shorter stages → higher clock
VLIWOne very long instruction word holds several independent operations; the compiler finds the parallelism (Itanium)
Out-of-order executionIssue instructions as their operands become ready; reorder buffer commits them in order
Multithreading / SMT (Hyper-Threading)One core interleaves several thread contexts to fill idle slots
MulticoreSeveral complete cores on one die — explicit MIMD

Amdahl’s Law Speedup = 1 / [(1 − f) + f/N] — the serial fraction limits the benefit of adding processors. f = parallelisable fraction, N = processors. As N → ∞, Speedup → 1/(1 − f).

1.6.4 PowerPC Processor

Exam line (परिचय):

PowerPC (Performance Optimization With Enhanced RISC — Performance Computing) is a 64-bit-capable RISC load/store architecture developed from 1991 by the AIM alliance of Apple, IBM and Motorola, derived from IBM’s POWER architecture used in the RS/6000. The first implementation, the PowerPC 601, shipped in 1993.

Key architectural features

FeatureDetail
TypeRISC, superscalar, load/store
Instruction lengthFixed 32 bits, mostly 3-address
GPRs32 general purpose registers (32-bit in 32-bit impl., 64-bit in 64-bit impl.)
FPRs32 floating-point registers, 64-bit, full IEEE 754
Addressing modesOnly three: register indirect, register indirect with immediate index (displacement), register indirect with index — typical RISC economy
CacheSeparate (Harvard-style) L1 instruction and data caches
EndiannessBi-endian; default big-endian
BranchesBranch prediction, no delay slot; dedicated branch unit
MemoryPaged virtual memory, segmented addressing, 32-/64-bit modes

PowerPC special-purpose registers (MCQ)

RegisterFunction
CR — Condition Register32 bits as 8 four-bit fields (CR0–CR7); holds comparison results so branches need not share one flags word
LR — Link RegisterHolds the return address for subroutine calls (bl)
CTR — Count RegisterLoop counter; bdnz decrements and branches — hardware loop support
XERInteger exception register — carry (CA), overflow (OV), summary overflow (SO), byte count
FPSCRFloating-point status and control (rounding mode, exceptions)
MSRMachine State Register — privilege level, interrupt enables, endian mode

Family members (chronology — MCQ मा आउँछ)

ChipYearNote
6011993First PowerPC; 32-bit; bridge from POWER
6031994Low power → used in PowerBook laptops
6041994High-performance desktop, 4-issue superscalar
6201997First 64-bit PowerPC
750 / G31997Backside L2 cache
7400 / G41999Added AltiVec / VMX — a 128-bit SIMD vector unit
970 / G5200364-bit, derived from IBM POWER4

Where PowerPC was used: Apple Power Macintosh / iMac / PowerBook (until the 2006 switch to Intel), IBM RS/6000 and AS/400, Xbox 360 (Xenon), PlayStation 3 (Cell Broadband Engine PPE), Nintendo GameCube and Wii, and still today in automotive, avionics, networking and industrial embedded control (NXP QorIQ). In 2019 the ISA became open as OpenPOWER.

PowerPC vs 8086/x86 — exam comparison

PowerPCIntel 8086/x86
PhilosophyRISCCISC
Instruction lengthFixed 32-bitVariable 1–15 bytes
Registers32 GPR + 32 FPR8 GPR (16-bit)
Memory accessLoad/Store onlyMost instructions
Addressing modes38+
Control unitHardwiredMicroprogrammed
EndiannessBig-endian (bi-endian)Little-endian
Condition codes8 separate CR fieldsOne FLAGS register
PipeliningDeep, easyHard — needs internal µop translation

1.7 808X and Intel Microprocessors

1.7.1 Intel 8086 — Architecture

Exam line:

The Intel 8086, introduced in 1978, is a 16-bit HMOS microprocessor with a 16-bit data bus and a 20-bit address bus, giving it 1 MB of directly addressable memory and a 64 KB I/O space. It contains about 29,000 transistors in a 40-pin DIP package and is internally divided into a Bus Interface Unit (BIU) and an Execution Unit (EU), which operate concurrently to give a primitive form of pipelining.

BIU vs EU (यो विभाजन 8086 को मूल अवधारणा हो)

Bus Interface Unit (BIU)Execution Unit (EU)
JobTalks to the outside worldExecutes instructions
Contains4 segment registers (CS, DS, SS, ES), IP, address-generation adder, 6-byte instruction queue, bus control logicALU, general registers (AX–DX, SP, BP, SI, DI), flag register, instruction decoder, EU control system
ActivityFetches instructions and operands, computes physical addresses, drives the busesDecodes and executes whatever is in the queue
BenefitPrefetching — while the EU executes, the BIU fills the queue → fetch/execute overlap

नेपालीमा: 8086 भित्र दुई “कर्मचारी” छन्। BIU भनेको सामान ल्याउने मान्छे — instruction अग्रिम ल्याएर 6-byte queue मा राख्छ। EU भनेको काम गर्ने मान्छे — queue बाट उठाएर चलाउँछ। दुवै सँगै चल्छन्, त्यसैले EU कुर्नुपर्दैन। यही pipelining को सुरुवाती रूप हो। तर branch/jump भएमा queue मा भएका सबै instruction बेकामे हुन्छन् → queue flush हुन्छ (यो penalty MCQ मा सोध्छ)।

8086 vs 8088 (पक्का MCQ)

80868088
External data bus16-bit8-bit
Internal architecture16-bit16-bit
Instruction queue6 bytes4 bytes
Memory1 MB1 MB
I/O-related pinBHE/S7, M/IOSS0, IO/M (inverted)
Used in—IBM PC (1981)

Register set (रटनु)

GroupRegistersSpecial use
General / Data (16-bit, splittable into 8-bit H & L)AX (AH,AL)Accumulator — MUL/DIV/IN/OUT implicitly use it
BX (BH,BL)Base register — the only data register usable as an offset/pointer
CX (CH,CL)Counter — LOOP, REP, shift/rotate counts
DX (DH,DL)Data — high half of MUL/DIV results, and holds the port address for variable-port IN/OUT
Pointer / IndexSPStack Pointer — offset of the top of stack, with SS
BPBase Pointer — accesses parameters/locals in the stack frame, with SS
SISource Index — source offset in string ops, with DS
DIDestination Index — destination offset in string ops, with ES
SegmentCSCode Segment — with IP
DSData Segment — default for data
SSStack Segment — with SP/BP
ESExtra Segment — with DI for strings
Instruction pointerIPOffset of the next instruction within CS — not directly writable
StatusFLAGS16-bit, 9 flags used

Flag register — 9 of 16 bits used

 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
  -  -  -  - OF DF IF TF SF ZF  - AF  - PF  - CF
TypeFlagBitMeaning
Conditional (set by ALU)CF Carry0Carry/borrow out of MSB
PF Parity2Result has even number of 1s
AF Auxiliary carry4Carry from bit 3→4 (BCD)
ZF Zero6Result = 0
SF Sign7MSB of result = 1
OF Overflow11Signed overflow
Control (set by programmer)TF Trap81 → single-step (debugging)
IF Interrupt enable91 (STI) → INTR allowed; 0 (CLI) → masked
DF Direction100 (CLD) → SI/DI auto-increment; 1 (STD) → auto-decrement

1.7.2 Memory Segmentation (निश्चित प्रश्न)

Problem: the 8086 has only 16-bit registers, but a 20-bit address bus. 16 bits can only express 64 KB — so how is 1 MB reached?

Solution — segment : offset addressing.

Physical Address = (Segment register value × 10H) + Offset
                 = (Segment value shifted LEFT by 4 bits) + Offset

Worked example: CS = 2000H, IP = 1234H PA = 2000H × 10H + 1234H = 20000H + 1234H = 21234H

Reverse question: which segment:offset pairs give PA = 21234H? Many — e.g. 2123:0004, 2000:1234, 2100:0234. Segment:offset is not unique; this is called address aliasing/overlapping and is a favourite MCQ.

Key segmentation facts (रटनु)

FactValue
Number of segments active at a time4 (CS, DS, SS, ES)
Maximum size of one segment64 KB (16-bit offset)
Total addressable memory1 MB (20-bit)
Segments must start on aparagraph boundary — a multiple of 16 bytes (so the low 4 bits of the base are 0)
Segments may overlap?Yes
Number of possible segment start addresses2¹⁶ = 65 536

Default segment:offset pairings (MCQ):

PairPurpose
CS : IPNext instruction
SS : SPTop of stack (PUSH/POP)
SS : BPStack frame access (parameters/locals)
DS : BX / SI / DI / displacementData access
ES : DIString destination

Advantages of segmentation (Exam line):

Segmentation allows a 16-bit processor to address 1 MB of memory, permits dynamic relocation of programs (only the segment register must be changed), separates code, data and stack so each can be independently protected and shared, and allows multiple programs to coexist without rewriting addresses.

1.7.3 8086 Pin Configuration & Operating Modes

40-pin DIP, 5 V, clock 5 MHz (8086), 8 MHz (8086-2), 10 MHz (8086-1).

PinsFunction
AD0–AD15Time-multiplexed address/data (address in T1, data in T2–T4)
A16/S3 – A19/S6Multiplexed upper address / status
BHE/S7Bus High Enable — selects the odd (upper) memory bank
ALEAddress Latch Enable — pulsed in T1 to latch the address into the 8282/8283 latch
RD, WRRead / Write strobes
M/IO1 = memory, 0 = I/O
DT/R, DENData transmit/receive and data enable — control the 8286/8287 transceiver
READYLow → insert wait states (slow memory/IO)
RESETCS = FFFFH, IP = 0000H → boot address FFFF0H; flags, DS, ES, SS, queue cleared
INTR, NMI, INTAMaskable interrupt, non-maskable interrupt, interrupt acknowledge
HOLD, HLDADMA bus request / acknowledge
TEST, LOCKUsed with WAIT for the 8087 coprocessor; bus lock for multiprocessing
MN/MXMode select — see below
CLK, Vcc, GNDFrom the 8284 clock generator; 5 V

Minimum vs Maximum mode (पक्का प्रश्न)

Minimum mode (MN/MX = Vcc / HIGH)Maximum mode (MN/MX = GND / LOW)
ProcessorsSingle processorMultiprocessor — supports the 8087 NDP / 8089 IOP
Control signalsGenerated by the 8086 itself (M/IO, RD, WR, ALE, DEN, DT/R, INTA)Generated by the external 8288 Bus Controller from status lines S0 S1 S2
Extra chips8284 clock, 8282 latch, 8286 transceiver+ 8288 bus controller, 8289 bus arbiter
Bus request pinsHOLD / HLDARQ/GT0, RQ/GT1
Queue status—QS0, QS1 — let the coprocessor track the queue
Cost / complexityLowHigh

8288 decodes S2 S1 S0: 000=INTA, 001=IORC, 010=IOWC, 011=HALT, 100=code access, 101=MRDC, 110=MWTC, 111=passive.

1.7.4 8086 Assembly Programming

Program skeleton

ASM
.MODEL SMALL
.STACK 100H
.DATA
    NUM1   DB  25H
    NUM2   DB  13H
    RESULT DB  ?
    MSG    DB  'Hello$'
.CODE
MAIN PROC
    MOV  AX, @DATA        ; load the data segment
    MOV  DS, AX
    MOV  AL, NUM1
    ADD  AL, NUM2
    MOV  RESULT, AL
    MOV  AH, 4CH          ; DOS terminate
    INT  21H
MAIN ENDP
END MAIN

Program 1 — sum of an array of N bytes

ASM
    MOV  CX, N            ; counter
    MOV  SI, OFFSET ARR   ; pointer
    MOV  AL, 0            ; running sum
NEXT:
    ADD  AL, [SI]
    INC  SI
    LOOP NEXT             ; CX ← CX−1, jump while CX ≠ 0
    MOV  SUM, AL

Program 2 — find the largest of N bytes

ASM
    MOV  CX, N
    DEC  CX
    MOV  SI, OFFSET ARR
    MOV  AL, [SI]         ; assume the first is the largest
UP:
    INC  SI
    CMP  AL, [SI]
    JAE  SKIP             ; jump if AL ≥ [SI]  (unsigned)
    MOV  AL, [SI]
SKIP:
    LOOP UP
    MOV  MAX, AL

Program 3 — multiply two 16-bit numbers

ASM
    MOV  AX, NUM1
    MUL  NUM2             ; unsigned: DX:AX ← AX × NUM2
    MOV  PROD_LOW,  AX
    MOV  PROD_HIGH, DX

MUL with a byte operand: AX ← AL × operand. With a word operand: DX:AX ← AX × operand.

Program 4 — block transfer using string instructions

ASM
    MOV  AX, @DATA
    MOV  DS, AX
    MOV  ES, AX           ; ES needed for the destination
    MOV  SI, OFFSET SRC
    MOV  DI, OFFSET DEST
    MOV  CX, COUNT
    CLD                   ; DF = 0 → auto-increment
    REP  MOVSB            ; repeat CX times: ES:[DI] ← DS:[SI]

Useful DOS interrupts (INT 21H with the function number in AH): 01H read a character, 02H display the character in DL, 09H display the $-terminated string at DS:DX, 0AH buffered input, 4CH terminate program.

1.7.5 Interfacing — the Intel support chips (रटनु)

ChipNameFunction
8255PPI — Programmable Peripheral Interface3 ports A, B, C = 24 parallel I/O lines. Modes: 0 simple I/O, 1 handshake (strobed) I/O, 2 bidirectional (port A only); plus BSR mode to set/reset individual port-C bits
8259PIC — Programmable Interrupt Controller8 interrupt inputs (IR0–IR7), cascadable to 64 levels, programmable priority (fixed/rotating), masking (IMR), supplies the vector type to the CPU
8257 / 8237DMAC — DMA Controller4 channels, address + word-count registers per channel, burst/cycle-stealing modes
8251USARTSerial communication — synchronous and asynchronous, programmable baud rate, parity, stop bits; RS-232 interface
8253 / 8254PIT — Programmable Interval Timer3 independent 16-bit counters, 6 modes (e.g. mode 3 = square-wave generator); used for the system clock tick and speaker tone
8279Keyboard/Display controllerScans a keyboard matrix and drives 7-segment displays
8284Clock generatorGenerates CLK, RESET, READY from a crystal
8282/8283Octal latchDemultiplexes address from AD0–AD15 using ALE
8286/8287Octal transceiverBuffers the bidirectional data bus
8288Bus controllerGenerates control signals in maximum mode
8289Bus arbiterMultiprocessor bus arbitration
8087NDP — Numeric Data ProcessorFloating-point math coprocessor; IEEE 754; 80-bit internal registers; works in max mode with TEST/WAIT

8255 — the standard interfacing question

Control word format (bit 7 = 1 → I/O mode; bit 7 = 0 → BSR mode). Port addresses with base X: X = Port A, X+1 = Port B, X+2 = Port C, X+3 = Control register.

Example: configure the 8255 at base address 80H with Port A as output, Port B as input, Port C as output, all in mode 0. Control word = 1 00 0 1 0 0 0 = 88H

ASM
    MOV  AL, 88H
    OUT  83H, AL          ; write to the control register
    MOV  AL, DATA
    OUT  80H, AL          ; send to Port A
    IN   AL, 81H          ; read from Port B

Memory interfacing arithmetic

To interface two 8-bit memory banks to the 8086’s 16-bit bus, the 8086 splits memory into an even (lower) bank selected by A0 = 0 and an odd (upper) bank selected by BHE = 0.

BHEA0Transfer
10Even byte only (from the lower bank)
01Odd byte only (from the upper bank)
00Full word from an even address — 1 bus cycle
11None

Misaligned (odd-address) word access needs TWO bus cycles — this is why aligning data on even addresses improves 8086 performance. यो MCQ मा सोधिन्छ।

1.7.6 Microinstruction Sequencing and Execution

Hardwired vs Microprogrammed control (पक्का 5-mark प्रश्न)

FeatureHardwired controlMicroprogrammed control
ImplementationFixed logic: gates, flip-flops, decoders, counters, sequential circuitA microprogram stored in control memory (control store / ROM)
SpeedFastSlower (extra control-memory fetch each step)
FlexibilityRigid — changing the instruction set means redesigning the circuitFlexible — just rewrite the microcode
Design / debuggingDifficult, error-proneSystematic, easy to modify, easy to add instructions
Cost for complex ISAVery highLower
Chip areaLess (for simple ISAs)More (control memory)
Suited toRISC (simple, regular instructions)CISC (complex, variable instructions)
ExamplesARM, MIPS, PowerPCIntel x86/8086, VAX, IBM 370

नेपालीमा: Hardwired भनेको “सिधै तारले जोडिएको सर्किट” — छिटो तर एकपटक बनेपछि फेर्न सकिँदैन। Microprogrammed भनेको “ROM भित्र सानो program लेखेर राखेको” — हरेक machine instruction भित्र धेरै microinstruction हुन्छन्। नयाँ instruction थप्नुपर्यो? ROM को microcode बदल्यो, सकियो। त्यसैले CISC (धेरै जटिल instruction भएको) लाई microprogramming सुहाउँछ।

Microprogrammed control unit — components

 Opcode from IR
       │
       ▼
┌──────────────┐    ┌──────────────┐    ┌──────────────────┐
│ Mapping      │───►│ Control      │───►│  Control Memory  │
│ Logic        │    │ Address Reg. │    │   (ROM/Writable  │
└──────────────┘    │   (CAR)      │    │   control store) │
       ▲            └──────────────┘    └────────┬─────────┘
       │                   ▲                     │
┌──────┴───────┐    ┌──────┴───────┐             ▼
│ Status/Flags │───►│  Sequencer   │   ┌────────────────────┐
└──────────────┘    │ (MUX + INCR  │◄──│ Control Data Reg.  │
                    │  + SBR)      │   │  (CDR / pipeline)  │
                    └──────────────┘   └─────────┬──────────┘
                                                 ▼
                                      Control signals to ALU,
                                      registers, buses, memory
ComponentFunction
Control Memory (control store)Holds the microprogram — one microinstruction per control word
CAR (Control Address Register)Holds the address of the next microinstruction — the “micro-PC”
CDR (Control Data Register)Holds the microinstruction currently being executed
SequencerDecides the next CAR value
IncrementerCAR ← CAR + 1 for sequential flow
Mapping logicConverts the opcode into the starting address of that instruction’s microroutine
SBR (Subroutine Register)Saves the return address for microsubroutines (shared microroutines such as effective-address calculation)
MUXSelects the next address source: increment / branch field / mapped opcode / SBR

Microinstruction format

┌──────────────┬──────────────┬──────────────┬──────────────┐
│  F1 F2 F3    │     CD       │      BR      │      AD      │
│ control      │  condition   │   branch     │   address    │
│ (micro-ops)  │   select     │    type      │    field     │
└──────────────┴──────────────┴──────────────┴──────────────┘
  • Control field — the micro-operations to perform this cycle
  • Condition (CD) — which status bit to test (unconditional, indirect, sign, zero)
  • Branch (BR) — JMP, CALL, RET, MAP
  • Address (AD) — branch target in control memory

Microinstruction sequencing methods

  1. Explicit next-address field — every microinstruction names its successor. Flexible, no incrementer, but a wider control word.
  2. Incrementer + branch field (two-field) — default is CAR+1; a branch field overrides it. Most common.
  3. Mapping from the opcode — the opcode is transformed into the microroutine’s start address. Mano’s mapping: 0 ∣ opcode ∣ 00.
  4. Subroutine via SBR — CALL saves CAR+1 in SBR, RET restores it.

Horizontal vs Vertical microinstructions (पक्का प्रश्न)

FeatureHorizontalVertical
EncodingUnencoded — one bit per control signalEncoded fields
Word lengthLong / wideShort / narrow
Decoder needed?No (or minimal)Yes — extra decode delay
ParallelismHigh — many micro-ops per microinstructionLow — usually one micro-op
SpeedFasterSlower
Control memory sizeLarge (wide words)Small
Microprogram lengthShorterLonger
ProgrammingHarder (bit-level)Easier (mnemonic-like)

Nanoprogramming (two-level control store): a short vertical microprogram indexes into a horizontal nanomemory, getting horizontal speed with vertical storage economy. Used in the Motorola 68000.

Microinstruction execution — the two phases of each micro-cycle

  1. Fetch: CDR ← ControlMemory[CAR]
  2. Execute: issue the control signals in CDR and simultaneously compute the next CAR in the sequencer (these overlap — a microinstruction pipeline).

Terminology ladder (रटनु):

Program  →  Instruction (machine/macro)  →  Microinstruction  →  Micro-operation

One machine instruction = several microinstructions; one microinstruction = several simultaneous micro-operations.

1.7.7 Intel processor evolution (MCQ का तथ्य)

ProcessorYearData busAddress busMemoryNote
400419714-bit——First microprocessor
800819728-bit14-bit16 KB
808019748-bit16-bit64 KB
808519768-bit16-bit64 KB40-pin, 6500 transistors
8086197816-bit20-bit1 MB29 000 transistors, 6-byte queue
808819798-bit20-bit1 MBUsed in the IBM PC
80286198216-bit24-bit16 MBProtected mode, virtual memory
80386198532-bit32-bit4 GBFirst 32-bit x86; paging
80486198932-bit32-bit4 GBOn-chip 8 KB cache + integrated FPU; 5-stage pipeline
Pentium199332-bit (64-bit ext.)32-bit4 GBSuperscalar (2 pipelines)
Pentium Pro / II / III1995–9936-bit64 GBOut-of-order, MMX/SSE
Pentium 42000NetBurst, Hyper-Threading
Core / Core i-series2006–Multicore, 64-bit (x86-64)

PART 2 — REVISION TOOLKIT

A. One-Page Formula Sheet (परीक्षा अघि यही पढ्नु)

Number systems & data

n-bit unsigned range0 … 2ⁿ − 1
n-bit 2’s complement range−2ⁿ⁻¹ … 2ⁿ⁻¹ − 1
n-bit 1’s comp / sign-magnitude−(2ⁿ⁻¹ − 1) … +(2ⁿ⁻¹ − 1)
2’s complement of X1's complement(X) + 1 = 2ⁿ − X
Signed overflowV = C_n ⊕ C_{n−1}
Binary → GrayG = B ⊕ (B >> 1)
BCD4 bits per decimal digit; 1010–1111 invalid

Floating point (IEEE 754)

Value(−1)^S × 1.M × 2^(E − bias)
Single1 + 8 + 23, bias 127
Double1 + 11 + 52, bias 1023
Multiply exponentE = E₁ + E₂ − bias
Divide exponentE = E₁ − E₂ + bias

Memory & cache

Address lines n2ⁿ locations
Chips needed(parallel for word size) × (banks for locations)
Offset/word bitslog₂(block size)
Direct-map tagn − log₂(lines) − log₂(block)
Fully-assoc tagn − log₂(block)
k-way tagn − log₂(lines/k) − log₂(block)
AMATHit time + Miss ratio × Miss penalty
T_avg parallelh·Tc + (1−h)·Tm
T_avg hierarchicalh·Tc + (1−h)(Tc + Tm)
Speed-upTm / T_avg

Disk

Access timeSeek + Rotational latency + Transfer
Avg rotational latency (ms)30000 / RPM
Capacityheads × cylinders × sectors/track × bytes/sector
RAID 5 capacityN − 1 disks, tolerates 1 failure
RAID 6 capacityN − 2 disks, tolerates 2 failures
RAID 1 / 10 capacityN / 2

Pipelining

Non-pipelined timen × k × t
Pipelined time(k + n − 1) × t
Speed-upn·k / (k + n − 1) → max = k
EfficiencySpeed-up / k
Throughputn / [(k + n − 1) t]
Amdahl’s law1 / [(1 − f) + f/N]

8086

Physical addressSegment × 10H + Offset
Memory20 address lines → 1 MB
I/O ports16 lines → 64 K
Max segment size64 KB
Segment boundarymultiple of 16 bytes
Instruction queue6 bytes (8088: 4)
Machine cycle4 T-states (T1–T4) + Tw
IVT00000H–003FFH, 1 KB, 4 bytes/entry, 256 types
Vector addresstype × 4
Boot address after RESETFFFF0H (CS = FFFFH, IP = 0000H)
Pushed on interruptFLAGS, CS, IP (6 bytes)

B. MCQ Bank — 70 questions with answers

(Negative marking 0.2 — नथाहा भए छोड्नु; दुईमा घटाउन सकेको भए अनुमान लगाउनु।)

#QuestionAnswer
1Von Neumann architecture uses ___ memory for data and instructionsOne (shared)
2Which architecture allows simultaneous instruction and data fetch?Harvard
3The “Von Neumann bottleneck” refers toThe shared single bus/memory limiting CPU speed
4RISC control unit is usuallyHardwired
5CISC instruction length isVariable
6PowerPC belongs to which class?RISC
7GPU parallelism is best classified asSIMD
8Which Flynn class is largely theoretical?MISD
9Multicore processors areMIMD
10Flynn’s classification was proposed in1966
11In 2’s complement, how many representations of zero?One
124-bit 2’s complement range−8 to +7
13Overflow in signed addition is detected byC_n ⊕ C_{n−1}
14Carry flag is relevant forUnsigned arithmetic
15Which code changes only one bit between successive values?Gray code
16Excess-3 code isSelf-complementing
17IEEE 754 single-precision exponent bias127
18IEEE 754 double-precision mantissa bits52
19Exponent all 1s and mantissa non-zero representsNaN
20The hidden bit in IEEE 754 isThe leading 1 of the normalised mantissa
21Booth’s algorithm is used forSigned binary multiplication
22In Booth’s algorithm, Q₀Q₋₁ = 10 meansSubtract M, then arithmetic shift right
23Carry-look-ahead adder is faster becauseAll carries are computed in parallel from G and P
24MAR holdsThe memory address
25Which register holds the address of the next instruction?PC
26Address bus isUnidirectional
27With 20 address lines, addressable memory is1 MB
28Daisy-chain arbitration gives priority byPhysical position in the chain
29One 8086 machine cycle consists of4 T-states
30ALE is activated in which T-state?T1
31Memory-mapped I/O uses which instructions?Any memory instruction (MOV, ADD…)
32Isolated I/O in the 8086 gives how many ports?64 K
33DMA transfers dataDirectly between I/O and memory, bypassing the CPU
34Which DMA mode does not slow the CPU at all?Transparent / hidden
358086 interrupt vector table size1 KB (00000H–003FFH)
36Interrupt type 0 in the 8086 isDivide by zero
37Which 8086 interrupt cannot be masked?NMI (type 2)
38DRAM needs refreshing becauseThe storage capacitor leaks charge
39SRAM stores a bit in aFlip-flop
40Cache works because ofLocality of reference
41Which mapping needs no replacement algorithm?Direct mapping
42Which mapping has the largest tag?Fully associative
43Dirty bit is used in which write policy?Write-back
44TLB is a cache ofPage table entries
45RAID 0 providesStriping with no redundancy
46Minimum disks for RAID 53
47Average rotational latency of a 7200 RPM disk≈ 4.17 ms
48Maximum speed-up of a k-stage pipelinek
49Operand forwarding solves which hazard?Data hazard
50Branch prediction solves which hazard?Control hazard
518086 physical address formulaSegment × 10H + Offset
528086 instruction queue size6 bytes
53Which 8086 unit contains the segment registers?BIU
54The 8086 register pair for the stack topSS : SP
55String destination offset is held inDI (with ES)
56Port address for variable IN/OUT is held inDX
57MN/MX grounded puts the 8086 inMaximum mode
58In max mode, control signals come fromThe 8288 bus controller
598255 provides how many I/O lines?24 (3 ports)
608259 can be cascaded to how many levels?64
618251 is aUSART (serial interface)
628087 is aMath/floating-point coprocessor
63Horizontal microinstructions areWide, unencoded, highly parallel
64Mapping logic in a microprogrammed CU convertsThe opcode into a control-memory start address
65CAR in a microprogrammed control unit is theMicro-program counter (next microinstruction address)
66Excitation table of a flip-flop givesThe inputs required for a desired state transition
67For a D flip-flop, excitation D =Q(t+1)
68Moore machine output depends onPresent state only
69Which flip-flop excitation table has the most don’t-cares?JK
70Intel 8086 was introduced in1978

C. Probable Short-Answer Questions (5 marks each)

Each needs: definition (1) + table or diagram (2) + example (1) + one-line conclusion (1). 5 मार्कमा लामो निबन्ध लेख्नु हुन्न — table बनाउनु।

  1. Differentiate between Von Neumann and Harvard architecture. (§1.1.4)
  2. Compare RISC and CISC architecture. (§1.1.5)
  3. Explain Flynn’s classification of computer architecture with examples. (§1.1.6)
  4. State the design procedure of a synchronous sequential circuit. (§1.1.2)
  5. Differentiate between Mealy and Moore machines. (§1.1.1)
  6. Why is 2’s complement preferred for representing signed numbers? (§1.1.7)
  7. Define the instruction cycle and explain its phases. (§1.1.11)
  8. Explain the three bus structures and bus arbitration methods. (§1.1.10)
  9. Write the program for X = (A+B)×(C+D) using zero-, one-, two- and three-address instructions. (§1.2.1)
  10. Explain any five addressing modes of the 8086 with examples. (§1.2.3)
  11. Differentiate memory-mapped I/O from isolated I/O. (§1.3.3)
  12. Compare programmed I/O, interrupt-driven I/O and DMA. (§1.3.2)
  13. Explain the interrupt structure of the 8086. (§1.3.4)
  14. What is Booth’s algorithm? Multiply −5 × 2 using it. (§1.4.2)
  15. Represent −12.75 in IEEE 754 single-precision format. (§1.4.3)
  16. Explain the floating-point addition algorithm. (§1.4.3)
  17. Differentiate SRAM and DRAM. (§1.5.2)
  18. Explain the memory hierarchy and the principle of locality. (§1.5.1)
  19. Write short notes on cache write policies. (§1.5.3)
  20. Explain RAID levels 0, 1, 5 and 6. (§1.5.5)
  21. Calculate disk access time for a given seek time and RPM. (§1.5.5)
  22. What are pipeline hazards and how are they resolved? (§1.6.3)
  23. Differentiate hardwired and microprogrammed control units. (§1.7.6)
  24. Differentiate horizontal and vertical microinstructions. (§1.7.6)
  25. Explain memory segmentation in the 8086 with an example. (§1.7.2)
  26. Differentiate minimum mode and maximum mode of the 8086. (§1.7.3)
  27. Explain the register organisation of the 8086. (§1.7.1)
  28. Explain the function of the 8255 PPI and its operating modes. (§1.7.5)
  29. Write the salient features of the PowerPC processor. (§1.6.4)
  30. Explain the flag register of the 8086. (§1.7.1)

D. Probable Long-Answer Questions (10 marks each)

यहाँ diagram अनिवार्य छ। प्रत्येकको ढाँचा दिइएको छ।

Q1. Explain cache memory. Discuss the mapping techniques with an example.

Plan: definition → why (locality) → block diagram CPU–cache–memory → address breakdown diagram → the three mapping techniques with a diagram each → the 16 MB / 64 KB / 16 B worked calculation table → replacement algorithms → write policies → AMAT formula with a numerical example → conclusion.

Q2. Explain the architecture of the Intel 8086 with a block diagram.

Plan: introduction (1978, 16-bit, 20-bit address, 1 MB) → labelled BIU/EU block diagram → BIU components and the 6-byte queue (pipelining) → EU components → complete register set table → flag register bit layout → segmentation with the Segment × 10H + Offset example → conclusion on fetch/execute overlap.

Q3. Explain DMA. Describe the DMA controller and its transfer modes.

Plan: why DMA (CPU overhead of programmed I/O) → definition → block diagram showing CPU, DMAC, memory, I/O with HOLD/HLDA → DMAC registers → the 6-step transfer sequence → the three modes table → DMA vs interrupt-driven I/O table → cache coherence problem → conclusion.

Q4. Explain instruction pipelining. Discuss hazards and calculate the speed-up.

Plan: definition → 5-stage space-time diagram → formulas → worked speed-up (4 stages, 100 instructions) → the three hazards with solutions → RAW/WAR/WAW → superscalar/VLIW/out-of-order → Amdahl’s law → conclusion.

Q5. Explain floating-point representation and arithmetic.

Plan: need for FP (dynamic range) → IEEE 754 single/double format diagram → bias, hidden bit → special values table → convert −12.75 → C14C0000H → addition algorithm steps with a worked example → multiplication/division exponent rules → rounding modes → overflow/underflow/NaN → fixed vs floating comparison.

Q6. Explain the microprogrammed control unit and microinstruction sequencing.

Plan: role of the control unit → hardwired vs microprogrammed table → labelled block diagram (CAR, control memory, CDR, sequencer, mapping logic, SBR, MUX) → microinstruction format diagram (F1F2F3, CD, BR, AD) → the four sequencing methods → horizontal vs vertical table → nanoprogramming → the micro-cycle’s two phases → conclusion (why CISC uses it).

Q7. Explain memory hierarchy, and secondary storage with RAID.

Plan: hierarchy pyramid diagram with speeds/sizes → locality → SRAM vs DRAM table → ROM family table → disk geometry diagram → access-time formula with a numerical example → disk scheduling one-liners → full RAID table → SSD vs HDD → banking-context conclusion (RAID 10 for the core banking DB; RAID is not a backup).

Q8. Explain the addressing modes of the 8086 with examples and applications.

Plan: definition of effective address → the full 13-mode table with 8086 examples → the numerical PC/R1/XR/M[] worked table → which HLL construct each mode serves (arrays → indexed, records → displacement, pointers → indirect, subroutines → stack, relocatable code → PC-relative) → conclusion on why many modes exist.

Q9. Design a synchronous sequential circuit (state diagram → circuit).

Plan: restate the problem → state diagram → state table → state assignment → transition table → excitation table using the chosen flip-flop → K-maps for each flip-flop input and the output → simplified Boolean expressions → final logic diagram → verification trace.

Q10. Compare RISC and CISC; explain the PowerPC as a RISC case study.

Plan: definitions → full RISC/CISC comparison table → the design philosophy (complexity in compiler vs hardware) → PowerPC: AIM alliance 1991, POWER lineage, 601 in 1993 → features table (32 GPR, 32 FPR, fixed 32-bit, 3 addressing modes, split L1, bi-endian) → special registers (CR, LR, CTR, XER) → family chronology → applications (Mac, RS/6000, Xbox 360, PS3, Wii, embedded) → PowerPC vs x86 table → conclusion (why RISC won in mobile/embedded, CISC survived via internal µops).

E. Nepali–English Glossary (मुख्य शब्दावली)

Englishनेपाली व्याख्या
Sequential circuitस्मृति (flip-flop) भएको परिपथ — output अहिलेको input + अघिल्लो अवस्थामा निर्भर
Stateपरिपथको वर्तमान अवस्था, flip-flop मा भण्डारित
Excitation tableचाहिएको next state पाउन flip-flop मा कुन input दिने भन्ने तालिका
Von Neumann bottleneckएउटै bus/memory हुँदा CPU ले कुर्नुपर्ने अवरोध
Stored-program conceptprogram पनि data सरह memory मा राख्ने अवधारणा
Pipeliningassembly-line जसरी धेरै instruction एकैचोटि फरक चरणमा चलाउने
Hazardpipeline मा अवरोध — resource, data वा branch कारण
Operand forwardingALU को नतिजा register मा लेख्न कुर्दै नकुरी सिधै अर्को चरणमा पठाउने
Locality of referenceभर्खर/नजिकको ठेगाना फेरि चाँडै प्रयोग हुने प्रवृत्ति
Cache hit / missखोजिएको data cache मा भेटियो / भेटिएन
Dirty bitcache block बदलिएको छ, memory मा लेख्न बाँकी छ भन्ने संकेत
Thrashingएउटै cache line मा दुई हट block बारम्बार धकेलाधकेल
Refresh cycleDRAM को capacitor charge पढेर पुनः लेख्ने चक्र
Effective addressaddressing mode ले गणना गरेर निकालेको operand को वास्तविक ठेगाना
Segmentation1 MB memory लाई 64 KB का खण्डमा बाँडेर 16-bit register ले पुग्ने बनाउने
Paragraph boundary१६ बाइटको गुणन — segment सुरु हुने ठेगाना
Interrupt vector tableकुन interrupt मा कुन routine चलाउने भन्ने ठेगाना सूची
ISRInterrupt Service Routine — interrupt आएपछि चल्ने उपकार्यक्रम
Context savinginterrupt अघि PC, flags, register stack मा जोगाउने
Cycle stealingDMA ले एक-एक bus cycle खोसेर data सार्ने तरिका
Bus arbitrationकुन device ले bus चलाउने भन्ने निर्णय प्रक्रिया
Wait stateढिलो memory कुर्न CPU ले थपिदिने अतिरिक्त clock अवधि
Microinstructionएउटा machine instruction भित्रको सानो नियन्त्रण पाइला
Control storemicroprogram राखिने ROM
Hardwired controlतारले सिधै बनेको नियन्त्रण परिपथ — छिटो तर अपरिवर्तनीय
Hidden/implicit bitIEEE 754 मा नलेखिने अघिल्लो 1.
Bias / Excess-kऋणात्मक exponent लेख्न सबैमा जोडिने स्थिर मान
Normalisationmantissa लाई 1.xxx रूपमा ल्याउने प्रक्रिया
Striping (RAID 0)data टुक्रा-टुक्रा गरी धेरै disk मा समानान्तर लेख्ने
Mirroring (RAID 1)दुई disk मा हुबहु नक्कल राख्ने
Parityहराएको data फेरि बनाउन मिल्ने गणितीय जाँच बिट

F. Last-Minute Revision Checklist

परीक्षाको अघिल्लो दिन यी २२ वटा कुरा मात्र दोहोर्याउनु — यहीँबाट धेरैजसो अंक आउँछ।

  • Von Neumann vs Harvard — table
  • RISC vs CISC — table (12 rows)
  • SISD / SIMD / MISD / MIMD + examples (GPU = SIMD, MISD = theoretical)
  • Flip-flop characteristic equations + excitation tables
  • 7-step sequential circuit design procedure
  • 2’s complement range formula + overflow C_n ⊕ C_{n−1}
  • X = (A+B)(C+D) in 0-, 1-, 2-, 3-address form
  • 13 addressing modes + the numerical EA table
  • Programmed I/O vs Interrupt vs DMA — table
  • Memory-mapped vs isolated I/O — table
  • 8086 IVT: 1 KB, 256 types, 4 bytes, vector = type × 4
  • DMA 6 steps + 3 modes
  • Booth’s algorithm — the 4-row rule table + one worked multiplication
  • IEEE 754: 1+8+23 bias 127, 1+11+52 bias 1023, special values
  • Convert one decimal to IEEE 754 by hand (practise −12.75)
  • FP addition 5 steps
  • SRAM vs DRAM — table
  • Cache: tag/line/word calculation for direct, fully-assoc, k-way
  • AMAT formula + one numerical
  • RAID 0/1/5/6/10 — capacity + fault tolerance
  • Disk access time, avg latency = 30000/RPM
  • Pipeline: (k + n − 1)t, speed-up → k, 3 hazards
  • Hardwired vs microprogrammed + horizontal vs vertical
  • 8086: PA = Seg × 10H + Offset, BIU/EU, 6-byte queue, min/max mode
  • Support chips: 8255 / 8259 / 8257 / 8251 / 8253 / 8087 / 8288
  • PowerPC: AIM 1991, RISC, 32 GPR + 32 FPR, CR/LR/CTR/XER, AltiVec on the G4

Reference books used for this unit (NRB परीक्षाको मानक पुस्तक)

TopicBook
1.1, 1.2, 1.4, 1.7.6**M. Morris Mano — *Computer System Architecture*** (3rd ed.)
1.1, 1.3, 1.5, 1.6**William Stallings — *Computer Organization and Architecture***
1.1, 1.2, 1.5**Hamacher, Vranesic & Zaky — *Computer Organization***
1.6.3 pipelining**Patterson & Hennessy — *Computer Organization and Design***
1.7 8086**Douglas V. Hall — *Microprocessors and Interfacing***
1.7 8086**Ramesh Gaonkar — *Microprocessor Architecture, Programming and Applications***
1.1.1, 1.1.2**Mano & Ciletti — *Digital Design*** (also covers Unit 2)

Frequently asked questions

What is the syllabus of NRB Assistant Director (IT) Paper I?

Paper I, “Information Technology – I”, is divided into Section (A) and Section (B). Section (A) contains four units: Computer Architecture & Organization and Microprocessors, Digital Logic Design, Operating Systems, and Database Management System and Design. Section (B) covers Computer Networks and related areas. This page covers Unit 1 of Section (A) in full.

How many marks is the NRB Assistant Director (IT) written examination?

The written stage totals 300 marks across three papers of 100 marks each: Paper I (Information Technology – I), Paper II (Information Technology – II) and Paper III (Current Developments in IT Sector and Emerging Technologies). Each paper has a pass mark of 40. Candidates who clear the written stage are then called for a 50-mark practical examination (pass mark 25) and a 40-mark interview.

Is there negative marking in the NRB Assistant Director (IT) exam?

Yes. 0.2 marks are deducted for each incorrect answer in the multiple-choice section. Because a correct answer earns 1 mark and a wrong answer costs 0.2, guessing is mathematically worthwhile once you have eliminated two of the four options — the expected value of such a guess is positive. Leave a question blank only when you cannot narrow it down at all.

Can I write the NRB IT exam answers in Nepali?

No. The syllabus states that questions will be asked in English and that the examinee should use English language to answer. This applies to both the written and the practical examination. Nepali is useful for understanding the concepts while you study, but every answer on the sheet must be in English — which is why each concept on this page also carries an “Exam line” giving the exact English wording.

Is a calculator allowed in the NRB Assistant Director (IT) exam?

A calculator is not allowed for the multiple-choice section. This matters for Unit 1, because the numerical questions here — cache tag widths, IEEE 754 conversions, physical-address calculation, rotational latency — must be done by hand. Practise them as mental arithmetic using powers of two rather than relying on a calculator.

What is the difference between Von Neumann and Harvard architecture?

Von Neumann architecture uses a single shared memory and a single bus for both instructions and data, so an instruction and a data word cannot be fetched in the same cycle — the limitation known as the Von Neumann bottleneck. Harvard architecture uses physically separate memories and buses for instructions and data, allowing both to be fetched simultaneously at the cost of more hardware. Most general-purpose processors are Von Neumann at the main-memory level but Harvard at the L1 cache level, an arrangement called modified Harvard.

What is the difference between RISC and CISC architecture?

RISC uses a small set of fixed-length instructions that mostly execute in one clock cycle, with many registers, few addressing modes, memory access restricted to load and store instructions, and a hardwired control unit. CISC uses a large set of variable-length instructions that each perform more work, with fewer registers, many addressing modes and a microprogrammed control unit. In one sentence: RISC shifts complexity from the hardware to the compiler, while CISC shifts complexity from the compiler to the hardware.

How is the physical address calculated in the Intel 8086?

The 8086 has 16-bit registers but a 20-bit address bus, so it forms a physical address from a segment and an offset:

Physical address = (segment register value × 10H) + offset

Multiplying by 10H is the same as shifting the segment value left by four bits. For example, with CS = 2000H and IP = 1234H, the physical address is 20000H + 1234H = 21234H. Because many different segment:offset pairs produce the same physical address, the mapping is not unique — a property called address aliasing.

What is Booth’s algorithm used for?

Booth’s algorithm performs signed binary multiplication in two’s complement form without needing to convert the operands or handle their signs separately. It works by recoding runs of consecutive 1s in the multiplier into a single subtraction followed by a single addition, so a long run of 1s costs two operations instead of one per bit. The decision each cycle is made by examining the two bits Q₀Q₋₁: subtract on 10, add on 01, and shift only on 00 or 11.

Which books should I read for the computer architecture unit?

The four standard references that match this syllabus most closely are **M. Morris Mano, Computer System Architecture (for data representation, instruction formats, computer arithmetic and the microprogrammed control unit), William Stallings, Computer Organization and Architecture (for I/O organization, memory systems and CPU structure), Douglas V. Hall, Microprocessors and Interfacing (for the 8086 and the Intel support chips), and Patterson & Hennessy, *Computer Organization and Design*** (for pipelining). The full topic-to-book mapping is given at the end of this page.

Which topics in this unit carry the most marks?

Judged by how this syllabus is typically set, the six highest-yield areas are cache memory and its mapping arithmetic, the 8086 BIU/EU architecture and memory segmentation, Booth’s algorithm, IEEE 754 floating-point conversion, direct memory access, and hardwired versus microprogrammed control. Each of these appears below with a solved numerical example, because these topics are almost always set as calculations rather than as descriptions.

If you are preparing for this examination, the companion post on the law component is NRB Act 2058 and BAFIA 2073: 10 exam questions with full model answers.

These notes are the first unit of Paper I, Section (A). Unit 2, Digital Logic Design, and Unit 3, Operating Systems, are now published in full; Unit 4, Database Management System and Design, is in preparation. In the meantime, several topics on the syllabus are already covered in depth elsewhere on this site:

Next in this series: Unit 2 — Digital Logic Design notes, covering gates, K-maps, flip-flops, counters, sequential machines and logic families.