Docsity

Computer Architecture: The Conceptual Architecture of a Computer, Exams of Architecture

Partial preview of the text

Download Computer Architecture: The Conceptual Architecture of a Computer and more Exams Architecture in PDF only on Docsity!

Computer Architecture

The Conceptual Architecture of a Computer

register 0

register 1

register 2

register 3

register n

CPU

word 1 word 2 word 3 word 4 word 5 word 6 word 7 word 8 word 9

word 10 word 11 word 12 word 13 word 14 word 15^ word

m

RAM:

registers hold small

amounts of data for

processing by the

CPU

CPU performs

operations on data

in registers (add,

subtract, etc.)

word 0

Reading / writing to some special memory addresses may cause peripheral devices like disk, display, etc. to perform a task

registers & RAM

store data as

binary numbers

PC

Hexadecimal Representation

6x

0

5x

1

2x

2

4x

+^3

Base 10 (decimal) notation:

Decimal isn’t good for computers because they work with bits.

But writing everything in binary would be tedious.

Hence, we often use base 16, aka “hexadecimal”:

1 0 A 0

0x

0

Ax

1

0x

2

1x

+^3

1x4096 + 10x16 = 4256

Base 16 (hexadecimal) notation:

Need 16 different digits, so use 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

A=10, B=11, C=12, D=13, E=14, F=

Add CPU instruction

ADD Rd, Rs, Rt Set register Rd to Rs + Rt

0 0 0 1 0 0 1 0 0 0 1 0 1 0 0 0 Instruction (aka opcode) Rd (^) Rs Rt

1 = ADD 2 = R2 2 = R2 8 = R

An instruction is encoded as a sequence of bits:

Written as a hexadecimal number: 122816

Load “Immediate” Instruction

0 1 1 1 0 1 1 0 1 1 0 0 1 0 0 0 Instruction (aka opcode) Rd immediate

7 = LIMM 6 = R6 200 = value

LIMM Rd, value Set register Rd to value

Written as a hexadecimal number: 76C8 16

= C8 16

For LIMM, the last 8 bits give the value to copy into Rd:

Load Instruction

1 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 Instruction (aka opcode) Rd address

8 = LOAD 4 = R4 136 = addr

LOAD Rd, addr Set register Rd to ram[addr]

Written as a hexadecimal number: 848816

For LOAD, the last 8 bits give the address of the memory cell to copy into Rd:

An Example Program

LIMM R1, 64 // R1 = 200

LIMM R2, 1E // R2 = 30

ADD R2, R1, R2 // R2 = R1 + R

STORE R2, 46 // ram[70] = R

What does this program do?

An Example Program

LIMM R1, 64 // R1 = 200

LIMM R2, 1E // R2 = 30

ADD R2, R1, R2 // R2 = R1 + R

STORE R2, 46 // ram[70] = R

What does this program do? Stores 200 + 30 into memory location 70

var r1 int = 200

var r2 int = 30

r2 = r1 + r

var ram70 int = r

Similar to the following Go program:

Go manages the registers and

memory locations for you.

It may keep a variable in a

register, memory, or both.

Where is the program stored?

The program is just a sequence of integers that encode for instructions.

LIMM R1, 64 // R1 = 200 ; 7164

LIMM R2, 1E // R2 = 30 ; 721E

ADD R2, R1, R2 // R2 = R1 + R2 ; 1212

STORE R2, 46 // ram[70] = R2 ; 9246

These integers are stored in the same RAM used for variables:

721E

address RAM

Where is the program stored?

The program is just a sequence of integers that encode for instructions.

LIMM R1, 64 // R1 = 200 ; 7164

LIMM R2, 1E // R2 = 30 ; 721E

ADD R2, R1, R2 // R2 = R1 + R2 ; 1212

STORE R2, 46 // ram[70] = R2 ; 9246

PC =

These integers are stored in the same RAM used for variables:

721E

address RAM

The CPU has a special register called PC

(“program counter”) that contains the

address of the current instruction.

After each instruction, the PC is

incremented by 1.

Where is the program stored?

The program is just a sequence of integers that encode for instructions.

LIMM R1, 64 // R1 = 200 ; 7164

LIMM R2, 1E // R2 = 30 ; 721E

ADD R2, R1, R2 // R2 = R1 + R2 ; 1212

STORE R2, 46 // ram[70] = R2 ; 9246

PC =

These integers are stored in the same RAM used for variables:

721E

address RAM

The CPU has a special register called PC

(“program counter”) that contains the

address of the current instruction.

After each instruction, the PC is

incremented by 1.

Where is the program stored?

The program is just a sequence of integers that encode for instructions.

LIMM R1, 64 // R1 = 200 ; 7164

LIMM R2, 1E // R2 = 30 ; 721E

ADD R2, R1, R2 // R2 = R1 + R2 ; 1212

STORE R2, 46 // ram[70] = R2 ; 9246

PC =

These integers are stored in the same RAM used for variables:

721E

address RAM

The CPU has a special register called PC

(“program counter”) that contains the

address of the current instruction.

After each instruction, the PC is

incremented by 1.

PC =

721E

address RAM

LIMM R1, 64 // R1 = 100 ; 7164

LIMM R2, 1E // R2 = 30 ; 721E

ADD R2, R1, R2 // R2 = R1 + R2 ; 1212

STORE R2, 46 // ram[70] = R2 ; 9246

R0 = 0

R1 = 0

R2 = 0

R3 = 0

Rn = 0

PC = 10

CPU

PC =

721E

address RAM

LIMM R1, 64 // R1 = 100 ; 7164

LIMM R2, 1E // R2 = 30 ; 721E

ADD R2, R1, R2 // R2 = R1 + R2 ; 1212

STORE R2, 46 // ram[70] = R2 ; 9246

R0 = 0

R1 = 0

R2 = 0

R3 = 0

Rn = 0

PC = 10

CPU

1E