0% found this document useful (0 votes)
620 views25 pages

Int Comput Low Sec9 - 1

Uploaded by

Daanya Ghani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
620 views25 pages

Int Comput Low Sec9 - 1

Uploaded by

Daanya Ghani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Margaret Debaddi

Siobhan Matthewson INTERNATIONAL


Series editor:
Peter Marshman
COMPUTING
FOR LOWER SECONDARY

SAMPLE PAGES

STAGE

9
DIGITAL
COMPUTER ATION
DIGITAL
LITERACY
SCIENCE TECHNOLOGY
LITERACY TECHNOLOGY

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 1 01/05/20 3:16 PM


International Computing for Lower Secondary
Deliver an exciting computing course for ages 11-14.The course covers the requirements of the national
curriculum for England and is mapped to the Level 2 CSTA K-12 Computer Science Standards and the
Cambridge Assessment International Education Digital Literacy Framework for Stages 7-9.

Available in the series:


£17.99
International Computing for Lower Secondary Student's Book Stage 7 9781510481985
International Computing for Lower Secondary Student's Book Stage 8 9781510481992
International Computing for Lower Secondary Student's Book Stage 9 9781510482005

Our Student's Books are also available in two digital formats:


The Student eTextbooks are downloadable version of the printed textbooks. They enable students to study
on the move and provide a cost-effective way to resource your classroom.

The Whiteboard eTextbooks are an online, interactive version of the printed textbooks that are ideal for
front-of-class teaching and lesson planning.

1 year access: £12.00/ 2 year access: £17.99


International Computing for Lower Secondary Student's Book Stage 7 Student eTextbook 9781510483538
International Computing for Lower Secondary Student's Book Stage 8 Student eTextbook 9781510483569
International Computing for Lower Secondary Student's Book Stage 9 Student eTextbook 9781510483606

£50 for access until 31st Aug 2025


International Computing for Lower Secondary Student's Book Stage 7 Whiteboard eTextbook
9781510483545
International Computing for Lower Secondary Student's Book Stage 8 Whiteboard eTextbook
9781510483552
International Computing for Lower Secondary Student's Book Stage 9 Whiteboard eTextbook
9781510483590

Online Teacher's Guide


Save time preparing your lessons with a cost-effective range of online resources such as teaching notes,
copyright guidance, curriculum links, glossary, 'how to use' instructions, Student Book answers, online safety
advice, software list, CPD videos and more.

£125 for access until 31st Aug 2025


International Computing for Lower Secondary Online Teacher's Guide Stage 7 9781510483484
International Computing for Lower Secondary Online Teacher's Guide Stage 8 9781510483491
International Computing for Lower Secondary Online Teacher's Guide Stage 9 9781510483507

To learn more about the series visit hoddereducation.com/international-computing

481985_01_Int_Comput_Low_Sec_SB_i-033.indd 2 2/18/20 8:21 PM


Contents

9.1 Drilling down: How the processor processes 8

9.2 Sorting it all out: Searching and sorting data structures 42

9.3 HTML, CSS, JavaScript: Web-Pro Games 76

9.4 Networking: Not just a way of meeting new people 108

9.5 Designing, solving and documenting solutions 140

9.6 Choosing and using: Databases and spreadsheets 172

7.6 Glossary 214


7.6 Index 220

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 3 01/05/20 3:16 PM


Introduction

About this book


This Student Book will continue to support your progression in computing and in the ongoing
development of the skills needed to progress to specific curriculum areas such as IGSE Computer
Science and IGCSE ICT. Building on the skills developed in the previous book in this series you will
further develop the technical skills needed to engage effectively in the digital world of today. It
supports the curriculum areas of digital literacy, computer science and information technology:

● Digital literacy focuses on the impact of


digital technology in today’s society. It
promotes understanding of the impact
of the digital world with an emphasis on
maintaining safety and well-being online.
● Computer science is the study of
computational thinking and the creation
of computer programs to solve problems.
It also explores how a computer interprets
and carries out instructions.
● Information technology looks at how to
use computer programs to solve problems.
It takes into consideration both usability
(how well a program works) and accessibility
needs (whether or not everybody is able to
use the program effectively).

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 4 01/05/20 3:19 PM


Introduction

Units
This Student Book has six units:

9.1 Drilling down: How the processor processes introduces students to the CPU,
registers and the fetch-decode-execute cycle. The concepts are illustrated using simple
assembly language instructions. The role of logic gates and truth tables is explored,
along with the continuing impact of advanced technology such as artificial intelligence
and virtual reality.

9.2 Sorting it all out: Searching and sorting data structures introduces students
to the concept of arrays and their implementation as lists in Python. For loops are
introduced, before moving on to the following searching and sorting algorithms:
insertion sort, bubble sort, linear search and binary search. These are covered in some
depth in both pseudocode and then as full Python implementations. Functions are
introduced along with the concept of testing code.

9.3 HTML, CSS, JavaScript: Web-Pro Games explores more sophisticated website
design for an online gaming company, with further coverage of CSS and the addition
of JavaScript to enable interactive webpage elements, such as forms and buttons.

9.4 Networking: Not just a way of meeting new people explores the wired and
wireless technologies that make up LANs and WANs, including the internet. This
chapter also discusses how data travels across networks, error detection and how it can
be encrypted. Legal issues surrounding personal data are also covered.

9.5 Designing, solving and documenting solutions covers the different roles within
a software development team – project manager, analyst, designer and programmer.
Students will learn about Gantt charts, wireframes, user requirements, test plans and
drawing up pseudocode solutions that address a client’s problem.

9.6 Choosing and using: Databases and spreadsheets focuses on a music promoter
running a large music festival, with business needs that can be addressed using
a combination of database and spreadsheet applications. Students will create a
relational database, produce more complex queries and reports, create forms for data
input, introduce macros, VLOOKUPs and pivot tables, and learn about presenting user-
friendly interfaces.

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 5 01/05/20 3:19 PM


Introduction

How to use this book


In each unit you will learn new skills by completing a series of tasks. Each unit starts with some
information followed by a list of the learning objectives that you will cover. These features also
appear in each unit:

Learning Outcomes
KEYWORDS
Important words are
This panel lists the things you will learn about in each unit. emboldened the first
time they appear in a
SCENARIO unit and are defined in
this panel. They also
This panel contains a scenario which puts the tasks into a real-world appear in the glossary.
context.
This panel suggests a
Do you remember? simple task to check
your understanding.
This panel lists the skills you should already be able to do before
starting the unit.
These speech
bubbles provide
Learn hints and tips as you
complete the tasks.
This panel introduces new concepts and skills.

DID YOU KNOW?


Practice
This panel provides an
interesting or important
This panel contains tasks with step-by-step instructions to apply fact about the task or
the new skills and or knowledge from the ‘Learn’ panel. theme.

Computational Thinking

This panel highlights tasks in the unit which involve one of the key areas of computational
thinking:
Pattern recognition: the identification of repeating tasks or features in a larger problem
to help solve more complex problems more easily.
Decomposition: breaking larger problems down into smaller more manageable tasks.
Each smaller task is examined and solved more easily than a larger more complex problem.
Abstraction: ignoring details or elements of a problem which are not needed when trying
to solve a problem.
Algorithmic thinking: providing a series of instructions which include details on how to
solve an identified problem.
Generalisation: the process of creating solutions to new problems using past knowledge
and experience to adapt existing algorithms.
Evaluation: the process of ensuring that an algorithmic solution is an effective and efficient
one – that it is fit for purpose.

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 6 01/05/20 3:19 PM


Introduction

Go further
This panel contains tasks to enhance and develop the skills
previously learnt in the unit.

Challenge yourself
This panel provides challenging tasks with additional instructions
to support new skills.

Final project
This panel contains the final tasks of the unit which encompass
all the skills developed. It can be used to support self/peer
assessment and teacher assessment.

Evaluation
This panel provides guidance on how to evaluate and, if necessary,
test the Final Project.

Student resources are available at www.hoddereducation.com/ student-resources

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 7 01/05/20 3:19 PM


Unit Drilling down: How the
9.1 processor processes
About the CPU
At the centre of all of the technologies we use today is a device known
KEYWORDS
as the central processing unit (CPU). The CPU contains all of the
central processing
electronic circuitry a computer needs to carry out all of the instructions unit (CPU): contains
provided by the computer programs running on the device. It is the all of the electronic
electronic circuitry inside circuitry a computer
needs to carry out
the CPU which is used
all of the instructions
to execute programs on provided by the
the electronic device. computer programs
Computer programs can running on the device
be written in high-level high-level language
(HLL): a programming
languages (HLL) (such language such as
as Python); these are Python, that is closer
easy for the programmer to human language
than the language a
to understand but computer understands
processing time needs to low-level language
be spent translating these (LLL): a programming
instructions into a format that the processor can understand. Programs language where
the commands
can also be written in low-level languages (LLL) (such as assembly
link directly to the
language or machine code). Assembly instructions the
language programs are designed processor can carry
specifically for each type of processor Think about the various out
assembly language:
and less translation is needed. models of PCs and mobile
phones available to users a low-level language
designed for a specific
The specification of the CPU can have today and how devices with
processor
an impact on the cost of a computer. higher processing capabilities
machine code:
The higher the specification, the more and memory are more
a computer
expensive.
expensive the device will be. programming
language consisting
In this unit you will learn: of binary instructions
that the computer can
➜ about the differences between high-level language, low-level understand without
language, assembly language and machine code a need to carry out
➜ about the main influences on processing speed of a digital device translation
register: a memory
➜ about the main role of the CPU and how it fetches, decodes and
location within the
executes instructions CPU itself, used
➜ the names and roles of the registers used when instructions are being for high speed
access to data such
fetched, decoded and executed as instructions,
memory addresses or
individual data items

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 8 01/05/20 3:19 PM


Unit 9.1 Drilling down: How the processor processes

➜ how computer systems use logic gates and buses for data KEYWORDS
manipulation and transmission logic gate: simple
➜ how to draw logic gates and produce truth tables to illustrate the devices which can be
operation of a logic gate used to carry out a
range of operations on
➜ how to combine logic gates to create a logic circuit used to support input data values
complex processes bus: communication
➜ to consider the impact of artificial intelligence (AR), virtual line used to transfer
signals from one part
reality (VR) and robotics on today’s society of a digital device to
➜ to consider the availability of such technologies across the world today another; for example,
(digital divide) and the impact they can have on everyday life a set of wires used
to transfer data
around the inside of a
SCENARIO computer
logic circuit: a
Tech-D is a new technology design company whose focus is designing combination of
technology which can be used to test young children’s mathematical logic gates used to
abilities. They have asked you to help with the development of a carry out complex
simple calculator which can be used in classrooms with children aged operations
truth table: a table
between 5 and 6 years of age. The important features Tech-D has which shows all
asked you to consider when you are helping to develop the calculator possible combinations
include: of inputs and outputs
• how the hardware specification in the for a logic gate
The instructions to artificial intelligence
calculator can be altered to change
be carried out are (AI): the use of
the processing capabilities of the quite simple so a high computers to simulate
calculator. specification, high cost intelligence displayed
• what language can be used to program device is not necessary. by humans
virtual reality (VR):
the calculator so that instructions can the use of technology
be quickly converted into a language the to create an artificial
calculator can easily carry out. environment that
• how the instructions are carried out by looks and feels
Additional components realistic to the end
the calculator, to make sure that the user
cost money so
hardware designers don’t include extra they so they should
components that are not required. To do not be included
this you need to examine the role of the unnecessarily.
CPU in a digital device and how it carries
out the fetch-execute cycle when running a
computer program
• limiting access to users whose
biometric details, such as a
finger print or retina scan,
are stored on the calculating
device. Your task is to help
design a logic circuit that will
help manage user access to
the calculator based on their
biometric details.

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 9 01/05/20 3:21 PM


International Computing for Lower Secondary

DID YOU KNOW? We will look later in


Since no two people can have the same voice, fingerprint or pattern in the retina of this unit at methods
their eyes, biometric authorisation is becoming popular. The term biometric comes of providing biometric
from ‘bio’, meaning life, and ‘metric’, meaning measurement. authorisation to
hardware devices and
applications.
KEYWORDS
biometric: the measurement of individuals’ unique physical characteristics
such as fingerprints and facial recognition
biometric authorisation: the use of biometric data to identify authorised users
to an application and limit control to technology

Do you remember?
Before starting this unit, you should be able to:
✔ carry out basic mathematical calculations such as addition and
subtraction
✔ enter a URL into a web browser to access a specified web site
✔ access a spreadsheet application and alter the contents of a cell
in a spreadsheet
✔ understand simple algorithms in the form of pseudo code or a
flowchart
✔ covert simple pseudocode and flowchart algorithms into coded
solutions
✔ use conditions in coding to support decision making
✔ understand the concept of repetition and its application in
programming
You should also know that:
✔ instructions entered into a computer must be converted into
binary before they can be carried out
✔ you can use spreadsheet applications to model real-life situations
✔ Boolean values are values which can only be represented by
TRUE or FALSE

10

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 10 01/05/20 3:21 PM


Unit 9.1 Drilling down: How the processor processes

Inside a digital device


Learn

Any processing by a digital


device is carried out by a part of
the device known as the central
processing unit (CPU). The CPU
is connected to a special circuit
board inside your computer. The
circuit board where the CPU is
located is called the motherboard
and the CPU is attached to the motherboard via a special
socket. Most digital devices have a CPU; for example, your
mobile phone, a washing machine, a microwave or your
computer at home. The CPU is the component inside a digital
device that does all of the work.
The motherboard is used to provide power to the CPU and all of
the other components inside the digital device.
The CPU carries out all of the instructions inside a digital device,
such as:
➤ Controlling the operation of other parts of the digital device KEYWORDS
➤ Fetching instructions circuit board: a
thin plastic plate or
➤ Carrying out instructions in computer program unit which contains
➤ Carrying out arithmetic and logical operations electronic components
motherboard: a
➤ Managing the input and output of data circuit board that
The main role of the CPU is to run (or execute) a set of stored houses the CPU and
provides connections
instructions known as a computer program. The CPU co-
between the hardware
ordinates all of the other parts of the computer when it is components inside a
executing a program. It does this using a device called the computer
internal clock or system clock. logical operations:
instructions carried
Just in the same way that students’ movement from one out using logical
class to another during the school day can be co-ordinated operators such as >,
by a school bell, the internal clock helps the CPU manage the <, >=, <>, where the
execution of each instruction in a program. The CPU needs a result can only be
certain number of clock ticks to carry out each instruction. TRUE or FALSE
The number of ticks carried out per second in a modern CPU internal clock (or
system clock): a timer
is measured in MHz (megahertz) or GHz (gigahertz). 1 MHz which is used to control
equals one million clock ticks per second. 1 GHz equals one the rate instructions are
billion clock ticks per second. carried out
clock ticks: a unit to
The more clock ticks there are every second, the more instructions
measure time inside a
the processor can carry out in one second. computer system

11

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 11 01/05/20 3:21 PM


International Computing for Lower Secondary

The speed computers work at has continued to increase


in recent years. Here are some of the other ways
Having two cores will
manufacturers have tried to increase processing speeds: not mean the processor can
➤ Including more than one core (processing unit) in the CPU. carry out twice as many
A single core can process an instruction or program on its instructions as a single core, as
own. CPUs can have more than one core so that more than some time and processing power
one program (set of instructions) can be carried out at the needs to be spent splitting
jobs or instructions between
same time.
each core.
[AQ] ➤ Increasing the amount of cache memory. Cache
Cache
memory
memory is located on the same chip as the CPU, and
is part
of the
can be accessed very quickly. The CPU will store
CPU frequently-used instructions in cache so it has faster Storing data in
and
closer access to them. With more cache memory available cache is like storing
to the
CPU more instructions can be accessed very quickly, which data in a drawer in
and the
improves the speed of the computer. your house instead of
RAM
outside in your garage.
➤ Increasing the amount of random access memory (RAM).
The drawer in your house is smaller
RAM is used to temporarily store programs and data and closer so the data is quicker
currently being used by the processor. RAM is placed and easier to find (and you
close to the CPU (but not as close as cache memory and, don’t have to go
therefore, cannot be accessed as quickly). RAM is much larger outside!)
than cache memory, however, and access times are still fast.
The more data that can be stored in RAM, the faster it can be
accessed by the CPU and the faster an instruction can be carried KEYWORDS
out. A computer with a larger amount of RAM has a higher core: an individual
processing unit) in the
performance than a computer with a lower amount of RAM.
CPU. Each processing
CPU can carry out its own
set of instructions
2. If data is in cache,
1. Look in cache for data. cache: high speed
send it to CPU and stop.
memory, close to the
cache processor, normally on
the same processor
3. If data is not in cache, 4. Send data from RAM; write it to chip, used to store
fetch from RAM. the cache and then send it to the CPU. frequently-used
RAM instructions so the
processor can access
If the processor can reduce the time needed to collect the them quickly.
instructions it is carrying out, it will also speed up processing time.

12

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 12 01/05/20 3:21 PM


Unit 9.1 Drilling down: How the processor processes

Practice

When purchasing a new computer it is always important to


look at the hardware specification, particularly the clock speed
(processing power), cache size and number of cores.
For example, the computer below has a clock speed of 4.5 GHz,
which means it operates at a speed of 4.5 billion clock ticks
per second. It has 8 processing cores, 8 GB of RAM and
16.5 MB of cache.
1 Hz = 1 instruction
in a second
1 kHz = 1000 instructions per second
ALIENZONE GAMER (INTEL) 1 MHz = 1000 kHz = 1 million instructions
per second
Intel® Core™ i7 9800X (8-core, 16.5MB Cache,
up to 4.5GHz with Intel® Turbo
1 GHz = 1000 MHz = 1 billion instructions
Windows 10 Home 64bit, English, Dutch,
per second
French, German, Italian
Note: ‘instructions’ does not mean lines
NVIDIA® GeForce® GTX™ 1050Ti with 4BG GDDRS
of code; it is the number
8GB Channel DDR4 at 2666MHz of different tasks the processor
2TB 7200RPM SATA 6Gb/s (Standard) can carry out of any
$2,800.00 kind at all.

Carry out the following tasks with a partner.


➤ Search the internet for a range of computer specifications
(five at the most). Your search criteria could include
specifications for computers with four cores (quad core), and
eight cores. Look also for computers with greater than 4 MB of
cache memory.
➤ Print a copy of each of the hardware specifications you
have found. Look only at the specifications focussing on the
number of cores, clock speed, RAM size and cache size.
o Highlight the clock speed, number of cores, RAM and
cache size in the specification. Think carefully about the
o Discuss which of the specifications you have following:
found you think would be the most powerful/ 1. Does each instruction it carries out
fastest in terms of processing. Give a reason relate to a single line of a program?
2. How fast the other parts of the
for your answer.
computer can operate – could a
➤ Discuss why even though a processor has a printer handle printing out the
clock speed of 3 GHz this does not mean the results of three billion
processor can carry out three billion lines of code instructions every second?
every second.

13

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 13 01/05/20 3:21 PM


International Computing for Lower Secondary

Inside the CPU KEYWORDS


control unit: issues
Practice commands to all of
the other hardware
components to help
The CPU has three main components. ensure programs are
➤ Arithmetic logic unit (ALU) – carries out all of the calculations carried out correctly
needed during the execution of a program. arithmetic logic unit
(ALU): carries out all
➤ Control unit (CU) – issues commands to all of the other
of the calculations
hardware components to help ensure programs are carried out needed during the
correctly. execution of a program
➤ Registers – store data about memory locations, instructions program counter
and data used during execution of an instruction. (PC): stores the
address of the next
o Accumulator (ACC) – a register used by the ALU to store the instruction waiting to
intermediate results of processing carried out by the ALU. be executed (carried
o Program counter (PC) – stores the address of the next out) by the CPU
instruction waiting to be executed (carried out) by the CPU. current instruction
register (CIR): stores
o Current instruction register (CIR) – stores the address of
the address of the
the instruction currently
instruction currently being executed by the CPU. being executed by the
o Memory address register (MAR) – holds the address of the CPU
memory location being accessed either to read data from, memory address
or to write data to. register (MAR): holds
the address of the
o Memory data register (MDR) – any data or instructions that memory location
pass into or out of main memory must pass through the MDR. being accessed either
to read data from, or
Central processing unit Main memory to write data to
memory data register
(MDR): any data or
Arithmetic logic Registers Bus instructions that pass
unit (ALU) into or out of main
ACC memory must pass
PC through the MDR
main memory: another
CIR name for RAM, which
MAR is used to store the
Control unit programs and data
MDR currently being
operated on by the
CPU
accumulator (ACC): a
Main memory is another name for RAM, which is used to store register which holds
the programs and data currently being operated on by the CPU. the intermediate
results of processing
Buses are sets of wires which can be used to carry a number of carried out by the ALU
different signals around a digital device. These include: address bus: identifies
➤ data (data bus) a location in main
memory which is to be
➤ details of memory locations to be accessed (address bus) accessed
➤ signals which tell other parts of the device what they are expected data bus: carries data
to do next (control bus). signals around the
inside of the device

14

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 14 01/05/20 3:21 PM


Unit 9.1 Drilling down: How the processor processes

KEYWORD
Buses in computers carry the signals in the same way that we
control bus: carries
can travel from one place to another on a bus.
control signals to
different parts of the
Address bus Data bus Control bus
digital device telling
This is like the Like the passengers When the bus stops them what task they
number and on a bus – these a bell sound is played need to carry out next
destination on the are the data signals with a message telling
front of a bus – tells which move around passengers which stop
the processor what the inside of the they have reached – this
location in memory computer; for carries special signals
will be opened to example, electrical which tell the processor
read data from or signals which what type of operations
to write data to represent the binary are being carried out,
code for letter R
when it is pressed on
a keyboard need to
be carried from the
keyboard to the CPU

Practice

Complete the following diagram to help ensure you have a full


understanding of the role played by each part of the CPU before
we look in more detail at how the CPU carries out instructions in
a computer program.
➤ Open the Microsoft Word document called Understanding the
CPU provided by your teacher.
➤ Label each of the parts of the CPU by including a description
of the role it plays in the fetch–decode–execute cycle.

ALU Control unit

Central processing
unit
Control unit

Arithmetic logic unit


Input Output
device Registers PC CIR device
ACC MAR MDR

Accumulator Main memory Registers

Main memory

15

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 15 01/05/20 3:21 PM


International Computing for Lower Secondary

High- and low-level languages

Learn

The instructions to be carried out by a computer are provided


by a computer program. Program developers use high-level
languages such as JavaScript, Python or Scratch to write
computer programs. However, before the processor can carry
out these instructions they need to be converted into a pattern
of 1s and 0s (binary) that the CPU understands.
Every CPU has its own set of binary instructions it understands.
This is called its instruction set. The instruction set of a CPU
is written in binary (also known as machine code) and is an
example of a low-level language.

var1 = 0.5 10100101010010101010101


If var1 > 1.3 or var1 < 0.9: 01010101010010101010100
High-level language (HLL) Low-level language (LLL)
● Easy for humans to read, write ● More difficult for humans to read, write Remember that
and modify. and modify. computers only
● Uses variables to identify loca- ● Identifies locations in memory using actu- understand instructions
tions in memory for storing data. al location addresses when storing data. which are written in
● Portable, which means they can ● Not portable which means they can run binary.
be run by any CPU. on a CPU with the same instruction set.

HLLs can be said to provide an abstract representation of how


the CPU operates. This means that the programmer does not
need to understand what is happening inside the CPU when
they are writing their HLL program; instead, they can focus on
writing a program to solve a task. It also means that each HLL
instruction will require more than one LLL instruction before it
can be carried out successfully. Since one HLL instruction can
represent more than one LLL, the programmer cannot always
make the most efficient use of the hardware of the CPU. This KEYWORDS
means HLL instructions take longer to carry out. instruction set: the set
of all instructions in
Experienced programmers can make use of a less abstract machine code that can
version of machine code, called assembly language. be executed by a CPU
abstract: a
Each assembly language instruction corresponds to one representation that
machine code instruction in the CPU’s instruction set. The does not show all of
difference however is that assembly language uses a set of the detail; the way a
codes or symbols to represent each instruction, rather than high-level language
can be used to
a group of 1s and 0s. The assembly language instructions are
represent more than
therefore easier for human programmers to understand, for one machine code
example, to output the word “Hi” to a computer screen: instruction

16

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 16 01/05/20 3:21 PM


Unit 9.1 Drilling down: How the processor processes

KEYWORDS
Assembly language instruction Machine code alternative opcode: an instruction
OUT "Hi" 10110101 01001000 01101001 to be carried out
operand: a data item
to be operated on or
a location in memory
Could be machine code ASCII for "H" ASCII for "i"
were the data is
instruction for output
stored

Operand
Opcode

Each machine code instruction is made up of an opcode (the


instruction to the carried out) and an operand (the data to be
operated on or a location in memory were the data is stored).
The diagram below helps us understand the link between the
CPU hardware, machine code, assembly language and high-level
languages.

High-level languages, such as


Python, Javascript, Scratch

Assembly language

Machine language

CPU hardware

Practice

Produce an infographic which clearly illustrates to a non-computer


expert the differences between high-level languages, assembly
language and machine code.
Your graphic should include:
➤ a description of each type of instruction
➤ an illustration which shows the relationship between each
language to the hardware of the CPU
➤ the advantages and disadvantages of each language type
➤ additional examples of high-level languages and examples of
their uses
➤ an illustration of the differences between a high-level
language instruction, an assembly language instruction and a
machine code instruction.

17

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 17 01/05/20 3:21 PM


International Computing for Lower Secondary

Introducing fetch–decode–execute… repeat

Learn

When executing computer programs the CPU will carry out many instructions every
second by going through a set of steps known as the instruction cycle.
An instruction cycle carried out by a
processor works in three stages. Fetch
1 Fetch – the CPU fetches an the next
instruction
instruction from a location in
memory.
2 Decode – the CPU needs to work
Execute Decode
out what the instruction means, i.e. the the
what is it telling the CPU to do. instruction instruction

3 Execute – once the CPU has


figured out what it has to do it can
then carry out that instruction.
This cycle is also known as the fetch–
decode–execute cycle. The processor
will continually fetch instructions
from memory, decode them and then
execute (or carry out) those instructions.

KEYWORDS
fetch: the process of collecting an instruction from another location
decode: the process of working out what the instruction means, what it is
telling the CPU to do
execute: the process of carrying out the instruction
instruction cycle: the cycle carried out by the CPU as it processes instructions.
fetch–decode–execute cycle: another name for the instruction cycle

Abstraction and algorithmic thinking

Using abstraction and pattern recognition you will convert a set


of coded program instructions into a more English-like set of
commands and then carry out the instructions represented by
those commands.

Practice

When we think about the fetch–decode–execute cycle it all seems quite straightforward.
The processor collects an instruction from memory, decodes it, and then carries out that
instruction. The following task will help you think about some of the stages involved in
the fetch–decode–execute cycle.

18

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 18 01/05/20 3:21 PM


Unit 9.1 Drilling down: How the processor processes

Your teacher will provide you with a worksheet called Introducing the fetch–decode–
execute cycle. The worksheet contains two tables.
Table 1: This instruction reference table explains a made-up assembly language
instruction set for a basic calculator CPU.
Table 2: This table is a set of memory locations with a short program (written using the
made-up assembly language instruction for the calculator). It contains three additional
columns for you to complete by showing the decoded version of each instruction, any
updated memory location contents and any output from the program.
The worksheet contains a simple program that the calculator needs to carry out.
During this task you will work with a partner to examine each instruction in the memory
locations 0-5.
To complete the task you must
➤ Read each instruction in Table 2 in turn (like a processor fetching an instruction from
memory).
➤ Use the instruction decode table (Table 1) to work out what the instruction is asking
you to do and write down the decoded instruction in the appropriate column (like a
CPU decoding an instruction). The first has been done for you.
➤ Carry out the instruction by updating any memory location contents in Table 2 or
showing any output from the program in the appropriate column (like a CPU executing
the program instruction)

TABLE 1 – Instruction references


Instruction (opcode) and
(operand) Example Description and illustration
X number X 23 Input a number (for example, input the number 23)
Y location Y 100 Store an input number in the memory location
shown (e.g. store the input number in location
100)
Z location 1, location 2, Z 100, 101, 102 Add together the numbers in the memory
location 3 locations shown and store the results in location
3 (e.g. add together the numbers in memory
locations 100 and 101 and store the results in
memory location 102)
P location P 102 Print / output the contents of the memory location
shown (e.g. print the contents of location 102)
S location 1, location 2 S 100, 101 Subtract the contents of memory location 1 from
the number in memory location 2 (for example,
subtract the number in memory location 100 from
the number in memory location 101)
M location 1, location 2 M 100, 101 Multiply the contents of memory location 1 and
memory location 2 (e.g. multiply the number
stored in memory locations 100 by the number in
memory location 101)

19

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 19 01/05/20 3:21 PM


International Computing for Lower Secondary

TABLE 2 – Assembly language program


Memory Updated Location
Location Instructions Decoded instruction Contents Output
0 X 45 Input the number 45
1 Y 10
2 X 217
3 Y 11
4 Z 10, 11, 12
5 P 12
6
7
8
9
10
11
12

Once you have finished this task, design your own program on the blank memory
locations table and ask your partner to decode and execute it operating
in the same way as a CPU completing the fetch, decode and
execute cycle. For example, try writing a program which adds
three numbers together and then outputs the results. How would you
amend instruction Z
Try adding your own assembly language instructions to the
to help you with this?
instruction decode table to make the task more complicated
for your partner.

20

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 20 01/05/20 3:21 PM


Unit 9.1 Drilling down: How the processor processes

All about the accumulator


Learn

The previous practice task resulted in you converting a coded


set of instructions into a set of instructions in a format that was
more easily recognisable to us as humans. We used a made-
up instruction set based on letters and numbers. However, the
Assembly language instruction set used by a CPU is a little
more complicated. A more realistic set of assembly language
instructions for our calculator could include the following.

Instruction Example Instruction meaning and example


LDA LDA 9 Load contents of location 9 into the accumulator
ADD ADD 10 Add contents of location 10 to the accumulator
SUB SUB 11 Subtract contents of location 11 from the
accumulator
STA STA 12 Store contents of accumulator in location 12
INP INP Place the input value typed in by the user into the
accumulator (replacing any value already stored in the
accumulator).
OUT OUT Display the contents of the accumulator to an output
display

Thinking about the program we executed as a group in the


previous practice panel the lines of code really only carried out
the following high-level language instruction:
By removing one level of
print (45 + 217) translation (not having to
convert a single high-level
language instruction into many
This one single high-level language instruction
machine code instructions)
represents many assembly language instructions.
processor time can be used
In the previous practice panel we entered the first more efficiently.
number, stored it in a memory location, entered a
second number, stored it in a second memory location,
and then added the contents of both locations together.
However, the CPU will use an additional register called the
accumulator to help with this task. We introduced the
accumulator on page XX
The accumulator acts almost like a short-term memory for
when looking at the
the CPU. When it is adding two numbers together the CPU
registers used by
will hold the first number in the accumulator, then add the the CPU).
second number to the accumulator before; for example,
storing or printing the result.

21

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 21 01/05/20 3:21 PM


International Computing for Lower Secondary

For example the following short assembly language instructions


allows us to place the contents of location 9 into the
accumulator and then add the contents of location 10 to the
accumulator.
The diagram below shows us some of the registers and part of a
program stored in memory by the calculator’s CPU.
Look how the contents of the accumulator change after each
instruction is executed (we can ignore the contents of the other
CPU registers for the moment).
1. After executing the first instruction LDA 10 (load the contents
of location 10 into the accumulator), the accumulator holds the
number 45.
Main Memory
Address Contents
CPU 0 LDA 10
1 ADD 11
2
MAR PC 3
address bus
4
5
CIR MDR 6
7
data bus
8
ACC 9
45 10 45
11 217
12

2. After executing the second instruction ADD 11 (add the


contents of location 11 to the value already stored in the
accumulator), the accumulator now holds the result of the ADD
calculation.
Main Memory
Address Contents
CPU 0 LDA 10
1 ADD 11
2
MAR PC 3
address bus
4
5
CIR MDR 6
7
data bus
8
ACC 9
262 10 45
11 217
12

22

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 22 01/05/20 3:22 PM


Unit 9.1 Drilling down: How the processor processes

Computational Thinking

Through the process of decomposition consider the steps


required by a CPU to add two numbers together and output the
result of the calculation if it uses the accumulator to store the
intermediate result of the calculation. [AQ]
not quite clear
Use algorithmic thinking to produce a short program using our what they are
referring to
updated assembly language program which will allow a user to: here - I assume
it’s the Assem-
✪ input a number bly Language
✪ store that number in a specified memory location instructions on
page 19?
✪ before allowing the user to input a second number
✪ add the two number together
✪ and output the result.

Practice

Use the updated This algorithm will help you complete this
assembly language task:
example to rewrite START
your program from
the previous practice
panel. But, this time, ADD AQ
Input first number
make use of the
AQ: This
accumulator. flow diagram
Remember the program doesn’t quite
Store the contents of the ACC in location 30 represent the
is designed to: task - memo-
ry addresses
➤ allow the user to input should be
two numbers 10 and 11,
Input second number and there’s
➤ store the numbers in no stage
memory locations 10 and for storing
second input
11
Add contents of location 30 to ACC in address 11,
➤ add the two numbers storing result
in location 12
together
➤ store the result in location
Output the contents of the accumulator
12
➤ output the result.
STOP

It is possible to test your code using a simulator called the Little


Man Computer (LMC).
KEYWORD
➤ Open an internet browser, such as Google Chrome.
Little Man Computer
➤ Enter the URL https://peterhigginson.co.uk/lmc
(LMC): an online CPU
➤ Enter your code into the coding window. simulation program

23

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 23 01/05/20 3:22 PM


International Computing for Lower Secondary

Output from the


program will be
displayed here

Input values can


be entered here

Click here to clear


➤ Click Submit to transfer the code into the Main Memory the code window
(RAM) and enter a new
program

The code will be


translated into
machine code
and placed in the
➤ Click the Run button to execute your code. first four locations
➤ When it is time to enter the first number the code will pause in memory; for
and a flashing cursor will appear in the input box at the example, the
bottom of the screen. machine code for
➤ Type the first number and press Enter. the first instruction
➤ The above process will be repeated. is 901.

Before you
type your second
number, check the
location in main memory
to check your number has
been stored correctly in the
location you specified in
Notice how the You can increase your second instruction;
or decrease the Number 8 was for example, in the example
steps of the
speed the LMC executes the number 8 was
Fetch Execute previously entered
instruction by clicking entered and stored
cycle are being and the processor
on the << or >> in location 98.
explained by has now stored it
buttons in location 98.
‘The Little Man!’

24

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 24 01/05/20 3:22 PM


Unit 9.1 Drilling down: How the processor processes

➤ Experiment with the LMC by creating a more complex


program. For example, one which allows the user to Watch the contents
enter three numbers, add them together and then of the registers used inside
the Little Man Computer as
stores the result in a memory location before it
your program is being execute.
outputs the answer. Notice how the contents
change as the program is
executed.

A detailed look: fetch–decode–execute


Learn

Using the LMC in the previous practice task gave you an idea of how each of the registers
inside the processor are used during the fetch–decode–execute cycle.
Let us look at how the contents of the registers are used by the CPU as it executes the
first line of the program shown in Main Memory in the example below.

Fetch
Main Memory
➤ The program counter Address Contents
contains the number 0 CPU 0 LDA 9
as this is the memory 1 ADD 10
2 STA 12
location of the first PC MAR 3
address bus
instruction to be 0 0 4
executed. CIR MDR
5
6
➤ This means that the MAR 7
data bus
is also equal to 0. 8
ACC 9 8
➤ This address in the MAR 10 2
is located via the address 11 9
bus. In this case the 12
memory location is 0.
➤ There is currently nothing Main Memory
in the MDR, CIR or ACC. Address Contents
➤ The contents of memory CPU 0 LDA 9
location 0 are read from 1 ADD 10
2 STA 12
main memory and sent PC MAR 3
via the data bus to the 0 0 address bus
4
MDR 5
CIR MDR 6
LDA 9 7
data bus
8
ACC 9 8
10 2
11 9
12

25

482005_U1_Int_Com_Low_Sec_SB_001-041.indd 25 01/05/20 3:22 PM

You might also like