编码不容易,望能帮到楼主。。楼主好好看
CRLF MACRO ;宏定义,实现回车换行
MOV AH, 2
MOV DL, 0DH
INT 21H
MOV AH, 2
MOV DL, 0AH
INT 21H
ENDM
D SEGMENT
SCORE DB 76,69,84,90,73,88,89,63,100,80 ; 数组接收分数
S DB 5 DUP(?) ; 预留5个位置存储每个分数段的人数
WORDS DB "THE NUMBER BETWEEN 60~69 IS: $"
WORDS1 DB "THE NUMBER BETWEEN 70~79 IS: $"
WORDS2 DB "THE NUMBER BETWEEN 80~89 IS: $"
WORDS3 DB "THE NUMBER BETWEEN 90~99 IS: $"
WORDS4 DB "THE NUMBER BETWEEN 100 IS: $"
D ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:D
BG:
MOV AX,D
MOV DS,AX
CALL COUNT ; 调用子程序
MOV AH,9 ; 输出每个分数段的人数
LEA DX,WORDS
INT 21H
MOV AH,2
MOV DL,S
ADD DL,30H
INT 21H
CRLF
MOV AH,9
LEA DX,WORDS1
INT 21H
MOV AH,2
MOV DL,S+1
ADD DL,30H
INT 21H
CRLF
MOV AH,9
LEA DX,WORDS2
INT 21H
MOV AH,2
MOV DL,S+2
ADD DL,30H
INT 21H
CRLF
MOV AH,9
LEA DX,WORDS3
INT 21H
MOV AH,2
MOV DL,S+3
ADD DL,30H
INT 21H
CRLF
MOV AH,9
LEA DX,WORDS4
INT 21H
MOV AH,2
MOV DL,S+4
ADD DL,30H
INT 21H
CRLF
MOV AH,4CH
INT 21H
COUNT: ; 子程序入口
MOV CX,10 ; 循环 10次
MOV SI,0
LOP:
INT 3
MOV AL,SCORE[SI]
CMP AL,70
JB NUMBER6 ; 比较进入不同的标号进行计算每个分数段人数
CMP AL,80
JB NUMBER7
CMP AL,90
JB NUMBER8
CMP AL,100
JE NUMBER10
JMP NUMBER9
NUMBER6: ; 不同标号之下的作用是计算每个分数段人数并存于预留的位置中
MOV BL,S
INC BL
MOV S,BL
JMP L
NUMBER7:
MOV BL,S+1
INC BL
MOV S+1,BL
JMP L
NUMBER8:
MOV BL,S+2
INC BL
MOV S+2,BL
JMP L
NUMBER9:
MOV BL,S+3
INC BL
MOV S+3,BL
JMP L
NUMBER10:
MOV BL,S+4
INC BL
MOV S+4,BL
JMP L
L:
INC SI
LOOP LOP
RET ; 子程序结束,放回主程序
CODE ENDS
END BG
data segment
chengji db 76,69,84,90,73,88,89,63,100,80
s6 db ?
s7 db ?
s8 db ?
s9 db ?
s10 db ?
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
lea si,chengji
lea bx,s6
mov cx,10
next:cmp byte ptr[si],90
jge next1
cmp byte ptr[si],80
jge next2
cmp byte ptr[si],70
jge next3
inc byte ptr[bx]
inc si
loop next
next5:int 3h
next1:cmp byte ptr[si],100
jz next4
inc byte ptr[bx+3]
inc si
loop next
jmp next5
next2:inc byte ptr[bx+2]
inc si
loop next
jmp next5
next3:inc byte ptr[bx+1]
inc si
loop next
jmp next5
next4:inc byte ptr[bx+4]
inc si
loop next
jmp next5
code ends
end start