Stack is a group of memory locations in the Read/Write memory. It is used for storage of binary information during the execution of a program. The beginning of the stack is defined in the program by using the instruction
LXI SP
This instruction loads a 16 bit memory address in the stack pointer register (SP) of the microprocessor. Once the SP is defined, storing of data bytes begins at the memory address that is one less than the address in the SP. The information is stored in reversed numerical order.
Data bytes in the register pair of the microprocessor can be stored in the stack in reversed order by using the instruction, RSH
. Data bytes can be transferred from the stack to representative register by using the instruction, POP
.
Since two data bytes are being stored at a time, the 16 bit memory address in the SP is decremented by 2. When data bytes are retrieved, the address is incremented by 2.
The stack is initialized at the highest available memory location to prevent the program from being removed by the stack information.
LXI SP, 16 bit address
This instruction loads SP register with the 16 bit address
PUSH Rp
where Rp stands for register pair. This instruction copies the content specified by the register pair into the stack.
PUSH B
PUSH D
PUSH H
When PUSH Rp is encountered the SP is decremented and the content of higher order register, B, D or H are copied in the locations shown by SP. The SP is again decremented and the lower order register content will be copied into the stack.
POP Rp
It copies the content of top two memory locations of the stack into the specified register pair, Rp. First content of the memory location indicated by the SP is copied into the lower order register and then the SP is incremented by 1. Now this content is copied into higher order register. Stack instructions belong to data transfer group. Thus content of source are not affected and no flags are affected.
POP B
POP D
POP H
What is hard computing? Hard computing is a traditional computing. It requires a precisely stated…
Soft computing is a problem solving technology. It tends to fuse synergically different aspects of…
Cluster computing is an approach to achieve high performance, reliability or high throughput computing by…
Magnitude Comparator is a combinational circuit capable of comparing the relative magnitude of two binary…
Full subtractor is a combinational circuit capable of performing subtraction on two bits namely minuend…
Half-subtractor is a combinational circuit capable of subtracting a binary number from another binary number.…