Assembly language Program to swap 2 numbers using stack

Code

org 100h
.stack 100h
.data
string1 db "Enter Number: $"
string2 db "Numbers after swapping  $"
.code
main proc
    mov ax,@data
    mov ds,ax
    
    mov cx,2
    l1:
    mov dx,offset string1
    mov ah,09
    int 21h
    
    mov ah,01
    int 21h
    push ax
    
    mov dx,10
    mov ah,02
    int 21h
    mov dx,13
    mov ah,02
    int 21h
    
    loop l1
    
    mov dx,offset string2
    mov ah,09
    int 21h
    
    mov cx,2
    l2:
      pop dx
      mov ah,02
      int 21h
      
      mov dx,10
      mov ah,02
      int 21h
      mov dx,13
      mov ah,02
      int 21h
      
            
    loop l2
    
    mov ah,4ch
    int 21h
    main endp
end main

Output



Comments

Popular posts from this blog

Assembly language program to input an integer from user and display whether the number is even or odd

Assembly language program to input string from user and display it

Assembly language program to input string from user and display its length