【文件属性】:
文件名称:显示学生名次 ams
文件大小:3KB
文件格式:ASM
更新时间:2013-07-12 08:04:08
学生名次 汇编
输入成绩,显示出学生的学号 成绩及名次DATAS SEGMENT
GRADE DB 50 DUP (?)
RANK DB 50 DUP (?)
STR1 DB 'please input the mark of class:','$'
str2 db 13,10,'$'
str3 db 'Num mark rank','$'
str4 db ' ','$'
str5 db 'input the number of the class(00~99):','$'
NUM dw ?
DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
call total
call input
call bijiao
call print
MOV AH,4CH
INT 21H
input proc
mov cx,num
mov si,0
mov dx,offset str1
mov ah,9
int 21h
call huanhang
D1: mov ah,1
int 21h
sub al,30h
cbw
push cx
mov cx,10
mul cx
add bx,ax
mov ah,1
int 21h
sub al,30h
cbw
add bx,ax
mov ax,bx
pop cx
mov bx,offset grade
mov [bx+si],ax
inc si
call huanhang
loop d1
ret
input endp
huanhang proc
mov dx,offset str2
mov ah,9
int 21h
ret
huanhang endp
bijiao proc
mov si,0
sub num,1
d0:
mov dl,1
mov bx,0
mov al,grade[si]
d3:
cmp al,grade[bx]
jl d4
jmp d2
d4:
inc dl
jmp d2
d2:
inc bx
cmp bx,num
jng d3
mov rank[si],dl
inc si
cmp si,num
jng d0
ret
bijiao endp
print proc
mov dx,offset str3
mov ah,9
int 21h
call huanhang
mov si,0
n2:
push si
inc si
mov ax,si
mov dh,10
div dh
mov bl,ah
add al,30h
mov ah,2
mov dl,al
int 21h
add bl,30h
mov ah,2
mov dl,bl
int 21h
call kongge
pop si
push si
mov al,grade[si]
mov dh,10
cbw
div dh
mov bl,ah
add al,30h
mov ah,2
mov dl,al
int 21h
add bl,30h
mov ah,2
mov dl,bl
int 21h
call kongge
pop si
mov al,rank[si]
cbw
mov dh,10
div dh
mov bl,ah
add al,30h
mov ah,2
mov dl,al
int 21h
add bl,30h
mov ah,2
mov dl,bl
int 21h
jmp n0
n0:
call huanhang
inc si
cmp si,num
jng n2
ret
print endp
kongge proc
mov dx,offset str4
mov ah,9
int 21h
ret
kongge endp
total proc
push cx
push ax
push bx
lea dx,str5
mov ah,9
int 21H
mov ah,1
int 21H
sub al,30H
mov ah,0
mov cx,10
mul cx
mov bx,ax
mov ah,1
int 21h
mov ah,0
sub al,30H
add bx,ax
mov num,bx
call huanhang
pop bx
pop ax
pop cx
RET
TOTAL ENDP
CODES ENDS
END START