0% found this document useful (0 votes)
2 views

Software development Teaching Guide

This document outlines the copyright and licensing terms for educational materials provided by PG Online Limited, specifically for a Computer Science unit. It includes a detailed teacher's guide with lesson plans, learning outcomes, and suggested resources for teaching topics such as software development methodologies and algorithm design. The unit aims to equip students with knowledge of programming paradigms, testing strategies, and practical algorithm writing skills.

Uploaded by

imanimeboi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Software development Teaching Guide

This document outlines the copyright and licensing terms for educational materials provided by PG Online Limited, specifically for a Computer Science unit. It includes a detailed teacher's guide with lesson plans, learning outcomes, and suggested resources for teaching topics such as software development methodologies and algorithm design. The unit aims to equip students with knowledge of programming paradigms, testing strategies, and practical algorithm writing skills.

Uploaded by

imanimeboi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Copyright

© 2016 PG Online Limited

The contents of this unit are protected by copyright.

This unit and all the worksheets, PowerPoint presentations, teaching guides and other
associated files distributed with it are supplied to you by PG Online Limited under licence
and may be used and copied by you only in accordance with the terms of the licence. Except
as expressly permitted by the licence, no part of the materials distributed with this unit may
be used, reproduced, stored in a retrieval system, or transmitted, in any form or by any
means, electronic or otherwise, without the prior written permission of PG Online Limited.

Licence agreement
This is a legal agreement between you, the teaching institution, and PG Online Limited. PG
Online Limited grants to you a non-exclusive, non-transferable, revocable licence to use this
unit and all the worksheets, PowerPoint presentations, teaching guides and other associated
files distributed with it in the course of teaching by your teachers and/or employees.

The materials distributed with this unit may be copied and used by your teachers and/or
employees on a single site only in the course of their teaching. You warrant that you shall
not, and shall procure that each of your teachers and/or employees shall not, share in any
way any of the materials or part of the materials with any third party, including users on
another site or individuals who are teachers and/or employees of a separate institution. You
acknowledge and agree that the materials must remain with you, the teaching institution, and
no part of the materials may be transferred to another institution. You also warrant that you
shall not, and shall procure that each of your teachers and/or employees shall not, procure,
authorise, encourage, facilitate or enable any third party to reproduce these materials in
whole or in part without the prior permission of PG Online Limited.

In consideration of the licence granted to you, you shall indemnify PG Online Limited against
all liabilities, costs, expenses, damages and losses (including but not limited to any direct,
indirect or consequential losses, loss of profit, loss of reputation and all interest, penalties
and legal costs and all other professional costs and expenses) suffered or incurred by PG
Online Limited arising out of or in connection with the exercise by you of your rights granted
under this licence.

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 2


Teacher’s Guide
Introduction
This teacher’s guide contains a detailed lesson plan to accompany the set of PowerPoint
slides and worksheets for each lesson.
The lessons are designed to form a basis for ideas for the teacher and should be adapted to
suit the teaching style and preferences of the individual teacher, and the resources and
nature of the individual school or Computing / ICT department.
The material supplied for this unit includes:
• 4 PowerPoint presentations, each designed to cover one or more lessons
• 4 worksheets
• 4 homework sheets
• An end-of-unit test for assessment purposes

Summary
The unit is subdivided into four topics and an end-of-unit assessment. Each topic may be
spread over more than one lesson, especially if time is spent in the lessons going over
homework tasks.
It is a theoretical unit covering the OCR Computer Science specification sections 1.2.3
(Software development) and 1.2.4 (Types of programming language). The first two lessons
cover systems analysis methods and algorithm design. The next two topics cover
programming paradigms, assembly language and an introduction to the main concepts of
object-oriented programming.

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 3


Learning Outcomes for the unit
At the end of this Unit all students should be able to:
• list the stages in the waterfall lifecycle model
• name two other systems development models
• name and describe different types of testing
• write a pseudocode algorithm to solve a simple problem
• use a trace table to trace through an algorithm
• interpret simple algorithms to describe their purpose
• list two features of a good algorithm
• Define the term “programming paradigm” and give an example of two paradigms
• define the terms object, class, method, attribute, inheritance
• draw a simple inheritance diagram for a set of classes in an object-oriented approach
• follow through a simple program using the LMC instruction set

Most students will be able to:


• briefly describe agile methodologies, extreme programming, the spiral model and rapid
application development
• write pseudocode algorithms to solve problems
• describe different programming paradigms, including procedural, and object oriented
paradigms
• explain the terms encapsulation and polymorphism
• write simple assembly code programs using the LMC instruction set
• distinguish between immediate, direct and indirect addressing modes in assembly
language

Some students will be able to:


• describe the relative merits and drawbacks of different software development
methodologies and when they might be used
• design algorithms to solve complex problems
• explain why different programming paradigms are suited to different applications and the
advantages of each
• describe and use four methods of addressing memory: immediate, direct, indirect and
indexed

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 4


Previous Learning

Some programming experience in a high-level language will be useful for this unit. It is
expected that practical programming lessons will take place in parallel with or prior to
studying this unit. Students should have a basic understanding of computer systems from
lessons delivered as part of the Key Stage 3 national curriculum and preferably also a GCSE
course in Computer Science.

Suggested Resources
A standard office suite of applications for the presentation and printing of provided
resources.
Access to the Internet so that students can run programs on the Little Man Computer and
possibly work through part of a Prolog tutorial.

The textbook OCR A Level Computer Science by PM Heathcote and RSU Heathcote,
endorsed by OCR and published in September 2016, provides comprehensive coverage of
all the theoretical topics in the OCR specification (H446).

Each of the twelve sections in the book corresponds to one of the teaching units in this
series and will be extremely useful as a course textbook and also as a revision guide.

Sample questions, many taken from past exam papers, are included at the end of each
chapter and can be set as additional homework. Answers to all questions and exercises,
including coded solutions to pseudocode algorithms are available in a free teacher’s pack
which can be ordered and downloaded from our website www.pgonline.co.uk

The book is published by PG Online in a printed and electronic edition. Please refer to
www.pgonline.co.uk for ordering and pricing details.

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 5


Vocabulary
Vocabulary associated with this Unit, such as:
analysis, design, implementations, black box testing, functional testing, white box testing,
structural testing, alpha testing, beta testing, waterfall lifecycle model, spiral model, agile
modelling, extreme programming, rapid application development
algorithm, trace table, programming paradigm, procedural language, functional programming
language, declarative language, logic programming, object-oriented paradigm, class, object,
method, attribute, inheritance, encapsulation, polymorphism
Little Man Computer (LMC), assembly language, machine code instruction, addressing
modes (immediate, direct, indirect and indexed), accumulator

Assessment
Students will sit an end-of-unit test.
A few points to note:
These are not live assessment questions. They have all been created from scratch for this
scheme of work. We cannot guarantee the areas covered in the test will cover all areas that
could come up in any given exam paper. That being said, when producing the test, the
following have been carefully taken into account:
• the range of questions is designed to elicit the understanding of students from E-A*
grade.
• appropriate command words and language is used across the range of questions
(list, describe, state, discuss, explain…)

Real exam papers go through a serious quality assurance process; feel free to use and
adapt these questions as you see fit.

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 6


Lesson plans
Topic 1 Systems analysis methods

Learning Objectives:

• Describe the waterfall lifecycle model, agile methodologies, extreme programming,


the spiral model and rapid application development
• Describe the relative merits and drawbacks of different methodologies and when
they might be used

Content Resources

Starter Software development T1


Systems analysis
What software can the students name? Probably Word, methods.pptx
Excel, Access, Internet Explorer, and other familiar packages
and browsers, as well as games software. They may mention
Windows, which is system software, and program compilers
and interpreters, which are also systems software.
What other software do they use? For example, in a
supermarket they may use a self-checkout. They may make
purchases or book cinema tickets online.
Point out that there are two categories of software –
application software, used to perform tasks such as writing a
letter or performing calculations, etc., and system software
such as the operating system which is needed to make the
computer function.
We will be dealing mainly with application software in any
examples in this unit, although the systems life cycle applies
to all types of software, whether application or system.
Main
Software development
The “lifecycle” model is the traditional way of developing a
system. It originated in the 1960s to develop large-scale
business systems involving a lot of data and number-
crunching. Payroll was often the first system to be
computerised, and there were no standard off-the-shelf
packages around in those days so everyone started from
scratch.
It is no longer the favoured model for developing modern
computer systems.
The five basic stages of the systems life cycle now need to
be described. They are shown in a cycle which starts with
Analysis, and after Maintenance it starts all over again. How
does that apply to a program like Windows, for example? As
soon as a new version comes out, work starts on the next

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 7


version and the cycle starts again. Why does this happen?
What is driving this continual development? New hardware,
new ideas, competition, user suggestions and complaints. Is
there anything they would suggest for the next version of
Windows? For example, what about having a different
method of closing down?
The next few slides list the steps taken at every stage of the
life cycle. Students need to know what occurs at each stage.

Testing strategies
Go over black box and white box testing. Both are needed;
every bit of code needs to be tested at least once, to make
sure the program does not crash or come up with a wrong
answer or unexpected action (white box). But white box on its
own will not find missing functions or menu options which
have not been coded – you can’t test what isn’t there! So
black box testing compares what should be there with what is
there.
Alpha testing is carried out in-house and by the user, once
the system has been installed on their hardware. Often it
turns out not to be quite what the user expected, and further
development will be necessary.
Beta testing is commonly carried out by large companies
such as Microsoft which has thousands of users and which
produces frequent new versions of software.
Acceptance testing takes place when everyone is fairly
confident that the system is complete and does what it is
supposed to do.
Maintenance
All systems undergo change over a period of time. Discuss
the three different types of maintenance.
In this cyclical model, each stage is completed before moving
on to the next stage.
The waterfall model
This is essentially an illustration of one pass through the
system lifecycle – each stage is completed before moving to
the next.
Go through the slides describing this model.

Give out Worksheet 1 and let students work in pairs or small Software development
groups to try and answer the questions in Tasks 1 and 2. If Worksheet 1 Systems
the students google, for example, “Artists websites” they will analysis methods
get a good idea of what sort of website might be required and
what questions they could ask the customer. For example,
Software development
http://www.websitedesignforartists.com/examples_of_artist_w
Worksheet 1 Answers
ebsites.html
Have a class discussion on the answers.

The Spiral and Agile models

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 8


Go through the descriptions, advantages and disadvantages
of each of these models.
The agile model was developed with the assumption that the
user will always want to make changes to their original
conception, and won’t always know what they want until they
see it. The agile model therefore embraces change, which
might otherwise become very frustrating with the waterfall
model.
Task 3 of the worksheet asks the students to draw their own
versions of each of these models, to make sure they have
grasped the points of each.
The matching exercise should help them to take in the rather
densely packed amount of information in this lesson.
Discuss the answers that the students have come up with.
Extreme programming
Extreme programming is a form of agile software
development.
Large projects
Some projects can take years to develop. Ask what can
happen during this time. (see next slide)

Rapid application development


This is an attempt to deal with the problem of very large
projects never being completed.

Plenary
Show the final slide and review the major points of the
lesson.
Give out Homework Sheet 1.

Software development
Homework 1 Systems
analysis methods
Software development
Homework 1 Answers

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 9


Topic 2 Writing and following algorithms

Preparation:
Bring in a set of playing cards or just simply cards with numbers written on them, to
demonstrate manually the insertion sort and possibly the bubble sort.
Learning Objectives:
• To understand the term ‘algorithm’
• To learn how to write and interpret algorithms using pseudocode

Content Resources

Starter: Software development T2


Writing and following
Ask the class to give a definition of an “algorithm”. Invite
algorithms.pptx
suggestions for real-world algorithms that have “changed the
world” – problems that are solved by computer which we take
for granted today. There are thousands of them – for example,
pattern recognition is used in scanning everything from bar
codes to fingerprints to detecting when a platform on an
underground railway has become too full for safety. Computer
systems can diagnose medical conditions, translate from one
language to another, decide prison sentences for convicted
criminals, decide when to switch street lights on.
More suggestions are given on the next slide.
Main:
Properties of a good algorithm
Discuss the properties of a good algorithm.
There are general rules for algorithms which students should
take heed of and apply in their own algorithms, however
simple. Ask them how they can ensure that their algorithms
are “designed in such a way that other people will be able to
understand and modify them if necessary”.
You could answer, writing the algorithm in a hierarchical way
that divides into modules. (This is distinct from making
program code easy to understand, which could also include
writing comments, using meaningful variable names.)
Using pseudocode
Pseudocode is used for designing algorithms. The OCR Exam
Board has a standard for pseudocode which will appear in any
exam questions, but students do not need to stick slavishly to
this when writing their own pseudocode algorithms. Anything
that is clear will be acceptable.
To a certain extent the pseudocode that a programmer uses is
dependent on the programming language that will be used –
the OCR pseudocode, for example, translates more or less
directly into a Python program.
Give out Worksheet 2 and ask students to complete Task 1. Software development

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 10


Give help as necessary. Worksheet 2 Writing and
following algorithms
When they have finished, go over their answers.
Software development
Sorting algorithms
Worksheet 2 Answers
Sorting is a very common procedure and there are many
W2 Qu1 Caesar
different sort algorithms.
cipher.py
How would the students sort 10 cards? Would that work well
for 50 cards? Remind them of different strategies for solving
problems – brute force, divide and conquer. Let them come up
with some ideas. They need to have cards or even bits of
paper with numbers written on them to try sorting manually.
Often students will sort their cards quickly without thinking; the
trick here is to force them to think about the strategy they are
employing – consciously or not.
The best algorithms, such as the merge sort and quicksort, are
thousands of times faster for large data sets than a bubble sort
or an insertion sort. However, they may be slower than the
common bubble sort for a very small data set of say 10
numbers.
Can students think of any examples of datasets that might
have upwards of 10 million numbers? TV Licensing Authority,
Vehicle Licencing Authority, Health Authority, Electoral
registers, spring to mind. There really is a need to be able to
sort and search large datasets quickly!
Students will not be expected, at this stage, to produce an
algorithm for a quicksort, merge sort or an insertion sort but
they should be able to trace through a bubble sort. (Sorting
algorithms are covered in more detail in Unit 12.)
Bubble sort
The bubble sort is the simplest algorithm of all, but also the
slowest sort for more than a very few items. Explain the
principle and let the students try it manually, using cards or
pieces of paper.
With the set of names Henry, Steve, Julie, Ava, Tom, Olivia,
the order after one pass will be Henry, Julie, Ava, Steve,
Olivia, Tom. Five passes are required to sort 6 names, or
more generally, n-1 passes to sort a list of length n.
To swap names[j] and names[j+1], use a temporary location:
temp = names[j]
names[j] = names[j + 1]
names[j + 1] = temp
Searching algorithms
These are also very common. Compare the linear search with
the binary search. Which category (brute force, divide and
conquer) do each of these strategies fall into? Are there any
other strategies that could be applied when searching for a
particular number in a sorted or unsorted list? (Not really – you
could guess randomly but that would be no better than a
sequential search.)

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 11


Binary search
The pseudocode for a binary search is given. It works equally
well on a sorted list of names or integers.
low and high are the indices of the first and last elements of
the array to be sorted; the first index is normally taken to be 0.
Recall that div performs integer division, i.e. it ignores the
remainder. Ask, in a list of 10 sorted items, with indices 0-9,
what will middle be? (Answer 4, which is the index of the 5th
item.) In a list of 11 items, what will middle be? (Answer 5, the
index of the 6th item.
Let them try out the binary search in a guessing game with a
partner – guess a number between 1 and 100 and see how
many guesses it takes to get it right. Guessing a number
between 1 and 1024 will give practice in powers of 2 – a useful
skill for computer scientists! It should take a maximum of 11
guesses (1024 = 210.)
To show this is true, consider 2 numbers (i.e. 2 1 numbers) It
will take up to 2 (1 + 1) guesses. With three numbers, also a
maximum of 2 guesses. With 4 (22) up to 7 numbers, a
maximum of (2 + 1=3) guesses is required. With 8 (23) up to
15 numbers, a maximum of (3 + 1=4) guesses is required.
With 210 numbers, a maximum of 10 + 1 guesses is required.
To guess a number between 1 and 100 (which is between 2 6
and 27) should take a maximum of 7 guesses.
There is a binary search routine in the folder – students could
perhaps turn this into a procedure and allow the user to enter Python program Binary
a name to search for, passing this as a parameter along with Search.py
the list to be searched.
Evaluating a program
Discuss what constitutes “good” program code. Students
should get into the habit of adding lots of comments, including
ones to identify themselves as the creator of the program,
explanations of each separate module, and any tricky bits of
code.
Using a standard for variable names and constants (e.g.
uppercase names for constants) is also very helpful when
writing a program of any length.
Following an algorithm
As a class exercise, practise drawing and completing a trace
table. This algorithm is Euclid’s algorithm for finding the
greatest common divisor. (i.e. the highest number that will
divide into both a and b) Get the students to discover this for
themselves – they could try the algorithm with a = 14, b = 35,
and a = 12, b = 32, for example, to help deduce what the
output is.
There is no need to fill in cells which do not change - but no
marks will be lost if the value of all variables is shown on each
row. There may be some variation in which row each variable
is entered on.
W2 Qu 2 bubble sort.py

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 12


Ask students to do the questions in Task 2 on the worksheet. W2 Qu 3 Russian
peasant’s algorithm

Plenary:
Go over the main points of the lesson.
Give out Homework 2.

Software development
Homework 3 Writing and
following algorithms
Software development
Homework 3 Answers
H2 Qu2 check
barcodes.py

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 13


Topic 3 Programming paradigms

Learning Outcomes:
• Understand the need for and characteristics of a variety of programming paradigms
• Describe the features of procedural languages
• Describe the features of declarative languages
• Describe the features of object-oriented languages
o Develop an understanding of classes, objects, methods, attributes,
inheritance, encapsulation and polymorphism

Content Resources

Starter: Software development


T3 Programming
What languages are the students familiar with? How would they
paradigms
describe these languages – procedural or object-oriented or
capable of both?

Main:
Four programming paradigms
There are four common programming paradigms. Emphasise
that a paradigm is a way or style of programming – it is not a
type of programming language. A particular programming
language may support one or more paradigms.
The students may not have heard of functional programming,
which is included here for completeness, but it is not included in
this specification so there is no need to go into detail.
Procedural programming
Languages such as Python, Pascal, VB all support a procedural
style of programming, with each statement being an instruction
of what to do next. In structured programming, the constructs
are limited to sequence, selection, iteration and recursion. In
modular structured programming, the program is split into a
series of subroutines which are called in a hierarchical manner,
starting with a main module.
Declarative programming
This is a completely different style of programming. The
example that students will most likely know is SQL – ask them
to describe an SQL statement, and what it does. How is this
style of programming different from procedural programming?
Logic programming
Prolog is an example of a type of declarative programming, also
called “logic programming”. More on this after they have done
the first task on the worksheet.

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 14


Functional programming
This is not on the OCR spec so is not covered here. It consists
of a series of function calls – Haskell is an example of a
functional programming language.
Software development
Give out Worksheet 3 and ask students to do Task 1. This will
Worksheet 3
give them a good idea of the many different programming
Programming
languages there are, and what paradigm they support.
paradigms
Go over the answers, and move on to discuss declarative
Software development
programming in more detail.
Worksheet 3 Answers
Programming in Prolog
Students will not need to be able to program in Prolog, but a
practical session will be interesting and useful for the students to
fully grasp the concepts behind the declarative programming
paradigm.
Go through the slides first to explain the concepts of facts, rules
and queries.
Note that /*….*/ are comment delimiters.
Variables in Prolog
These start with an uppercase letter.
Summary of Prolog
This slide summarises the basic concepts of declarative
programming – unlike a procedural program, you do not specify
the steps to be taken in solving the problem.
Backtracking
This is an important concept in Prolog. Prolog will take a
particular route through the facts and rules, and if that does not
produce an answer, it will backtrack and try another route until
either the problem is solved or there are no more facts and rules
to explore.
At this point, students could spend time going through some of
the online tutorial at
www.doc.gold.ac.uk/~mas02gw/prolog_tutorial/prologpages
Alternatively, they could try the online version at www.swi-
prolog.org/
Applications of declarative programming
Some applications are given. Ask, why is it suitable for
processing natural language? What do we mean by “processing
natural language?” This could mean, for example, scanning a
word document for grammatical errors, or translating a
statement from one language to another.
A natural language has syntax rules, which can be expressed in
Prolog. What it cannot do is determine whether a sentence
makes sense – “Monkeys eat bananas” is true, but “Bananas
eat monkeys” is also syntactically correct but makes no sense!
Medical diagnosis is another obvious application, as all
symptoms and associated diagnoses can be entered as a series

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 15


of facts and rules, probabilities etc.
Ask students to fill in the table in Task 2 of the worksheet.
Go over their answers.
You may find this is a good place to end the lesson, and
continue with OOP next lesson. Question 1 on the homework
could be set, leaving question 2 for next week.
Object oriented programming
This lesson introduces the concepts of OOP but does not go
into details of how classes and objects would be coded. A
lesson in Unit 11 goes into slightly more detail but the teaching
of practical object-oriented programming is not included, since
implementation will vary according to the language being used.

Object oriented programming


Explain the concept of an object, which has attributes and
methods. Use the example of the frog and the bank account,
and ask for other examples of objects and the attributes and
methods they might possess. e.g. student, film, car, journey,
hotel room…
Class
Define a class as a blueprint for an object. This is where the
attributes and methods are declared.
Encapsulation
This is a very important concept in OOP – closely related to
information hiding.
Information hiding
Explain what this means and how it is achieved in a class
definition – attributes are normally private meaning they cannot
be changed directly. They can only be changed through a
method which sets them to a particular value or changes the
value through processing of some kind.
Example
Show how a turtle class may have attributes and methods.
New turtle objects can then be created which look and behave
differently because their attributes have been given different
values using parameters.
Defining a class
Pseudocode statements which give the general idea of how
these concepts are turned into a program are shown here.
You can point out where the attributes are declared as private,
and the methods public. Remind them of encapsulation.
Unless students are starting on practical OOP, they do not need
to go any further into the coding at this time.
Objects in a class are typically created using a constructor, i.e. a
procedure called new, defined within the class. Go back a slide

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 16


to see how an object in class turtle is created by calling the
procedure new.
Inheritance
This is an important concept in OOP. Explain the concept of
classes and subclasses and ask for other examples. e.g.
property may be house or flat. House may be detached, semi,
terrace – ask the students to draw an inheritance diagram like
the one on the next slide. What attributes are common to all
properties, and what additional attributes might house have?

The “is a” rule


The “is a” rule is used to determine whether inheritance is
appropriate. Theoretically a man could inherit some of the
properties of a mouse but this would cause some confusion.
Note the open-headed arrows in the diagram, which must be
drawn in this way in an inheritance diagram.
Polymorphism
Explain this important concept – objects may behave differently
from their superclass in response to a method call, depending
on which class they are in.
Ask students to do Task 3 on the worksheet.
This task asks them to define the terms that have been
explained in the slides – it should serve as a useful recap and
they should take some time over it, looking up definitions if
necessary or asking for help.
The task could be done in groups so that discussions can take
place.

Plenary Software development


Go over the answers, make sure everyone has written down the Homework 3
main points and put the worksheet in a ring binder! Programming
paradigms
Give out Homework 3.
Software development
Homework 3 Answers

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 17


Topic 4 Assembly language

Learning Outcomes:
• Write and follow simple assembly language programs
• Understand and apply immediate, direct, indirect and indexed addressing modes

Content Resources

Starter Software development


T4 Assembly language
The early years…
Admiral Dr Grace Hopper is one of the “greats” in computing
history. She invented the language COBOL, and finally retired
from the US Navy when she was almost 80 years old.
Students are probably aware that early computers were
programmed entirely in machine code, by physically setting an
array of switches to ON of OFF and pressing an ENTER switch
after each instruction.
Main
Levels of programming languages
This topic is about the low-level language.
Assembly language
It uses mnemonic codes and there is, in general, a one-to-one
correspondence between assembly language instructions and
machine code instructions. The instruction set is dependent on
the architecture of the processor, so every different type of
processor has a different assembly language.
The Little Man Computer
This imaginary computer with its instruction set was created for
educational purposes by Dr Stuart Madnick in 1965.
It is well worth getting the students to download it from
http://peterhigginson.co.uk/LMC/ and entering all the assembly
programs in the worksheets. It allows you to enter a program
and run it, and shows the operation of the Fetch-Decode-
Execute cycle as it executes.
Example
Get the students to follow through the program, which adds the
two numbers entered by the user.
All calculations are carried out by the ALU and the result is
stored in the accumulator.
Are the meanings of the mnemonics easy to guess, if no
comments are supplied?
Can students write a program to find three times the number
entered? (Either add the number 3 times, or add it to itself and
add this to the original number.) You could make up some other
simple examples to get them used to the idea of everything
having to be loaded into the accumulator before any change can

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 18


be made to it.
There are several sample programs on the LMC site which can
be selected and run. http://peterhigginson.co.uk/LMC/
Note that for example, the statement
x DAT 3 will initialise the variable x to 3.
Software development
Give out Worksheet 4 and ask students to try the questions in
Worksheet 4 Assembly
Task 1. It will be very valuable to enter them to the LMC and
language
execute them.
Software development
The instruction set
Worksheet 4 Answers
Some more Branch instructions would be useful! Branch if not
equal, branch if negative, etc.
Format of a machine code instruction
The diagram shows a machine code instruction held in 16 bits.
In reality it would occupy at least 32 bits in a standard desktop
computer. The size of the operand determines how many
addresses can be directly accessed. The size of the opcode
determines the maximum number of instructions in the
instruction set.
With 6 bits for the basic machine operations, there are 26 =
64possible operations. There are 8 bits for the operand allowing
a maximum address of 28 – 1 = 255.
Addressing modes
The addressing mode specifies what the bits in the operand
actually represent. They could be a value, an address, the
address of a variable holding an address, or an index (which will
be explained shortly.)
Students should be able to name, identify and explain the four
different addressing modes. The LMC uses only direct
addressing. You cannot load a value straight into the
accumulator.
The advantage of indirect addressing is that you can access
many more than 255 memory locations. A memory location of
16 bits can hold an address of 216 – 1 = 65,535, rather than just
255. So by specifying that location 200, for example, holds the
address of the data that you want, you can look in location 200
and find, for example, 60,000, which is where the data is held.
Example
Go through these as a class exercise and make sure everyone
gets the point. In high level programming, statements such as
x = 53, x = y, are in effect using different forms of addressing. Software development
Homework 4 Assembly
Indexed addressing language
This is equivalent to a high level statement in a loop, processing Software development
an element of an array; e.g. incrementing n in a FOR loop and Homework 4 Answers
writing
x = alist[n]
Example

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 19


Go through the example, and then ask students to do the
question in Task 2 of the worksheet.
Plenary
Go through the answers.

Recap the lesson, and set the Homework.

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 20


Unit assessment test

Learning Outcomes:
• Be able to apply their knowledge in answers to a range of questions
• Be able to highlight areas of strength and any gaps in their understanding
of computers

Content Resources

Students should complete the Software development Unit Software development


Assessment Test. Unit Assessment
Answers are available in the Software development Unit Software development
Assessment Answers sheet. Unit Assessment
Answers
The test is designed to be printed, with answers to be written on
the test paper.

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 21


Acknowledgements
The authors and publisher would like to thank all contributors for their kind permission to
reproduce their photographs or images, screenshots of their websites or other copyright
material in the PowerPoint Guides.
ENIAC computer © Corbis UK Ltd.
Images unless otherwise stated © Shutterstock
Every effort has been made to trace the copyright holders and we apologise in advance for
any unintentional omissions. We would be pleased to insert the appropriate
acknowledgement in any subsequent edition of this publication.
This material contains links to relevant websites featured in the teacher’s guide. Every effort
has been made to ensure that at the time of distribution, the links remain unbroken, the
material remains up-to-date and that links are not inadvertently linked to sites that could be
considered offensive. PG Online cannot be held responsible for the content of any website
mentioned in this material. It is sometimes possible to find relocated sites by typing the
original URL into a browser. Any errors should be reported directly to
[email protected] and changes will be made in any subsequent editions of
the material.

Artwork

Summer solstice © 2008 Hilary Turnbull


Mixed media on canvas, 51x61cm
www.hilaryturnbull.co.uk

OCR AS and A Level Computer Science Unit 3 © 2016 PG Online Limited 22

You might also like