register organization, stack

19
CLASS PRESENTATION UNIT-1 Mohammad Asif Iqbal Assistant Professor, Deptt of ECE,

Upload: asif-iqbal

Post on 21-Mar-2017

203 views

Category:

Engineering


1 download

TRANSCRIPT

Page 1: Register organization, stack

CLASS PRESENTATION

UNIT-1

Mohammad Asif IqbalAssistant Professor, Deptt of ECE,JETGI, Barabanki

Page 2: Register organization, stack

CLASS TEST

Page 3: Register organization, stack

Q1:-HOW CAN YOU DROP A RAW EGG ONTO A CONCRETE SURFACE WITHOUT CRACKING IT.

Page 4: Register organization, stack

WHAT WE WILL STUDY IN THIS CLASS….

1 General Register Organization

2 Stack Organization

Page 5: Register organization, stack

General Register Organization

Page 6: Register organization, stack

REGISTERSSmall units of memory to hold data/instructions temporally during execution. There are 2 kind of register in the CPU.

1. Special purpose register

2. General purpose register

Page 7: Register organization, stack

SPECIAL PURPOSE REGISTER

These are used for the specific purpose by the control hardwarePROGRAM CONTROL (PC): used to remember the location in memory of the instructions currently being executed.INSTRUCTION REGISTER (IR): Used to remember that instruction.PROCESSOR STATUS REGISTER: used to remember status information about current state of processor, e.g. whether an arithmetic overflow has occurred.

Page 8: Register organization, stack

GENERAL PURPOSE REGISTER

Available for use by the programmerUseful for remembering the useful dataWhy is it a good idea to do this?

Page 9: Register organization, stack

WHY USE GENERAL PURPOSE REGISTERS?

There is a large speed disparity between the processor and the memory where instructions and data are storedConsider a 1 GHz processor

oThis frequency corresponds to a 1 nanosecond time scale.oMilli (10-3), micro (10-6) nano (10-9)oG (giga) 230 for memory ; 109 for frequency, disk size.

Memory : 100 nanosecond time scaleAside: More on nanosecond

ospeed of light: 300,000km/sec or 0.3 m/nsec

Page 10: Register organization, stack

GENERAL PURPOSE REGISTER

Available for use by the programmerUseful for remembering the useful dataA typical processor today has 32 GPRs, say R0, R1,….R31The operands to an instruction could come either from registers or from main memory.

Page 11: Register organization, stack

StackOrganization

PART TWO

Page 12: Register organization, stack

STACK ORGANIZATIONStack or LIFO(Last-In, First-Out)

o A storage device that stores information • The item stored last is the first item retrieved = a stack of tray

o Stack Pointer (SP)• The register that holds the address for the stack• SP always points at the top item in the stack

o Two Operations of a stack : Insertion and Deletion of Items• PUSH : Push-Down = Insertion• POP : Pop-Up = Deletion

Page 13: Register organization, stack

TYPES OF STACK

1) Register Stack (Stack Depth: LIMITED) oA finite number of memory words or

register(stand alone)2) Memory Stack (Stack Depth: FLEXIBLE) oA portion of a large memory

Page 14: Register organization, stack

REGISTER STACK

0)1()0(

][1

EMTYFULLthenSPIf

DRSPMSPSP Increment SP

: Write to the stack: Check if stack is full: Mark not empty

Push Operation

The first item is stored at address 1, and the last item is stored at address 0

Pop Operation

0)1()0(

1][

FULLEMTYthenSPIf

SPSPSPMDR : Read item from the of stack

: Decrement Stack Pointer: Check if stack is empty: Mark not full

Page 15: Register organization, stack

EXAMPLE OF PUSH& POP OPERATION.

D

C

B

A

A

00

10

DR

FULL EMTY PUSH A

01

PUSH B

10PUSH C

11

1 0

FULL EMTY

PUSH D

POP D

D

DR

Page 16: Register organization, stack

MEMORY STACK Push Operation

The first item is stored at address 4000

Pop Operation

DRSPMSPSP

][

1

1][

SPSP

SPMDR

Program(instruc tions)

Data(operands)

Stac k

SP

PC

AR

DR

1000

2000

4001

3000

4000399939983997

AddressMemory unit

Start Here

Page 17: Register organization, stack

RPN (Reverse Polish Notation)

The common mathematical method of writing arithmetic expressions imposes difficulties when evaluated by a computer

A stack organization is very effective for evaluating arithmetic expressions A * B + C * D AB * CD * +

( 3 * 4 ) + ( 5 * 6 ) 34 * 56 * +

3 12

6

5

42

30

12

5

1212

4

3

43 +*65*

Page 18: Register organization, stack

HERE IS YOUR ANSWER….ANY WAY YOU WANT, BECAUSE A CONCRETE FLOOR IS VARY HARD TO CRACK.

Page 19: Register organization, stack

THANK YOU!