----------------
请把“小于20个数的例子”,显示出来,大家帮你改改。
----------------------------------冒泡排序
如想增加数据只需在a变量中添加,
同时长度len要相应的更改
----------------------------------
data segment
len dw 10
a dw -1,2,100,-100,99,-120,15,46,411,102
b dw 0
data ends
code segment
main proc far
assume cs:code,ds:data
start:
push ds
sub ax,ax
push ax
mov ax,data
mov ds,ax
mov cx,len
dec cx
loop1:
mov di,cx
mov bx,0
loop2:
mov ax,a[bx]
cmp a[bx+2],ax
jge cotinue
xchg ax,a[bx+2]
mov a[bx],ax
cotinue:
add bx,2
loop loop2
mov cx,di
loop loop1
mov si,0
loop3:
mov bx,a[si]
call bini
call crlf
add si,2
mov di,len
add di,len
cmp si,di
jl loop3
ret
main endp
bini proc near
mov cx,10000d
call bin
mov cx,1000d
call bin
mov cx,100d
call bin
mov cx,10d
call bin
mov cx,1d
call bin
ret
bini endp
bin proc near
mov ax,bx
mov dx,0
div cx
mov bx,dx
mov dl,al
add dl,30h
mov ah,02h
int 21h
ret
bin endp
crlf proc near
mov dl,0ah
mov ah,02h
int 21h
mov dl,0dh
mov ah,02h
int 21
ret
crlf endp
code ends
end start
MOV CX, 19
LP0:
LEA BX, TABLE
PUSH CX
LP1:
MOV AL, [BX]
CMP AL, [BX + 1]
JBNEXT
XCHG AL, [BX + 1]
MOV [BX], AL
NEXT:
INC BX
LOOP LP1
POP CX
LOOP LP0
HLT
END
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)