Instruction set

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

Instruction set

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What is an instruction set?
A The list of all the commands a CPU can process
B The list of all the programs stored on a hard drive
2. Which of these is a typical instruction in a CPU's instruction set?
A ADD
B PRINTER
3. Do all CPU designs use exactly the same instruction set?
A No, each CPU design has its own instruction set
B Yes, every CPU uses the same instruction set
4. Which part of the CPU decodes an instruction using the instruction set?
A The program counter (PC)
B The control unit (CU)
5. What does the instruction STORE usually do?
A Copies a value from memory into the CPU
B Copies a value from the CPU into memory

Match the Pairs

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

Left columnRight column
1ADD 5 AAn instruction set is the list of commands a CPU can process, not the data stored in RAM.
2JUMP 20 BCIR: ADD 5 -> CU decodes: ADD
3An instruction set includes commands to move data between registers and memory CEach CPU design has its own instruction set, so a program using one design's commands may not work on another.
4The control unit decodes each instruction by matching it to a command in the instruction set DLOAD 10 STORE 11
5A program written for one CPU always runs on any other CPU because all CPUs share the same instruction set. EAn instruction from the instruction set that makes the CPU continue from the instruction at address 20
6An instruction set is the list of data values stored in RAM. FAn instruction from the instruction set that tells the CPU to add the value 5 to the accumulator

Definitions

instruction set

Fill in the Blanks

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

1.
____ 10 // copy memory 10 into ACC ADD 11 // add memory 11 to ACC STORE 12 // save ACC into address 12
2.
LOAD 10 ADD 11 _____ 12 // save ACC into address 12
3.
ADD 1 ____ 1 // go back to the first line
4.
LOAD 10 ADD __ // add the value at address 11 STORE 12
5.
// the CU decodes using the instruction set decoded = lookup(opcode, _______________)

Spot the Error

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

Question 1
A iset = ["LOAD", "ADD"]
B iset.append("STORE")
C iset.append("JUMP")
D print(len(iset)
Question 2
A ins = "ADD 5"
B iset = ["LOAD", "ADD", "JUMP"]
C opcode = ins.split()[0]
D if opcode == iset:
E print("CU can decode it")
Question 3
A LOAD 20 # copy RAM to ACC
B ADD 21 # add value to ACC
C STORE 22 # copy RAM to ACC
D HALT
Question 4
A # CPU A: LOAD, ADD, STORE
B # CPU B: LOAD, SUB, JUMP
C # All designs share one set
D # so code for A may fail on B
Question 5
A iset = ["LOAD" "ADD", "JUMP"]
B for cmd in iset:
C print(cmd)

Answer Key

Instruction set
Section A: Quick Questions
Q1
A — The list of all the commands a CPU can process
Q2
A — ADD
Q3
A — No, each CPU design has its own instruction set
Q4
B — The control unit (CU)
Q5
B — Copies a value from the CPU into memory
Section B: Match the Pairs
Q1
ADD 5 → An instruction from the instruction set that tells the CPU to add the value 5 to the accumulator
Q2
JUMP 20 → An instruction from the instruction set that makes the CPU continue from the instruction at address 20
Q3
An instruction set includes commands to move data between registers and memory → LOAD 10 STORE 11
Q4
The control unit decodes each instruction by matching it to a command in the instruction set → CIR: ADD 5 -> CU decodes: ADD
Q5
A program written for one CPU always runs on any other CPU because all CPUs share the same instruction set. → Each CPU design has its own instruction set, so a program using one design's commands may not work on another.
Q6
An instruction set is the list of data values stored in RAM. → An instruction set is the list of commands a CPU can process, not the data stored in RAM.
Section C: Definitions
Q1
instruction set — The list of all the commands (such as load, add, store and jump) that a CPU design can process. The control unit decodes each instruction using it.
Section D: Fill in the Blanks
Q1
LOAD 10 // copy memory 10 into ACC ADD 11 // add memory 11 to ACC STORE 12 // save ACC into address 12
Q2
LOAD 10 ADD 11 STORE 12 // save ACC into address 12
Q3
ADD 1 JUMP 1 // go back to the first line
Q4
LOAD 10 ADD 11 // add the value at address 11 STORE 12
Q5
// the CU decodes using the instruction set decoded = lookup(opcode, instruction_set)
Section E: Spot the Error
Q1
D — The closing bracket of print() is missing. It should be print(len(iset)), which prints 4, the number of commands in the instruction set.
Q2
D — A single command cannot equal a whole list. To check that the command is in the instruction set, use in: if opcode in iset:
Q3
C — STORE copies the value from the accumulator into RAM, not the other way round. The comment should say: copy ACC to RAM.
Q4
C — Each CPU design has its own instruction set, so different CPUs can understand different commands. That is why code for A may fail on B.
Q5
A — A comma is missing between "LOAD" and "ADD". Each command in the list must be separated by a comma.