Assembly Language
1. The LMC Instruction Set (Simplified)
Key Mnemonics:
LDD [Add]: Load from AddressADD [Add]: Add value at Address to ACCSTO [Add]: Store ACC value to AddressINC [Reg]: Increment RegisterOUT: Output value in ACCEND: Terminate program
// Program at Addresses 100-103
100: LDD 200
101: ADD 201
102: STO 202
103: END
// Initial Memory Values
200: 15
201: 10
100: LDD 200
101: ADD 201
102: STO 202
103: END
// Initial Memory Values
200: 15
201: 10
2. Worked Exam Trace
We start with the PC at 100. Each row shows the state after the Fetch and Execute stages for that instruction.
| PC | MAR | MDR | CIR | ACC |
|---|---|---|---|---|
| 100 | --- | --- | --- | 0 |
| 101 | 200 | 15 | LDD 200 | 15 |
| 102 | 201 | 10 | ADD 201 | 25 |
| 103 | 202 | 25 | STO 202 | 25 |
3. Analysis of the Cycle
- Fetch: The PC (100) is moved to MAR. The instruction "LDD 200" moves from RAM to MDR, then to CIR. PC increments to 101.
- Execute: The CPU sees "LDD 200", so it puts 200 in the MAR, fetches the data (15) into the MDR, and finally loads it into the Accumulator (ACC).
Final Memory State:
Address 202 now contains the value 25.
Address 202 now contains the value 25.
⚠️ Exam Note: Immediate vs. Direct Addressing
- Direct Addressing (LDD 200): Go to address 200 and get the number stored there.
- Immediate Addressing (LDI 200): Load the actual number 200 into the accumulator.