有符号8位整数的冒泡排序
相对于无符号那篇的差别之有第37行的判断转移
1 ;有符号整数的冒泡排序 2 3 assume cs:code,ds:data 4 data segment 5 db 61h,84h,93h,0c4h,17h,0ffh,52h,2ah 6 ;db 8h,7h,6h,5h,4h,3h,2h,0ffh 7 data ends 8 9 code segment 10 start: 11 mov ax,data 12 mov ds,ax ;定义数据段 13 14 mov cx,7 ;外层循环次数 15 16 call loopi 17 mov ax,4c00h 18 int 21h 19 20 loopi: 21 22 call s 23 24 25 loop loopi 26 ret ;call loopi返回 27 28 29 s: 30 push cx 31 mov si,7 32 s1: 33 34 mov al,[si] 35 mov dl,[si-1] 36 cmp al,dl 37 jge x ;符合就不执行交换 38 39 xchg al,dl 40 41 x: mov [si],al ;更新数据 42 mov [si-1],dl 43 dec si 44 loop s1 45 46 pop cx 47 ret 48 49 50 code ends 51 end start