About PUSH and POP in microprocessor/controller

  • Thread starter reddvoid
  • Start date
  • Tags
    Push
In summary, the PUSH operation copies data from a register to the top of the stack and the contents of the register remain unchanged. The POP operation does the opposite by copying the top stack data to the register and adjusting the stack pointer. Moving operations do not change the content of the source register, unless there are new processors that have changed this behavior.
  • #1
reddvoid
119
1
Does PUSH operation moves or copies data from register to top of stack ;
I mean, what happens to the contents of the register from which the data is pushed ?
 
Engineering news on Phys.org
  • #2
Does PUSH operation moves or copies data from register to top of stack ;
I mean, what happens to the contents of the register from which the data is pushed ?
 
  • #3
nothing, its still there. push just places a copy of the data onto the stack and adjusts the stack pointer register.

pop does the opposite grabbing the top stack data copying to the register and changing the stack pointer register to the next value in the stack.
 
  • #4
The content of the register is unchanged. Moving operations don't change the source register.
 
  • #5
Unless the new processors changed, push or move the content of the register on stack don't change the content of the register.
 
  • #6
Thank you :)
 

Related to About PUSH and POP in microprocessor/controller

1. What is PUSH and POP in microprocessor/controller?

PUSH and POP are instructions used in microprocessors/controllers to save and retrieve data from the stack. The stack is a temporary storage area in the memory that is used for storing data and return addresses during the execution of a program.

2. How does PUSH and POP work?

When PUSH instruction is executed, it stores the data onto the top of the stack by decrementing the stack pointer. When POP instruction is executed, it retrieves the data from the top of the stack by incrementing the stack pointer.

3. What is the purpose of PUSH and POP in microprocessor/controller?

The main purpose of PUSH and POP instructions is to save and retrieve data in the stack. This is useful in managing the execution of a program by allowing the processor to temporarily store and retrieve data without having to access the main memory.

4. What are the differences between PUSH and POP?

The main difference between PUSH and POP is that PUSH stores data onto the stack, while POP retrieves data from the stack. Additionally, PUSH decrements the stack pointer, while POP increments it. Also, PUSH can take multiple data values as input, while POP can only retrieve one data value at a time.

5. How are PUSH and POP used in programming?

PUSH and POP instructions are commonly used in programming to manage the execution of subroutines or functions. When a subroutine is called, the return address is pushed onto the stack, and when the subroutine is finished, the return address is popped from the stack to continue the execution of the main program. They are also used for passing parameters and local variables between different parts of a program.

Similar threads

  • Electrical Engineering
Replies
25
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
Replies
15
Views
822
  • Electrical Engineering
Replies
20
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
3K
Replies
8
Views
376
Replies
26
Views
2K
  • Electrical Engineering
Replies
5
Views
3K
  • Classical Physics
Replies
11
Views
1K
  • Electrical Engineering
Replies
26
Views
2K
Back
Top