After this chapter you will be able to
- trace the contents of PC, MAR, MDR, IR and AC at every step of an instruction
- solve address-bus, word-size, chip-count and page-table problems with the working shown
- identify instruction formats and addressing modes from a given instruction
- explain interrupt types, priority methods and the three I/O transfer methods
- separate look-alike facts on control units, Flynn’s classes, endianness, memory types and motherboard parts
📌 MUST KNOW - This is extra, harder material that adds to the main book. Read Chapters 1, 3, 4, 5 and 6 first. The main chapters answer most exam questions; this part is for the hardest ones, so do not start here.
Chapters 4, 5 and 6 give the basic units, the register list, the bus and the memory types. Chapters 40 and 46 cover cache mapping, IPC, Amdahl’s Law and the pipeline. This chapter adds only what a harder paper asks on top of them.
49.1 Registers: What Each Holds at Every Step
A Mains question asks which register holds what at a given moment. Take a one-address (accumulator) machine.
| Address | Instruction / data | Meaning |
|---|---|---|
| 200 | LDA 500 | AC ← M[500] |
| 201 | ADD 501 | AC ← AC + M[501] |
| 202 | STA 502 | M[502] ← AC |
| 500 | 7 | Data |
| 501 | 5 | Data |
Trace of ADD 501 (LDA has already run, so AC = 7 and PC = 201).
| Step | Micro-operation | PC | MAR | MDR | IR | AC |
|---|---|---|---|---|---|---|
| Fetch 1 | MAR ← PC | 201 | 201 | old | old | 7 |
| Fetch 2 | MDR ← M[MAR]; PC ← PC + 1 | 202 | 201 | ADD 501 | old | 7 |
| Fetch 3 | IR ← MDR | 202 | 201 | ADD 501 | ADD 501 | 7 |
| Decode | CU reads opcode ADD; MAR ← address part of IR | 202 | 501 | ADD 501 | ADD 501 | 7 |
| Execute 1 | MDR ← M[MAR] | 202 | 501 | 5 | ADD 501 | 7 |
| Execute 2 | AC ← AC + MDR | 202 | 501 | 5 | ADD 501 | 12 |
- The PC is incremented during fetch, not after execute. While ADD runs, it already holds 202.
- During fetch the MDR holds an instruction; during execute it holds data.
- For STA 502 the direction reverses: MAR ← 502, MDR ← AC, then M[MAR] ← MDR.
Match the register with what it holds
| Register | Holds |
|---|---|
| PC (8086: IP) | Address of the next instruction |
| IR | Opcode and address field of the current instruction |
| MAR | Address sent out on the address bus |
| MDR / MBR | Word just read from, or about to be written to, memory |
| AC | One operand before an ALU operation and the result after it |
| SP | Address of the top of the stack |
| Index register | A value added to an address field (array position) |
| Base register | Starting address of a program or data block |
★ EXAM POINT - MAR connects to the address bus; MDR connects to the data bus. MAR is loaded only from the CPU side, so it is one-way like the address bus. MDR is two-way like the data bus.
49.2 Flags, Stack and Segment Registers
Status flags are bits set by the ALU; control flags are set by the programmer.
| Flag | Set to 1 when |
|---|---|
| Carry (CY / CF) | An unsigned result goes out of the top bit |
| Zero (Z) | The result is 0 |
| Sign (S) | The top bit of the result is 1 (negative in signed form) |
| Parity (P) | The result has an even number of 1s |
| Auxiliary carry (AC / AF) | A carry passes from bit 3 to bit 4 (used for BCD) |
| Overflow (OF) | A signed result is too large for the register |
- Intel 8085: 5 flags (S, Z, AC, P, CY) in an 8-bit flag register. It has no overflow flag.
- Intel 8086: 9 flags: 6 status (CF, PF, AF, ZF, SF, OF) and 3 control (TF trap/single-step, DF direction, IF interrupt enable).
Worked example: two 8-bit additions
- 9CH + 64H = 1001 1100 + 0110 0100 = 1 0000 0000. The register keeps 00H. CY = 1, Z = 1, S = 0, P = 1 (zero 1s is even), AC = 1 (C + 4 = 16 carries out of bit 3). Signed view: −100 + 100 = 0, so OF = 0.
- 50H + 50H = 0101 0000 + 0101 0000 = 1010 0000 (A0H). CY = 0, Z = 0, S = 1, P = 1 (two 1s), AC = 0. Signed view: +80 + +80 = +160, beyond +127, so OF = 1.
⚠ COMMON CONFUSION - Carry is for unsigned numbers; overflow is for signed numbers. Example 1 sets carry without overflow; example 2 sets overflow without carry.
Stack pointer. In the 8085 and x86 the stack grows downward. An 8085 PUSH stores two bytes: SP = 2400H → PUSH B → SP = 23FEH. CALL and every interrupt push the PC onto the stack.
Segment registers (8086): CS, DS, SS, ES. Physical address (20-bit) = segment × 10H + offset.
- CS = 2000H, IP = 0150H → 20000H + 0150H = 20150H.
- A segment is at most 64 KB, because the offset is 16 bits.
- Index registers: SI, DI. Base registers: BX, BP.