Computer Structure-2 (2)
Computer Structure-2 (2)
You need to know a little about how these are connected together. This is a simplified version of
how it works.
Processor Memory
(CPU)
Control
if x > 2
ALU
Data bus
33 + 17
11011
● The registers are a small amount of memory inside the processor that can store data
temporarily, especially during calculations.
● The control unit decodes and executes instructions, and keeps other parts of the processor
in time with its clock. We talk about the control unit more in Higher.
● The arithmetic logic unit (ALU) does all of the calculations and logical decisions a program
requires.
When you have written programs with if statements, the == < > operators use the ALU.
In summary - what you need to know:
Component Description
Processor Does the ‘thinking’ of the computer. Has three parts - the registers, control unit
and arithmetic logic unit (ALU)
Registers Small amount of temporary memory inside the processor, holds data and
instructions while they are being processed
Main memory Main memory is divided into memory locations. Each location has a unique
memory address. Connected to the processor by address and data buses.
Address bus Carries addresses in one direction from processor to main memory.
Data bus Carries data/instructions in both directions between memory and processor
There are lots of types of questions that can be asked about these components.
This question
starts off about
databases (part a),
but asks where in
the processor a
comparison/condition would be checked. Since this is an example of logic, it would be done in the
arithmetic logic unit, or ALU (1 mark).
In part (i) of this question,
you would say that the data
bus is what is used to
transfer data from memory
to the processor.
2. State the bus that carries addresses from the processor to main memory.
3. The data bus carries instructions. What else can it carry? (read the description of the data
bus carefully)
4. State the part of the processor that stores values temporarily while they are being used by
the processor.
5. State the part of the processor that keeps other parts in time using the clock.
6. In two marks, explain how memory is organised in the computer.
7. State the part of the processor that could decide if 259 was greater than 116.
8. State the part of the computer that carries data in both directions between memory and the
processor.
9. The computer fetches two numbers from memory, adds them together, and displays the
result. State the part of the system that would: (a) transfer the unique addresses of the
numbers to memory, (b) carry the numbers back to the processor, (c) carry out the
calculation to add them together.
(a)
(b)
(c)
Interpreters and Compilers
We write our programs in Python. Python is easy for us to read (it looks a bit like English), but it isn’t
readable for the computer. The computer only understands machine code (binary 1s and 0s). Before
the program can be run, it has to be translated into machine code by an interpreter or a compiler.
Both interpreters and compilers are types of translators. What we use - Python in Replit - is
interpreted. That means you can see your errors ‘live’ as they happen.
A compiler would find all syntax errors once at the start of the program, but we would have to wait
while the whole program is compiled before we can run it.
An interpreter translates the program line by A compiler translates the program all at once
line. It takes each line of your program (e.g. in at the start of the program. It translates all the
Python), translates it, and runs it. Because it code, then tells you if there were any errors.
runs line by line, the interpreter can tell you
where an error happens, i.e. how far through A compiled program doesn’t need to be
the program you got when the error occurred - translated every time you run it. This saves
time - the program only needs to be translated
where it stopped.
once.
This makes it easier to find where errors are.
Once the program is compiled, it can’t be
Interpreters are often built into the program edited. If you are selling the program, you can
editing tools you use (e.g. Replit), so you can sell people the compiled version, and they
run the interpreter without leaving the editor. won’t be able to see or edit your original code.
You might be
asked why a
particular
program was
compiled or
interpreted. To
answer this, you could give an advantage of using a compiler (or interpreter).
These are usually short 1-mark questions, and you don’t need to know a lot about interpreters and
compilers. Learn a few of the advantages of each, and remember that all programs must be
translated before they can run.
2. State one advantage of using an interpreter when testing a program for errors.
3. State one advantage of using a compiler when you are going to sell the finished software.
4. State which translator type processes all of the code at once, and which translates line by
line.
All at once
Line by line
5. State why a compiled program (not the compiler itself!) uses less main memory than an
interpreted one.
6. State which translator type makes it easier to test the code without leaving the editor.
7. Explain the role of machine code when writing and running a program you have written.
8. State which translator type produces programs that don’t need to be translated every time
they run.