data segment num1 Dw ? num2 Dw ? num3 Dw ? num4 Dw ? num5 Dw ? num6 Dw ? nums DW ? nvalues Db 6 msg0 DB 'Enter positive decimal values or 999 to stop.$' msg1 DB 'Value 1:$' msg2 DB 'Value 2:$' msg3 DB 'Value 3:$' msg4 DB 'Value 4:$' msg5 DB 'Value 5:$' msg6 DB 'Value 6:$' msg7 DB 'Sorted values are:$' msg8 DB 'End of program$' data ends working_storage segment stack dw 100h dup(?) working_storage ends code segment assume cs:code,ds:data,ss:working_storage extrn putdec:proc,putcrlf:proc,getdec:proc,getchar:proc,putchar:proc start: mov ax,data mov ds,ax dopass:mov si,0 mov dx,6 mov Dx,offset msg0 mov ah,9h int 21h call putcrlf mov Dx,offset msg1 mov ah,9h int 21h call getdec cmp ax,999 jae finish mov nums[si],ax ;add nums[si],num1 mov ax,nums[si] call putcrlf mov Dx,offset msg2 mov ah,9h int 21h ;inc si call getdec cmp ax,999 jae finish check:;mov nums[si+1],ax ;add nums[si+1],num2 cmp nums[si+1],ax jnc noswap mov bx,nums[si+1] mov nums[si+1],ax mov nums[si],bx mov ax,nums[si+1] call putdec call putcrlf mov ax,bx call putdec call putcrlf ;mov Dx,offset msg3 ; mov ah,9h ; int 21h ; inc si ; call getdec ; cmp ax,999 ; jae finish ; add nums[si],ax ;add nums[si+2],num3 ; call putcrlf ; mov Dx,offset msg4 ; mov ah,9h ; int 21h ;call getdec ;cmp ax,999 ;jae finish ;mov num4,ax ;mov cx,num4 ;call putcrlf ;mov Dx,offset msg5 ;mov ah,9h ;int 21h ; call getdec ; cmp ax,999 ; jae finish ; mov num5,ax ;mov cx,num5 ; call putcrlf ; mov Dx,offset msg6 ; mov ah,9h ;int 21h ; call getdec ; cmp ax,999 ; jae finish ; mov num6,ax ;mov cx,num6 ; call putcrlf noswap: inc si loop check dec dx jnz dopass mov Dx,offset msg7 mov ah,9h int 21h finish:mov Dx,offset msg8 mov ah,9h int 21h call putcrlf mov ax,4c00h int 21h code ends end start