Skip to the worksheet
Revision Library
Choose a subject

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.

This topic is chapter 6 of A Level Computer Science Topic Workbook 1 and chapter 6 of A Level Computer Science 10-Minute Tests.

Revision Library
revisionlibrary.co.uk
A-Level · Computer Systems

1.6 Computer Architecture, Assembly and the LMC

OCR H446 · Calculators not allowed · about 90 minutes
Total Marks
Name: _______________________________    Date: ____ / ____ / ______
Answer ALL questions. Show all your working.
1
Two assembly instructions are STA 250 (store the value in the accumulator directly to memory address 250) and BRA 50 (branch always to the instruction at address 50).
(a)Using register transfer notation, describe the execute stage of STA 250.(3)
(b)Using register transfer notation, describe the execute stage of BRA 50.(2)
(c)Explain how the execute stage of BRA 50 is able to change the normal sequential order in which instructions are fetched.(2)
(Total for Question 1 is 7 marks)
2
A processor's assembly language supports both immediate and direct addressing. LDM #45 loads the value 45 directly into the accumulator. LDD 45 loads, into the accumulator, whatever value is currently stored at memory address 45.
(a)Explain what is meant by immediate addressing.(2)
(b)Explain what is meant by direct addressing.(2)
(c)Memory address 45 currently holds the value 12. State the value that would be loaded into the accumulator by (i) LDM #45 and (ii) LDD 45, and (iii) explain why these two answers are different.(3)
(Total for Question 2 is 7 marks)
3
The Little Man Computer (LMC) is a simplified model used to help understand how a real processor carries out the fetch-decode-execute cycle.
(a)State what the LMC is used to model.(1)
(b)Complete the table to match each part of the LMC model to its real computer equivalent.
i) Calculator:
ii) In-tray:
iii) Out-tray:
iv) Mailboxes:
(4)
(c)State the number of mailboxes in the standard LMC model, and the range of values each mailbox can hold.(2)
(Total for Question 3 is 7 marks)
4
The same assembly language also supports indirect addressing (LDI) and indexed addressing (LDX), where LDX uses the index register (IX).
(a)Explain what is meant by indirect addressing.(2)
(b)Explain what is meant by indexed addressing, with reference to the index register (IX).(2)
(c)Memory address 60 holds the value 80. Memory address 63 holds the value 55. Memory address 80 holds the value 7. The index register (IX) currently holds the value 3. State the value loaded into the accumulator, and (where relevant) the effective address used, for (i) LDD 60, (ii) LDI 60, (iii) LDX 60.(4)
(Total for Question 4 is 8 marks)
5
The table below sets out the LMC instruction set. Some cells have been left blank.
OpcodeMnemonicMeaning
1xx(i)Add the value in mailbox xx to the accumulator
(ii)SUBSubtract the value in mailbox xx from the accumulator
3xxSTA(iii)
5xxLDALoad the value in mailbox xx into the accumulator
(iv)BRABranch always: set the program counter to xx
7xx(v)If the accumulator is zero, set the program counter to xx
(vi)BRPIf 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)HLTStop the program executing
(a)Complete the table by giving the missing mnemonic or opcode for each of (i) to (viii).(8)
(b)Explain the purpose of a DAT instruction in an LMC program, giving an example.(2)
(Total for Question 5 is 10 marks)
6
The LMC program below inputs two numbers and outputs their sum.
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.
(a)Complete a trace table showing the value in the accumulator (ACC) and in mailbox 99 immediately after each instruction (addresses 00 to 05) executes, and any value output.(6)
(b)State the value output by the program.(1)
(c)State the purpose of mailbox 99 in this program.(1)
(Total for Question 6 is 8 marks)
7
Discuss the extent to which the Little Man Computer (LMC) is a realistic model of how a modern processor carries out the fetch-decode-execute cycle. Your answer should consider registers, addressing modes and instruction sets.
(Total for Question 7 is 6 marks)
8
An LMC program is required that: inputs two numbers; subtracts the second number from the first; outputs the result if it is zero or positive; outputs 0 instead if the true result would be negative.
(a)Write LMC mnemonics for a program that meets this specification. Mailbox addresses do not need to be given, but the mnemonics must be in a logical, executable order.(6)
(b)Explain why the BRP instruction must be used at this point, rather than BRZ.(2)
(c)State the output of the program in part (a) for the input pairs (i) 8 then 8, (ii) 20 then 8, (iii) 8 then 20.(3)
(Total for Question 8 is 11 marks)
9
The LMC program below inputs a number and counts down from it, outputting each value in turn.
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.
(a)Complete a trace table showing the value in the accumulator and in mailbox 90 during each pass through the loop (addresses 02 to 07), all values output, and the point at which the program halts.(8)
(b)The instruction at address 07 (BRA 02) is changed to BRA 00. Explain the effect this would have if the program were run again with the input 4.(2)
(Total for Question 9 is 10 marks)
Mark scheme · 1.6 Computer Architecture, Assembly and the LMC

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.

Question 1

7 marks
Did your answer earn the marks?

Question 2

7 marks
Did your answer earn the marks?

Question 3

7 marks
Did your answer earn the marks?

Question 4

8 marks
Did your answer earn the marks?

Question 5

10 marks
Did your answer earn the marks?

Question 6

8 marks
Did your answer earn the marks?

Question 7

6 marks
Did your answer earn the marks?

Question 8

11 marks
Did your answer earn the marks?

Question 9

10 marks
Did your answer earn the marks?
Mark my answers

Worksheets are written for Revision Library and come with a full mark scheme; a few English packs quote an out-of-copyright text, and name it on the page. Exam board names and specification codes say which qualification a pack suits: we are not affiliated with, endorsed by or approved by any exam board, and no past-paper question is reproduced here. Rights queries: hello@revisionlibrary.co.uk