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
| Item | Value |
|---|---|
| Post | Assistant Director (Information Technology), Officer Third Class, Technical Service |
| Organisation | Nepal Rastra Bank (the central bank of Nepal) |
| Paper | Paper I — Information Technology – I |
| Full marks / pass marks | 100 / 40 |
| Objective section | 25 MCQ × 1 = 25 marks, 30 minutes, −0.2 per wrong answer, no calculator |
| Subjective section | 9 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 total | 300 marks across Papers I, II and III |
| Later stages | Practical examination 50 marks (pass 25), interview 40 marks |
| Syllabus approved | 2080/05/07 |
| Official syllabus | 11-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
- 1.1 Basic Structures
- 1.1.9 Basic Operational Concepts
- 1.1.10 Bus Structures
- 1.1.11 Instruction Cycle, Machine Cycle, Execution Cycle
- 1.2 Processing Unit
- 1.3 Input/Output Organization
- 1.4 Computer Arithmetic
- 1.5 Memory Systems
- 1.6 CPU Structure and Function
- 1.7 808X and Intel Microprocessors
Part 2 — revision toolkit
- PART 2 — REVISION TOOLKIT
- A. One-Page Formula Sheet (परीक्षा अघि यही पढ्नु)
- B. MCQ Bank — 70 questions with answers
- C. Probable Short-Answer Questions (5 marks each)
- D. Probable Long-Answer Questions (10 marks each)
- E. Nepali–English Glossary (मुख्य शब्दावली)
- F. Last-Minute Revision Checklist
- Frequently asked questions
- Related reading on CSSNepal
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
| Feature | Synchronous | Asynchronous |
|---|---|---|
| State change | Only at clock edge | As soon as input changes |
| Clock | Common clock to all FFs | No common clock |
| Speed | Slower (limited by clock) | Faster |
| Design | Easy, predictable | Hard — race condition, hazards |
| Example | Synchronous counter, registers | Ripple counter, SR latch |
Mealy vs Moore (हरेक वर्ष MCQ आउने विषय)
| Moore | Mealy | |
|---|---|---|
| Output depends on | Present state only | Present state AND present input |
| Output written on | State circle in diagram | Transition arrow in diagram |
| States needed | More | Fewer |
| Output timing | Synchronous with clock, delayed by 1 cycle | Reacts immediately, can glitch |
| Notation | Z = 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 प्रश्न यहीँबाट आउँछ):
- Word statement → State Diagram (problem बुझेर state चित्र बनाउने)
- State Diagram → State Table (present state, input, next state, output)
- State Reduction / Minimisation (equivalent states मिलाउने — optional)
- State Assignment (प्रत्येक state लाई binary code दिने; n states → ⌈log₂n⌉ FFs)
- Transition Table → Excitation Table (चुनिएको flip-flop को excitation table प्रयोग गरी प्रत्येक FF को input चाहिने मान निकाल्ने)
- K-Map simplification (प्रत्येक FF input र output का लागि minimal Boolean expression)
- Draw the logic diagram and verify.
Flip-flop Characteristic Equations (रटनु)
| Flip-flop | Characteristic equation Q(t+1) = |
|---|---|
| SR | S + R′Q (with SR = 0) |
| D | D |
| JK | JQ′ + K′Q |
| T | T ⊕ Q = TQ′ + T′Q |
Excitation Tables (step 5 मा यही चाहिन्छ — X = don’t care)
| Q(t) → Q(t+1) | S R | J K | D | T |
|---|---|---|---|---|
| 0 → 0 | 0 X | 0 X | 0 | 0 |
| 0 → 1 | 1 0 | 1 X | 1 | 1 |
| 1 → 0 | 0 1 | X 1 | 0 | 1 |
| 1 → 1 | X 0 | X 0 | 1 | 0 |
सम्झने तरिका (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₀ |
|---|---|---|---|
| 00 | 01 | 0X | 1X |
| 01 | 10 | 1X | X1 |
| 10 | 11 | X0 | 1X |
| 11 | 00 | X1 | X1 |
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 (निश्चित प्रश्न)
| Feature | Von Neumann (Princeton) | Harvard |
|---|---|---|
| Memory | One memory for instruction + data | Separate instruction & data memory |
| Buses | Single shared bus | Separate buses for each |
| Fetch | Instruction and data cannot be fetched together | Can be fetched simultaneously |
| Speed | Slower — Von Neumann bottleneck | Faster |
| Cost / complexity | Cheap, simple | Costly, more pins & wires |
| Instruction/data width | Must be same | Can differ |
| Self-modifying code | Possible | Not possible (data memory ≠ code memory) |
| Used in | General-purpose PCs (x86), most CPUs | DSPs, 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 रटनु)
| Feature | RISC | CISC |
|---|---|---|
| Full form | Reduced Instruction Set Computer | Complex Instruction Set Computer |
| No. of instructions | Few (~50–150) | Many (~200–400+) |
| Instruction length | Fixed (e.g. 32-bit) | Variable (1–15 bytes in x86) |
| Clock cycles / instruction | Mostly 1 (pipelined) | Many (2–15) |
| Addressing modes | Few (3–5) | Many (8–20+) |
| Registers | Many (32–192) | Few (8–16) |
| Memory access | Only LOAD / STORE | Almost any instruction can touch memory |
| Control unit | Hardwired | Microprogrammed |
| Pipelining | Easy & deep | Difficult |
| Code size | Larger | Smaller |
| Compiler work | High (compiler optimises) | Low (hardware does the work) |
| Power | Low | Higher |
| Examples | ARM, MIPS, SPARC, PowerPC, RISC-V, Atmel AVR | Intel 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 को संख्या।
| Type | Streams | Meaning | Example |
|---|---|---|---|
| SISD | 1 instr, 1 data | Traditional uniprocessor, sequential | Classic Von Neumann machine, single-core 8086, early PCs |
| SIMD | 1 instr, many data | One instruction applied to many data items at once (data parallelism) | GPU, vector/array processors, Intel MMX/SSE/AVX, ILLIAC-IV, CM-2 |
| MISD | many instr, 1 data | Many instructions on the same data — mostly theoretical | Systolic arrays; fault-tolerant redundant systems (e.g. Space Shuttle flight computers) |
| MIMD | many instr, many data | Independent 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
| Decimal | Sign-Magnitude | 1’s Complement | 2’s Complement | Excess-8 (bias) |
|---|---|---|---|---|
| +5 | 0101 | 0101 | 0101 | 1101 |
| −5 | 1101 | 1010 | 1011 | 0011 |
| 0 | 0000 / 1000 (two zeros) | 0000 / 1111 (two zeros) | 0000 only | 1000 |
| Range (n=4) | −7 … +7 | −7 … +7 | −8 … +7 | −8 … +7 |
General range formulas (रटनु):
- Unsigned n-bit:
0to2ⁿ − 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 निकाल्ने २ तरिका:
- सबै bit उल्टाउने (1’s complement) + 1 जोड्ने.
- दायाँबाट पहिलो
1सम्म जस्तै सार्ने, त्यसपछिका सबै bit उल्टाउने. उदाहरण:0110**1000**→1001**1000**
Other data codes
| Code | Purpose / Note |
|---|---|
| BCD (8421) | Each decimal digit in 4 bits. 1010–1111 invalid. Used in calculators, financial/banking displays |
| Packed BCD | Two digits per byte |
| Excess-3 | BCD + 0011. Self-complementing, no 0000 code |
| Gray code | Only one bit changes between consecutive values → used in shaft encoders, K-maps. Binary→Gray: G = B XOR (B>>1) |
| ASCII | 7-bit, 128 chars (+1 parity) |
| Extended ASCII | 8-bit, 256 chars |
| EBCDIC | 8-bit, IBM mainframes |
| Unicode | 16/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)
| Operation | Rule |
|---|---|
| 2’s comp addition | Add normally; discard final carry out |
| 2’s comp subtraction | A − B = A + (2's complement of B) |
| Overflow detection | Overflow 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 addition | Add; if carry out, add it back (end-around carry) |
| Carry vs Overflow | Carry 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 सहित)
| Register | Full form | Function |
|---|---|---|
| PC | Program Counter | Holds the address of the next instruction |
| IR | Instruction Register | Holds the instruction currently being executed |
| MAR | Memory Address Register | Holds the address being sent to memory |
| MDR / MBR | Memory Data/Buffer Register | Holds data being read from or written to memory |
| AC | Accumulator | Holds the ALU operand/result (in 1-address machines) |
| R0…R(n−1) | General Purpose Registers | Fast local operand storage |
| SP | Stack Pointer | Points to the top of the stack |
| PSW / Flags | Program Status Word | Condition codes: Z, C, S/N, V/O, P, AC |
| TR | Temporary Register | Internal 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
| Bus | Direction | Carries | Width decides |
|---|---|---|---|
| Address bus | Unidirectional (CPU → memory/IO) | Address of location/port | Memory capacity = 2^(width). 8086: 20 lines → 1 MB |
| Data bus | Bidirectional | Actual data | Word size / throughput. 8086: 16 lines; 8088: 8 lines |
| Control bus | Mixed | RD, WR, CLK, RESET, INTR, ALE, M/IO, HOLD, HLDA, READY | Coordination/timing |
महत्वपूर्ण MCQ: Address bus unidirectional, data bus bidirectional. n address lines → 2ⁿ addressable locations.
Bus organisation types
| Type | Structure | Speed | Cost |
|---|---|---|---|
| Single-bus | All units share one bus | Slowest (one transfer at a time) | Cheapest, fewest pins |
| Two-bus | Separate CPU↔memory and CPU↔I/O | Medium | Medium |
| Three-bus | Dedicated paths (+ DMA/IOP path) | Fastest | Most expensive |
Bus arbitration (कसले bus चलाउने भन्ने निर्णय):
| Method | How | Priority | Note |
|---|---|---|---|
| Daisy chaining | Grant signal passes serially device to device | Fixed by physical position | Simple, few lines; nearest device starves the rest; one failure blocks all downstream |
| Polling / Rotating | Arbiter asks each device in turn | Can be rotated (fair) | More lines, programmable |
| Independent request | Each device has its own BR/BG line pair | Fully flexible | Fastest, 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)| Term | Definition |
|---|---|
| T-state / Clock cycle | One period of the CPU clock — the smallest timing unit |
| Machine cycle | Time 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 cycle | Time to fetch and completely execute one instruction = 1 to 6 machine cycles |
| Fetch cycle | Sub-cycle that brings the instruction into the IR |
| Execute cycle | Sub-cycle that actually performs the operation |
The instruction cycle — five phases (Exam answer)
- Fetch —
MAR ← PC; MDR ← M[MAR]; IR ← MDR; PC ← PC + 1 - Decode — control unit interprets the opcode, identifies operands
- Operand fetch (Effective Address calculation) — resolve the addressing mode, read operand from memory/register; may be indirect cycle if indirect mode
- Execute — ALU performs the operation
- 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,
ALEpulsed high to latch it - T2 — address removed, bus turns around;
RD/WRasserted; status lines set - T3 — data actually transferred (memory/IO places data on bus);
READYsampled - T4 — data latched, control signals deactivated, cycle ends
- Tw (wait state) — inserted between T3 and T4 if
READYis 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 × R23 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, R16 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 X7 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 X8 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, R7ALU 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
| Class | Instructions |
|---|---|
| Data transfer | MOV, LOAD, STORE, XCHG, PUSH, POP, IN, OUT, LEA, LDS/LES |
| Arithmetic | ADD, ADC (add with carry), SUB, SBB, INC, DEC, MUL, IMUL, DIV, IDIV, NEG, CMP, CBW, CWD, AAA/DAA (BCD adjust) |
| Logical | AND, OR, XOR, NOT, TEST |
| Shift | SHL/SAL, SHR (logical, fills 0), SAR (arithmetic, preserves sign) |
| Rotate | ROL, ROR, RCL, RCR (through carry) |
| Transfer of control | JMP, CALL, RET, conditional jumps (JZ, JNZ, JC, JNC, JE, JNE, JG, JL, JA, JB), LOOP, INT, IRET |
| String | MOVS, CMPS, SCAS, LODS, STOS (+ REP prefix) |
| Processor control | CLC, STC, CLI, STI, CLD, STD, NOP, HLT, WAIT, LOCK, ESC |
Key distinctions MCQ loves:
CMP A,B=SUBthat sets flags but does not store the result.TEST A,B=ANDthat sets flags but does not store the result.SHRfills with 0 → for unsigned division by 2.SARreplicates 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.
| # | Mode | Effective Address | Example (8086) | Use case |
|---|---|---|---|---|
| 1 | Implied / Implicit | Operand is implicit in the opcode | CLC, NOP, HLT, CMC | Shortest instruction |
| 2 | Immediate | Operand is in the instruction; EA not used | MOV AX, 1234H | Initialising constants — fastest, no memory access |
| 3 | Register | Operand in a register; EA = R | MOV AX, BX | Fast, no memory cycle |
| 4 | Direct / Absolute | EA = address field | MOV AX, [2000H] | Simple global variables |
| 5 | Indirect | EA = M[address field] — two memory accesses | MOV AX, [[2000H]] (conceptual) | Pointers; large address space with small field |
| 6 | Register Indirect | EA = contents of register | MOV AX, [BX] | Pointers, loops — most used |
| 7 | Auto-increment / decrement | EA = R, then R ← R ± d | LODSB (SI auto-increments) | Array/string traversal, stack |
| 8 | Displacement / Based | EA = R + displacement | MOV AX, [BX+4] | Structure/record fields |
| 9 | Indexed | EA = base address + index register | MOV AX, [SI+2000H] | Array elements |
| 10 | Base-Index (+ displacement) | EA = Base + Index (+ disp) | MOV AX, [BX+SI+4] | 2-D arrays, array inside a record |
| 11 | Relative / PC-relative | EA = PC + signed displacement | JMP SHORT LABEL | Position-independent / relocatable code, branches |
| 12 | Stack | Operand at top of stack, implicit | PUSH AX, POP BX, ADD (0-addr) | Expression evaluation, subroutine linkage |
| 13 | Base Register | EA = Base register + displacement | segment:offset in 8086 | Relocation, 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.
| Mode | EA | Operand fetched |
|---|---|---|
| Direct | 500 | M[500] = 800 |
| Immediate | — (operand = 500) | 500 |
| Indirect | M[500] = 800 | M[800] |
| Relative (PC-relative) | PC + 500 = 202 + 500 = 702 | M[702] = 325 |
| Indexed | XR + 500 = 100 + 500 = 600 | M[600] = 900 |
| Register | — | R1 = 400 |
| Register indirect | R1 = 400 | M[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:
- CPU and device communication / control (command decoding)
- Data buffering (speed matching — device र memory बीच)
- Error detection (parity, checksum, timeout)
- Address recognition (कुन port मेरो हो भन्ने चिन्नु)
- Timing and synchronisation
- Data format conversion (serial↔parallel, voltage levels)
1.3.2 Three techniques of I/O (मुख्य comparison table)
| Programmed I/O | Interrupt-driven I/O | DMA | |
|---|---|---|---|
| Who transfers data | CPU | CPU | DMA controller |
| CPU waits? | Yes — busy-wait / polling loop | No — does other work until interrupted | No — fully free |
| Data path | Device → CPU → Memory | Device → CPU → Memory | Device ↔ Memory directly |
| Transfer unit | Word/byte | Word/byte | Block |
| CPU overhead | Highest | Medium (ISR per word) | Lowest (only setup + completion) |
| Speed | Slowest | Medium | Fastest |
| Hardware cost | Cheapest | Medium | Most expensive |
| Suitable for | Slow devices, few bytes, simple systems | Moderate-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_PORTInterrupt-driven I/O
Device raises INTR when ready. CPU finishes the current instruction, then:
- Completes current instruction (interrupts are checked at instruction boundaries)
- Pushes PC (and flags, and registers) onto the stack — context saving
- Loads the ISR address from the interrupt vector table
- Executes the ISR (Interrupt Service Routine / handler)
IRET→ pops flags and PC → resumes the interrupted program
1.3.3 Memory-Mapped I/O vs I/O-Mapped (Isolated) I/O — निश्चित प्रश्न
| Feature | Memory-Mapped I/O | I/O-Mapped / Isolated I/O |
|---|---|---|
| Address space | I/O ports share the memory address space | Separate I/O address space |
| 8086 address lines used | All 20 lines | Only 16 lines (A0–A15) |
| 8086 port capacity | Part of the 1 MB memory | 64 K ports (2¹⁶) |
| Instructions used | Any memory instruction — MOV, ADD, AND, CMP, INC… | Only IN and OUT |
| Control signal | MEMR / MEMW (M/IO = 1) | IOR / IOW (M/IO = 0) |
| Memory lost to I/O | Yes — I/O eats memory addresses | No |
| Decoding hardware | More complex (20-bit decode) | Simpler (16-bit decode) |
| Flexibility | High — full instruction set on ports | Low — only IN/OUT |
| Used in | Motorola 68000, ARM, most RISC, PowerPC | Intel x86/8086 supports both |
सम्झने तरिका: Memory-mapped = “I/O ले memory को ठेगाना चोर्छ, तर बदलामा सबै instruction प्रयोग गर्न पाउँछ”। Isolated = “आफ्नै छुट्टै ठेगाना, तर IN/OUT मात्र”।
1.3.4 Basic Interrupt System
Types of interrupts
| Classification | Types |
|---|---|
| By source | Hardware (external device) vs Software (INT n instruction) |
| By maskability | Maskable (can be disabled by CLI) vs Non-maskable (NMI) |
| By vectoring | Vectored (device supplies the address) vs Non-vectored (fixed address) |
| By cause | External (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
| Type | Name | Cause |
|---|---|---|
| 0 | Divide by zero | DIV/IDIV quotient overflow |
| 1 | Single step / Trap | TF = 1 — used by debuggers |
| 2 | NMI | Non-maskable hardware interrupt pin — cannot be disabled |
| 3 | Breakpoint | 1-byte INT 3 instruction |
| 4 | Overflow | INTO when OF = 1 |
| 5–31 | Reserved by Intel | |
| 32–255 | Available to the user | e.g. INT 21H = DOS services |
Priority (highest → lowest): Divide-by-zero / INT n / INTO → NMI → INTR → Single-step (lowest).
Interrupt priority resolution methods
| Method | How it works | Pros / Cons |
|---|---|---|
| Software polling | ISR checks each device’s flag in a fixed order | Cheap hardware, slow |
| Daisy chaining (serial) | INTA ripples through devices; nearest one with a pending request grabs it and puts its vector on the bus | Few lines; priority fixed by physical position |
| Parallel priority interrupt | Register + priority encoder + mask register | Fast, programmable priority; more hardware |
| 8259 PIC | Dedicated chip: 8 inputs, cascadable to 64 levels, programmable fixed/rotating priority, masking | Industry 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 रटनु)
- CPU programs the DMA controller: starting memory address, word count, direction (read/write), and mode.
- Device requests service → DMA controller asserts
HOLD(bus request) to CPU. - CPU completes the current bus cycle, floats (tri-states) its address, data and control buses, and replies with
HLDA(hold acknowledge). - DMA controller becomes bus master and transfers data device ↔ memory, incrementing the address register and decrementing the word count after each word.
- When the word count reaches zero, DMA releases
HOLDand raises an interrupt (EOP — End of Process) to tell the CPU the block is complete. - 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
| Mode | Behaviour | Effect on CPU |
|---|---|---|
| Burst / Block transfer | Whole block transferred in one go; CPU halted until done | Fastest transfer, CPU starved longest |
| Cycle stealing | One word per bus acquisition, then bus returned | CPU slowed slightly; good compromise — most common |
| Transparent / Hidden | Transfers 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:
| Flag | Set 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
| Adder | Principle | Delay | Note |
|---|---|---|---|
| Half adder | S = A⊕B, C = AB | — | No carry-in |
| Full adder | S = A⊕B⊕Cin, Cout = AB + Cin(A⊕B) | — | Building block |
| Ripple-carry adder | n full adders chained | O(n) — slow, carry must propagate | Simple, cheapest |
| Carry-look-ahead adder (CLA) | Generate Gi = AiBi, Propagate Pi = Ai⊕Bi; Ci+1 = Gi + PiCi | O(log n) | Fastest practical, more gates |
| Carry-save adder | Three operands → sum + carry vectors | Used inside multipliers | |
| Carry-select adder | Compute both carry-in cases, select | Between 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₋₁ | Meaning | Action |
|---|---|---|
0 0 | middle of a run of 0s | ASR only (arithmetic shift right) |
0 1 | end of a run of 1s | A ← A + M, then ASR |
1 0 | beginning of a run of 1s | A ← A − M, then ASR |
1 1 | middle of a run of 1s | ASR 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.
| Step | Q₀Q₋₁ | Action | A | Q | Q₋₁ |
|---|---|---|---|---|---|
| init | — | — | 0000 | 1011 | 0 |
| 1 | 1 0 | A ← A − M = 1110; ASR | 1111 | 0101 | 1 |
| 2 | 1 1 | ASR only | 1111 | 1010 | 1 |
| 3 | 0 1 | A ← A + M = 0001; ASR | 0000 | 1101 | 0 |
| 4 | 1 0 | A ← A − M = 1110; ASR | 1111 | 0110 | 1 |
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):
A ← 0,Q ← dividend,M ← divisor, count = n- Shift left
A, Qby 1 A ← A − M- If
A < 0(sign bit = 1):Q₀ ← 0and restoreA ← A + Melse:Q₀ ← 1 - Decrement count; repeat from 2 until count = 0
- 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 │
└───┴──────────────┴───────────────────────────────┘| Format | Total bits | Sign | Exponent | Mantissa | Bias | Approx. decimal digits |
|---|---|---|---|---|---|---|
Single precision (float) | 32 | 1 | 8 | 23 | 127 | ~7 |
Double precision (double) | 64 | 1 | 11 | 52 | 1023 | ~16 |
| Extended (x87) | 80 | 1 | 15 | 64 | 16383 | ~19 |
| Half | 16 | 1 | 5 | 10 | 15 | ~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) | M | Meaning |
|---|---|---|
| all 0s | 0 | ±Zero |
| all 0s | ≠ 0 | Denormalised / subnormal number (no hidden bit, value = 0.M × 2^(1−bias)) |
| all 1s | 0 | ±Infinity |
| all 1s | ≠ 0 | NaN (Not a Number) — e.g. 0/0, √(−1) |
Worked conversion: represent −12.75 in IEEE 754 single precision
- Sign: negative → S = 1
12.75in binary:12 = 1100,0.75 = .11→1100.11- Normalise:
1100.11 = 1.10011 × 2³→ actual exponent = 3 - Biased exponent
E = 3 + 127 = 130 = 10000010 - Mantissa = fraction after the leading 1, padded to 23 bits:
10011 0000 0000 0000 0000 00 - 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 रटनु)
- Check for zeros — if either operand is 0, return the other.
- 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?” को उत्तर)
- Add or subtract the aligned mantissas (with sign handling).
- Normalise the result — shift left and decrement the exponent, or shift right and increment, until the form
1.xxxis restored. - 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)
- Round to nearest, ties to even — the default
- Round toward zero (truncate / chop)
- Round toward +∞ (ceiling)
- 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)
| Feature | SRAM | DRAM |
|---|---|---|
| Storage element | Flip-flop (6 transistors) | Capacitor + 1 transistor |
| Refresh needed? | No | Yes — every few ms, else charge leaks |
| Speed | Fast | Slower |
| Density | Low (big cell) | High (tiny cell) |
| Cost per bit | High | Low |
| Power | High static, low dynamic | Lower overall |
| Used as | Cache, registers | Main memory |
| Volatile? | Yes | Yes |
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
| Type | Written by | Erasable by | Reusable |
|---|---|---|---|
| Mask ROM | Manufacturer (at fabrication) | Not erasable | No |
| PROM | User, once, by blowing fuses | Not erasable | No |
| EPROM | User, electrically | UV light (quartz window), whole chip | Yes (~1000×) |
| EEPROM | User, electrically | Electrically, byte-wise | Yes |
| Flash | User, electrically | Electrically, block-wise | Yes — 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 = 8banks - 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:
| Mapping | Address fields | Tag width |
|---|---|---|
| Direct | Tag ∣ Line ∣ Word | n − l − b (where cache has 2^l lines) |
| Fully associative | Tag ∣ Word | n − b |
| k-way set associative | Tag ∣ Set ∣ Word | n − s − b (where 2^s sets = lines/k) |
The three mapping techniques
| Feature | Direct Mapping | Fully Associative | Set Associative (k-way) |
|---|---|---|---|
| Rule | Block j → line j mod L | Block can go anywhere | Block j → set j mod S, any of k lines in that set |
| Tag comparators | 1 | L (all, in parallel) | k |
| Hardware cost | Cheapest | Most expensive (CAM) | Middle — practical compromise |
| Replacement algorithm | Not needed (only one choice) | Needed (LRU etc.) | Needed, within the set |
| Conflict misses | Highest — thrashing if two hot blocks map to the same line | None | Low |
| Tag size | Smallest | Largest | Middle |
| Search time | Fastest | Slowest | Middle |
| Used in practice | Rare / simple L1 | Small TLBs, victim caches | Almost 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¹²
| Mapping | Word | Line / Set | Tag | Total |
|---|---|---|---|---|
| Direct | 4 | Line = 12 | 24 − 12 − 4 = 8 | 24 ✔ |
| Fully associative | 4 | — | 24 − 4 = 20 | 24 ✔ |
| 4-way set assoc. | 4 | Sets = 4096/4 = 1024 = 2¹⁰ → 10 | 24 − 10 − 4 = 10 | 24 ✔ |
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
| Algorithm | Rule | Note |
|---|---|---|
| FIFO | Replace the oldest loaded block | Simple; may evict a hot block |
| LRU (Least Recently Used) | Replace the block unused for the longest time | Best practical performance, exploits temporal locality; costly to track exactly (pseudo-LRU used) |
| LFU (Least Frequently Used) | Replace the least-referenced block | Needs counters; old hot blocks stick |
| Random | Pick any | Cheapest hardware, surprisingly decent |
| Optimal (OPT/MIN) | Replace the block needed furthest in the future | Theoretical benchmark only — needs future knowledge |
Write policies
| Policy | Mechanism | Pros | Cons |
|---|---|---|---|
| Write-through | Write to cache and memory at the same time | Memory always consistent; simple; safe for DMA/multiprocessor | High bus traffic, slow writes |
| Write-back (copy-back) | Write only to cache; set a dirty bit; write to memory only on eviction | Fast, far less bus traffic | Memory temporarily stale → coherence problem with DMA/other cores |
| Write buffer | Queue in front of memory | Hides write-through latency | Extra hardware |
| Write-allocate | On a write miss, first load the block into cache | Good with write-back | Extra read |
| No-write-allocate (write-around) | On a write miss, write straight to memory | Good with write-through | No benefit on rewrite |
The three C’s — types of cache miss
| Miss | Cause | Reduced by |
|---|---|---|
| Compulsory / Cold-start | First-ever reference to a block | Larger blocks, prefetching |
| Capacity | Cache too small to hold the working set | Larger cache |
| Conflict / Collision | Too many blocks map to the same set | More 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 रटनु)
| Level | Technique | Min disks | Usable capacity | Fault tolerance | Note |
|---|---|---|---|---|---|
| RAID 0 | Striping, no redundancy | 2 | N (100%) | None | Best performance & capacity, highest risk |
| RAID 1 | Mirroring | 2 | N/2 (50%) | 1 disk per mirror | Best read, costly, simple recovery |
| RAID 2 | Bit-level striping + Hamming ECC | 3 | — | 1 disk | Obsolete |
| RAID 3 | Byte-level striping + dedicated parity disk | 3 | N−1 | 1 disk | Parity disk is a bottleneck |
| RAID 4 | Block-level striping + dedicated parity disk | 3 | N−1 | 1 disk | Parity disk is a bottleneck |
| RAID 5 | Block striping + distributed parity | 3 | N−1 | 1 disk | Most popular — good read, write penalty |
| RAID 6 | Block striping + dual distributed parity | 4 | N−2 | 2 disks | Safer, higher write cost |
| RAID 10 (1+0) | Mirror then stripe | 4 | N/2 | 1 per mirror set | Best 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
| HDD | SSD | |
|---|---|---|
| Technology | Rotating magnetic platters | NAND flash, no moving parts |
| Access time | 5–10 ms | 0.05–0.1 ms |
| Seek penalty | Large (mechanical) | None — true random access |
| Shock resistance / noise / power | Poor / noisy / higher | Good / silent / lower |
| Cost per GB | Lower | Higher |
| Wear | Mechanical failure | Limited 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)
| Class | Purpose |
|---|---|
| General purpose | Any use — operands, addresses (AX, BX…, R0–R31) |
| Data registers | Data only (accumulator) |
| Address registers | Index register, segment pointer, stack pointer, base register |
| Condition code / flags | Partly 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 WBPipeline 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); asn → ∞,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 (तीन किसिम — रटनु)
| Hazard | Cause | Solution |
|---|---|---|
| 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 |
| Data | An instruction needs a result not yet produced | Operand forwarding / bypassing, register renaming, compiler scheduling, stall (bubble) |
| Control (branch) | The next address is unknown until the branch resolves | Branch 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
| Technique | Idea |
|---|---|
| Superscalar | Multiple pipelines issue several instructions per cycle; hardware finds the parallelism. IPC > 1 |
| Superpipelined | More, shorter stages → higher clock |
| VLIW | One very long instruction word holds several independent operations; the compiler finds the parallelism (Itanium) |
| Out-of-order execution | Issue 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 |
| Multicore | Several 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
| Feature | Detail |
|---|---|
| Type | RISC, superscalar, load/store |
| Instruction length | Fixed 32 bits, mostly 3-address |
| GPRs | 32 general purpose registers (32-bit in 32-bit impl., 64-bit in 64-bit impl.) |
| FPRs | 32 floating-point registers, 64-bit, full IEEE 754 |
| Addressing modes | Only three: register indirect, register indirect with immediate index (displacement), register indirect with index — typical RISC economy |
| Cache | Separate (Harvard-style) L1 instruction and data caches |
| Endianness | Bi-endian; default big-endian |
| Branches | Branch prediction, no delay slot; dedicated branch unit |
| Memory | Paged virtual memory, segmented addressing, 32-/64-bit modes |
PowerPC special-purpose registers (MCQ)
| Register | Function |
|---|---|
| CR — Condition Register | 32 bits as 8 four-bit fields (CR0–CR7); holds comparison results so branches need not share one flags word |
| LR — Link Register | Holds the return address for subroutine calls (bl) |
| CTR — Count Register | Loop counter; bdnz decrements and branches — hardware loop support |
| XER | Integer exception register — carry (CA), overflow (OV), summary overflow (SO), byte count |
| FPSCR | Floating-point status and control (rounding mode, exceptions) |
| MSR | Machine State Register — privilege level, interrupt enables, endian mode |
Family members (chronology — MCQ मा आउँछ)
| Chip | Year | Note |
|---|---|---|
| 601 | 1993 | First PowerPC; 32-bit; bridge from POWER |
| 603 | 1994 | Low power → used in PowerBook laptops |
| 604 | 1994 | High-performance desktop, 4-issue superscalar |
| 620 | 1997 | First 64-bit PowerPC |
| 750 / G3 | 1997 | Backside L2 cache |
| 7400 / G4 | 1999 | Added AltiVec / VMX — a 128-bit SIMD vector unit |
| 970 / G5 | 2003 | 64-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
| PowerPC | Intel 8086/x86 | |
|---|---|---|
| Philosophy | RISC | CISC |
| Instruction length | Fixed 32-bit | Variable 1–15 bytes |
| Registers | 32 GPR + 32 FPR | 8 GPR (16-bit) |
| Memory access | Load/Store only | Most instructions |
| Addressing modes | 3 | 8+ |
| Control unit | Hardwired | Microprogrammed |
| Endianness | Big-endian (bi-endian) | Little-endian |
| Condition codes | 8 separate CR fields | One FLAGS register |
| Pipelining | Deep, easy | Hard — 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) | |
|---|---|---|
| Job | Talks to the outside world | Executes instructions |
| Contains | 4 segment registers (CS, DS, SS, ES), IP, address-generation adder, 6-byte instruction queue, bus control logic | ALU, general registers (AX–DX, SP, BP, SI, DI), flag register, instruction decoder, EU control system |
| Activity | Fetches instructions and operands, computes physical addresses, drives the buses | Decodes and executes whatever is in the queue |
| Benefit | Prefetching — 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)
| 8086 | 8088 | |
|---|---|---|
| External data bus | 16-bit | 8-bit |
| Internal architecture | 16-bit | 16-bit |
| Instruction queue | 6 bytes | 4 bytes |
| Memory | 1 MB | 1 MB |
| I/O-related pin | BHE/S7, M/IO | SS0, IO/M (inverted) |
| Used in | — | IBM PC (1981) |
Register set (रटनु)
| Group | Registers | Special 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 / Index | SP | Stack Pointer — offset of the top of stack, with SS |
| BP | Base Pointer — accesses parameters/locals in the stack frame, with SS | |
| SI | Source Index — source offset in string ops, with DS | |
| DI | Destination Index — destination offset in string ops, with ES | |
| Segment | CS | Code Segment — with IP |
| DS | Data Segment — default for data | |
| SS | Stack Segment — with SP/BP | |
| ES | Extra Segment — with DI for strings | |
| Instruction pointer | IP | Offset of the next instruction within CS — not directly writable |
| Status | FLAGS | 16-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| Type | Flag | Bit | Meaning |
|---|---|---|---|
| Conditional (set by ALU) | CF Carry | 0 | Carry/borrow out of MSB |
| PF Parity | 2 | Result has even number of 1s | |
| AF Auxiliary carry | 4 | Carry from bit 3→4 (BCD) | |
| ZF Zero | 6 | Result = 0 | |
| SF Sign | 7 | MSB of result = 1 | |
| OF Overflow | 11 | Signed overflow | |
| Control (set by programmer) | TF Trap | 8 | 1 → single-step (debugging) |
| IF Interrupt enable | 9 | 1 (STI) → INTR allowed; 0 (CLI) → masked | |
| DF Direction | 10 | 0 (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) + OffsetWorked 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 (रटनु)
| Fact | Value |
|---|---|
| Number of segments active at a time | 4 (CS, DS, SS, ES) |
| Maximum size of one segment | 64 KB (16-bit offset) |
| Total addressable memory | 1 MB (20-bit) |
| Segments must start on a | paragraph 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 addresses | 2¹⁶ = 65 536 |
Default segment:offset pairings (MCQ):
| Pair | Purpose |
|---|---|
| CS : IP | Next instruction |
| SS : SP | Top of stack (PUSH/POP) |
| SS : BP | Stack frame access (parameters/locals) |
| DS : BX / SI / DI / displacement | Data access |
| ES : DI | String 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).
| Pins | Function |
|---|---|
AD0–AD15 | Time-multiplexed address/data (address in T1, data in T2–T4) |
A16/S3 – A19/S6 | Multiplexed upper address / status |
BHE/S7 | Bus High Enable — selects the odd (upper) memory bank |
ALE | Address Latch Enable — pulsed in T1 to latch the address into the 8282/8283 latch |
RD, WR | Read / Write strobes |
M/IO | 1 = memory, 0 = I/O |
DT/R, DEN | Data transmit/receive and data enable — control the 8286/8287 transceiver |
READY | Low → insert wait states (slow memory/IO) |
RESET | CS = FFFFH, IP = 0000H → boot address FFFF0H; flags, DS, ES, SS, queue cleared |
INTR, NMI, INTA | Maskable interrupt, non-maskable interrupt, interrupt acknowledge |
HOLD, HLDA | DMA bus request / acknowledge |
TEST, LOCK | Used with WAIT for the 8087 coprocessor; bus lock for multiprocessing |
MN/MX | Mode select — see below |
CLK, Vcc, GND | From the 8284 clock generator; 5 V |
Minimum vs Maximum mode (पक्का प्रश्न)
Minimum mode (MN/MX = Vcc / HIGH) | Maximum mode (MN/MX = GND / LOW) | |
|---|---|---|
| Processors | Single processor | Multiprocessor — supports the 8087 NDP / 8089 IOP |
| Control signals | Generated 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 chips | 8284 clock, 8282 latch, 8286 transceiver | + 8288 bus controller, 8289 bus arbiter |
| Bus request pins | HOLD / HLDA | RQ/GT0, RQ/GT1 |
| Queue status | — | QS0, QS1 — let the coprocessor track the queue |
| Cost / complexity | Low | High |
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
.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 MAINProgram 1 — sum of an array of N bytes
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, ALProgram 2 — find the largest of N bytes
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, ALProgram 3 — multiply two 16-bit numbers
MOV AX, NUM1
MUL NUM2 ; unsigned: DX:AX ← AX × NUM2
MOV PROD_LOW, AX
MOV PROD_HIGH, DXMUL with a byte operand: AX ← AL × operand. With a word operand: DX:AX ← AX × operand.
Program 4 — block transfer using string instructions
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 (रटनु)
| Chip | Name | Function |
|---|---|---|
| 8255 | PPI — Programmable Peripheral Interface | 3 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 |
| 8259 | PIC — Programmable Interrupt Controller | 8 interrupt inputs (IR0–IR7), cascadable to 64 levels, programmable priority (fixed/rotating), masking (IMR), supplies the vector type to the CPU |
| 8257 / 8237 | DMAC — DMA Controller | 4 channels, address + word-count registers per channel, burst/cycle-stealing modes |
| 8251 | USART | Serial communication — synchronous and asynchronous, programmable baud rate, parity, stop bits; RS-232 interface |
| 8253 / 8254 | PIT — Programmable Interval Timer | 3 independent 16-bit counters, 6 modes (e.g. mode 3 = square-wave generator); used for the system clock tick and speaker tone |
| 8279 | Keyboard/Display controller | Scans a keyboard matrix and drives 7-segment displays |
| 8284 | Clock generator | Generates CLK, RESET, READY from a crystal |
| 8282/8283 | Octal latch | Demultiplexes address from AD0–AD15 using ALE |
| 8286/8287 | Octal transceiver | Buffers the bidirectional data bus |
| 8288 | Bus controller | Generates control signals in maximum mode |
| 8289 | Bus arbiter | Multiprocessor bus arbitration |
| 8087 | NDP — Numeric Data Processor | Floating-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
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 BMemory 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.
BHE | A0 | Transfer |
|---|---|---|
| 1 | 0 | Even byte only (from the lower bank) |
| 0 | 1 | Odd byte only (from the upper bank) |
| 0 | 0 | Full word from an even address — 1 bus cycle |
| 1 | 1 | None |
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 प्रश्न)
| Feature | Hardwired control | Microprogrammed control |
|---|---|---|
| Implementation | Fixed logic: gates, flip-flops, decoders, counters, sequential circuit | A microprogram stored in control memory (control store / ROM) |
| Speed | Fast | Slower (extra control-memory fetch each step) |
| Flexibility | Rigid — changing the instruction set means redesigning the circuit | Flexible — just rewrite the microcode |
| Design / debugging | Difficult, error-prone | Systematic, easy to modify, easy to add instructions |
| Cost for complex ISA | Very high | Lower |
| Chip area | Less (for simple ISAs) | More (control memory) |
| Suited to | RISC (simple, regular instructions) | CISC (complex, variable instructions) |
| Examples | ARM, MIPS, PowerPC | Intel 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| Component | Function |
|---|---|
| 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 |
| Sequencer | Decides the next CAR value |
| Incrementer | CAR ← CAR + 1 for sequential flow |
| Mapping logic | Converts 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) |
| MUX | Selects 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
- Explicit next-address field — every microinstruction names its successor. Flexible, no incrementer, but a wider control word.
- Incrementer + branch field (two-field) — default is
CAR+1; a branch field overrides it. Most common. - Mapping from the opcode — the opcode is transformed into the microroutine’s start address. Mano’s mapping:
0 ∣ opcode ∣ 00. - Subroutine via SBR —
CALLsavesCAR+1in SBR,RETrestores it.
Horizontal vs Vertical microinstructions (पक्का प्रश्न)
| Feature | Horizontal | Vertical |
|---|---|---|
| Encoding | Unencoded — one bit per control signal | Encoded fields |
| Word length | Long / wide | Short / narrow |
| Decoder needed? | No (or minimal) | Yes — extra decode delay |
| Parallelism | High — many micro-ops per microinstruction | Low — usually one micro-op |
| Speed | Faster | Slower |
| Control memory size | Large (wide words) | Small |
| Microprogram length | Shorter | Longer |
| Programming | Harder (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
- Fetch:
CDR ← ControlMemory[CAR] - 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-operationOne machine instruction = several microinstructions; one microinstruction = several simultaneous micro-operations.
1.7.7 Intel processor evolution (MCQ का तथ्य)
| Processor | Year | Data bus | Address bus | Memory | Note |
|---|---|---|---|---|---|
| 4004 | 1971 | 4-bit | — | — | First microprocessor |
| 8008 | 1972 | 8-bit | 14-bit | 16 KB | |
| 8080 | 1974 | 8-bit | 16-bit | 64 KB | |
| 8085 | 1976 | 8-bit | 16-bit | 64 KB | 40-pin, 6500 transistors |
| 8086 | 1978 | 16-bit | 20-bit | 1 MB | 29 000 transistors, 6-byte queue |
| 8088 | 1979 | 8-bit | 20-bit | 1 MB | Used in the IBM PC |
| 80286 | 1982 | 16-bit | 24-bit | 16 MB | Protected mode, virtual memory |
| 80386 | 1985 | 32-bit | 32-bit | 4 GB | First 32-bit x86; paging |
| 80486 | 1989 | 32-bit | 32-bit | 4 GB | On-chip 8 KB cache + integrated FPU; 5-stage pipeline |
| Pentium | 1993 | 32-bit (64-bit ext.) | 32-bit | 4 GB | Superscalar (2 pipelines) |
| Pentium Pro / II / III | 1995–99 | 36-bit | 64 GB | Out-of-order, MMX/SSE | |
| Pentium 4 | 2000 | NetBurst, Hyper-Threading | |||
| Core / Core i-series | 2006– | Multicore, 64-bit (x86-64) |
PART 2 — REVISION TOOLKIT
A. One-Page Formula Sheet (परीक्षा अघि यही पढ्नु)
Number systems & data
| n-bit unsigned range | 0 … 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 X | 1's complement(X) + 1 = 2ⁿ − X |
| Signed overflow | V = C_n ⊕ C_{n−1} |
| Binary → Gray | G = B ⊕ (B >> 1) |
| BCD | 4 bits per decimal digit; 1010–1111 invalid |
Floating point (IEEE 754)
| Value | (−1)^S × 1.M × 2^(E − bias) |
| Single | 1 + 8 + 23, bias 127 |
| Double | 1 + 11 + 52, bias 1023 |
| Multiply exponent | E = E₁ + E₂ − bias |
| Divide exponent | E = E₁ − E₂ + bias |
Memory & cache
| Address lines n | 2ⁿ locations |
| Chips needed | (parallel for word size) × (banks for locations) |
| Offset/word bits | log₂(block size) |
| Direct-map tag | n − log₂(lines) − log₂(block) |
| Fully-assoc tag | n − log₂(block) |
| k-way tag | n − log₂(lines/k) − log₂(block) |
| AMAT | Hit time + Miss ratio × Miss penalty |
| T_avg parallel | h·Tc + (1−h)·Tm |
| T_avg hierarchical | h·Tc + (1−h)(Tc + Tm) |
| Speed-up | Tm / T_avg |
Disk
| Access time | Seek + Rotational latency + Transfer |
| Avg rotational latency (ms) | 30000 / RPM |
| Capacity | heads × cylinders × sectors/track × bytes/sector |
| RAID 5 capacity | N − 1 disks, tolerates 1 failure |
| RAID 6 capacity | N − 2 disks, tolerates 2 failures |
| RAID 1 / 10 capacity | N / 2 |
Pipelining
| Non-pipelined time | n × k × t |
| Pipelined time | (k + n − 1) × t |
| Speed-up | n·k / (k + n − 1) → max = k |
| Efficiency | Speed-up / k |
| Throughput | n / [(k + n − 1) t] |
| Amdahl’s law | 1 / [(1 − f) + f/N] |
8086
| Physical address | Segment × 10H + Offset |
| Memory | 20 address lines → 1 MB |
| I/O ports | 16 lines → 64 K |
| Max segment size | 64 KB |
| Segment boundary | multiple of 16 bytes |
| Instruction queue | 6 bytes (8088: 4) |
| Machine cycle | 4 T-states (T1–T4) + Tw |
| IVT | 00000H–003FFH, 1 KB, 4 bytes/entry, 256 types |
| Vector address | type × 4 |
| Boot address after RESET | FFFF0H (CS = FFFFH, IP = 0000H) |
| Pushed on interrupt | FLAGS, CS, IP (6 bytes) |
B. MCQ Bank — 70 questions with answers
(Negative marking 0.2 — नथाहा भए छोड्नु; दुईमा घटाउन सकेको भए अनुमान लगाउनु।)
| # | Question | Answer |
|---|---|---|
| 1 | Von Neumann architecture uses ___ memory for data and instructions | One (shared) |
| 2 | Which architecture allows simultaneous instruction and data fetch? | Harvard |
| 3 | The “Von Neumann bottleneck” refers to | The shared single bus/memory limiting CPU speed |
| 4 | RISC control unit is usually | Hardwired |
| 5 | CISC instruction length is | Variable |
| 6 | PowerPC belongs to which class? | RISC |
| 7 | GPU parallelism is best classified as | SIMD |
| 8 | Which Flynn class is largely theoretical? | MISD |
| 9 | Multicore processors are | MIMD |
| 10 | Flynn’s classification was proposed in | 1966 |
| 11 | In 2’s complement, how many representations of zero? | One |
| 12 | 4-bit 2’s complement range | −8 to +7 |
| 13 | Overflow in signed addition is detected by | C_n ⊕ C_{n−1} |
| 14 | Carry flag is relevant for | Unsigned arithmetic |
| 15 | Which code changes only one bit between successive values? | Gray code |
| 16 | Excess-3 code is | Self-complementing |
| 17 | IEEE 754 single-precision exponent bias | 127 |
| 18 | IEEE 754 double-precision mantissa bits | 52 |
| 19 | Exponent all 1s and mantissa non-zero represents | NaN |
| 20 | The hidden bit in IEEE 754 is | The leading 1 of the normalised mantissa |
| 21 | Booth’s algorithm is used for | Signed binary multiplication |
| 22 | In Booth’s algorithm, Q₀Q₋₁ = 10 means | Subtract M, then arithmetic shift right |
| 23 | Carry-look-ahead adder is faster because | All carries are computed in parallel from G and P |
| 24 | MAR holds | The memory address |
| 25 | Which register holds the address of the next instruction? | PC |
| 26 | Address bus is | Unidirectional |
| 27 | With 20 address lines, addressable memory is | 1 MB |
| 28 | Daisy-chain arbitration gives priority by | Physical position in the chain |
| 29 | One 8086 machine cycle consists of | 4 T-states |
| 30 | ALE is activated in which T-state? | T1 |
| 31 | Memory-mapped I/O uses which instructions? | Any memory instruction (MOV, ADD…) |
| 32 | Isolated I/O in the 8086 gives how many ports? | 64 K |
| 33 | DMA transfers data | Directly between I/O and memory, bypassing the CPU |
| 34 | Which DMA mode does not slow the CPU at all? | Transparent / hidden |
| 35 | 8086 interrupt vector table size | 1 KB (00000H–003FFH) |
| 36 | Interrupt type 0 in the 8086 is | Divide by zero |
| 37 | Which 8086 interrupt cannot be masked? | NMI (type 2) |
| 38 | DRAM needs refreshing because | The storage capacitor leaks charge |
| 39 | SRAM stores a bit in a | Flip-flop |
| 40 | Cache works because of | Locality of reference |
| 41 | Which mapping needs no replacement algorithm? | Direct mapping |
| 42 | Which mapping has the largest tag? | Fully associative |
| 43 | Dirty bit is used in which write policy? | Write-back |
| 44 | TLB is a cache of | Page table entries |
| 45 | RAID 0 provides | Striping with no redundancy |
| 46 | Minimum disks for RAID 5 | 3 |
| 47 | Average rotational latency of a 7200 RPM disk | ≈ 4.17 ms |
| 48 | Maximum speed-up of a k-stage pipeline | k |
| 49 | Operand forwarding solves which hazard? | Data hazard |
| 50 | Branch prediction solves which hazard? | Control hazard |
| 51 | 8086 physical address formula | Segment × 10H + Offset |
| 52 | 8086 instruction queue size | 6 bytes |
| 53 | Which 8086 unit contains the segment registers? | BIU |
| 54 | The 8086 register pair for the stack top | SS : SP |
| 55 | String destination offset is held in | DI (with ES) |
| 56 | Port address for variable IN/OUT is held in | DX |
| 57 | MN/MX grounded puts the 8086 in | Maximum mode |
| 58 | In max mode, control signals come from | The 8288 bus controller |
| 59 | 8255 provides how many I/O lines? | 24 (3 ports) |
| 60 | 8259 can be cascaded to how many levels? | 64 |
| 61 | 8251 is a | USART (serial interface) |
| 62 | 8087 is a | Math/floating-point coprocessor |
| 63 | Horizontal microinstructions are | Wide, unencoded, highly parallel |
| 64 | Mapping logic in a microprogrammed CU converts | The opcode into a control-memory start address |
| 65 | CAR in a microprogrammed control unit is the | Micro-program counter (next microinstruction address) |
| 66 | Excitation table of a flip-flop gives | The inputs required for a desired state transition |
| 67 | For a D flip-flop, excitation D = | Q(t+1) |
| 68 | Moore machine output depends on | Present state only |
| 69 | Which flip-flop excitation table has the most don’t-cares? | JK |
| 70 | Intel 8086 was introduced in | 1978 |
C. Probable Short-Answer Questions (5 marks each)
Each needs: definition (1) + table or diagram (2) + example (1) + one-line conclusion (1). 5 मार्कमा लामो निबन्ध लेख्नु हुन्न — table बनाउनु।
- Differentiate between Von Neumann and Harvard architecture. (§1.1.4)
- Compare RISC and CISC architecture. (§1.1.5)
- Explain Flynn’s classification of computer architecture with examples. (§1.1.6)
- State the design procedure of a synchronous sequential circuit. (§1.1.2)
- Differentiate between Mealy and Moore machines. (§1.1.1)
- Why is 2’s complement preferred for representing signed numbers? (§1.1.7)
- Define the instruction cycle and explain its phases. (§1.1.11)
- Explain the three bus structures and bus arbitration methods. (§1.1.10)
- Write the program for
X = (A+B)×(C+D)using zero-, one-, two- and three-address instructions. (§1.2.1) - Explain any five addressing modes of the 8086 with examples. (§1.2.3)
- Differentiate memory-mapped I/O from isolated I/O. (§1.3.3)
- Compare programmed I/O, interrupt-driven I/O and DMA. (§1.3.2)
- Explain the interrupt structure of the 8086. (§1.3.4)
- What is Booth’s algorithm? Multiply
−5 × 2using it. (§1.4.2) - Represent
−12.75in IEEE 754 single-precision format. (§1.4.3) - Explain the floating-point addition algorithm. (§1.4.3)
- Differentiate SRAM and DRAM. (§1.5.2)
- Explain the memory hierarchy and the principle of locality. (§1.5.1)
- Write short notes on cache write policies. (§1.5.3)
- Explain RAID levels 0, 1, 5 and 6. (§1.5.5)
- Calculate disk access time for a given seek time and RPM. (§1.5.5)
- What are pipeline hazards and how are they resolved? (§1.6.3)
- Differentiate hardwired and microprogrammed control units. (§1.7.6)
- Differentiate horizontal and vertical microinstructions. (§1.7.6)
- Explain memory segmentation in the 8086 with an example. (§1.7.2)
- Differentiate minimum mode and maximum mode of the 8086. (§1.7.3)
- Explain the register organisation of the 8086. (§1.7.1)
- Explain the function of the 8255 PPI and its operating modes. (§1.7.5)
- Write the salient features of the PowerPC processor. (§1.6.4)
- 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 concept | program पनि data सरह memory मा राख्ने अवधारणा |
| Pipelining | assembly-line जसरी धेरै instruction एकैचोटि फरक चरणमा चलाउने |
| Hazard | pipeline मा अवरोध — resource, data वा branch कारण |
| Operand forwarding | ALU को नतिजा register मा लेख्न कुर्दै नकुरी सिधै अर्को चरणमा पठाउने |
| Locality of reference | भर्खर/नजिकको ठेगाना फेरि चाँडै प्रयोग हुने प्रवृत्ति |
| Cache hit / miss | खोजिएको data cache मा भेटियो / भेटिएन |
| Dirty bit | cache block बदलिएको छ, memory मा लेख्न बाँकी छ भन्ने संकेत |
| Thrashing | एउटै cache line मा दुई हट block बारम्बार धकेलाधकेल |
| Refresh cycle | DRAM को capacitor charge पढेर पुनः लेख्ने चक्र |
| Effective address | addressing mode ले गणना गरेर निकालेको operand को वास्तविक ठेगाना |
| Segmentation | 1 MB memory लाई 64 KB का खण्डमा बाँडेर 16-bit register ले पुग्ने बनाउने |
| Paragraph boundary | १६ बाइटको गुणन — segment सुरु हुने ठेगाना |
| Interrupt vector table | कुन interrupt मा कुन routine चलाउने भन्ने ठेगाना सूची |
| ISR | Interrupt Service Routine — interrupt आएपछि चल्ने उपकार्यक्रम |
| Context saving | interrupt अघि PC, flags, register stack मा जोगाउने |
| Cycle stealing | DMA ले एक-एक bus cycle खोसेर data सार्ने तरिका |
| Bus arbitration | कुन device ले bus चलाउने भन्ने निर्णय प्रक्रिया |
| Wait state | ढिलो memory कुर्न CPU ले थपिदिने अतिरिक्त clock अवधि |
| Microinstruction | एउटा machine instruction भित्रको सानो नियन्त्रण पाइला |
| Control store | microprogram राखिने ROM |
| Hardwired control | तारले सिधै बनेको नियन्त्रण परिपथ — छिटो तर अपरिवर्तनीय |
| Hidden/implicit bit | IEEE 754 मा नलेखिने अघिल्लो 1. |
| Bias / Excess-k | ऋणात्मक exponent लेख्न सबैमा जोडिने स्थिर मान |
| Normalisation | mantissa लाई 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 परीक्षाको मानक पुस्तक)
| Topic | Book |
|---|---|
| 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.
Related reading on CSSNepal
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:
- Database management system fundamentals — covers Unit 4’s relational model, keys, ER diagrams and normalisation
- Query processing in a DBMS and query optimization — Unit 4.17
- Distributed database concepts — Unit 4.19
- NoSQL databases — background for Unit 4.12 and 4.19
- Free SQL Lab — practise the DDL, DML and DCL queries of Unit 4.3 in the browser
- Class 12 Computer Science notes — the NEB foundation for several of these topics
Next in this series: Unit 2 — Digital Logic Design notes, covering gates, K-maps, flip-flops, counters, sequential machines and logic families.
