首页 > 代码库 > 汇编选择排序

汇编选择排序

dseg segment        source_data dw ?,-1,3,6,1,5        count equ $-source_datadseg endscseg segment        assume cs:cseg , ds:dsegstart:               mov ax , dseg        mov ds , ax        mov bx , count     ;外循环指针        sub bx ,2next_loop:        mov ax , [bx]        mov di , bx        ;mark        mov si , bx        ;内循环指针        sub si , 2        jz  next_labelfind_next:        mov dx , [si]        cmp dx , ax        jge next        mov ax , [si]        mov di , sinext:   sub si , 2        jnz find_next         cmp di , bx        je  next_label        mov ax , [bx]        mov dx , [di]        xchg ax , dx        mov [bx] , ax        mov [di] , dxnext_label:        sub bx , 2        jnz next_loop                mov ax , 4c00h                          int 21h cseg endsend  start

 

汇编选择排序