1. C H A P T E R 1
O V E R V I E W O F C O M P U T E R S A N D L O G I C
PROG0101
FUNDAMENTALS OF
PROGRAMMING
PROG0101
FUNDAMENTALS OF PROGRAMMING
CHAPTER 1
COMPUTER AND MACHINE CYCLE
2. 2
Definition of Computer
Computer can be define as a computer is a programmable
machine.
A computer program is a collection of instructions that
performs a specific task when executed by a computer.
A computer requires programs to function.
A computer program is usually written by a computer
programmer in a programming language.
3. 3
Definition of Computer
What computers can do?
Office works (documents, letters, memos etc …)
Entertainment
Access information
Education
Online shopping
Video conferencing
Desktop publishing
Etc …
4. 4
Definition of Computer
Computer Parts
Computer can be divided into two parts:
Hardware
System Unit
Input devices
Output devices
Software
System software
Programming software
Application software
5. 5
Basic Computer Operations
Basic Computer Operations
DATA
(INPUT)
PROCESS DATA
INFORMATION
(OUTPUT)
STORE
DATA, INFORMATION & INSTRUCTION
6. 6
Basic Computer Operations
Basic Computer Operations
The computer performs four basic operations:
Receive input data
Process data
Produce output information
Store data, information and instructions.
7. 7
Machine Cycle
Machine Cycle
Machine cycle is the basic operation cycle of a computer
processor.
It is the process by which a computer processor retrieves a
program instruction from its memory, determines what
actions the instruction requires, and carries out those
actions.
This cycle is repeated continuously from bootup to when
the computer is shut down.
8. 8
Machine Cycle
Machine Cycle
There are four steps in machine cycle:
Instruction Phase:
Fetch - get an instruction from Main Memory
Decode - translate it into computer commands
Execution Phase
Execute - actually process the command
Store - write the result to Main Memory
10. 10
Machine Cycle
Machine Cycle
For example, to add the numbers 5 and 6 and display the answer on the
screen requires the following steps:
1. Fetch instruction: "Get number at address 123456"
2. Decode instruction.
3. Execute: ALU finds the number. (which happens to be 5)
4. Store: The number 5 is stored in a temporary spot in Main Memory.
5 - 8 Repeat steps for another number (= 6)
9. Fetch instruction: "Add those two numbers"
10. Decode instruction.
11. Execute: ALU adds the numbers.
12. Store: The answer is stored in a temporary spot.
13. Fetch instruction: "Display answer on screen."
14. Decode instruction.
15. Execute: Display answer on screen.