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.
They is not.
Either in registers or on the stack.
Registers or RAM-memory.
In programming, registers can be assigned to various functions such as storing temporary variables, holding function arguments, and managing return values. Commonly used registers include the accumulator (for arithmetic operations), index registers (for addressing), and stack pointers (for managing function calls and local variables). Additionally, general-purpose registers can be utilized for different tasks depending on the architecture and specific requirements of the program. The flexibility in using registers allows programmers to optimize performance and resource management in their applications.
Registers
here, just the registers are used to store the temporary data in the variables instead of RAM.
The registers that are pushed and popped from the stack during interrupt servicing depend on the processor architecture and whether or not a specific register is used by the service routine. Automatically pushed and popped registers include the program counter, flags, and (often) the accumulator. Manually pushed and popped registers include any others that are used, i.e. modified, by the routine. Some programmers push and pop all registers, but that can be unnecessary and wasteful (of time) if some registers are not modified.
Registers work like variables in computer code, but they are hard-wired and very fast. Actual variables are stored in RAM, and it is much faster for the CPU to access its own registers than to access RAM. CPU registers are the temporary areas in which software runs in the CPU. The majority of CPU operations are done using the registers. There are also special registers which are usually not directly accessed by user code. There is a flags register, and that is what returns the status of operations so the CPU can easily know if a result was zero, overflowed, carried, etc. There is an Instruction Pointer register which lets the CPU know where it is when executing code. That is not user editable, but user code certainly changes it by design. There is a Stack Pointer (SP) register, at least in PC compatible CPUs. The stack is an area of memory set aside for storing things from registers using the PUSH instruction. The POP instruction restores values into registers from memory. The SP register records where in the stack the next stack operation is to take place. The Call and Return instructions also use the stack to know where to come back to, and software uses the stack to pass parameters between functions and subroutines. So SP is a very important register.
Block transfer in 8085... PUSH FLAGS {optional, if registers need to be saved} PUSH B PUSH D PUSH H LXI H,COUNT LXI B,SOURCE LXI D,DESTINATION LOOP LDAX B STAX D INX B INX D DCX H MOV A,H ORA L JNZ LOOP POP H {optional, if registers need to be saved} POP D POP B POP FLAGS
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.
Microprocessor consists of different types of registers. They special purpose registers, general purpose registers, address registers, floating point registers and constant registers.
In 8085 general purpose registers are used to hold data like any other registers. In 8085 there are six types of special registers called general purpose registers. The general purpose registers in 8085 are B, C, D, E, H and L. Each register can hold 8 bit data. Apart from above functions these registers can also be used to work in pairs to hold 16 bit data. They can work in pairs such as B-C, D-E, H-L to store 16 bit data. The H-L pair work as a memory pointer. A memory pointer holds the address of a particular memory location. They can store 16 bit address as they work in pairs.