急求 编程序统计学生的数学成绩分别归类90~99,80~89,70~79,60~69分及60分以下,

2024-12-02 04:08:34
推荐回答(1个)
回答1:

data segment
credit dw 76,69,84,90,73,88,99,63,60,25
mes1 db '60-69:$'
mes2 db '70-79:$'
mes3 db '80-89:$'
mes4 db '90-99:$'
mes5 db '0-59:$'
v1 db ?
v2 db ?
v3 db ?
v4 db ?
v5 db ?
data ends

code segment
assume cs:code,ds:data
main proc far
start:
mov ax,data
mov ds,ax
call count
mov ah,4ch
int 21h
ret
main endp

count proc near
lea si,credit
mov cx,0ah
m1:mov bx,[si]
add si,2
cmp bx,59
jg m7
inc v5
jmp m6 ;50-59
m7:cmp bx,69
jg m2
inc v1
jmp m6 ;60-69
m2:cmp bx,79
jg m3 ;70-79
inc v2
jmp m6
m3:cmp bx,89
jg m4 ;80-89
inc v3
jmp m6
m4:cmp bx,99
jg m6 ;90-99
inc v4
jmp m6
m6:loop m1

mov dx,offset mes1;输出字符串及对应的人数
mov ah,09h
int 21h
mov dl,v1
add dl,30h
mov ah,02h
int 21h
call crlf

mov dx,offset mes2
mov ah,09h
int 21h
mov dl,v2
add dl,30h
mov ah,02h
int 21h
call crlf

mov dx,offset mes3
mov ah,09h
int 21h
mov dl,v3
add dl,30h
mov ah,02h
int 21h
call crlf

mov dx,offset mes4
mov ah,09h
int 21h
mov dl,v4
add dl,30h
mov ah,02h
int 21h
call crlf

mov dx,offset mes5
mov ah,09h
int 21h
mov dl,v5
add dl,30h
mov ah,02h
int 21h
call crlf
exit:
ret
count endp

crlf proc near;回车换行子程序
mov dl,0ah
mov ah,02h
int 21h
mov dl,0dh
mov ah,02h
int 21h
ret
crlf endp

code ends
end start