📄 成绩统计与查询.asm
字号:
stu struc
sname db 15 dup(' ')
snumber db 9 dup(' ')
math dw ?
eng dw ?
chinese dw ?
ave dw ?
mathout db ?
engout db ?
chineseout db ?
aveout db ?
stu ends
;
data segment
student1 stu <'changdongsheng$','05055113$',85,80,90,0,0,0,0,0>
student2 stu <'chenhaibo $','05055114$',81,79,91,0,0,0,0,0>
student3 stu <'duyankang $','05055115$',90,91,92,0,0,0,0,0>
student4 stu <'jishengqiang $','05055116$',84,83,89,0,0,0,0,0>
student5 stu <'jindaoyuan $','05055117$',80,81,80,0,0,0,0,0>
student6 stu <'lanjingjie $','05055118$',70,75,80,0,0,0,0,0>
student7 stu <'liyunchuan $','05055119$',80,75,83,0,0,0,0,0>
student8 stu <'heqihui $','05055120$',88,84,90,0,0,0,0,0>
student9 stu <'hongcan $','05055121$',83,82,89,0,0,0,0,0>
student10 stu <'guoguanhua $','05055122$',80,78,83,0,0,0,0,0>
student11 stu <'duanyue $','05055123$',86,85,91,0,0,0,0,0>
student12 stu <'weixinghua $','05055124$',80,81,80,0,0,0,0,0>
student13 stu <'yanpan $','05055125$',87,86,93,0,0,0,0,0>
student14 stu <'zengyifei $','05055126$',70,73,80,0,0,0,0,0>
student15 stu <'wanghongtao $','05055127$',69,70,81,0,0,0,0,0>
student16 stu <'wangbo $','05055128$',88,89,93,0,0,0,0,0>
student17 stu <'tianfeng $','05055129$',80,85,90,0,0,0,0,0>
student18 stu <'panchunhua $','05055130$',81,83,87,0,0,0,0,0>
student19 stu <'penghao $','05055131$',80,87,95,0,0,0,0,0>
student20 stu <'zhanghang $','05055132$',87,86,93,0,0,0,0,0>
address dw ?
number1 dw 0
number2 dw 0
number3 dw 0
number4 dw 0
number5 dw 0
string1 db 'input the way of paixu:1-math,2-eng,3-chinese,4-average$'
string2 db 'again y/n$'
string3 db 'above 90 point/percent:$'
string4 db 'above 80 point/percent:$'
string5 db 'above 70 point/percent:$'
string6 db 'above 60 point/percent:$'
string7 db 'below 60 point/pencent:$'
data ends
;
code segment
;
assume cs:code,ds:data
;
main proc far
start:
mov ax,data
mov ds,ax
;求各个学生的平均成绩
call Gaverage
;各种排序
first:
mov ah,02h
mov dl,0ah
int 21h
mov ah,02h
mov dl,0dh
int 21h
lea dx,string1
mov ah,09h
int 21h
mov dl,0ah
mov ah,02h
int 21h
mov dl,0dh
mov ah,02h
int 21h
mov ah,01h
int 21h
mov bl,al
mov ah,02h
mov dl,0ah
int 21h
mov dl,0dh
mov ah,02h
int 21h
mov al,bl
.if al=='1'
call paixumath
.elseif al=='2'
call paixueng
.elseif al=='3'
call paixuchinese
.elseif al=='4'
call paixuave
.endif
lea dx,string2
mov ah,09h
int 21h
mov ah,02h
mov dl,0ah
int 21h
mov ah,02h
mov dl,0dh
int 21h
mov ah,01h
int 21h
cmp al,'y'
jz first
back:
;成绩统计
call tongji
;
mov ah,02h
mov dl,0ah
int 21h
mov ah,02h
mov dl,0dh
int 21h
lea dx,string3
mov ah,09h
int 21h
mov ax,number1
call outputdata
mov ah,02h
mov dl,20h
int 21h
mov ax,number1
mov dx,0
mov bx,100
mul bx
mov bx,20
div bx
call outputdata
mov dl,25h
mov ah,02h
int 21h
;
mov ah,02h
mov dl,0ah
int 21h
mov ah,02h
mov dl,0dh
int 21h
lea dx,string4
mov ah,09h
int 21h
mov ax,number2
call outputdata
mov ah,02h
mov dl,20h
int 21h
mov ax,number2
mov dx,0
mov bx,100
mul bx
mov bx,20
div bx
call outputdata
mov dl,25h
mov ah,02h
int 21h
;
mov ah,02h
mov dl,0ah
int 21h
mov ah,02h
mov dl,0dh
int 21h
lea dx,string5
mov ah,09h
int 21h
mov ax,number3
call outputdata
mov ah,02h
mov dl,20h
int 21h
mov ax,number3
mov dx,0
mov bx,100
mul bx
mov bx,20
div bx
call outputdata
mov dl,25h
mov ah,02h
int 21h
;
mov ah,02h
mov dl,0ah
int 21h
mov ah,02h
mov dl,0dh
int 21h
lea dx,string6
mov ah,09h
int 21h
mov ax,number4
call outputdata
mov ah,02h
mov dl,20h
int 21h
mov ax,number4
mov dx,0
mov bx,100
mul bx
mov bx,20
div bx
call outputdata
mov dl,25h
mov ah,02h
int 21h
;
mov ah,02h
mov dl,0ah
int 21h
mov ah,02h
mov dl,0dh
int 21h
lea dx,string7
mov ah,09h
int 21h
mov ax,number5
call outputdata
mov ah,02h
mov dl,20h
int 21h
mov ax,number5
mov dx,0
mov bx,100
mul bx
mov bx,20
div bx
call outputdata
mov dl,25h
mov ah,02h
int 21h
;
mov ax,4c00h
int 21h
main endp
;求平均成绩函数
average proc near
push bx
push ax
mov ax,0
add ax,[si].math
add ax,[si].eng
add ax,[si].chinese
mov dl,3
div dl
mov ah,0
mov [si].ave,ax
pop ax
pop bx
ret
average endp
;求各个学生的平均成绩函数
Gaverage proc near
push si
push cx
mov cx,20
lea si,student1
next:
cmp cx,0
jz return
call average
add si,36
loop next
return:
pop cx
pop si
ret
Gaverage endp
;输出数据函数,数据放在AX中
outputdata proc near
push ax
mov bl,10
div bl
add ax,3030h
mov bx,ax
mov dl,bl
mov ah,02h
int 21h
mov dl,bh
mov ah,02h
int 21h
pop ax
ret
outputdata endp
;按数学成绩排序函数
paixumath proc near
push si
push cx
push ax
push bx
push dx
mov cx,20
next1:
cmp cx,0
jz return1
push cx
mov cx,20
lea si,student1
mov ax,0
next11:
cmp cx,0
jz four1
mov bl,[si].mathout
cmp bl,0
jnz second1
cmp [si].math,ax
jb second1
mov ax,[si].math
mov address,si
second1:
add si,36
dec cx
jmp next11
four1:
mov si,address
mov bl,1
mov [si].mathout,bl
lea dx,[si].sname
mov ah,09h
int 21h
mov dl,20h
mov ah,02h
int 21h
lea dx,[si].snumber
mov ah,09h
int 21h
mov dl,20h
mov ah,02h
int 21h
mov ax,[si].math
call outputdata
mov dl,0ah
mov ah,02h
int 21h
mov dl,0dh
mov ah,02h
int 21h
pop cx
dec cx
jmp next1
return1:
pop dx
pop bx
pop ax
pop cx
pop si
ret
paixumath endp
;按英语成绩排序函数
paixueng proc near
push si
push cx
push ax
push bx
push dx
mov cx,20
next2:
cmp cx,0
jz return2
push cx
mov cx,20
lea si,student1
mov ax,0
next22:
cmp cx,0
jz four2
mov bl,[si].engout
cmp bl,0
jnz second2
cmp [si].eng,ax
jb second2
mov ax,[si].eng
mov address,si
second2:
add si,36
dec cx
jmp next22
four2:
mov si,address
mov bl,1
mov [si].engout,bl
lea dx,[si].sname
mov ah,09h
int 21h
mov dl,20h
mov ah,02h
int 21h
lea dx,[si].snumber
mov ah,09h
int 21h
mov dl,20h
mov ah,02h
int 21h
mov ax,[si].eng
call outputdata
mov dl,0ah
mov ah,02h
int 21h
mov dl,0dh
mov ah,02h
int 21h
pop cx
dec cx
jmp next2
return2:
pop dx
pop bx
pop ax
pop cx
pop si
ret
paixueng endp
;按语文成绩排序函数
paixuchinese proc near
push si
push cx
push ax
push bx
push dx
mov cx,20
next3:
cmp cx,0
jz return3
push cx
mov cx,20
lea si,student1
mov ax,0
next33:
cmp cx,0
jz four3
mov bl,[si].chineseout
cmp bl,0
jnz second3
cmp [si].chinese,ax
jb second3
mov ax,[si].chinese
mov address,si
second3:
add si,36
dec cx
jmp next33
four3:
mov si,address
mov bl,1
mov [si].chineseout,bl
lea dx,[si].sname
mov ah,09h
int 21h
mov dl,20h
mov ah,02h
int 21h
lea dx,[si].snumber
mov ah,09h
int 21h
mov dl,20h
mov ah,02h
int 21h
mov ax,[si].chinese
call outputdata
mov dl,0ah
mov ah,02h
int 21h
mov dl,0dh
mov ah,02h
int 21h
pop cx
dec cx
jmp next3
return3:
pop dx
pop bx
pop ax
pop cx
pop si
ret
paixuchinese endp
;按平均成绩排序函数
paixuave proc near
push si
push cx
push ax
push bx
push dx
mov cx,20
next4:
cmp cx,0
jz return4
push cx
mov cx,20
lea si,student1
mov ax,0
next44:
cmp cx,0
jz four4
mov bl,[si].aveout
cmp bl,0
jnz second4
cmp [si].ave,ax
jb second4
mov ax,[si].ave
mov address,si
second4:
add si,36
dec cx
jmp next44
four4:
mov si,address
mov bl,1
mov [si].aveout,bl
lea dx,[si].sname
mov ah,09h
int 21h
mov dl,20h
mov ah,02h
int 21h
lea dx,[si].snumber
mov ah,09h
int 21h
mov dl,20h
mov ah,02h
int 21h
mov ax,[si].ave
call outputdata
mov dl,0ah
mov ah,02h
int 21h
mov dl,0dh
mov ah,02h
int 21h
pop cx
dec cx
jmp next4
return4:
pop dx
pop bx
pop ax
pop cx
pop si
ret
paixuave endp
;对该班同学成绩的统计函数
tongji proc near
push si
push cx
push bx
mov cx,20
lea si,student1
one:
mov bx,[si].ave
cmp bx,60
jb two
cmp bx,70
jb three
cmp bx,80
jb four
cmp bx,90
jb five
inc number1
jmp six
two:
inc number5
jmp six
three:
inc number4
jmp six
four:
inc number3
jmp six
five:
inc number2
jmp six
six:
add si,36
dec cx
jnz one
pop bx
pop cx
pop si
ret
tongji endp
;
code ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -