i have problem in this code it work well in 1st loop then its bug as si and di still the same and making alot of jumps without any change
this code sorting descending

jmp strXt0
arr dw 0x1,0x9,0x3,0x2,0x7,0x3,0x6,0x4,0x9,0x5
arr_e equ $
strXt0:
mov si, arr
mov di, arr+2
mov cx, 0
srto_l:
mov al, [si]
cmp al, [di]
jg swap
srto_retrnx:
add [si], 2
add [di], 2
cmp [di], arr_e
jz prgnmxexit 
jmp strXt0
swap:
xchg al, [di]
mov [si], al
mov al, [si+1]
xchg al, [di+1]
mov [si+1], al
inc cx
jmp srto_retrnx
prgnmxexit:
or cx, cx
jz done   
jmp strXt0
done:

so any 1 can help me whats the error?

In lines 13 & 14, what you want to be doing is incrementing the pointer, not adding two to the contents of where they are pointing.

    add     si, 2
    add     di, 2

or

    inc     si
    inc     si
    inc     di
    inc     di

then

    cmp     di, arr_e
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.