OCR GCSE Computing

Download Report

Transcript OCR GCSE Computing

Session Objectives#11
COULD explain how the computer distinguishes between data and memory addresses
SHOULD describe how instructions are coded as bit patterns
MUST identify what program instructions consist of
Write a simple program using machine code
GCSE Computing#BristolMet
Representation of Program Instructions
During the fetch phase of the processing cycle, the CPU fetches
the first instruction from the start memory address location.
The CPU will then decode the instruction to find out what it
needs to do next. In the meantime it has already updated a
register, the program counter, to point to the next memory
location so that it can fetch the next instruction.
A program instruction, for example “print” [character A] has 2
parts, the instruction “print” which is called the operator, and
the data part, the operand, in this case [A].
The operand may be specific data or it may be a reference to
another memory address location, to save to or retrieve
previously stored data from. A typical instruction may be to add
the data in a memory location to data in another register, the
accumulator
GCSE Computing#BristolMet
KEY TERMS
Register – Special fast access part of the CPU that stores data
in use by the CPU.
Program Counter – A register in the CPU that keeps the address
of the next instruction.
Accumulator – A register in the CPU that stores data currently
being used by the CPU.
Operator – The part of the instruction which tells the computer
what to do.
Operand – The part of the instruction that tells the CPU what to
apply the operation to (either specific data or a memory
address).
What does the Program counter do when it receives a new
instruction?
Can you think of examples of operations which occur in the
accumulator
GCSE Computing#BristolMet
Representation of Program Instructions
The diagram below is of a 10 bit instruction.
The first three bits represent the op-code and the final six
bits represent the operand. The middle bit (the number bit)
distinguishes between operands that are memory addresses and
operands that are numbers. When the bit is set to '1', the
operand represents a number. 0 would mean???
GCSE Computing#BristolMet
Machine Code and Assembly Language
Notice that all the op-codes are given an English mnemonic to
simplify programming. Together these mnemonics are called an
assembly language. Programs written in assembly language must be
converted to their binary representation before the CPU can
understand them. This is usually done by another program called
an assembler, hence the name.
View the program simulations
GCSE Computing#BristolMet
Writing Machine code from LMC assembly
language
TASK: Using the code library from the LMC simulator attempt to
write binary machine code for the following simple programs.
NB The Operator will only
need the first 3 bits
COD
MEANING
E
1ab Load
2ab Store
3ab Add
Input number 5
Add number 3
Store Result in 10
4ab Subtract
500 Input
600 Output
700 Stop
800 Skip If Negative
801 Skip If Zero
101 0 0101
011 0 0011
010 1 1010
GCSE Computing#BristolMet
802 If Skip Positive
9AB Jump