This is an assembly language 8086 program to find the gcd of three unsigned 16 bit numbers.
I have checked the code several times and I feel this should be correct.
It runs and gives neither error nor warning but it gives output as different symbols (like smileys, arrows and all).
I can't figure out what to do next.
.model small
.stack 100h
.data
arr DW 4800h,1600h,3200h
gcd DW ?
.code
main proc
mov ax,@data
mov ds,ax
mov cx,0
mov si,offset arr
mov bx,[si]
jmp L1
L1:
inc si
inc cx
mov ax,[si]
jmp compare
compare:
cmp ax,bx
jg up1
jb excg
up1:
aad
div bx
cmp dx,0000h
je exit
jmp up2
excg:
xchg ax,bx
jmp up1
up2:
mov ax,bx
mov bx,dx
mov dx,0
jmp up1
exit:
mov gcd,bx
cmp cx,2
jne L1
je display
display:
mov dx,bx
mov ah,2
int 21h
mov ax,4c00h
int 21h
main endp
end main