Computer Architecture, Assembly and the LMC - Worksheets, Questions and Revision
9 original exam-style questions - 6 pages of questions with a full mark scheme - free printable PDF.
Computer Architecture, Assembly and the LMC revision guideMore A Level Computer Science practiceMock exams
This topic is chapter 6 of A Level Computer Science Topic Workbook 1 and chapter 6 of A Level Computer Science 10-Minute Tests.
1.6 Computer Architecture, Assembly and the LMC
i) Calculator:
ii) In-tray:
iii) Out-tray:
iv) Mailboxes:(4)
| Opcode | Mnemonic | Meaning |
|---|---|---|
| 1xx | (i) | Add the value in mailbox xx to the accumulator |
| (ii) | SUB | Subtract the value in mailbox xx from the accumulator |
| 3xx | STA | (iii) |
| 5xx | LDA | Load the value in mailbox xx into the accumulator |
| (iv) | BRA | Branch always: set the program counter to xx |
| 7xx | (v) | If the accumulator is zero, set the program counter to xx |
| (vi) | BRP | If the accumulator is zero or positive, set the program counter to xx |
| 901 | (vii) | Input a value from the in-tray into the accumulator |
| (viii) | HLT | Stop the program executing |
00 INP
01 STA 99
02 INP
03 ADD 99
04 OUT
05 HLT
99 DAT 000
The program is run with the inputs 15, then 23, entered in that order.
00 INP
01 STA 90
02 LDA 90
03 BRZ 08
04 OUT
05 SUB 91
06 STA 90
07 BRA 02
08 HLT
90 DAT 000
91 DAT 001
The program is run with the input 4.
Question 1
- (a) MAR <- 250, oe (the operand address is copied to the MAR)M1
- (a) MDR <- [ACC], oe (the value to be written is copied from the accumulator to the MDR)M1
- (a) [[MAR]] <- [MDR], oe (the value in the MDR is written to the memory location addressed by the MAR)A1
- (a) Answer: MAR <- 250; MDR <- [ACC]; [[MAR]] <- [MDR]
- (b) PC <- 50, oe (the operand value from the CIR is copied directly into the PC)M1
- (b) correctly identifies that no memory read or write, and no change to the ACC, is needed to carry this outA1
- (b) Answer: PC <- 50
- (c) normally the PC is incremented by 1 during fetch so that it points to the next instruction in sequence oeB1
- (c) the execute stage of BRA overwrites the PC with the operand address instead, so the next fetch reads the instruction at that new address rather than the following one oeB1
- (c) Answer: Because the execute stage of BRA directly overwrites the PC with a new address, the next fetch reads from that address instead of the next sequential one.
Question 2
- (a) the operand given in the instruction is the actual data value to be used, not an address oeB1
- (a) correct reference to the example, e.g. LDM #45 loads the literal value 45 into the accumulatorB1
- (a) Answer: In immediate addressing the operand is the data value itself, e.g. LDM #45 loads the value 45 directly into the accumulator.
- (b) the operand given in the instruction is the address of the memory location holding the data to be used oeB1
- (b) correct reference to the example, e.g. LDD 45 loads whatever value is currently stored at address 45B1
- (b) Answer: In direct addressing the operand is the address of the memory location holding the data, e.g. LDD 45 loads whatever value is stored at address 45.
- (c) (i) 45, caoB1
- (c) (ii) 12, caoB1
- (c) (iii) LDM treats its operand as the data itself, whereas LDD treats its operand as an address and fetches the value stored there, so the two instructions use the number 45 in completely different ways oeB1
- (c) Answer: (i) 45 (ii) 12 (iii) LDM uses 45 as the value; LDD uses 45 as an address, giving the different value 12 stored there.
Question 3
- (a) a simplified model of how a (von Neumann) processor carries out the fetch-decode-execute cycle oeB1
- (a) Answer: A simplified model of how a processor carries out the fetch-decode-execute cycle.
- (b) i) Accumulator (ACC)B1
- (b) ii) input device oeB1
- (b) iii) output device oeB1
- (b) iv) main memory/RAM oeB1
- (b) Answer: Calculator = accumulator; in-tray = input device; out-tray = output device; mailboxes = main memory.
- (c) 100 mailboxes, numbered 00 to 99B1
- (c) each mailbox holds a 3-digit number, from 000 to 999 oeB1
- (c) Answer: 100 mailboxes (numbered 00-99), each holding a 3-digit number from 000 to 999.
Question 4
- (a) the operand is the address of a memory location which itself holds the address of the data to be used (a pointer) oeB1
- (a) as a result, memory must be accessed twice to obtain the actual data value oeB1
- (a) Answer: In indirect addressing the operand points to a memory location that itself contains the address of the data, so memory is accessed twice to reach the actual value.
- (b) the effective address used is found by adding the contents of the index register (IX) to the address given in the operand oeB1
- (b) this is useful for accessing a sequence of consecutive memory locations, e.g. the elements of an array, by changing IX rather than the instruction itself oeB1
- (b) Answer: In indexed addressing the effective address is the operand address plus the value in IX, which allows a sequence of locations (e.g. an array) to be accessed by changing IX rather than the instruction.
- (c) (i) 80, cao (direct addressing: the value stored at address 60)B1
- (c) (ii) 7, cao (indirect addressing: address 60 holds 80, so the value at address 80 is loaded)B1
- (c) (iii) effective address = 63, cao (60 + IX, i.e. 60 + 3)B1
- (c) (iii) value loaded = 55, cao, ft from the effective address (the value stored at address 63)B1
- (c) Answer: (i) 80 (ii) 7 (iii) effective address 63, value loaded 55
Question 5
- (a) (i) ADDB1
- (a) (ii) 2xxB1
- (a) (iii) Store the value in the accumulator into mailbox xx oeB1
- (a) (iv) 6xxB1
- (a) (v) BRZB1
- (a) (vi) 8xxB1
- (a) (vii) INPB1
- (a) (viii) 000B1
- (a) Answer: (i) ADD (ii) 2xx (iii) Store the value in the accumulator into mailbox xx (iv) 6xx (v) BRZ (vi) 8xx (vii) INP (viii) 000
- (b) DAT reserves a mailbox to be used for storing a data value/variable, rather than as an executable instruction oeB1
- (b) valid example given, e.g. total DAT 0 reserves a mailbox labelled 'total', initialised to the value 0B1
- (b) Answer: DAT reserves a mailbox for storing a data value rather than an instruction, e.g. total DAT 0 reserves a mailbox called total, initialised to 0.
Question 6
- (a) address 00 (INP): ACC = 15B1
- (a) address 01 (STA 99): mailbox 99 = 15B1
- (a) address 02 (INP): ACC = 23B1
- (a) address 03 (ADD 99): ACC = 38 (23 + 15)B1
- (a) address 04 (OUT): output = 38B1
- (a) address 05 (HLT): the program stops executing, consistent with all prior valuesB1
- (a) Answer: 00 INP: ACC=15. 01 STA 99: mailbox99=15. 02 INP: ACC=23. 03 ADD 99: ACC=38. 04 OUT: outputs 38. 05 HLT: program stops.
- (b) 38, cao, ft from part (a)B1
- (b) Answer: 38
- (c) temporary storage for the first input value, so that it is not lost/overwritten when the second value is input, and can later be added to it oeB1
- (c) Answer: It temporarily stores the first input value so it is not overwritten before it can be added to the second input.
Question 7
- Level 3 A well-balanced discussion covering similarities and differences across registers, addressing modes and instruction sets, with a clear, justified overall conclusion on how realistic the model is. Technical terms are used accurately throughout.5-6
- Level 2 A discussion covering at least two of registers/addressing modes/instruction sets, with some valid comparison points, but a conclusion that is only partly justified, or an imbalance towards similarities or differences only.3-4
- Level 1 Limited comparison, largely a description of the LMC or of a real processor rather than a comparison between them; little or no reference to registers, addressing modes or instruction sets.1-2
- Level 0 No relevant content, or the response does not address the question.0
- Indicative content:
- The LMC uses a single general-purpose register (the accumulator/calculator), whereas a real processor has several distinct registers (PC, MAR, MDR, CIR, ACC, and sometimes an index register or general-purpose registers)
- The LMC's own cycle (fetch a mailbox, decode the opcode, execute it) mirrors the real fetch-decode-execute stages, so it is a valid simplified teaching model of the underlying process and of concepts such as branching and the role of the PC
- The LMC effectively only supports direct addressing of mailboxes for its ADD/SUB/STA/LDA instructions; it has no genuine immediate, indirect or indexed addressing, unlike a real processor which typically supports all of these
- The LMC's instruction set is very small (around ten instructions), compared with the much larger and more varied instruction sets of real processors
- LMC mailboxes store decimal numbers (000-999) directly as data or instructions, whereas real memory stores binary patterns, with instructions encoded in machine code as a binary opcode and operand
- The LMC has no concept of interrupts, pipelining, cache, or clock-driven timing, all of which significantly affect the performance of a real processor
- Overall the LMC is a useful, simplified model for understanding the sequence of fetch, decode, execute and basic branching, but it omits many features (multiple registers, full addressing modes, binary representation, performance features) present in a real processor, so it should be regarded as only a partial representation
- Credit either an overall conclusion (broadly realistic vs mostly unrealistic) provided it is supported by specific, accurate comparison points from at least two of the three areas named in the question
Question 8
- (a) INP followed by STA to input and store the first numberB1
- (a) INP followed by STA to input and store the second numberB1
- (a) LDA (first value) then SUB (second value) to compute the difference in the accumulatorB1
- (a) BRP used immediately after the subtraction, to branch directly to the output step when the difference is zero or positiveB1
- (a) a fallback path, taken only when the branch is not taken, that loads 0 into the accumulator (e.g. via LDA of a mailbox holding DAT 0) before reaching the output step oeB1
- (a) OUT then HLT to output the accumulator and stop; DAT mailboxes correctly reserved for both inputs and the constant 0B1
- (a) Answer: 00 INP / 01 STA 97 / 02 INP / 03 STA 98 / 04 LDA 97 / 05 SUB 98 / 06 BRP 09 / 07 LDA 99 / 08 BRA 09 / 09 OUT / 10 HLT / 97 DAT 0 / 98 DAT 0 / 99 DAT 0
- (b) BRZ only branches when the accumulator is exactly zero, so it would fail to branch whenever the difference is positive oeB1
- (b) BRP branches for both a zero and a positive accumulator, which correctly matches the requirement to output the true difference whenever it is zero or positive oeB1
- (b) Answer: BRZ would only catch a zero result and would miss positive results, whereas BRP correctly branches for both zero and positive differences, matching the specification.
- (c) (i) 0, cao (8 - 8 = 0, BRP taken)B1
- (c) (ii) 12, cao (20 - 8 = 12, BRP taken)B1
- (c) (iii) 0, cao (8 - 20 = -12, BRP not taken, fallback outputs 0)B1
- (c) Answer: (i) 0 (ii) 12 (iii) 0
Question 9
- (a) pass 1: ACC=4 then falls to 3 after the subtraction; output 4B1
- (a) pass 2: ACC=3 then falls to 2; output 3B1
- (a) pass 3: ACC=2 then falls to 1; output 2B1
- (a) pass 4: ACC=1 then falls to 0; output 1B1
- (a) mailbox 90 correctly tracked across passes as 4, 3, 2, 1, 0B1
- (a) on the fifth test at address 02/03, ACC (loaded from mailbox 90) = 0B1
- (a) the BRZ 08 condition is now met, so the program branches to address 08 rather than continuing the loopB1
- (a) final output sequence correctly stated as 4, 3, 2, 1 in that order, with no fifth output, and the program then haltsB1
- (a) Answer: Outputs, in order: 4, 3, 2, 1. Mailbox 90 takes the values 4, 3, 2, 1, 0 across the loop; once it reaches 0 the BRZ branches to HLT and the program stops.
- (b) execution would return to address 00 (INP) instead of address 02 at the end of each pass, so the program would request a brand new input value every time round the loop oeB1
- (b) this would overwrite the countdown value with whatever is newly input, so the program would no longer count down automatically from the original value oeB1
- (b) Answer: The loop would jump back to INP instead of LDA 90, so a new value would be requested and stored on every pass, overwriting the countdown and breaking the intended automatic countdown behaviour.
Mark your answers
Check answers without an account. Some answers can be checked automatically; use the mark scheme to mark the rest.