Fork me on GitHub

汇编:3个数排序(从大到小)

;三个数排序(从大到小)
DATAS SEGMENT
array db 12,250,123
DATAS ends

CODES SEGMENT
    ASSUME CS:CODES, DS:DATAS
    START:
        mov AX,DATAS
        mov DS,AX

        mov si,offset array
        mov al,[si]
        mov bl,[si+1]
        mov cl,[si+2]
        cmp al,bl
        jae flag1   ;大于等于跳转
        xchg al,bl  ;交换
    flag1:
        cmp al,cl
        jae flag2   ;大于等于跳转
        xchg al,cl  ;交换
    flag2:
        cmp bl,cl
        jae flag3
        xchg bl,cl  ;交换
    flag3:            ;重新放入缓冲区
        mov [si],al
        mov [si+1],bl
        mov [si+2],cl
        mov ah,4ch
        int 21H
CODES ends
    end START

 

posted @ 2019-01-09 13:58  粥里有勺糖  阅读(1276)  评论(0编辑  收藏  举报