Question 10
AQA Computer Science June 2018 Paper 2AS6 marks
On the specification
- 10.1
- 3.7 Fundamentals of computer organisation and architecture
Question text
10 Table 3 – standard AQA assembly language instruction set. This should be used box to answer question part 1 0 . 1 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. Figure 3 shows an incomplete assembly language program, intended to perform box integer division by 10. The program decrements the value in R1 in steps of 10 until the value stored in R1 is less than 10. Each time that the value in R1 is decreased by 10 the value in R3 is increased by 1. For example, if R1 started at 43 the sequence of numbers stored in R1 would be 43, 33, 23, 13, 3 and the final value in R3 would be 4. 10.1 Complete the program in Figure 3. You should assume that R1 has already been assigned a value to divide. You may not need to use all four lines for your solution and you should not write more than one instruction per line. [4 marks] Figure 3 MOV R3, #0 loopstart: CMP R1, #10 end: HALT A processor supports 32 different basic machine code operations, and two addressing box modes represented by a single bit, as shown in Figure 4 below. Figure 4 Opcode Basic machine Addressing Operand operation mode 0 0 0 1 1 0 0 1 1 1 0 1 1 0 1 10.2 How many different opcodes is the machine potentially capable of supporting? [1 mark] 10.3 In direct addressing, the value stored in the operand is the address of the memory location which contains the data to process. In direct addressing mode, how many memory locations could a processor that used the instruction format described in Figure 4 potentially make use of? [1 mark]