Question 7
AQA Computer Science June 2023 Paper 2 (7517/2)A level12 marks
On the specification
- 7.1
- 3.7 Fundamentals of computer organisation and architecture3.5 Fundamentals of data representation
- 7.2
- 3.7 Fundamentals of computer organisation and architecture3.5 Fundamentals of data representation
- 7.3
- 3.7 Fundamentals of computer organisation and architecture3.5 Fundamentals of data representation
Question text
7 For question parts 07.1 and 07.2 you should assume that memory locations and registers store 8-bit values. These question parts use the AQA assembly language instruction set in Table 3 on page 23. Assembly language instructions can be used to perform masking, which allows the values of individual bits or groups of bits within a number to be isolated or set independently of the values of the other bits in the number. For example, to isolate the values of the rightmost four bits of an 8-bit number, the number could be ANDed with the binary value 00001111. The assembly language instruction AND R0, R1, #15 performs a bitwise logical AND operation between the value in register R1 and the number 15 (equivalent to 00001111 in binary), storing the result in register R0. 7.1 In binary, show the result of applying the instruction AND R0, R1, #15 when register R1 contains the decimal value 70 which is 46 in hexadecimal. [1 mark] R1 0 1 0 0 0 1 1 0 15 0 0 0 0 1 1 1 1 R0 7.2 In binary, show the result of applying the instruction ORR R0, R1, #48 when register R1 contains the decimal value 6 which is 6 in hexadecimal. [1 mark] R1 0 0 0 0 0 1 1 0 48 0 0 1 1 0 0 0 0 R0 7 3 box . A computer program is required to display the value of the contents of a memory location that stores an 8-bit value. The value should be displayed on the screen of the computer in hexadecimal. Part of the process required to do this is to convert the value stored in the memory location into the correct ASCII codes for each of the two digits that represent that value in hexadecimal. For example, if the memory location contained: 10 0 1 1 1 1 0 which is 9E in hexadecimal, then the ASCII codes of the characters that need to be displayed are: 0 1 1 1 0 0 1 0 1 0 0 0 1 0 1 The first of these is the ASCII code of the character 9, the second is the ASCII code of the character E. Write an assembly language program using the AQA assembly language instruction set that will load a value from memory location 100 and store the ASCII code of the first (lefthand) digit of the hexadecimal representation of this value in memory location 101 and the ASCII code of the second (righthand) digit of the hexadecimal representation of this value in memory location 102. Your program should use masking and/or shifting to complete this task. The ASCII codes of the hexadecimal digits are shown in Table 2 and the AQA assembly language instruction set is in Table 3 on page 23. Table 2 ASCII Code ASCII Code Digit Decimal Binary Digit Decimal Binary 0 48 0110000 8 56 0111000 1 49 0110001 9 57 0111001 2 50 0110010 A 65 1000001 3 51 0110011 B 66 1000010 4 52 0110100 C 67 1000011 5 53 0110101 D 68 1000100 6 54 0110110 E 69 1000101 7 55 0110111 F 70 1000110 [10 marks] This table is included so that you can answer question parts 07.1, 07.2 and 07.3. box Table 3 – 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–12