Question 9
AQA Computer Science November 2020 Paper 2 (7517/2)A level8 marks
On the specification
- 9.1
- 3.7 Fundamentals of computer organisation and architecture
- 9.2
- 3.7 Fundamentals of computer organisation and architecture
Question text
9 box Figure 11 shows the format of a machine code instruction for a particular processor and one instruction in that format. Figure 11 9.1 If the operand can be used to refer to any location in the memory, how many memory locations can the processor address? [1 mark] 9.2 One of the two addressing modes that the processor supports is immediate addressing. Explain what is meant by immediate addressing. [1 mark] Table 2 – Standard AQA assembly language instruction set box 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–12 9 3 box . The Vernam cipher encrypts a plaintext character by performing a logical operation between a character in the plaintext and part of the key. Write an assembly language program, using the AQA assembly language instruction set shown on page 28 in Table 2, to encrypt a plaintext character using this method. You should assume that: • the character code of the plaintext character to be encrypted is stored in memory location 101 • the part of the key to use to encrypt the character is stored in memory location 102 The encrypted ciphertext character should be stored in memory location 103 [3 marks] 9 4 box . A message has been encrypted using the Caesar cipher with a key value of 5 Using the Caesar cipher, each capital letter is replaced by another capital letter (as determined by the key value) whenever it is encrypted or decrypted. The pseudocode in Figure 12 is supposed to decrypt a single capital letter character in the message, but it does not work properly. Figure 12 asciicode CHAR_TO_INT(ciphertextcharacter) asciicode asciicode - 5 plaintextcharacter INT_TO_CHAR(asciicode) • CHAR_TO_INT is a function that returns the ASCII code of a character. • INT_TO_CHAR is a function that returns the character corresponding to an ASCII code. The ASCII code for capital letters is shown in Figure 13. Figure 13 Letter ASCII Letter ASCII Code Code A 65 N 78 B 66 O 79 C 67 P 80 D 68 Q 81 E 69 R 82 F 70 S 83 G 71 T 84 H 72 U 85 I 73 V 86 J 74 W 87 K 75 X 88 L 76 Y 89 M 77 Z 90 By analysing the pseudocode in Figure 12, explain what the problem with the algorithm represented by the pseudocode is and how it could be rectified. [3 marks]