Assembly code; 源程序是照着飒龙哥写的,问题出在输入十进制,排序后显示有错误~思考了很久,实在不会,希望大家帮忙看看。谢谢了Student struc number db 10 dup(' ') student_name db 8 dup(' ') score db 0Student endsstack1 segment stack dw 100 dup(?) stack1 endsdata segmentstudents Student 10 dup(<>)real_count dw 0 flag dw 0ffffh sort dw 10 dup(0) buf_max db 11count db 0chars 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 endscode segmentAssume cs:code,ds:data,es:data ,ss:stack1start: 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 ysno2ysno1: clc jmp ysno3ysno2: stcysno3: 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 sortloop1: 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,8loopname: 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 exitwrite_error: mov dx,offset write_error_msg call display_string jmp exitgetnumber 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 retgetnumber endpgetname 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 retgetname endpgetscore 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 retgetscore endpgetstring 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 retgetstring endpbinary proc push bx push cx push dx push si mov si,offset chars mov ax,0 mov dh,0 mov bx,10loop3: 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 retbinary endpsort_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 retsort_score endpinsert 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 loop6loop9: pop di pop dx pop bx retinsert endpdisplay_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 loop10loop20: pop dx add dl,'0' mov ah,2h int 21h loop loop20 pop bx pop dx pop ax pop cx retdisplay_number endpdisplay_string proc push ax mov ah,9 int 21h pop ax retdisplay_string endpnewline proc push ax push dx mov ah,2 mov dl,0dh int 21h mov dl,0ah int 21h pop dx pop ax retnewline endptable proc push ax push dx mov ah,2 mov dl,9 int 21h pop dx pop ax rettable endpcode ends end start