Presentation is loading. Please wait.

Presentation is loading. Please wait.

CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#9) By Dr. Syed Noman.

Similar presentations


Presentation on theme: "CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#9) By Dr. Syed Noman."— Presentation transcript:

1 CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#9) By Dr. Syed Noman

2 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. 2

3 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) 3 1 2 3 4 Top of Stack

4 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 xor dx,dx ; mov dx, 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 4

5 Assignment 3a Write an assembly language program that print the numbers from an array of length 5. 5

6 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. 6


Download ppt "CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#9) By Dr. Syed Noman."

Similar presentations


Ads by Google