这段代码实现的功能是将几个数从键盘输入(数的正负号和小数点加起来最长不超过20位),空格来分隔两数,按回车输入结束,输入第10个数后也结束.后面把这10个数字
输出.但是我输入一个数是正确的,输入两个以上的数的时候程序在输出完的数字后面有段乱码,查了半天也找不要原因,麻烦哪位高手运行下,帮我找找问题出在哪
data segment
number db 200 dup(?)
numlenth dw 10 dup(?)
count1 dw ?
count2 dw ?
exit db 0dh,0ah,'please any key to exit','$'
input db 'please input the numbers:(dapart them with keyboard "space" and end with keyboad "enter")',0dh,0ah,'$'
output db 0dh,0ah,'the sorted numbers are:',0dh,0ah,'$'
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
sub si,si
sub bx,bx
sub di,di
sub cx,cx
mov count1,0
mov count2,0
mov ah,09h
lea dx,input
int 21h
sub dx,dx
inputdata:mov ah,01h
int 21h
cmp al,20h
jz nextdata
cmp al,0dh
jz endinput
inc count1
mov number[si],al
inc si
jmp inputdata
nextdata: mov dx,count1
mov numlenth[di],dx
add count2,20
mov si,count2
cmp count2,200
jz sortdata
mov count1,0
add di,1
jmp inputdata
endinput:mov dx,count1
mov numlenth[di],dx
inc di
sortdata: mov count1,0
mov ah,09h
lea dx,output
int 21h
sub si,si
sub bx,bx
sub cx,cx
mov count1,0
mov count2,di
sub dx,dx
outputnext:mov cx,numlenth[si]
sub di,di
add di,count1
add cx,count1
outputdata:mov dl,number[di]
mov ah,02h
int 21h
inc di
cmp di,cx
jz outputspace
jmp outputdata
outputspace:
inc si
cmp si,count2
jz exitall
mov dl,20h
mov ah,02h
int 21h
add count1,20
jmp outputnext
exitall:
mov ah,09h
lea dx,exit
int 21h
mov ah,01h
int 21h
mov ah,4ch
int 21h
code ends
end start