📄 汇编学生成绩 管理.txt
字号:
data segment
sno db '123456789'
sname db 25 dup(' ')
chn db 10 dup(?)
math db 10 dup(?)
physic db 10 dup(?)
che db 10 dup(?)
english db 10 dup(?)
total dw 5h,6h,2h,1h,0h,0h,0h,0h,0h,0h
msg0 db 'input the name of student $'
msg1 db 'input the chinese score of student $'
msg2 db 'input the math score of student $'
msg3 db 'input the physic score of student $'
msg4 db 'input the chemistry score of student $'
msg5 db 'input the english score of student $'
msg6 db 'input the number of students : $'
msg7 db 'No. chinese math physic chem eng total name $'
count dw ?
countj dw ?
counti dw ?
totalS dw ?
we dw ?
temp db ?
number dw ?
data ends
;*************************************************************************
;main start from here
code segment
;main proc far
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
jmp here
here:
lea dx,msg6 ;cin the number of student
mov ah,09h
int 21h
mov ah,1
int 21h
sub al,30h
mov ah,0
mov number,ax ;put the number in mem
mov dl,0dh
call dispchar
mov dl,0ah
call dispchar
mov cx,number
ll:
mov bx,number ;cin the students' name
sub bx,cx
mov count,bx ;count the number
call cinname
mov dl,0dh
call dispchar
mov dl,0ah
call dispchar
loop ll
mov cx,number ;cin the score of the student
ll1:
mov bx,number
sub bx,cx
mov count,bx
call cinnum
mov dl,0dh
call dispchar
mov dl,0ah
call dispchar
loop ll1
; put the title of interface
lea dx,msg7
mov ah,09h
int 21h
mov dl,0dh
call dispchar
mov dl,0ah
call dispchar
mov cx,number ;display the information you have just input
ll5:
mov bx,number
sub bx,cx
mov count,bx
call outshow
loop ll5
call sort ;sort the total
;put out the title
lea dx,msg7
mov ah,09h
int 21h
mov dl,0dh
call dispchar
mov dl,0ah
call dispchar
mov cx,number ;display the information again
lla:
mov bx,number
sub bx,cx
mov count,bx
call outshow
loop lla
int 3
mov ax,4c00h
int 21h
;*************************************************************************
;input the name of the student
cinname proc near
push di
push dx
push bx
push cx
lea dx,msg0
mov ah,09h
int 21h
call nice
lea cx,sname
mov di,0
newchar:
mov ah,1
int 21h
cmp al,08h ;deal with 'back space'
jz n
cmp al,65d
jl exit
cmp al,90d ;the char just input shoud between 'a'~'z' or 'A'~'Z'
jl l
cmp al,97d ;or exit
jl exit
cmp al,122d
jg exit
l:
mov si,ax ;count the address
mov ax,count
mov bx,0ah
mul bx
add ax,di
xchg si,ax
mov bx,cx
mov [bx+si],al
inc di
mov bx,di
cmp bx,9d
jg exit
jmp newchar
n: ;deal with 'back space'
dec di
mov bx,di
cmp bx,0
jl m
jmp newchar
m:inc di ;di count the number of char in the word
jmp newchar
exit:
pop cx
pop bx
pop dx
pop di
ret
cinname endp
;***************************************************************************
;get number from keyboard
getnum proc near
mov bx,0
newcharn:
mov ah,1
int 21h
sub al,30h ;change the number from ascll to value
jl exitn
cmp al,9d
jg exitn
xchg ax,bx
mov cx,10d
mul cx
xchg ax,bx
add bx,ax
jmp newcharn
exitn:
ret
getnum endp
;****************************************************************************
;input the score
cinnum proc near
push ax
push bx
push cx
push dx
mov cx,0
mov totalS,cx ;count the total of students' score
mov cx,6
ll2:
mov di,6
sub di,cx
mov si,cx
lea dx,chn
mov countj,dx
cmp di,5 ;di==5 go to write the total
jz nog
call puthelp
call getnum
mov ax,di
mul cx
mov cx,count
add ax,cx
xchg ax,si
mov dx,countj
xchg dx,bx
mov [bx+si],dl
mov dh,0
add totalS,dx ;add the number to total
xchg ax,si
mov cx,si
mov dl,0dh
call dispchar
mov dl,0ah
call dispchar
loop ll2
jmp goe
nog: ;deal with the total
mov ax,di
mov cx,10d
mul cx
mov cx,count
add ax,cx
add ax,cx
xchg ax,si
mov dx,countj
mov bx,totalS
xchg dx,bx
mov [bx+si],dx
goe:
pop dx
pop cx
pop bx
pop ax
ret
cinnum endp
;************************************************************************
;show interface puthelp
puthelp proc near
push ax
push bx
push cx
push dx
cmp di,0
jz m1
cmp di,1
jz m2
cmp di,2
jz m3
cmp di,3
jz m4
cmp di,4
jz m5
jmp ex
m1: ;chose the message
lea dx,msg1
mov ah,09h
int 21h
call nice
jmp ex
m2:
lea dx,msg2
mov ah,09h
int 21h
call nice
jmp ex
m3:
lea dx,msg3
mov ah,09h
int 21h
call nice
jmp ex
m4:
lea dx,msg4
mov ah,09h
int 21h
call nice
jmp ex
m5:
lea dx,msg5
mov ah,09h
int 21h
call nice
ex:
pop dx
pop cx
pop bx
pop ax
ret
puthelp endp
;**********************************************************************
;to put num out in dex
;countnum
countnum proc near
push ax
push bx
push cx
push dx
push di
push si
mov cx,3
mov di,100d
ll4:
mov ax,dx
mov dx,0
div di ;div 100d 10d 1d
cmp ax,9d
jg exitnum
mov bx,dx
add al,30h
mov dl,al
call dispchar
mov ax,di
mov dx,0
mov di,10d
div di
mov di,ax
mov dx,bx
loop ll4
exitnum:
pop di
pop si
pop dx
pop cx
pop bx
pop ax
ret
countnum endp
;*********************************************************************
;to put out the message outshow
outshow proc near
push ax
push bx
push cx
push dx
mov dl,0h ;put out the No. of the student
call dispchar
mov dl,0h
call dispchar
lea bx,sno
mov si,count
mov dl,[bx+si]
call dispchar
mov dl,09h
call dispchar
mov cx,6 ;put out the score of the student
ll3:
mov di,6
sub di,cx
mov si,cx
lea dx,chn
mov countj,dx
cmp di,5
jz nog2
mov ax,di
mov cx,10d
mul cx
mov cx,count
add ax,cx
xchg ax,si
mov dx,countj
xchg dx,bx
mov dl,[bx+si]
;mov dl,65d
mov dh,0
call countnum
xchg ax,si
mov cx,si
mov dl,09h
call dispchar
loop ll3
jmp goe2
nog2: ;put out the total
mov ax,di
mov cx,10d
mul cx
mov cx,count
add ax,cx
add ax,cx
xchg ax,si
mov dx,countj
;mov dx,258d
xchg dx,bx
mov dx,[bx+si]
call countnum
mov dl,09h
call dispchar
goe2:
mov cx,10 ;put out the name
ll6:
mov si,10
lea dx,sname
sub si,cx
mov ax,count
mov bx,10d
mul bx
add si,ax
mov bx,dx
add si,9d
mov dl,[bx+si]
call dispchar
loop ll6
mov dl,0dh
call dispchar
mov dl,0ah
call dispchar
pop dx
pop cx
pop bx
pop ax
ret
outshow endp
;********************************************************************
;tomake the interface nice
nice proc near
mov dx,count ;to show the value of count
add dx,31h
call dispchar
mov dl,0h
call dispchar
mov dl,58d
call dispchar
mov dl,0h
call dispchar
ret
nice endp
;*************************************************************************
;act
act proc near
mov di,counti ;do chang the char in place counti and countj
mov dx,countj
mov temp,dl
mov si,di
mov ax,we
xchg si,ax
mul si
xchg si,ax
mov dl,temp
mov dh,0
mov di,dx
mov ax,we
xchg di,ax
mul di
xchg di,ax
mov al,[bx+si]
mov cl,[bx+di]
xchg cl,al
mov [bx+si],al
mov [bx+di],cl
ret
act endp
;**************************************************************************
;exchang the two line chg
chg proc near
push ax
push bx
push cx
push dx
push di
push si
jmp there
there:
lea bx,sno ;change No.
mov ax,1
mov we,ax
call act
mov ch,0 ;chang name
mov cl,10d
mov we,cx ;the weight is 10d
ll13:
lea bx,sname
add bl,ch
adc bh,0
call act
inc ch
cmp ch,10
jl ll13
mov ch,0 ;chang score
lea bx,chn
ll14:
mov ax,1
mov we,ax
call act
add bx,10d
inc ch
cmp ch,5
jl ll14
lea bx,total ;chang total
mov ax,2
mov we,ax ;the weight is 2
call act
add bx,1
call act
pop di
pop si
pop dx
pop cx
pop bx
pop ax
ret
chg endp
;***************************************************************************
;to put the totals int the right place
sort proc near
lea bx,total
mov cx,10 ;counter of the number of students
ll8:
mov dx,10
mov counti,dx
sub counti,cx
mov dx,counti
ll7:
mov countj,dx
mov si,counti
add si,si
mov dx,[bx+si] ;sort the information by total
mov si,countj
add si,si
mov ax,[bx+si]
cmp ax,dx
jl skip
jz skip
call chg
skip:
mov dx,countj
inc dx
cmp dx,10
jl ll7
loop ll8
sort endp
;*********************************************************************
;dispchar
dispchar proc near ;put out a char
mov ah,2
int 21h
ret
dispchar endp
code ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -