大作业.asm
来自「该程序用于实现学生数据库管理」· 汇编 代码 · 共 961 行 · 第 1/2 页
ASM
961 行
failed endp
outfname proc near
mov bx,0
mov cl,count
nextgo1:cmp student[bx][si],60;成绩和60比较,小于则打出名单
jb outname1
add bl,x
loop nextgo1
jmp failquit
outname1:call output;打出不及格同学名单
add bl,x
loop nextgo1
failquit:ret
outfname endp
sort proc near
cmp count,0
je exit1
redo: lea dx,ChoSort
mov ah,9
int 21h
mov ah,1
int 21h
sub al,30h
js error2
cmp al,5
ja error2
cmp al,1
je sort1
cmp al,2
je sort2
cmp al,3
je sort3
cmp al,4
je sorta
jmp exit1
sort1: call sortsco1
call outorder
jmp redo
sort2: call sortsco2
call outorder
jmp redo
sort3: call sortsco3
call outorder
jmp redo
sorta: call sortscoa
call outorder
jmp redo
error2: lea dx,InpErr
mov ah,9
int 21h
jmp redo
exit1: ret
sort endp
initrate proc near
mov cl,count
mov bl,0
mov di,0
initial:mov rateinfo[di],bl
inc di
add bl,x
loop initial;初始化学生排名
ret
initrate endp
sortall proc near
push ax
push bx
push di
push cx
call initrate
mov cl,count
dec cx
jz sortquit;只有一名学生,则不必排名
;以下代码为冒泡排序
loop1: mov di,0
mov bl,rateinfo[di]
push cx
loop2: mov al,student[bx][si]
inc di
mov bl,rateinfo[di]
cmp al,student[bx][si]
jae continue
call ratechg
continue:loop loop2
pop cx
loop loop1
sortquit:pop cx
pop di
pop bx
pop ax
ret
sortall endp
outorder proc near
;输出排序后的学生信息
mov cl,count
mov di,0
outnext:mov bl,rateinfo[di]
call ctrlf
call output
mov ah,0
call outscore
inc di
loop outnext
ret
outorder endp
sortsco1 proc near
mov si,15
call sortall
ret
sortsco1 endp
sortsco2 proc near
mov si,16
call sortall
ret
sortsco2 endp
sortsco3 proc near
mov si,17
call sortall
ret
sortsco3 endp
ratechg proc near
;交换排名
mov al,rateinfo[di-1]
xchg al,rateinfo[di]
mov rateinfo[di-1],al
mov bl,rateinfo[di]
ret
ratechg endp
sortscoa proc near
push ax
push bx
push di
mov si,18
call initrate
mov cl,count
dec cx
loop3: mov di,0
mov bl,rateinfo[di]
push cx
loop4: mov ah,student[bx][19]
inc di
mov bl,rateinfo[di]
cmp ah,student[bx][19];先比较成绩的高位
ja continue1
je carryon;高位相等则比较低位
call ratechg
jmp continue1
carryon:dec di
mov bl,rateinfo[di]
mov al,student[bx][si]
inc di
mov bl,rateinfo[di]
cmp al,student[bx][si]
jae continue1
call ratechg
continue1:loop loop4
pop cx
loop loop3
pop di
pop bx
pop ax
ret
sortscoa endp
Stasum proc near
push dx
push ax
lea dx,staall
mov ah,9
int 21h
mov bx,0
mov dx,0
mov cl,count
readd: mov ah,student[bx][19]
mov al,student[bx][18]
add dx,ax;计算总分之和
add bl,x
loop readd
mov ax,dx
div count;计算总分平均
mov ah,0
mov dh,100
div dh
call outdigit
mov cl,1
mov flag,1
call sinscore
pop ax
pop dx
ret
Stasum endp
stasin proc near
push dx
push ax
push si
lea dx,stasingle1
mov ah,9
int 21h
mov si,15
call sinavg
lea dx,stasingle2
mov ah,9
int 21h
inc si
call sinavg
lea dx,stasingle3
mov ah,9
int 21h
inc si
call sinavg
pop si
pop ax
pop dx
ret
stasin endp
sinavg proc near
push ax
push bx
push dx
mov bx,0
mov dx,0
mov ah,0
mov cl,count
sagain: mov al,student[bx][si]
add dx,ax;计算单科成绩和
add bl,x
loop sagain
mov ax,dx
div count;计算单科成绩平均
mov ah,0
mov cl,1
mov flag,1
call sinscore
call ctrlf
pop dx
pop bx
pop ax
ret
sinavg endp
sinseg proc near
push dx
push ax
push si
lea dx,score1seg
mov ah,9
int 21h
mov si,15
call scoreseg
lea dx,score2seg
mov ah,9
int 21h
inc si
call scoreseg
lea dx,score3seg
mov ah,9
int 21h
inc si
call scoreseg
pop si
pop ax
pop dx
ret
sinseg endp
scoreseg proc endp
lea dx,sinsegment
mov ah,9
int 21h
mov dh,10
call rcount
ret
scoreseg endp
rcount proc near
push di
push si
push dx
push ax
push bx
push cx
mov cl,count
mov bx,0
recount: cmp segflag,0;如果segflag为1,则打出总分分数段;为0则打出单科分数段
jne ssum
mov ah,0
mov al,student[bx][si]
jmp skeep
ssum: mov al,student[bx][18]
mov ah,student[bx][19]
skeep: div dh
mov ah,0 ;做除法时余数存在ah中会影响结果
sub ax,5
jns made
mov ax,0
made: mov di,ax
inc segn[di]
add bl,x
loop recount
mov si,0
mov ah,0
mov cx,6
loopn: push cx
mov al,segn[si]
mov flag,1
mov cl,1
call sinscore
inc si
pop cx
loop loopn
mov di,0
mov cl,6
clear: mov segn[di],0
inc di
loop clear
mov segflag,0
pop cx
pop bx
pop ax
pop dx
pop si
pop di
ret
rcount endp
sumseg proc endp
lea dx,sumsegc
mov ah,9
int 21h
lea dx,sumsegment
mov ah,9
int 21h
mov bx,0
sumadd: mov al,student[bx][18]
mov ah,student[bx][19]
mov dh,30;隔30分为一个分数段
mov segflag,1
call rcount
ret
sumseg endp
statistic proc near
prompt1:lea dx,ChoSta
mov ah,9
int 21h
mov ah,1
int 21h
sub al,30h
js ierror
cmp al,5
ja ierror
cmp al,1
je stas
cmp al,2
je staa
cmp al,3
je stasn
cmp al,4
je staan
jmp exits
stas: call stasin
jmp quits
staa: call Stasum
jmp quits
stasn: call sinseg
jmp quits
staan: call sumseg
jmp quits
ierror: lea dx,InpErr
mov ah,9
int 21h
quits: jmp prompt1
exits: ret
statistic endp
display proc near
cmp count,0
je over1
mov cl,count
mov bx,0
rotate: call ctrlf
call output;打出名字
mov ah,0
call outscore;打出成绩
add bl,x
loop rotate
over1: ret
display endp
output proc near
push si
mov si,0
outname:cmp student[bx][si],'$'
je follow
mov dl,student[bx][si]
mov ah,2
int 21h
inc si
jmp outname
follow: call space
pop si
ret
output endp
outscore proc near
push cx
push di
mov di,15
mov cl,3
call sinscore
mov al,student[bx][18]
mov ah,student[bx][19]
mov dh,100
div dh
call outdigit
mov flag,1
mov cl,1
call sinscore
pop di
pop cx
ret
outscore endp
sinscore proc near
push dx
push ax
push di
next1: cmp flag,0;flag为0则不从student取数
jne jmpflag
mov al,student[bx][di]
cmp ax,100
je full
jmpflag:mov ah,0
div y;y=10
call outdigit
mov ah,0
call outdigit
jmp next2
full: lea dx,fullmark
mov ah,9
int 21h
next2: call space
inc di
loop next1
mov flag,0
pop di
pop ax
pop dx
ret
sinscore endp
outdigit proc near
mov dl,al
mov al,ah
push ax
add dl,30h;打出al的内容
mov ah,2
int 21h
pop ax
ret
outdigit endp
;*******************************************
CSEG ENDS
END START ; set entry point.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?