发布网友 发布时间:2022-04-23 15:41
共1个回答
热心网友 时间:2023-10-08 18:57
;以下和你要求的差不多,改改就可以用,有什么不懂得可以问我
data segment
credit dw 76,69,84,90,73,88,99,63,100,80
mes1 db '60-69:$'
mes2 db '70-79:$'
mes3 db '80-:$'
mes4 db '90-99:$'
mes5 db '100:$'
v1 db ? ;60-69段人数计数器
v2 db ? ;70-79段人数计数器
v3 db ? ;80-段人数计数器
v4 db ? ;90-99段人数计数器
v5 db ? ;100段人数计数器
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,60
jl m6
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,
jg m4 ;80-
inc v3
jmp m6
m4:cmp bx,99
jg m5 ;90-99
inc v4
jmp m6
m5:cmp bx,100
jg m6 ;100
inc v5
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
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