Question 5

AQA Computer Science June 2017 Paper 2A level11 marks

On the specification

5.1
4.7 Fundamentals of computer organisation and architecture
5.2
4.7 Fundamentals of computer organisation and architecture
5.3
4.7 Fundamentals of computer organisation and architecture
Question text

5 Figure 4 shows the structure of an example machine code instruction, taken from the instruction set of a particular processor. Figure 4 Opcode Operand(s) Basic Machine Addressing Operation Mode 1 1 1 1 0 0 1 0 1 1 1 0 0 1 5.1 State the purpose of the operand part of an instruction and explain how the addressing mode is related to this. [2 marks] Figure 5 shows an assembly language program together with the contents of a section of the main memory of the computer that the program will be executed on. Each main memory location and register can store a 16-bit value. The assembly language instruction set that has been used to write the program is listed in Table 1 on the next page. Figure 5 Program Memory Main Memory LDR R1, 100 Address Contents LSL R2, R1, #2 (in decimal) (in decimal) ADD R1, R1, R2 100 10 LDR R3, 101 101 50 CMP R3, R1 102 80 BEQ labela MOV R4, #0 B labelb labela: MOV R4, #1 labelb: STR R4, 102 HALT 5.2 Complete the trace table below, in decimal, to show how the values stored in the registers and main memory change as the program in Figure 5 is executed. You may not need to use all of the rows. [4 marks] Register Contents Main Memory Location Contents R1 R2 R3 R4 100 101 102 5.3 Explain what the assembly language program in Figure 5 does. [1 mark] Table 1 – standard AQA assembly language instruction set LDR Rd, <memory ref> Load the value stored in the memory location specified by <memory ref> into register d. STR Rd, <memory ref> Store the value that is in register d into the memory location specified by <memory ref>. ADD Rd, Rn, <operand2> Add the value specified in <operand2> to the value in register n and store the result in register d. SUB Rd, Rn, <operand2> Subtract the value specified by <operand2> from the value in register n and store the result in register d. MOV Rd, <operand2> Copy the value specified by <operand2> into register d. CMP Rn, <operand2> Compare the value stored in register n with the value specified by <operand2>. B <label> Always branch to the instruction at position <label> in the program. B<condition> <label> Branch to the instruction at position <label> if the last comparison met the criterion specified by <condition>. Possible values for <condition> and their meanings are: EQ: equal to NE: not equal to GT: greater than LT: less than AND Rd, Rn, <operand2> Perform a bitwise logical AND operation between the value in register n and the value specified by <operand2> and store the result in register d. ORR Rd, Rn, <operand2> Perform a bitwise logical OR operation between the value in register n and the value specified by <operand2> and store the result in register d. EOR Rd, Rn, <operand2> Perform a bitwise logical XOR (exclusive or) operation between the value in register n and the value specified by <operand2> and store the result in register d. MVN Rd, <operand2> Perform a bitwise logical NOT operation on the value specified by <operand2> and store the result in register d. LSL Rd, Rn, <operand2> Logically shift left the value stored in register n by the number of bits specified by <operand2> and store the result in register d. LSR Rd, Rn, <operand2> Logically shift right the value stored in register n by the number of bits specified by <operand2> and store the result in register d. HALT Stops the execution of the program. Labels: A label is placed in the code by writing an identifier followed by a colon (:). To refer to a label the identifier of the label is placed after the branch instruction. Interpretation of <operand2> <operand2> can be interpreted in two different ways, depending on whether the first character is a # or an R: • # – use the decimal value specified after the #, eg #25 means use the decimal value 25. • Rm – use the value stored in register m, eg R6 means use the value stored in register 6. The available general purpose registers that the programmer can use are numbered 0 to 12. 5.4 Discuss the advantages and disadvantages of programming using a high-level language compared to programming using assembly language. [4 marks]