Google

Sep 23, 2008

stack program for push and pop

following is the assembly language program for push and pop operations in a stack.

code segment
main:
mov sp,1000h initialize SP to point to stack
mov ax,1234h
mov bx,5678h
mov cx,9abcdh
push ax
push cx
pop ax
pop ax
pop bx
pop cx
mov bx,0200h
mov w[bxx],1234h; address 0200 holds 1234
push [0200h]
push[bx]
mov bx,0210h
pop [bx]
pop[0212h]
imp main ; demo again
code ends

This program establishes the stack at 0100h and puts some random numbers in registers AX , BX , CX. AX is pushed on the stack that stores it at SS:OFFFh(MSB) and SS:0FFEh{LSB}. BX and CX are stored in similar manner with the attendant decrement of SP bt 2 for each push. The contents of the stack are then popped from the stack, in reverse order.

You might be also interested in:


:: Find Square Root of a hexadecimal number in assembly language
:: common intreview questions on 8086
:: Assembly Language Source Codes

No comments: