汇编语言 分数段
汇编语言 设有一个数组存放学生的成绩(0100),编制一个子程序统计059分,60~69分, 70~79分, 80~89分,90~100分的人数,并分别存放到scoreE, scoreD, scoreC, scoreB, scoreA单元中,编写一~个主程序与之配合使用。
源程序:
stack segment stack
dw 512 dup(?)
stack ends
data segment
score db 30,33,67,59,69,78,81,100,83,84,93
count equ($-score)/type score
scoreA db 30h
scoreB db 30h
scoreC db 30h
scoreD db 30h
scoreE db 30h
data ends
code segment 'code'
assume cs:code,ds:data,ss:stack
start:
mov ax,data
mov ds,ax
call scores
mov bl,scoreA
call counts
mov dl,20h
mov ah,02h
int 21h
mov bl,scoreB
call counts
mov dl,20h
mov ah,02h
int 21h
mov bl,scoreC
call counts
mov dl,20h
mov ah,02h
int 21h
mov bl,scoreD
call counts
mov dl,20h
mov ah,02h
int 21h
mov bl,scoreE
call counts
mov ax,4c00h
int 21h
scores proc
xor si,si
mov cx,count
lop: cmp score[si],0
jb last
cmp score[si],60
jb se
cmp score[si],70
jb sd
cmp score[si],80
jb sc
cmp score[si],90
jb sb
cmp score[si],101
jb sa
jmp last
sa: inc scoreA
jmp last
sb: inc scoreB
jmp last
sc: inc scoreC
jmp last
sd: inc scoreD
jmp last
se: inc scoreE
last: inc si
loop lop
ret
scores endp
counts proc
mov bh,30h
cmp bl,39h
ja s1
mov dl,bl
mov ah,02h
int 21h
jmp there
s1: sub bl,0ah
inc bh
cmp bl,39h
ja s1
mov dl,bh
mov ah,02h
int 21h
mov dl,bl
mov ah,02h
int 21h
there: ret
counts endp
code ends
end start