当前位置:首页 > 正文

求助:一道简单的汇编语言程序设计

作者:小雪发布时间:2023-03-02浏览:468


8086汇编语言,使用masm5汇编器编译通过
data segment
score db 30,40,50,60,70,80,90,67,70 ;9个学生的分数
num_under60 db 0 ;60以下的人数
num_60to69 db 0 ;60到69的人数
num_70to79 db 0 ;70到79的人数
num_80to89 db 0 ;80到89的人数
num_90to99 db 0 ;90到99的人数
num_100 db 0 ;100的人数
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
xor ax,ax
mov cx,9 ;循环9次
lea bx,score
compare:
cmp byte ptr [bx],60 ;与60比较
jl under60
jmp is60to69
is60to69:
cmp byte ptr [bx],70 ;与70比较
jl _60to69
jmp is70to79
is70to79:
cmp byte ptr [bx],80 ;与80比较
jl _70to79
jmp is80to89
is80to89:
cmp byte ptr [bx],90 ;与90比较
jl _80to89
jmp is90to99
is90to99:
cmp byte ptr [bx],100 ;与100比较
jl _90to99
jz equal100
under60: ;如果低于60
add num_under60,1
jmp con
_60to69: ;如果在60到69之间
add num_60to69,1
jmp con
_70to79: ;如果在70到79之间
add num_70to79,1
jmp con
_80to89: ;如果在80到89之间
add num_80to89,1
jmp con
_90to99: ;如果在90到99之间
add num_90to99,1
jmp con
equal100: ;如果等于100
add num_100,1
con:
lea bx,[bx+1]
loop compare
last: ;输出
mov dl,num_under60 ;输出60以下的人数
add dl,30h
mov ah,2
int 21h
mov dl,num_60to69 ;输出60到69的人数
add dl,30h
mov ah,2
int 21h
mov dl,num_70to79 ;输出70到79的人数
add dl,30h
mov ah,2
int 21h
mov dl,num_80to89 ;输出80到89的人数
add dl,30h
mov ah,2
int 21h
mov dl,num_90to99 ;输出90到99的人数
add dl,30h
mov ah,2
int 21h
mov dl,num_100 ;输出100的人数
add dl,30h
mov ah,2
int 21h
mov ah,4ch ;返回DOS
int 21h
code ends
end start


声明:部分资源转载自互联网,转载目的在于传递更多知识,并不代表本网赞同其观点和对其真实性负责。如有侵权或者知识有谬误之处,麻烦通知删除,谢谢!联系方式: zzsla2022#163.com