Anda di halaman 1dari 26

Electrical Energy

Conversion and
Power Systems

Universidad
de Oviedo

Lesson 2 How Computers Work


Semester 1 Microcontrollers
Lecturers: Juan Daz
Jorge Garca

Presentation:
Ignacio lvarez Garca
ISA-Uniovi 2004

Outline

Introduction

Blocks in a Computer

Instructions execution

A computer

Machine that executes instructions sequentially

Instructions and Data stored in MEMORY

Address
000..00
000..01
000..10

Program=sequence of instructions
Memory organized in addresses

Instructions, data and operations in BINARY CODE


Content
01101100
00101110
11111100
...

Read instruction
from memory

Fetch next
instruction

Inst1:
Inst2:
Inst3:

11101100
MOV X,3
01101101
MOV Z,X

Instructions in binary code

Decode
instruction

Store result

X:
Y:
Z:

00000000
0
00000111
7
00000010
2

Data in binary code

Get
operands

Calculate
result

11101011
ADD Z,Y
...

...

Parts of a computer
Control Unit (CU): organizes the
operation of the computer

Artimetihc-Logic Unit (ALU):


executes arithmetic (+,-,*,/) and
logic (bit level) (AND, OR, )
operations

CU

ALU

Registers: Temporary places for


storing information

CPU

registers

Memory

Memory: Main place of


information storage (code and
data)

I/O Devices: Allow


communication with the outer
world
I/O

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst1

CPU

Instruction:
Operand 1:
Operand 2:

ALU
Result:

Address
000..00
000..01
000..10

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000000
00000111
00000010

0
7
2

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst1

Instruction:

11101100

CPU

Operand 1:
Operand 2:

ALU
Result:

Address
000..00
000..01
000..10

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000000
00000111
00000010

0
7
2

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst1

Instruction:

11101100
MOV X,3

CPU

Operand 1:
Operand 2:

ALU
Result:

Address
000..00
000..01
000..10

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000000
00000111
00000010

0
7
2

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst1

Instruction:

MOV X,3

Operand 1:

00000011

CPU

Operand 2:

ALU
Result:

Address
000..00
000..01
000..10

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000000
00000111
00000010

0
7
2

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst1

Instruction:

MOV X,3

Operand 1:

00000011

CPU

Operand 2:

ALU
Result:

Address
000..00
000..01
000..10

00000011

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000000
00000111
00000010

0
7
2

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst1

Instruction:

MOV X,3

Operand 1:

00000011

CPU

Operand 2:

ALU
Result:

Address
000..00
000..01
000..10

00000011

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000011
00000000
00000111
00000010

3
0
7
2

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst2
Inst1

Instruction:

MOV X,3

Operand 1:

00000011

+1

CPU

Operand 2:

ALU
Result:

Address
000..00
000..01
000..10

00000011

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000011
00000111
00000010

3
7
2

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst2
Inst2

Instruction:

MOV X,3

Operand 1:

00000011

CPU

Operand 2:

ALU
Result:

Address
000..00
000..01
000..10

00000011

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000011
00000111
00000010

3
7
2

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst2

Instruction:

11101011

Operand 1:

00000011

CPU

Operand 2:

ALU
Result:

Address
000..00
000..01
000..10

00000011

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000011
00000111
00000010

3
7
2

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst2

Instruction:

MOV Z,X
11101011

Operand 1:

00000011

CPU

Operand 2:

ALU
Result:

Address
000..00
000..01
000..10

00000011

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000011
00000111
00000010

3
7
2

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst2

Instruction:

MOV Z,X

Operand 1:

00000011
00000011

CPU

Operand 2:

ALU
Result:

Address
000..00
000..01
000..10

00000011

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000011
00000111
00000010

3
7
2

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst2

Instruction:

MOV Z,X

Operand 1:

00000011

CPU

Operand 2:

ALU
Result:

Address
000..00
000..01
000..10

00000011
00000011

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000011
00000111
00000010

3
7
2

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst2

Instruction:

MOV Z,X

Operand 1:

00000011

CPU

Operand 2:

ALU
Result:

Address
000..00
000..01
000..10

00000011

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000011
00000111
00000010
00000011

3
7
2
3

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst3
Inst2

Instruction:

MOV Z,X

Operand 1:

00000011

+1

CPU

Operand 2:

ALU
Result:

Address
000..00
000..01
000..10

00000011

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000011
00000111
00000011

3
7
3

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst3
Inst2

Instruction:

11101011
MOV Z,X

Operand 1:

00000011

CPU

Operand 2:

ALU
Result:

Address
000..00
000..01
000..10

00000011

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000011
00000111
00000011

3
7
3

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst3
Inst2

Instruction:

11101011
ADD Z,Y

Operand 1:

00000011

CPU

Operand 2:

ALU
Result:

Address
000..00
000..01
000..10

00000011

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000011
00000111
00000011

3
7
3

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst3
Inst2

Instruction:

11101011
ADD Z,Y

Operand 1:

00000011
00000111

CPU

Operand 2:

ALU
Result:

Address
000..00
000..01
000..10

00000011

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000011
00000111
00000011

3
7
3

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst3
Inst2

Instruction:

11101011
ADD Z,Y

Operand 1:

00000111

Operand 2:

00000011

CPU

ALU
Result:

Address
000..00
000..01
000..10

00000011

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000011
00000111
00000011

3
7
3

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst3
Inst2

Instruction:

11101011
ADD Z,Y

Operand 1:

00000111

Operand 2:

00000011

CPU

ALU
Result:

Address
000..00
000..01
000..10

00001010
00000011

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000011
00000111
00000011

3
7
3

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

Inst3
Inst2

Instruction:

11101011
ADD Z,Y

Operand 1:

00000111

Operand 2:

00000011

CPU

ALU
Result:

Address
000..00
000..01
000..10

00001010

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000011
00000111
00000011
00001010

3
7
10
3

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Prog. Count.

???
Inst2

Instruction:

11101011
ADD Z,Y

Operand 1:

00000111

Operand 2:

00000011

CPU

ALU
Result:

Address
000..00
000..01
000..10

00001010

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000011
00000111
00000011
00001010

3
7
10
3

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Execution of Instructions

Example: x=3; z=x+y;

Repeat
Address
000..00
000..01
000..10

Prog. Count.

???
Inst2

Instruction:

11101011
ADD Z,Y

Operand 1:

00000111

Operand 2:

00000011

CPU

ALU
Result:

00001010

Content
01101100
00101110
11111100
...

Inst1:
Inst2:
Inst3:

11101100
11101011
01101101
...

MOV X,3
MOV Z,X

X:
Y:
Z:

00000011
00000111
00000011
00001010

3
7
10
3

...

Read instruction
from memory

Fetch next
instruction

Decode
instruction

Store result

Get
operands

Calculate
result

ADD Z,Y

Anda mungkin juga menyukai