关于排序的一段代码,求大神帮忙解决一下,该如何解决

关于排序的一段代码,求大神帮忙解决一下
Assembly code




; 源程序是照着飒龙哥写的,问题出在输入十进制,排序后显示有错误~思考了很久,实在不会,希望大家帮忙看看。谢谢了
Student struc
    number            db 10 dup(' ')
    student_name       db 8 dup(' ')
    score             db 0
Student ends
stack1 segment stack
       dw 100 dup(?)
       
stack1  ends


data segment

students Student   10 dup(<>)

real_count dw 0                 

flag dw 0ffffh                  
sort dw 10 dup(0)             
                               
buf_max db 11
count   db 0

chars   db 11 dup(0)

f1 db 'C:\score.txt',0           
mess1 dw ?   

create_error_msg      db 0dh,0ah,'create file error!','$'
write_error_msg       db 0dh,0ah,'write file error!','$'
enter_number          db 0dh,0ah,0dh,0ah,'enter number    : $'
enter_student_name    db 0dh,0ah,'enter student_name  : $'
enter_score           db 0dh,0ah,'enter score : $'
yesorno               db 0dh,0ah,'continue?  y=continue  n=finish   $'
mess2               db 0dh,0ah,'                      ',0dh,0ah
                      db         'number',9,9,'student_name ',9,9,'score',0dh,0ah,'$'
                  
data ends
code segment
Assume cs:code,ds:data,es:data ,ss:stack1

start:
     mov ax,data
     mov ds,ax
     mov es,ax
     mov cx,10
     mov di,offset students
     mov cx,10
     
     
     
next: 
     push cx
     call getnumber    ;从键盘上输入number
     
     call getstring
     call getname      ;从键盘上输入student_name
     add  di,10        ;调整变址
     call getstring
     call getscore
     call binary
     add  di,8
     mov [di],al
     inc  real_count
     
     
     push dx
     push ax     
     mov dx,offset yesorno
     mov ah,9
     int 21h
        
     mov ah,1
     int 21h
     cmp al,'y'
     jz  ysno1
     jmp ysno2
ysno1:
     clc
     jmp ysno3
ysno2:
     stc
ysno3:
     pop ax
     pop dx
     
     jc next1
     add di,1
     pop cx
     loop next
     
next1:
     call sort_score
     call newline
     mov dx,offset mess2      
     call display_string    
     mov cx,real_count         
     mov di,offset sort
loop1:
     push cx
     mov  bx,[di]
     xor  si,si
     mov  ah,2
     mov  cx,10
     
loopnumber:
     mov  dl,(Student    ptr [bx]).number[si]
     int  21h
     inc  si
     loop loopnumber
     
     
     call table
     xor si,si
     mov ah,2
     mov cx,8
loopname:     
     mov dl,(Student    ptr [bx]).student_name[si]
     int 21h
     inc si
     loop loopname
     
     call table
     
     call table
 
     mov dl,(Student    ptr [bx]).score
     call display_number
     call newline
     inc di
     inc di
     
     pop cx
     loop loop1
     
     
     mov ah,3ch
     mov cx,0
     mov dx,offset f1
     int 21h
     jc create_error
     mov mess1,ax

     xor dx,dx
     mov ax,19      
     mul real_count    
     mov cx,ax        
     mov ah,40h
     mov bx,[mess1]
     mov dx,offset students
     int 21h
     jc write_error

     mov ah,3eh
     mov bx,[mess1]
     int 21h
        
exit:
     mov ax,4c00h
     int 21h
        
create_error:
     mov dx,offset create_error_msg
     call display_string
     jmp exit
write_error:
     mov dx,offset write_error_msg
     call display_string
     jmp exit


getnumber proc
        push ax
        push dx
        mov ah,9
        mov dx,offset enter_number
        int 21h               
        mov [buf_max],11      
        mov dx,offset buf_max
        mov ah,0ah
        int 21h
        pop dx
        pop ax
        ret
getnumber endp

getname proc
        push ax
        mov ah,9
        mov dx,offset enter_student_name
        int 21h
        mov [buf_max],9
        mov dx,offset buf_max
        mov ah,0ah
        int 21h
        pop ax
        ret
getname endp

getscore proc
        push ax
        mov ah,9
        mov dx,offset enter_score
        int 21h
        
        mov [buf_max],4
        mov dx,offset buf_max
        mov ah,0ah
        int 21h
        
        pop ax
        ret
getscore endp
getstring proc
        push si
        push di
        push cx
        
        mov si,offset chars
        xor cx,cx
        
        mov cl,count
        rep movsb

        pop cx
        pop di
        
        pop si
        ret
getstring endp



binary proc
        push bx
        push cx
        push dx
        push si
        
        mov si,offset chars
        mov ax,0
        mov dh,0
        mov bx,10
loop3:
        mov dl,[si]     
        cmp dl,0dh
        jz loop4
        
        
        
        sub dl,30h
        add ax,dx
        mul bx
        inc si
        jmp loop3
        
loop4:
        pop si
        pop dx
        pop cx
        pop bx
        
        ret
binary endp




sort_score  proc
        push ax
        push bx
        push si
        push di
        
        mov bx,offset students          
        mov di,offset sort              
        mov cx,real_count              
loop5:
        mov al,(Student ptr [bx]).score 
        call insert                     
        add bx,19                       
        add di,2                        
        loop loop5                      
        
        pop di
        pop si
        pop bx
        pop ax
        ret
sort_score endp




insert proc
        push bx
        push dx
        push di
        
        mov dx,bx       
loop6:
        mov bx,[di-2] 
        cmp bx,0ffffh   
        jnz loop7      
        mov [di],dx     
        jmp loop9        
loop7:
        cmp al,(Student ptr [bx]).score
        ja  loop8  ;
        mov [di],dx     
        jmp loop9        
loop8:
        mov [di],bx     
        sub di,2
        jmp loop6

loop9:
        pop di
        pop dx
        pop bx
        ret
insert endp




display_number proc near
        push cx
        push ax
        push dx
        push bx

                     
        mov bx,10    
        xor cx,cx    
loop10:
        xor dx,dx   
        div bx      
        push dx     
        inc cx      
        cmp ax,0   
        jnz loop10
loop20:
        pop dx
        add dl,'0'   
        mov ah,2h
        int 21h
        loop loop20
        
        pop bx
        pop dx
        pop ax
        pop cx
        ret
display_number endp


display_string proc
        push ax
        mov ah,9
        int 21h
        pop ax
        ret
display_string endp


newline proc
        push ax
        push dx
        mov ah,2
        mov dl,0dh
        int 21h
        mov dl,0ah
        int 21h
        pop dx
        pop ax
        ret
newline endp


table proc
        push ax
        push dx
        mov ah,2
        mov dl,9
        int 21h
        pop dx
        pop ax
        ret
table endp
code ends
    end start