25-Comp-A3 Computer Architecture · May 2013
Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)
98-Comp-A3, Computer Architecture — National Exams, May 2013. Open-book, 3 hours; six questions of equal value (20 marks each); FIVE constitute a complete exam (all six answered below as a complete study resource).
Reference texts: Patterson & Hennessy, Computer Organization and Design, 6th ed. — instruction encoding & the stored-program principle (Ch.2, Q1), memory addressing & data representation (Ch.2, Q2), cache organization & memory hierarchy (Ch.5, Q3 & Q6), procedure-call conventions & unsigned arithmetic (Ch.2–3, Q4), and CPU performance / the multicycle datapath (Ch.1 & Ch.4, Q5) — covering all six questions.
Question text not reproduced: the examination questions are © Engineers and Geoscientists BC. Open the official past paper (linked at the top of this page) to read the question, then follow the worked solution below.
Given. (a) A 256-element array, 2 bytes/element, first element at address BASE, byte-addressable memory. (b) A 3-node singly-linked list (1)→(2)→(3); each node = 4-byte integer + 4-byte "next" pointer; big-endian storage; node (1) starts at 0x100, nodes packed back-to-back in list order.
Find. (a) A formula for the address of the N-th array element. (b) The exact byte-by-byte memory contents of all three list nodes.
Approach. (a) apply the standard array-indexing rule, address = base + index × element size. (b) lay out each 8-byte node back-to-back starting at 0x100, and write each 4-byte field in big-endian order (most-significant byte at the lowest address).
BASE + 2(N−1).0x100, packing back-to-back gives node (2) at 0x100+8=0x108 and node (3) at 0x108+8=0x110. Node (3) is the tail, so its "next" pointer is NULL (0x00000000). Writing each 4-byte field big-endian (MSB at the lowest address of the field) gives the table below.| Address range | Field | Bytes (hex, MSB first) |
|---|---|---|
| 0x100–0x103 | node (1) int = 1 | 00 00 00 01 |
| 0x104–0x107 | node (1) next → 0x108 | 00 00 01 08 |
| 0x108–0x10B | node (2) int = 2 | 00 00 00 02 |
| 0x10C–0x10F | node (2) next → 0x110 | 00 00 01 10 |
| 0x110–0x113 | node (3) int = 3 | 00 00 00 03 |
| 0x114–0x117 | node (3) next = NULL | 00 00 00 00 |
| Part | Result |
|---|---|
| (a) N-th element address | $BASE+2N$ (0-based N) |
| (b) node addresses | (1)=0x100, (2)=0x108, (3)=0x110; full byte map above |