Computer Organization Semester Guide: CPU, Memory and Assembly Worked Together
Follow one set of values from memory through assembly and a five-stage pipeline, then practise cache mapping, address translation and I/O overhead.
KnowledgeGate Team
Exam prep & CS education

Computer Organization Semester Guide: CPU, Memory and Assembly Worked Together
Students often memorise two's-complement rules, CPU block diagrams, assembly syntax, pipeline formulae, cache fields and DMA definitions as separate chapters, then struggle to trace one value across them. A deliberately defined 32-bit teaching machine carries 5, 7, 12 and 17 from memory through four instructions and a five-stage pipeline. It also checks -18 in 8-bit two's complement, address 0x120 in a direct-mapped cache, and CPU service overhead for a 4096-byte I/O transfer.
Use the CS Fundamentals collection when you need to place this topic beside the other core subjects.
1. Learn COA as one value-moving system, not six isolated units
The dependency chain is data representation -> ISA and assembly -> instruction cycle and datapath -> pipelining -> cache and virtual memory -> I/O organisation. The ISA says what the bits mean. The datapath moves those bits, and the pipeline overlaps those movements. Memory organisation decides where operands arrive from, while I/O extends the same movement beyond main memory.
The toy machine and selected numericals connect those ideas. Arithmetic circuits, microprogrammed control, multiprocessor coherence and complete bus protocols add separate mechanisms beyond this chain. If you also need the surrounding CS subjects, Zero to Hero provides a wider semester route. The Computer Organization and Architecture Basics survey explains definitions, overflow and one instruction-cycle example. Here, the worked path connects representation, assembly, pipeline, cache and I/O.
2. Fix the bit pattern before tracing the hardware
Start with -18 in 8-bit two's complement:
18 = 00010010Invert every bit:
11101101Add 1:
11101101 + 1 = 11101110
Check using signed weights: -128 + 64 + 32 + 8 + 4 + 2 = -18. If interpreted as unsigned, the same eight bits mean 238. A bit pattern does not determine its meaning without a representation.
Sign-extension gives 11111111 11101110, or 0xFFEE. Zero-extension gives 00000000 11101110 = 0x00EE = 238. The wrong rule changes the value before the ALU begins.
Store 0x12345678 from byte address 0x140. Little-endian memory holds 0x78, 0x56, 0x34, 0x12 at 0x140 through 0x143; big-endian holds 0x12, 0x34, 0x56, 0x78. Endianness changes placement, not the register's arithmetic value after loading the word.
3. Trace four assembly instructions through the datapath
The teaching machine has 32-bit registers, byte-addressed memory, 4-byte words and fixed 4-byte instructions. R0 stays 0. Initially, PC=0x0040, R1=0x0120, M[0x0120]=5 and M[0x0124]=7. Here, LD Rd,k(Rb) means Rd <- M[Rb + sign_extend(k)]; ADD Rd,Rs,Rt means Rd <- Rs + Rt. With these definitions, the trace is deterministic.
0x0040: LD R2,0(R1) effective address 0x0120, R2=5
0x0044: LD R3,4(R1) effective address 0x0124, R3=7
0x0048: ADD R4,R2,R3 R4=5+7=12
0x004C: ADD R5,R4,R2 R5=12+5=17The next PC is 0x0050. The first load fetches at 0x0040 and sets PC=0x0044; reads R1=0x0120; computes 0x0120+0=0x0120; reads 5; and writes R2=5. Its controls are RegWrite=1, MemRead=1, MemWrite=0, ALUSrc=immediate, MemToReg=1. ADD uses 1,0,0,register,0. Review Addressing Modes and Instruction Formats for the assembly bridge. The CPU Organization Basics post traces an accumulator machine's MAR, MDR, IR and AC state; this example traces a 32-bit load/add path.

4. Pipeline the same program and account for the one real stall
Use five one-cycle stages, IF, ID, EX, MEM, WB, separate instruction and data access, EX forwarding, and hazard detection that freezes PC and IF/ID. There is no branch.
The schedule is:
Instruction | Pipeline timing |
|---|---|
I1 | IF1, ID2, EX3, MEM4, WB5 |
I2 | IF2, ID3, EX4, MEM5, WB6 |
I3 | IF3, ID4, stall/held-ID5, EX6, MEM7, WB8 |
I4 | IF4, held-IF5, ID6, EX7, MEM8, WB9 |
I3 needs R3 after I2's MEM5. It forwards into I3's EX6, creating one bubble. I1's R2 is ready, and R4=12 forwards from I3 EX6 to I4 EX7, so neither adds a stall.
Without overlap, four instructions occupy 4 x 5 = 20 stage-cycles. This trace finishes in 9 cycles, giving finite-sequence speedup 20/9 = 2.22, not 5. Pipeline latency and throughput are different, and real clock overhead or unequal stage delays can reduce measured speedup.

5. Map the program's addresses through cache, TLB and main memory
Take a 64-byte direct-mapped cache, 4-byte blocks and 12-bit byte addresses. It has 64/4=16 lines, so each address splits into 6 tag bits | 4 index bits | 2 offset bits.
For 0x120 = 000100 1000 00, the block number is 0x120/4=72, the line is 72 mod 16=8, the tag is floor(72/16)=4, and the offset is 0. For 0x124 = 000100 1001 00, the block is 73, line 9, tag 4, offset 0.
With an initially empty cache, loading 0x120 misses and fills line 8 with tag 4. Loading 0x124 misses and fills line 9 with tag 4. A later access to 0x120 hits line 8. If hit time is 1 ns, miss rate is 0.05 and miss penalty is 50 ns, then AMAT = 1 + 0.05 x 50 = 3.5 ns. Under these assumptions, AMAT is 3.5 ns.
For translation, use 4 KiB pages. Virtual address 0x00004120 has VPN 0x4 and page offset 0x120. A TLB hit mapping VPN 0x4 to PFN 0x2A produces physical address 0x0002A120; the page offset survives translation. Continue with Memory Hierarchy and Virtual Memory for deeper paging and TLB treatment. For direct mapping alone, Direct Mapping in Cache Memory works through 32-bit 0x12345678 tags and conflict misses; the 12-bit split here is one step in a semester chain.
6. Compare programmed I/O, interrupts and DMA by CPU work
Assume a device transfers 4096 bytes. The CPU runs at 2 GHz, so one cycle is 0.5 ns. Programmed I/O services one 4-byte word in 25 cycles. Interrupt-driven I/O raises one interrupt per 256 bytes at 400 CPU cycles each. DMA needs 800 setup cycles and one 400-cycle completion interrupt.
Method | CPU overhead calculation | CPU service time |
|---|---|---|
Programmed I/O |
|
|
Interrupt-driven I/O |
|
|
DMA |
|
|
Polling repeatedly occupies the CPU. Interrupts move service to event boundaries. DMA lets a controller move the block before notifying the CPU. These figures compare CPU overhead under the stated model, not end-to-end device time. Bus arbitration, transfer rate, cache effects and overlap are outside this numerical. The Computer Interfaces in COA post works through interface registers, handshaking and occupancy windows; these 4 KiB figures isolate CPU service cycles.
7. Practise the exam-style traps that connect diagrams to numericals
Exam-style A: What are the signed and unsigned meanings of
11111110? In 8-bit two's complement it is-2; unsigned it is254. Sign-extension gives0xFFFE.Exam-style B: Change I2 to
LD R3,8(R1). The effective address is0x0128, notPC+8, because this addressing mode usesR1as the base.Exam-style C: Remove forwarding from the pipeline. State whether an ID read can observe a WB write in the same cycle before counting stalls, because the answer depends on that register-file timing convention.
Exam-style D: Map
0x120in the stated cache. The result is tag 4, line 8, offset 0.Exam-style E: Which I/O values are CPU overhead rather than wall-clock transfer time? All three are overhead values under their stated assumptions.
Recurring traps include ignoring width and signedness, using the PC instead of the base register, quoting ideal pipeline speedup without fill and stalls, and mixing page, cache and word offsets. Use the COA question bank for optional mixed practice. University syllabi and paper instructions determine the local marks split, topic frequency and compulsory sections; the calculations above are subject examples, not a universal exam pattern.
8. Computer Organization semester short version and next step
Recall the chain: interpret bits -> compute effective address -> trace control and data -> place every pipeline stage by cycle -> split memory addresses -> count CPU work for I/O.
Now test it. Replace M[0x0124]=7 with -2: R3=-2, R4=3, R5=8. Map 0x160: block 88, line 8, tag 5, offset 0, evicting the 0x120 block from line 8. Double DMA setup to 1600 cycles: total overhead is 2000 cycles, or 1.0 microsecond. For a focused next step, use the Computer Architecture and Organisation course.
Keep learning
CPU Organization Basics: Registers, Instruction Cycle and Worked Examples
Follow PC, MAR, MDR, IR and AC through LOAD, ADD and STORE on a small 16-bit CPU. Then calculate opcode space, address capacity and common trace traps.
CPU Organization Basics MCQs: 12 Solved Questions with Explanations
Test whether you can follow an instruction through the CPU, then solve 12 exam questions on registers, buses, memory capacity and clock timing.
Programming the Basic Computer (COA): Instruction Set, Assembly Language and Worked Examples
Learn the Morris Mano Basic Computer by decoding an indirect instruction and assembling a subtraction program from source to final memory values.
General Hardware Terms Explained: CPU, Memory, Storage and I/O Worked Examples
Connect hardware acronyms to one computer-system map, then learn the differences through four step-by-step numericals, a classification table and practice checks.





