Created
February 5, 2016 23:36
-
-
Save abrarShariar/c0b7d50ca4a2a7076586 to your computer and use it in GitHub Desktop.
swap two input using [xchg]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;SWAP two input using xchg | |
.model small | |
.stack 100h | |
.data | |
a db '[a] : $' | |
b db '[b] : $' | |
a_in db ? | |
b_in db ? | |
.code | |
main proc | |
;input part | |
mov ax,@data ;prepare data segment | |
mov ds,ax | |
mov ah,09h ;print string | |
lea dx,a | |
int 21h | |
mov ah,01h ;input char | |
int 21h | |
mov a_in,al | |
mov ah,02h ;tab | |
mov dl,09h | |
int 21h | |
mov ah,09h ;string print | |
lea dx,b | |
int 21h | |
mov ah,01h ;input char | |
int 21h | |
xchg a_in,al | |
mov b_in,al | |
;output part | |
mov ah,02h ;newline | |
mov dl,0Ah | |
int 21h | |
mov dl,0Dh | |
int 21h | |
mov ah,09h ;string print | |
lea dx,a | |
int 21h | |
mov ah,02h ;char output | |
mov dl,a_in | |
int 21h | |
mov dl,09h ;tab | |
int 21h | |
mov ah,09h ;string print | |
lea dx,b | |
int 21h | |
mov ah,02h ;char output | |
mov dl,b_in | |
int 21h | |
mov ah,4ch ;terminate | |
int 21h | |
main endp | |
end main | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment