data segment num1 Dw ? num2 Dw ? msg0 DB 'Enter positive decimal values or 999 to stop.$' msg1 DB 'Value $' 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 mov si,0 mov cx,6 mov bx,1 mov Dx,offset msg0 mov ah,9h int 21h call putcrlf repeat:mov Dx,offset msg1 mov ah,9h int 21h mov ax,bx call putdec call getdec cmp ax,999 jae finish add nums[si],ax mov ax,nums[si] inc si inc bx dec cx jnz repeat mov Dx,offset msg7 mov ah,9h int 21h call putcrlf mov cx,6 check:mov bx,nums[si] mov dx,nums[si+1] cmp dx,bx ja next mov nums[si],dx mov nums[si+1],bx ;mov num1,bx mov ax,nums[si] call putdec call putcrlf mov ax,nums[si+1] call putdec call putcrlf next: mov ax,bx call putdec mov ax,dx call putdec inc si dec cx jmp check finish:mov Dx,offset msg8 mov ah,9h int 21h call putcrlf mov ax,4c00h int 21h code ends end start