60 likes | 143 Vues
CEN 226 : Computer Organization & Assembly Language : CSC 225 (Lec#9). By Dr. Syed Noman. Push and Pop instructions. The stack is typically used to save and restore the values of registers used in subprograms.
E N D
CEN 226: Computer Organization & Assembly Language :CSC 225(Lec#9) By Dr. Syed Noman
Push and Pop instructions • The stack is typically used to save and restore the values of registers used in subprograms. • The stack is an area of memory (RAM) where we can temporarily store items. We say that we "push the item onto the stack" to save it. • To get the item back from the stack, we "pop the item from the stack". • The 8086 provides push and pop instructions for storing and retrieving items from the stack.
Number display program logic • 1234 / 10 : quotient = 123, remainder = 4 (push 4) • 123 / 10: quotient = 12, remainder = 3 (push 3) • 12 / 10: quotient = 1, remainder = 2 (push 2) • 1 / 10: quotient = 0, remainder = 1 (push 1) Top of Stack
Number display program .model small .stack 100h .code my proc mov ax,1234 mov dx,0 mov bx,10 mov cx,0 again: div bx push dx xordx,dx ; movdx, 0 inc cx cmp ax,0 jne again mov ah,2 next: pop dx add dl,30h int 21h loop next mov ax,4c00h int 21h my endp end my
Assignment 3a • Write an assembly language program that print the numbers from an array of length 5.
Assignment 3b • Write an assembly language program that prints after reversing the case of the letters only, in an string inputted by the user in the buffer.