Question 6

AQA Computer Science November 2021 Paper 2 (7517/2)A level8 marks

On the specification

6.1
3.7 Fundamentals of computer organisation and architecture3.4 Theory of computation
6.2
3.7 Fundamentals of computer organisation and architecture3.4 Theory of computation
Question text

6 Figure 4 shows an assembly language program which has been written using the box AQA assembly language instruction set. The instruction set is explained in Table 1 on page 15. Figure 4 CMP R2, #0 BEQ exit MOV R0, #0 MOV R3, #1 moveleft: LSL R2, R2, #1 LSL R3, R3, #1 CMP R2, R1 BLT moveleft BEQ mainloop LSR R2, R2, #1 LSR R3, R3, #1 mainloop: CMP R1, R2 BLT skip ADD R0, R0, R3 SUB R1, R1, R2 skip: AND R4, R3, #1 CMP R4, #1 BEQ skipshiftR2 LSR R2, R2, #1 skipshiftR2: LSR R3, R3, #1 CMP R3, #0 BNE mainloop exit: HALT The program takes its input values from registers R1 and R2 and stores its output in registers R0 and R1 6.1 box Complete the trace table below to show the results of executing the program in Figure 4 when the initial values in registers R1 and R2 are 34 and 6 Each register can hold a 16-bit value. You may find it easier to understand the operation of the program if you write the contents of the registers out in both binary and decimal. You may not need to use all the rows in the table. [6 marks] R0 R1 R2 R3 R4 100010 (34) 110 (6) 6.2 The initial values for the program (its inputs) are stored in R1 and R2 and the final box values stored in R0 and R1 are its outputs. By considering the inputs and the outputs in your trace table for Question 06.1, describe the purpose of the program. [2 marks]