Computer architecture · A level · OCR H446 1.1.1, AQA 7517 4.7.3.1, Eduqas A500QS 2.1 · about 20 min
The ALU, control unit and clock, general-purpose and dedicated registers, and the status flags an 8-bit ALU sets.
[1 mark]Which register holds the instruction currently being decoded and executed?
[1 mark]What does the control unit do?
[1 mark]An 8-bit ALU adds 200 and 100. Which flag is set?
[1 mark]What does this program print?
def flags(a, b):
r = (a + b) & 255
return r, r >> 7, int(r == 0)
print(flags(100, 50))
print(flags(128, 128))[1 mark]What is the difference between a general-purpose register and a dedicated register?
Write alu_add(a, b) yourself for an 8-bit ALU. Its inputs a and b are whole numbers from 0 to 255 (bytes). It works out the 8-bit result (0 to 255, anything that does not fit is lost) and the four flags N, Z, C and V, each 0 or 1, exactly as the table above defines them.
For each pair in pairs, print one line in the form 200 + 100 = 44 N=0 Z=0 C=1 V=0: the two inputs, the 8-bit result, then the flags in the order N, Z, C, V. The robot does not move.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
pairs = [(20, 30), (100, 50), (200, 100), (128, 128), (255, 1)]
def alu_add(a, b):
return a + bPlan your program here, then type it in and press Run.
alu_sub(a, b) that works out a - b as an 8-bit subtraction and sets N, Z and V.