Arithmetic logic unit (ALU)

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Arithmetic logic unit (ALU)

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What does the ALU do in the CPU?
A Stores the whole program permanently
B Carries out arithmetic calculations and logical comparisons
2. Which task is carried out by the ALU?
A Adding two numbers together
B Sending the address to the address bus
3. Where is the result of an ALU calculation usually held?
A In the program counter (PC)
B In the accumulator (ACC)
4. Which of these is a logical operation the ALU can perform?
A AND
B Fetch
5. The ALU compares 7 and 5 to decide if 7 > 5. What type of operation is this?
A A logical comparison
B A memory read

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1ALU AThe CU does not do calculations or comparisons. The ALU does arithmetic and logic. The CU only controls and coordinates.
2ACC <- ACC + 5 B(age >= 16) AND (hasTicket == TRUE)
3The ALU performs arithmetic, such as subtracting one number from another CThe part of the CPU that carries out arithmetic calculations and logical comparisons
4The ALU performs logical decisions, such as comparing two values with AND Dresult = 20 - 8
5The control unit (CU) adds the numbers 4 + 3 and does the comparisons. EThe ALU does arithmetic (add, subtract) and also logical operations (AND, OR, NOT, comparisons).
6The ALU can only add numbers. It cannot do logic such as AND, OR, NOT. FThe ALU adds 5 to the value held in the accumulator and stores the result back in the accumulator

Definitions

ALU

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
ACC ← 10 ACC ← ACC _ 5
2.
ACC ← 20 ACC ← ACC _ 8
3.
IF age >= 16 ___ mark > 50 THEN
4.
IF a = 1 __ b = 1 THEN
5.
___ ← ACC + 5

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A ACC ← 8
B B ← 3
C ACC ← ACC - B
D OUTPUT ACC // 11
Question 2
A ACC ← 10
B ACC ← ACC + 4
C OUTPUT ACC // 6
Question 3
A A ← 7
B R ← A > 5 AND A > 10
C OUTPUT R // TRUE
Question 4
A LOCKED ← TRUE
B // ALU applies NOT
C OPEN ← LOCKED
D OUTPUT OPEN // FALSE
Question 5
A ACC ← 65
B PASS ← 50
C R ← ACC <= PASS
D OUTPUT R // TRUE

Answer Key

Arithmetic logic unit (ALU)
Section A: Quick Questions
Q1
B — Carries out arithmetic calculations and logical comparisons
Q2
A — Adding two numbers together
Q3
B — In the accumulator (ACC)
Q4
A — AND
Q5
A — A logical comparison
Section B: Match the Pairs
Q1
ALU → The part of the CPU that carries out arithmetic calculations and logical comparisons
Q2
ACC <- ACC + 5 → The ALU adds 5 to the value held in the accumulator and stores the result back in the accumulator
Q3
The ALU performs arithmetic, such as subtracting one number from another → result = 20 - 8
Q4
The ALU performs logical decisions, such as comparing two values with AND → (age >= 16) AND (hasTicket == TRUE)
Q5
The control unit (CU) adds the numbers 4 + 3 and does the comparisons. → The CU does not do calculations or comparisons. The ALU does arithmetic and logic. The CU only controls and coordinates.
Q6
The ALU can only add numbers. It cannot do logic such as AND, OR, NOT. → The ALU does arithmetic (add, subtract) and also logical operations (AND, OR, NOT, comparisons).
Section C: Definitions
Q1
ALU — Arithmetic logic unit: the part of the CPU that does calculations (add, subtract) and logic decisions (AND, OR, NOT, comparisons). Results are held in the accumulator.
Section D: Fill in the Blanks
Q1
ACC ← 10 ACC ← ACC + 5
Q2
ACC ← 20 ACC ← ACC - 8
Q3
IF age >= 16 AND mark > 50 THEN
Q4
IF a = 1 OR b = 1 THEN
Q5
ACC ← ACC + 5
Section E: Spot the Error
Q1
C — The ALU should ADD 8 and 3 to give 11. Subtracting would give 5. Line 3 should be ACC ← ACC + B.
Q2
B — The ALU must subtract 4 from 10 to get 6. Adding gives 14. It should be ACC ← ACC - 4.
Q3
B — 7 is not greater than 10, so the AND comparison would be FALSE. The ALU should test A < 10 so the result is TRUE.
Q4
C — The comment says the ALU applies NOT, which reverses TRUE to FALSE. Without NOT, OPEN would be TRUE. It should be OPEN ← NOT LOCKED.
Q5
C — 65 is greater than or equal to 50, so the comparison gives TRUE. Using <= would give FALSE. It should be R ← ACC >= PASS.