Q.While implementing a stack on a register stack, the stack pointer register is
Correct answer: decremented first during push operation
Explanation
In a register based stack the stack pointer (SP) typically points to the top of the stack. During the push operation, you first decrement the stack pointer (since the stack grows towards lower memory addresses), and then you store the value at the memory location pointed to by the stack pointer. Similarly, for the pop operation you first access the value at the location pointed to by the stack pointer and then increment the stack pointer.
In a register based stack the stack pointer (SP) typically points to the top of the stack. During the push operation, you first decrement the stack pointer (since the stack grows towards lower memory addresses), and then you store the value at the memory location pointed to by the stack pointer. Similarly, for the pop operation you first access the value at the location pointed to by the stack pointer and then increment the stack pointer.