I did a bubble sort alp to sort a byte list in descending order .. the idea of the bubble sort is to compare between the first two elements then if one is bigger it goes to the beginning of the list ..
The list is for example: 2,4,1,3,7,9,11 .. NUMBER DB 2,4,1,3,7,9,11
That's the code :
MOV SI,O ; SI is the first number in the list MOV DI,0 ; DI is the number compared with SI MOV AL,NUMBER[SI] MOV DI,SI INC DI INNER: CMP AL,NUMBER[DI] JLE SWAP CONITNUE: INC DI CMP DI,7 JNE INNER INC SI CMP SI,6 JNE OUTER JMP FINISH SWAP: MOV DL,NUMBER[DI] XCHG NUMBER[SI],DL MOV NUMBER[DI],DL MOV AL,NUMBER[SI] JMP CONTINUE FINISH: MOV AX,4C00H INT 21
Thanks guys .