1 / 7

Lab 6

Lab 6. Stack. Push & Pop Instructions. POP destination. PUSH source. Last in First Out, First in Last Out SP initialized to 100H which represent empty stack. SP might contain offset address. (Stack Not Empty) PUSH decreases SP by 2 POP increases SP by 2. Example 1.

Download Presentation

Lab 6

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab 6 Stack

  2. Push & Pop Instructions • POP destination • PUSH source Last in First Out, First in Last Out SP initialized to 100H which represent empty stack. SP might contain offset address. (Stack Not Empty) PUSH decreases SP by 2 POP increases SP by 2

  3. Example 1 • Swap contents of CX = 30H and BX=32H, display it before and after swapping org 100h MOV CX,30H ;moving contents into registers MOV BX,32H MOV AH,2 ;display first content MOV DX,CX INT 21H MOV AH,2 ;display second content MOV DX,BX INT 21H MOV AH,9 ;display newline LEA DX,NL INT 21H PUSH CX ;swapping contents PUSH BX POP CX POP BX MOV AH,2 ;display first contents MOV DX,CX INT 21H MOV AH,2 ;display second contents MOV DX,BX INT 21H ret NL DB 0DH,0AH,"$"

  4. Procedures Invoking procedures: • CALL name • name PROC ;body of procedure ret name ENDP

  5. INDEC / OUTDEC • Input and display it in a new line. org 100h CALL INDEC MOV BX,AX MOV AH,9 LEA DX,NL INT 21H MOV AX,BX CALL OUTDEC ret NL DB 0DH,0AH,"$" INCLUDE 'PGM9_1.ASM' INCLUDE 'PGM9_3.ASM' END

  6. Exercise • Let the user input 2 numbers and displaythe result of multiplication.

  7. Solution org 100h CALL INDEC MOV BX,AX CALL NEWL XOR AX,AX CALL INDEC MUL BX XOR BX,BX MOV BX,AX CALL NEWL MOV AX,BX CALL OUTDEC ret NL DB 0DH,0AH,"$" NEWL PROC MOV AH,9 LEA DX,NL INT 21H RET NEWL ENDP INCLUDE 'PGM9_1.ASM' INCLUDE 'PGM9_3.ASM' END

More Related