Start New Discussion within our Software Development Community

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 $
mov si, arr
mov di, arr+2
mov cx, 0
mov al, [si]
cmp al, [di]
jg swap
add [si], 2
add [di], 2
cmp [di], arr_e
jz prgnmxexit 
jmp strXt0
xchg al, [di]
mov [si], al
mov al, [si+1]
xchg al, [di+1]
mov [si+1], al
inc cx
jmp srto_retrnx
or cx, cx
jz done   
jmp strXt0

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


    inc     si
    inc     si
    inc     di
    inc     di


    cmp     di, arr_e
This article has been dead for over six months. Start a new discussion instead.