Question 12
AQA Computer Science June 2018 Paper 2A level6 marks
On the specification
- 12.1
- 3.7 Fundamentals of computer organisation and architecture3.5 Fundamentals of data representation
- 12.2
- 3.7 Fundamentals of computer organisation and architecture
- 12.3
- 3.7 Fundamentals of computer organisation and architecture3.5 Fundamentals of data representation
Question text
12 The pseudo-code in Figure 12 shows one method for carrying out encryption of a box single character using the Caesar Cipher. If the character to be encrypted is a capital letter, then the encrypted character will be shifted along the alphabet by the number of positions specified by the key. If the character is not a capital letter, then the encrypted character is set to be equal to the original character. The pseudo-code assumes that the letter to encrypt is stored using the Unicode UTF-8 encoding method, for which the values of capital letters (in decimal) are shown in Table 3. Figure 12 IF characterCode >= 65 AND characterCode <= 90 THEN encryptedCode characterCode + keyValue IF encryptedCode > 90 THEN encryptedCode encryptedCode – 26 ENDIF ELSE encryptedCode characterCode ENDIF Table 3 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 Figure 13 shows an incomplete assembly language program that has been written to implement the pseudo-code algorithm shown in Figure 12. The assembly language instruction set that has been used to write the program is listed in Table 4 on page 22. The symbols and indicate the positions of missing lines of code. Figure 13 box CMP R1, #65 BLT doNotEncrypt CMP R1, #90 BGT doNotEncrypt ADD R3, R1, R2 doNotEncrypt: finished: HALT 12.1 By analysing the assembly language program in Figure 13, explain the purpose for which the registers R1, R2 and R3 have been used. [2 marks] Register Purpose R1 R2 R3 12.2 On Figure 13, write the assembly language instruction that is missing from position . [1 mark] 12.3 On Figure 13, write the assembly language instructions that are missing from position . [3 marks] Turn to page 23 for the next question Table 4 – 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 to 12.