Ques. What is stack? Give the organization of register stack with all necessary elements and explain the working of push and pop operations.
AKTU 2016-17, Marks 15
Answer :
Stack:It is a useful feature that is included in the CPU which follows the LIFO principle(Last In First Out).It is a storage device that stores info in such a manner that the item stored last is the first item retrieved.
Register Stack:A stack register is a computer central processor register whose purpose is to keep track of a call stack. It can be placed in a portion of a large memory or it can be organized as a collection of a finite number of memory words or registers.
Stack Pointer:It is the register that holds the address for the stack,because it’s value always points at the top of stack.
Operations of Stack:
1. Push:Operation of insertion in stack and increase the value of stack pointer by
Execution of Push Operation
SP<--SP+1 M[SP]<--DR if(SP==0) then FULL<--1 EMTY<--0
2. Pop:Operation of deletion in stack and it decreases the value of stack pointer by1.
Execution of Pop Operation
DR<--M[SP] SP<--SP-1 if(SP==0) then EMTY<--1 FULL<--0
Ques. What is a memory stack? Explain its role in managing subroutines with the help of neat diagrams.
AKTU 2016-17, Marks 15
Answer :
Memory Stack:
A stack can be implemented in a RAM attached to a CPU,the implementation of stack is done by assigning a portion of memory to a stack operation,and using a processor register as a stack pointer.Computer memory is partitioned into 3 parts namely:
1.Program
2.Data
3.Stack
Memory stacks are linear data structures (locations) used to store data in a computer's memory. Usually, the stack is used for storing data when subroutines are called.
Subroutine:A subroutine is a reusable program module. A main program can call or jump to the subroutine one or more times.
Return address of a subroutine is stored in stack memory.As the last Subroutine called is the first one to be returned ( Last in first out format). So stack data structure is the most efficient way to store the return addresses of the Subroutines.
Ques. What is the stack organization? Compare register stack and memory stack.
Answer :
Stack can reside in a portion of a large memory unit or it can be organized as a collection of a finite number of registers.
Ques. Explain an accumulator based central processing unit organization with block diagram.
Answer :
Block Diagram of accumulator based central processing unit organization:
ALU: Arithmetic operations are performed on the data.
Flags:Flags are also registers or bits inside registers which are set or cleared for a particular condition on an arithmetic operation.
ACC:It acts as the default temporary storage register location for all operations.
PC:This keeps track of the instruction address in memory from where the next instruction needs to be fetched
Stack Pointer(SP):It is involved in managing the stack transfers during and program execution.
Decoder:It decodes the fetched instruction.
Instruction Register(IR):This register stores the instruction after being fetched from the memory.
Timing and Control Unit:This block manages the sequencing of events on a timeline between various components of a CPU.
General Purpose Registers R1,R2,R3:These registers are involved in operations like load inputs, store intermediate results of arithmetic ,logical and shift micro-operations. The initial inputs are loaded into registers from memory and final results are later moved into memory.
0 Comments