0

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

Edited by Alerwiali: n/a

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Ancient Dragon
0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.