.model small
.stack
.data
array db 12,45,13,9,45,48,68,32,5,11
count equ $-array
.code
.startup
mov ax,count
xor dx,dx
mov bx,offset array
call qsort
mov cx,count
again:
xor ax,ax
mov al,byte ptr[bx]
call input
inc bx
loop again
mov ah,4ch
int 21h
END
qsort proc near
cmp dx,ax
jae exit
call partion
sub cx,1
mov ax,cx
call qsort
add cx,2
mov dx,cx
call qsor
exit:
ret
qsort endp
END
partion proc near
push ax
push dx
mov si,dx
mov di,ax
mov dl,byte ptr[bx][si]
mov dh,byte ptr[bx][di]
call swap
sub ax,si
mov cx,ax
mov di,si
mov al,dh
next:
mov dl,byte ptr[bx][si]
cmp dl,al
jae sign
mov dh,byte ptr[bx][di]
call swap
inc di
sign:
inc si
loop next
mov dh,byte ptr[bx][di]
mov dl,byte ptr[bx][si]
call swap
xor cx,cx
mov cl,dl
pop dx
pop ax
ret
partion endp
END
swap proc near
xchg dl,dh
mov byte ptr[bx][si],dl
mov byte ptr[bx][di],dh
ret
input proc near
mov dl,10
div dl
mov dx,ax
add dx,3030h
cmp dl,0
je next
mov ah,2
int 21h
next:
mov dl,dh
mov ah,2
int 21h
ret
input endp
END
------解决思路----------------------
每个子程后面的 END 语句是不可以有的吧,endp 已经标示子程结束了;END 是说整个源程序结束了,其后的内容是不被处理的。