汇编高手来 学生成绩排序。哪里有错? 全部分了。大家帮忙,初学啊
data segment
buf db 10, ?, 10 dup('$')
input1 db 'Please input the student name:$'
input2 db 'Please input the score(0-100):$'
name1 db 100 dup(?)
score1 dw 10 dup(0)
data ends
stack segment para 'stack' stack
db 200 dup( 0 )
stack ends
code segment
assume cs:code, ds:data, ss:stack
begin:
mov ax, data
mov ds, ax
mov es, ax
mov ax, stack
mov ss, ax
mov cx, 10
mov bx, 0
input:
lea dx,input1 ;输出input1
mov ah,09h
int 21h
lea dx, buf ;输入buf
mov ah, 0ah
int 21h
mov dl, 13
mov ah, 2
int 21h
mov dl, 10
int 21h
lea dx, buf
add dx, 2
mov ah, 9
int 21h
mov dl, 13
mov ah, 2
int 21h
mov dl, 10
int 21h
push cx ;存储姓名
push ds
pop es
cld
mov cl, buf[1]
xor ch, ch
lea si, buf[2]
lea di, name1
rep movsb
pop cx
push cx
cld
push ds
pop es
lea di,buf
add di,2
mov cx,10
mov al,'$'
rep stosb
pop cx
lea dx,input2 ;输出input2
mov ah,09h
int 21h
lea dx, buf ;输入buf
mov ah, 0ah
int 21h
push si ;存储buf
push cx
lea si,buf
add si,2
mov cl,buf[1]
cld
xor dx, dx
lp:
mov ax, 10
mul dx
mov dx, ax
lodsb
and ax, 0FH
add dx, ax
loop lp
pop cx
pop si
mov score1[bx],dx
inc bx
mov dl, 13
mov ah, 2
int 21h
mov dl, 10
int 21h
lea dx, buf
add dx, 2
mov ah, 9
int 21h
mov dl, 13
mov ah, 2
int 21h
mov dl, 10
int 21h
push cx
cld
push ds
pop es
lea di,buf
add di,2
mov cx,10
mov al,'$'
rep stosb
pop cx
dec cx
cmp cx,0
je compare
jmp input
compare:
mov cx,10
dec cx
compare1:
mov di,cx
mov bx,0 ;比较score,并输出
compare2:
mov ax,score1[bx]
cmp ax,score1[bx+2]
jge continue
xchg ax,score1[bx+2]
mov score1[bx],ax
continue:
add bx,2
loop compare2
mov cx,di
loop compare1
mov di,9
Print: ;打印排好的score
int 1
xor ax,ax
mov al,score1[di]
xor cx,cx
DoDiv:
mov bl,10
div bl
push ax
inc cx
xor ah,ah
cmp al,0
jnz DoDiv
DoPrt:
pop dx
xchg dh,dl
add dl,30h
mov ah,2
int 21h
loop DoPrt
cmp di,-1
jne ddd
ddd:
dec di
jmp print
Exit: mov ah, 4ch
int 21h
code ends
end begin