12
Main Memory & Memory Main Memory & Memory Addresses Addresses

Memory & the fetch decode-execute cycle

Embed Size (px)

Citation preview

Page 1: Memory & the fetch decode-execute cycle

Main Memory & Main Memory & Memory AddressesMemory Addresses

Page 2: Memory & the fetch decode-execute cycle

Memory Memory

A memory chip is used to store A memory chip is used to store all our data. A chip which is set all our data. A chip which is set next to the CPU as it makes next to the CPU as it makes direct contact with the CPU.direct contact with the CPU.

• Volotile - stores data temporarily, It means that when the computer is switched off, that particular data is removed completely from the system. E.g. RAM

• Non-volotile - stores data permanently, it means that when the computer is switched off all data remains stored in the system. E.g. ROM

Page 3: Memory & the fetch decode-execute cycle

Difference between ROM & Difference between ROM & RAMRAM

Page 4: Memory & the fetch decode-execute cycle

What is Machine Code?What is Machine Code?

Machine code is the only form of program Machine code is the only form of program instructions that the computer hardware can instructions that the computer hardware can understand and execute directly. All other forms understand and execute directly. All other forms of computer language must be translated into of computer language must be translated into machine code in order to be executed by the machine code in order to be executed by the hardware. E.g. Assembly languagehardware. E.g. Assembly language

Assembly language is a symbolic Assembly language is a symbolic representation of machine code, which allows representation of machine code, which allows programmers to write programs in machine programmers to write programs in machine code without having to deal with the long binary code without having to deal with the long binary strings. strings.

Page 5: Memory & the fetch decode-execute cycle

Assembly Language is made up Assembly Language is made up of op-codes and operands of op-codes and operands Instructions in assembly Instructions in assembly language are rather simple language are rather simple

• An opcode is a single instruction that can be executed by the CPU. In machine language it is a binary or hexadecimal value such as 'b6' loaded into the instruction registere.g. Mov, add , jmp

•Operands are manipulated by the opcode. MOV, AL, 34HThe operands are the register named AL and the value 34 hex

Page 6: Memory & the fetch decode-execute cycle

Fetch-Decode-Fetch-Decode-ExecuteExecute Cycle Cycle

Page 7: Memory & the fetch decode-execute cycle

Both the data and the program that acts upon that data are loaded into main memory (RAM) by the operating system. The CPU is now ready to do some work.

THE FETCH – EXECUTE CYCLE

Page 8: Memory & the fetch decode-execute cycle

Steps of the Fetch/Execute Cycle:

• Get the next instruction• Figure out what to do• Gathering the data needed

to do it• Do it• Save the result, and • Repeat (billions of

times/second)!

Page 9: Memory & the fetch decode-execute cycle

Fetch Cycle • The Program Counter (PC) contains the address of

the next instruction to be fetched

• The address contained in the PC is copied to the

Memory Address Register (MAR).

• The instruction is copied from the memory location

contained in the MAR and placed in the Memory

Buffer Register (MBR).

• The entire instruction is copied from the MBR and

placed in the Current Instruction Register (CIR)

• The PC is incremented so that it points to the next

instruction to be fetched

Page 10: Memory & the fetch decode-execute cycle

Execute Cycle

• The address part of the instruction is placed in the MAR

• The instruction is decoded and executed

• The processor checks for interrupts (signals from devices or other sources seeking the attention of the processor) and either branches to the relevant interrupt service routine or starts the cycle again.

Page 11: Memory & the fetch decode-execute cycle

CU

Program Counter

Instruction Register

100 Multiply no. in 500,501

101 Store result in 502

  

500 21

501 18

502  

1.The PC contains the address of location 100

2.CU fetches instruction in location 100

3. Make a copy of the instruction into the IR

4. Increment the PC by 1

5. Activate the right circuits to execute the instruction

ALU

Accumulator

PC

IR

Acc

Multiply no. in 500, 501

100101

378

Page 12: Memory & the fetch decode-execute cycle

CU

Program Counter

Instruction Register

100 Multiply no. in 500,501

101 Store result in 502

  

500 21

501 18

502  

1. The PC contains the address of location 101

2. CU fetches instruction in location 101

3. A copy of the instruction is saved in the IR

4. Increment the PC

5. Activate the right circuits to execute the instruction

378

ALU

Accumulator

PC

IR

Acc

Multiply no. in 500, 501Store result

in 502

101102

378