На MASMe примерно так:
mov ax, word ptr[0502h]
cmp ax, word ptr[0506h]
jg @reorder
jl @ordered
mov ax, word ptr[0500h]
cmp ax, word ptr[0504h]
ja @reorder
@ordered:
mov word ptr[0600h], ax
mov ax, word ptr[0502h]
mov word ptr[0602h], ax
mov ax, word ptr[0504h]
mov word ptr[0604h], ax
mov ax, word ptr[0506h]
mov word ptr[0606h], ax
jmp @end:
@reorder:
mov word ptr[0604h], ax
mov ax, word ptr[0502h]
mov word ptr[0606h], ax
mov ax, word ptr[0504h]
mov word ptr[0600h], ax
mov ax, word ptr[0506h]
mov word ptr[0602h], ax
@end: