;Following program takes two numbers from user and stores them in v1 and v2 respectively, then exchanges the values of v1 and v2 using XCHG command in assembly Language on 8086.
TITLE XCHG in Assembly Language
.model small
.stack
.data
v1 db ?
v2 db ?
.code
;input first number
mov ah,1h
int 21h
mov v1,al; v1 = first number
int 21h
mov v2,al; v2 = second number
;print v1(first) number
mov ah,2h
mov dl,v1
int 21h
;print v2(2nd) number
mov dl,v2
int 21h
;Xchange values of v1 and v2
mov al,v1
xchg al,v2
mov v1,al
;print newline
mov dl,10
int 21h
;print v1(first) number
mov ah,2h
mov dl,v1
int 21h
;print v2(2nd) number
mov dl,v2
int 21h
mov ax,0
mov ah,4ch
int 21h
end
No comments:
Post a Comment