Want this question answered?
Push instruction pushes two byte of data on the top of the stack.
If the stack is empty assume the stack pointer has a value of P. when you push something on the stack you increment P. when you pull something from stack you decrement P.
Its not a stack counter - its a stack pointer. The stack pointer is a register that points to the top of the stack. In the Intel configuration, it points to the next item to be popped off the stack. To push an item requires that the stack pointer be decremented first, and then the item is written. The inverse operation - the pop - requires read then increment.
I am not sure about 8086, but I can tell you the whole procedure in 8085. PUSH instruction always pushes two bytes of data i.e. total 16 bits. Example: Assume that Stack is already initialized and SP is at 2008 address location. Then PUSH B instruction will have following steps: 1) The stack pointer (SP) will be pointing to the uppermost position of the stack (actually stack works in opposite order in terms of Addresses. e.g. if SP is now at address 2008, then PUSH instruction will store the contents on 2007 & 2006). 2) The contents of register B & C will be saved on to the stack such that contents of register B will be at 2007 & that of C will be at 2006 address location. 3) The SP is now modified to 2006.
STACK operation in 8085 microprocessor.The stack is a reserved area of the memory in RAM where temporary information may be stored. An 8-bit stack pointer is used to hold the address of the most recent stack entry. This location which has the most recent entry is called as the top of the stack.When the information is written on the stack, the operation is called PUSH. When the information is read from the stack, the operation is called POP. The stack works on the principle of Last in First Out or Fist in Lat Out
STACK operation in 8085 microprocessor.The stack is a reserved area of the memory in RAM where temporary information may be stored. An 8-bit stack pointer is used to hold the address of the most recent stack entry. This location which has the most recent entry is called as the top of the stack.When the information is written on the stack, the operation is called PUSH. When the information is read from the stack, the operation is called POP. The stack works on the principle of Last in First Out or Fist in Lat Out
Processor status word ( PSW ) in the case of 8085 refers to the collection of the values of the flag register and accumulator. It is used with the command push: PUSH PSW With this command, the proccessor saves the value of accumulator (A) and the values of the flag bits to the stack.
The value being pushed (push [value]) is placed on the top of the stack (esp) and the size of the value is added to esp.
To reset the pending RST 7.5 instruction in the 8085, you need to execute a SIM instruction with a particular value in the accumulator. PUSH FLAGS MVI A,10H SIM POP FLAGS Of course the PUSH and POP are optional, if you don't need to preserve the value of the accumulator.
The PUSH instruction decrements the stack pointer by the size of the operand and then stores its operand at the memory address pointed to by the stack pointer. This leaves the stack pointer always pointing to the last element pushed onto the stack.The POP instruction reverses the sequence, retrieving the operand first, and then incrementing the stack pointer by the size of the operand.Also, PUSH and POP do not work on variables - they only work on register values. You can pop/push a variable, however, by using a register and then storing/retrieving the register to/from memory.
If this is a homework assignment, you really should try to answer it on your own first, otherwise the value of the reinforcement of the lesson due to actually doing the assignment will be lost on you.The call-return and push-pop instruction sequences on the 8085 are similar in that each pushes something on the stack and then pops something off the stack.In the case of call-return, that something is the program counter. In the case of push-pop, that something is up to the programmer, and it can be one of AF, BC, DE, or HL.
When you use a stack type instruction, such as PUSH B, you are using the effective address contained in the SP (Stack Pointer) register. In this example, m(SP-1) is set to B, m(SP-2) is set to C, and SP is set to SP-2.