org 100h mov dl, 0ah int 21h begin: mov dl, 0dh int 21h ; Read first ternary digit mov ah, 09h ;check if all numbers are the mov dx, offset msg same int 21h cmp bl, bh ;compare num1 and mov ah, 01h num 2 int 21h je cmp_1n3 ;either compare sub al, '0' ;convert ASCII to decimal num 1 and num 3 or num 2 and num 3. mov bl, al ;store 1st num If equal jump to cmp_1n3, if not read the nxt line mov ah, 02h jmp largest_num mov dl, 0ah int 21h cmp_1n3: mov dl, 0dh cmp bl, cl int 21h jne largest_num ;jump/Go to finding the largest number if not equal ; Read second ternary digit ;display all numbers are the mov ah, 09h same mov dx, offset msg1 mov ah, 09h int 21h mov dx, offset msg3 mov ah, 01h int 21h int 21h ; Exit the program so it wont run sub al, '0' ;convert ASCII to decimal the other codes mov bh, al ;store 2nd num mov ah, 4Ch int 21h mov ah, 02h mov dl, 0ah largest_num: int 21h cmp bl, bh ;compare num1 and mov dl, 0dh num2 int 21h jg compare_1n3 ;if bl is greater than it will jump to compare_1n3 if not it ; Read third ternary digit reads the next line/code mov ah, 09h cmp bh, cl ; compare num2 and mov dx, offset msg2 num 3 int 21h jl compare_1n3 ;if bh is less than mov ah, 01h it will jump to compare_1n3 if not it int 21h reads the next line/code sub al, '0' ;convert ASCII to decimal add bh, '0' ;convert bh/num2 to mov cl, al ; store 3rd num ASCII ;display num1 mov ah, 09h mov ah, 02h mov dx, offset msg4 mov dl, bl ;store num1 to dl int 21h int 21h
;display num2 ; Exit the program
mov ah, 02h mov ah, 4Ch mov dl, bh ;store num2 to dl int 21h int 21h
; Exit the program so it wont run
the other codes msg db 'Enter First number[0-9]: $' mov ah, 4Ch msg1 db 'Enter Second number[0-9]: $' int 21h msg2 db 'Enter Third number[0-9]: $' msg3 db 'ALL NUMBERS ARE THE compare_1n3: SAME $' cmp bl, cl ;compare num1 and msg4 db 'The largest NUMBER is: $' num 3 jg display_num3 ;if greater code ends than jump to display_num3 and if not end begin read the nxt line/code add cl, '0' ;convert to ASCII
mov ah, 09h
mov dx, offset msg4 int 21h
;display num1 mov ah, 02h mov dl, cl ;store num3 to dl int 21h
Model Small Stack Data msg1 DB "Enter First Number $" msg2 DB "Enter Second Number: $" msg3 DB "Difference BTW Two Numbers: $" Num1 DB ? Num2 DB ? Code Main Proc, @data,, msg1