what is wrong with this

;Author   : Alerwi Ali 
;Function : Sort an array of 10 elemnts(Bubble sort)
.model small
.stack
     size equ 10 
.data
vett  db 1,4,3,2,4,-1,-4,0,6,10
temp  db ?
i     db 0
j     db 1
.code
.startup 
   mov ax,@data
   mov dx,ax
   
   xor si,si
   xor cx,cx
   mov cx,size
   lea si,vett
   
Loop1:
        add i,1
        cmp i,size
        jl NestedLoop
        mov bl,[si]
        cmp bl,si+1
      
NestedLoop:
         add j,1
         mov al,size
         sub al,1
         mov dl,i
         sub al,dl
         mov dl,1  
         mov size,al
         cmp j,al         
         jl condition
         jge loop1
         
         
         

condition:
        mov bl,[si]
        cmp bl,si+1
        jg swap
        loop NestedLoop
swap:  
            
      mov temp,bl
      mov bl,si+1
      mov [si],bl
      mov bl,temp
      mov si+1,bl
      loop NestedLoop   

End

What is it supposed to do? Use a debugger to single step through the program to see why it doesn't do what you want it to do.

It is supposed to sort the elements of 'vett' By using bubble sort .

lines 16 and 17: delete them because it isn't necessary to zero out the registers before moving some other value intol them.

line 45: why compare bl with the loop counter? bl contains one of the integers from the array. Similar with line 54. I think you need to put [ and ] around si+1

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.