IITIAN1997 STUDIO

Computer architecture and system programming

JLEE CSE · 10 practice questions with answers

Practise and take a mock test →

CPU, memory hierarchy, addressing and system software

Topics: Von Neumann architecture, functional units, buses; instruction formats and addressing modes; ALU and control unit; memory hierarchy, cache and virtual memory; I/O, interrupts, DMA; pipelining; assemblers, loaders, linkers, macros, compilers.

Computer organisation and addressing

A von Neumann machine keeps program and data in the same memory and runs the fetch–decode–execute cycle. Buses: address (one-way, its width sets the addressable memory, 2ⁿ locations), data and control. Addressing modes: immediate, register, direct, indirect, indexed, relative.

  • n address lines → 2ⁿ locations
  • Fetch → decode → execute
  • Immediate, direct, indirect, indexed

Example: How many bytes can a 32-bit address bus reach?

  1. 2³² bytes.
  2. = 4 GB.

Answer: 4 GB

Example: In which addressing mode is the operand part of the instruction?

  1. The value itself is in the instruction.
  2. Immediate addressing.

Answer: Immediate

Memory hierarchy and cache

Faster memory is smaller and costlier, so computers use a hierarchy. Cache works because of locality of reference. Effective access time ≈ h·t_cache + (1 − h)·t_memory for hit ratio h (simple model). Cache mapping: direct (each block to one line), fully associative, set-associative. Virtual memory lets programs use more memory than RAM by paging to disk.

  • Locality makes caches work
  • EAT = h t_c + (1 − h) t_m
  • Lines = cache size/block size

Example: Cache 10 ns, memory 100 ns, hit ratio 0.9. Find the effective access time.

  1. EAT = 0.9 × 10 + 0.1 × 100.
  2. = 19 ns.

Answer: 19 ns

Example: How many lines has a 64 KB direct-mapped cache with 64-byte blocks?

  1. 65 536/64.
  2. = 1024 lines.

Answer: 1024

Pipelining, I/O and system software

A k-stage pipeline finishes n instructions in k + n − 1 cycles instead of nk, giving a speed-up approaching k (hazards reduce it). I/O uses programmed I/O, interrupts or DMA (direct memory access, the device moves data without the CPU). System software: assemblers (two-pass), compilers, linkers (join object files), loaders (place programs in memory), and macro processors.

  • Pipeline time = k + n − 1 cycles
  • DMA: data without CPU
  • Linker joins; loader loads

Example: A 5-stage pipeline runs 100 instructions. Find the speed-up over no pipelining.

  1. Without: 500 cycles; with: 5 + 99 = 104 cycles.
  2. Speed-up ≈ 4.8.

Answer: ≈ 4.8

Example: Which phase of a compiler turns characters into tokens?

  1. It groups characters into keywords, identifiers and symbols.
  2. Lexical analysis.

Answer: Lexical analysis

A Von Neumann machine stores data and instructions in one memory; a Harvard machine separates them. Instructions run fetch, decode, execute. Hardwired control is fast, and microprogrammed control is flexible. Addressing modes locate operands: immediate, direct, indirect, register, indexed. Cache exploits locality with average access time T = hT_c + (1 − h)T_m. DMA moves data without CPU involvement. Interrupts signal the CPU rather than polling. Pipelining raises throughput but faces structural, data and control hazards. An assembler translates assembly code, a linker joins object files, a loader places a program in memory, and a compiler translates high-level code in phases from lexical analysis to code generation.

  • RISC: simple fixed-length instructions; CISC: many complex ones.
  • Cache mappings: direct, associative, set-associative.
  • Two-pass assemblers build a symbol table on the first pass.
  • Lexical analyser produces tokens.
  • Word length is the bits processed at a time.

Key formulas

  • T_avg = hT_c + (1 − h)T_m
  • speedup ≤ n stages
  • memory = 2^(address bits)

Practice questions

Von Neumann architecture uses

  1. one memory for data and code
  2. separate memories
  3. no memory
  4. cache only
Show the answer

Answer: A. one memory for data and code Stored-program concept.

DMA transfers data

  1. through the CPU only
  2. without CPU involvement
  3. only to printers
  4. only by polling
Show the answer

Answer: B. without CPU involvement Direct memory access.

Pipelining improves

  1. throughput
  2. instruction length
  3. memory size
  4. power at zero cost
Show the answer

Answer: A. throughput Parallel stages.

Cache works because of

  1. locality of reference
  2. large size
  3. low price
  4. magnets
Show the answer

Answer: A. locality of reference Temporal and spatial.

RISC processors have

  1. many complex instructions
  2. few simple instructions
  3. no registers
  4. no pipeline
Show the answer

Answer: B. few simple instructions Reduced set.

An assembler converts

  1. high-level code to assembly
  2. assembly to machine code
  3. machine code to source
  4. text to PDF
Show the answer

Answer: B. assembly to machine code Translator.

A linker

  1. joins object files
  2. edits text
  3. prints output
  4. runs interrupts
Show the answer

Answer: A. joins object files Resolves references.

The compiler phase producing tokens is

  1. lexical analysis
  2. syntax analysis
  3. code generation
  4. optimisation
Show the answer

Answer: A. lexical analysis Scanner.

The fastest storage is

  1. registers
  2. cache
  3. RAM
  4. disk
Show the answer

Answer: A. registers Inside the CPU.

Immediate addressing has the operand

  1. in the instruction
  2. in memory
  3. in a port
  4. on disk
Show the answer

Answer: A. in the instruction Encoded directly.

The practice questions were written for this studio; they are not copied from ASTU papers. ASTU publishes no topic syllabus for these exams, so the topics are an informed guide based on diploma courses, not an official list.

Practise and take a mock test →