zzp139 发表于 2008-8-5 11:59

汇编的冒泡排序

汇编的冒泡排序
冒泡排序是一个程序员所必须写的程序

代码:

data segment
array dw 0001h,0002h,0003h,0005h,0000h
count equ ($-array)/2
table dw count dup(?)
flag db 0
data ends

code segment
assume ds:data,cs:code
start:
mov ax,data
mov ds,ax
mov es,ax
lea si,array
lea di,table
mov cx,count
rep movsw
mov bx,offset table
mov cx,count
call display

l3:
mov cx,count
lea si,array
sub cx,1
mov flag,0
l0:
mov bx,
cmp bx,
jnc l2
mov dx,
mov di,
mov ,di
mov ,dx
mov flag,1
l2:
add si,2
loop l0
cmp flag,1
jnc l3

mov bx,offset array
mov cx,count
call display
mov ah,4ch
int 21h
display proc
ll:
mov dl,' '
mov ah,2
int 21h
mov si,
mov dx,si
mov dl,dh
shr dl,1
shr dl,1
shr dl,1
shr dl,1
add dl,30h
cmp dl,3ah
jc l31
add dl,07h
l31:
mov ah,2
int 21h
mov dl,dh
and dl,0fh
add dl,30h
cmp dl,3ah
jc l4
add dl,07h
l4:
mov ah,2
int 21h
mov dx,si
shr dl,1
shr dl,1
shr dl,1
shr dl,1
add dl,30h
cmp dl,3ah
jc l5
add dl,07h
l5:
mov ah,2
int 21h
mov dx,si
and dl,0fh
add dl,30h
cmp dl,3ah
jc l6
add dl,07h
l6:
mov ah,2
int 21h
mov dl,' '
mov ah,2
int 21h
add bx,2
loop ll
ret
display endp
code ends
end start

0ne丶无罪 发表于 2010-10-28 18:14

额 不懂
页: [1]
查看完整版本: 汇编的冒泡排序