主题:求助各位——汇编语言排序问题
DATAS SEGMENT
data1 dw 10 dup(?) ;此处输入数据段代码
data3 db "cong da dao xiao pai xu:",0dh,0ah,"$"
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
mov si,offset data1
mov cx,10
mov bx,5
Input:mov ah,1
int 21h
mov [si],al
inc si
inc di
loop Input
lea si,data1
Begain1:mov cx,bx
lea si,data1
Repeat1: mov ax,word ptr[si]
cmp ax,word ptr[si+2]
jge Exchange
jmp GoOn
Exchange: xchg ax,[si+2] ;字节比较
mov [si],ax
GoOn: inc si
inc si
loop Repeat1
dec bx
jnz Begain1
Begain2:lea si,data1
mov cx,12
mov dl,0ah
mov ah,2
int 21h
mov dx,offset data3
mov ah,9
int 21h
mov bl,03h
Output:mov dl,[si]
mov ah,2
int 21h
dec bl
dec cx
inc si ;//注意:在跳转之前就加一
cmp bl,01h
jng Space
cmp cx,00h
jg Output
jmp Over
Space:mov dl,' '
mov ah,2
int 21h
mov bl,03h
jmp Output
Over: MOV AH,4CH
INT 21H
CODES ENDS
END START
我要做的是 对任意输入10个数进行排序,可是程序有问题,只对某些序列可以排序
请高手帮帮忙看看 是怎么回事
data1 dw 10 dup(?) ;此处输入数据段代码
data3 db "cong da dao xiao pai xu:",0dh,0ah,"$"
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
mov si,offset data1
mov cx,10
mov bx,5
Input:mov ah,1
int 21h
mov [si],al
inc si
inc di
loop Input
lea si,data1
Begain1:mov cx,bx
lea si,data1
Repeat1: mov ax,word ptr[si]
cmp ax,word ptr[si+2]
jge Exchange
jmp GoOn
Exchange: xchg ax,[si+2] ;字节比较
mov [si],ax
GoOn: inc si
inc si
loop Repeat1
dec bx
jnz Begain1
Begain2:lea si,data1
mov cx,12
mov dl,0ah
mov ah,2
int 21h
mov dx,offset data3
mov ah,9
int 21h
mov bl,03h
Output:mov dl,[si]
mov ah,2
int 21h
dec bl
dec cx
inc si ;//注意:在跳转之前就加一
cmp bl,01h
jng Space
cmp cx,00h
jg Output
jmp Over
Space:mov dl,' '
mov ah,2
int 21h
mov bl,03h
jmp Output
Over: MOV AH,4CH
INT 21H
CODES ENDS
END START
我要做的是 对任意输入10个数进行排序,可是程序有问题,只对某些序列可以排序
请高手帮帮忙看看 是怎么回事