dseg segment source_data dw ?,-1,3,6,1,5 count equ $-source_data dseg ends cseg segment assume cs:cseg , ds:dseg start: mov ax , dseg mov ds , ax mov bx , count ;外循环指针 sub bx ,2 next_loop: mov ax , [bx] mov di , bx ;mark mov si , bx ;内循环指针 sub si , 2 jz next_label find_next: mov dx , [si] cmp dx , ax jge next mov ax , [si] mov di , si next: 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] , dx next_label: sub bx , 2 jnz next_loop mov ax , 4c00h int 21h cseg ends end start
时间: 2024-11-05 17:26:35