1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Bubble sort getting max number

Discussion in 'Assembly Language Programming (ALP) Forum' started by Black Baron, May 10, 2008.

  1. Black Baron

    Black Baron New Member

    May 10, 2008
    Likes Received:
    Trophy Points:
    Hey there ..
    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
            CMP AL,NUMBER[DI]
            JLE SWAP
            INC DI
            CMP DI,7
            JNE INNER
            INC SI
            CMP SI,6
            JNE OUTER
            JMP FINISH
            MOV DL,NUMBER[DI]
            XCHG NUMBER[SI],DL
            MOV NUMBER[DI],DL
            MOV AL,NUMBER[SI]
            JMP CONTINUE
            MOV AX,4C00H
            INT 21 
    Now, I want to get the maximum number .. what do you think if I take the value of SI at the end because it will be the maximum .. how can I do that in this code ?

    Thanks guys .

Share This Page