You are on page 1of 8

AS Computing

COMP 2
Revision Notes

COMP 2 - Revision Notes


Hardware
Software

Physicalcomponentsofthecomputer
Sequencesofinstructionsorprogramswhichrunonthecomputer

Generations of Programming Language


First Generation Machine code
Machinecodeistheactualsequenceofzerosand
onesthatthecomputercandirectlydecodeand
run.
Advantages

Disadvantages

Itistheonlylanguageacomputercanactually
understand.Allotherlanguagesmustbetranslated
intomachinecodetorun.Machinecodeneedsno
translation.
Itsprettymuchimpossibleforhumanbeingsto
read.

Basic Machine Code instructions (operators)


Machinecodeinstructionsareasinglenumberthathastwoparts,anoperator(thefirst
partofthenumber)thattellsthecomputerwhattodo,andtheoperand(thesecond
part)thattellsitwhattodoitwith.Youneedtoknowaboutthreeoperators:
Load Taketheoperand(anumber)andputitintheaccumulator
AddTaketheoperandandaddittothenumbercurrentlyintheaccumulator
Storeputthenumbercurrentlyintheaccumulatorintheaddressgivenin[operand]

Second Generation Assembly Language


Usessimpleletterabbreviationstomakemachine
codeseasiertoremember,readandwrite
Advantages

Disadvantages

Simplerforhumanstounderstand.Asimpleoneto
onetranslationofmachinecodeinstructionsallows
directmanipulationofthecomputer.
Needstobetranslated(assembled),inordertorun.
Thisisntdifficult,butitsanextrastep.
Becauseitsaonetoonetranslationofmachine
code,itsverylongwindedandmachineratherthan
problemfocused.

Third Generation Imperative Programming Languages


Instructionsareexecutedinasequencedefinedbyyou,the
programmer.
Python,Pascal,C++,VisualBasic
Problemfocusedratherthanmachinefocused,platform
independentaprogramcanrunondifferentmachines
(aftertranslation).Quickandeasytowrite,understand
anddebug.
Requirestranslationbycomplexsoftware(compiler/
interpreter).Translationisofteninefficientresultingin
largerandslowercodethanassemblylanguage.

Examples
Advantages

Disadvantages

Fourth Generation Declarative Languages


Instructionsdefinewhatistobedone,butnotthedetail
ofhowtodoit.
Prolog,SQL
Cansimplifycomplextasksbysettingoutfactsandrules,
thenlettingalgorithmsworkoutasolution.
Notsuitableforalltypesofproblem.Requirescomplex
analysisandtranslationsoftware.

Examples
Advantages
Disadvantages

Types of Translation Software


Machine
Code

Assembler

2ndGenAssemblyLanguage

Compilerallatonce
Interpreterlineatatime
Assembler

Process
Use
Reason

Compiler

Process

3rdand4thGen
ImperativeandDeclarative
languages

TranslatessecondgenerationAssemblylanguageinto
machinecodeinaonetooneoperation
RunninganAssemblyLanguageprogram
RequiretorunAssemblyLanguage.Therearenoother
optionsforAssemblyLanguage
Translatesthird/fourthgenerationlanguagesintoMachine
Codeinaonetomanyrelationship.Checksthesyntaxof
theprogram,thentranslatesallofthecodeinonegoand
producesanoutputfilewhichcanthenberundirectly
withoutthecompilerbeingpresent.

Use

Reason

Interpreter

Process

Use
Reason

Wheretestedsoftwareistobeshippedouttoauser,
wheretheprogramneedstobeasfastaspossibleorneeds
toberunwithoutadditionalprogramsupport.Cannotbe
easilychanged.
Speedofexecution,simplicityofproduct,cantbechanged
Translatesthird/fourthgenerationlanguagesintoMachine
Codeonelineatatime.Checksthesyntaxofeachlineand
thentranslatesintomachinecodeandexecutesthe
programonthecomputer.
Softwareunderdevelopment,softwarerunincontrolled
environment.
Softwaredebugging,linebylineanalysis.

Internal and External Hardware Components of a


Computer
3 buses:

One arrow goes onto the


bus from the Processor

All the other arrows come


out of the bus

Address Bus
Identifies
locations
Most arrows are
double headed

Except for VDU (Out)

Data Bus
Carriesdatato
andfromthe
processor

Control Bus
Carriescontrol
signals,
controls
devices

And Keyboard (In)

All arrows are double

Processor
Buses

Main
Memory

Thesethree
componentsare
knownastheCentral
ProcessingUnit,or
CPU

AnythingnotpartoftheCPUiscalledaPeripheral.Peripheralsareusually
consideredexternaldevices.AnexampleofaperipheralisSecondarystorage,the
Keyboard,theMonitor.

SecondarystorageisstoragethatisnotMainMemory.Anexamplewouldbethe
HardDisk.

Mainmemoryisaddressable,inotherwords,eachlocationinmemoryhasaunique
codeitsaddress.Toreadorwritetomemory,theprocessorwritestheaddressto
theaddressbus,thenusesthecontrolbustoindicateareadorwriteoperation.The
dataistransferredtoorfromtheselectedaddressoverthedatabus.Allthreebuses
worktogethertogethertheyarecalledtheSystemBus.

The Processor and the Fetch-Execute Cycle

Component parts of the Processor


Program control
unit
Arithmetic and
Logic Unit
Clock

General purpose
and dedicated
registers

Fetchesprograminstructionsfrommemory,decodesthem
andthenexecutesthemoneatatime.
Performsarithmeticandlogicaloperationsondata(for
example,adding,ANDing)
Eachpulseisthesignalforanothercycleofoperations.The
clockcoordinatesalldevicesinacomputer,makingsurethey
allacttogether.
Fast,temporarystoragelocationsinsidetheprocessor.

Making the computer Faster


Increase the clock speed

Increase the bus width

Increase the word length

Shoulddirectlyincreasetheperformance
ofacomputerbyspeedingupthecycle,
thetimeittakestheprocessorto
completeaninstruction.
Thesystembusisasignificant
bottleneck.Largenumbersorcomplex
instructionsmustbesplitintosmaller
partstofitacrossthebus.Wideningthe
busmeanslesssplittingandbetter
performance.
Wordlengthaffectsthesizeofthe
registersandreducestheneedtosplit
largenumbersorcomplexoperations

acrossmultipleregisters,thusimproving
performance.

The Fetch-Execute Cycle


Step1:ContentsofProgram
CountercopiedintoMemory
AddressRegister

+1
Program Counter

Main
Memory

Memory Address Register

Step2:ProgramCounter
incrementedby1

Memory Buffer Register

Step4:ContentofMBR
copiedtoCIR

Current Instruction Register

Step3:Contentsofmemory
addressedbyMARcopiedtoMBR

ALU

Step5:ContentofCIR
decodedandexecuted

Note: Its essential to remember the name and Mnemonic of the four
special purpose registers here. PC, MAR, MBR, CIR.
Machine code instructions are often represented in Hexadecimal

The stored program concept

Machinecodeinstructionsarestoredinmainmemory,fromwhichtheyarefetched
andexecuted.Theseinstructionscanbereplacedbyothersatanytime.

Logic Gates
AND

A
0
0
1
1

B
0
1
0
1

Q
0
0
0
1

A.B

Outputisononlywhen
bothinputsareon,
otherwiseitsoff.

OR

NOT
XOR

NAND

NOR

XNOR

A
0
0
1
1
A
0
1

B
0
1
0
1
Q
1
0

Q
0
1
1
1

A
0
0
1
1

B
0
1
0
1

Q
0
1
1
0

A
0
0
1
1

B
0
1
0
1

Q
1
1
1
0

A
0
0
1
1

B
0
1
0
1

Q
1
0
0
0

A
0
0
1
1

B
0
1
0
1

Q
1
0
0
1

A+B

A
A B

Outputisonifeitherofthe
inputsison,orboth.

Outputisoniftheinputis
off,andoffiftheinputis
on.
Outputisonifoneinputis
onandtheotherisoff,
otherwisetheoutputis
off.

A.B

ThereverseofanAND
gate,outputisonunless
bothinputsareon,in
whichcaseitisoff.

A+B

ThereverseofanORgate,
outputisononlyifboth
inputsareoff.Ifanyinput
ison,theoutputisoff.

A B

ThereverseofanXOR,
outputisononlyifboth
inputsarethesame.If
theyaredifferent,output
isoff.

Boolean Algebra and Simplifications


A.B=B.A
A+B=B+A
(A+B)+C=A+(B+C)
A.(B+C)=A.B+A.C
De Morgans Law

( X Y ) X.Y

X.X=X
X. X 0
1+A = 1
0+A=0
0.A=A
1.A=A

X.Y X Y

Steps for De Morgans Law


1. Swap the expression from and to or - or or to and

2. Invert each side of the expression


3. Invert the entire expression
4. Remove any duplicate inversions
Think of it this way ..

You might also like