汇编(输入成绩20个,进行分类,别人的作业,我帮着做的)

汇编(输入成绩20个,进行分类,别人的作业,我帮着做的)_第1张图片

s5为60分以下,s6为60-69,依这个类推

汇编(输入成绩20个,进行分类,别人的作业,我帮着做的)_第2张图片



assume cs:code,ds:data,ss:stack
data segment
inform db 0dh,0ah,"please input number:$"
ins5 db 0dh,0ah,"s5:$"
ins6 db 0dh,0ah,"s6:$"
ins7 db 0dh,0ah,"s7:$"
ins8 db 0dh,0ah,"s8:$"
ins9 db 0dh,0ah,"s9:$"
ins10 db 0dh,0ah,"s10:$"
;s5 db 6 dup(0)
s5 dw 0
s6 dw 0
s7 dw 0
s8 dw 0
s9 dw 0
s10 dw 0
sum dw 0
buf db 50
db ?
db 50 dup(?)

data ends

stack segment stack
    db 200 dup(0)
stack ends

code segment
start:
mov ax,data
mov ds,ax
;---显示
lea dx,inform
mov ah,9
int 21h
;---输入
lea dx,buf
mov ah,10
int 21h
mov cl,buf+1;--实际字符个数
mov ch,0
cmp cx,1
jnz rs
inc cx
rs:
call ifs

;--------
mov cx,6
mov bx,offset ins5
mov si,offset s5
ggs:
lea dx,[bx]
mov ah,9
int 21h
add bx,6

mov dl,BYTE ptr[si]
call intTochar


inc si
inc si

loop ggs

;---

mov ax,4c00h
int 21h

ifs proc near
push cx
cmp cx,0
jz s4

dec cx

lea si,buf+2
ts:inc si
loop ts
pop cx
mov bx,10
mov ax,1
s:
push ax
mov dl,BYTE ptr[si]
mov dh,0

sub dl,30h
cmp dl,0
;---低于0跳转
jb hs
cmp dl,9
;---高于9跳转
ja hs

mul dl
add sum,ax
pop ax
mul bx
dec si
jmp s3

hs:
pop ax
dec si
call pd
s3:
loop s
call pd
s4:
ret
ifs endp

pd proc near

push ax
push bx
push cx
push dx
mov ax,sum
cmp ax,0
jz s11
cmp ax,60
jb ss5
cmp ax,70
jb ss6
cmp ax,80
jb ss7
cmp ax,90
jb ss8
cmp ax,100
jb ss9
cmp ax,100
jz ss10
jmp s11




ss5:inc BYTE ptr[s5]
jmp s11
ss6:inc BYTE ptr[s6]
jmp s11
ss7:inc BYTE ptr[s7]
jmp s11
ss8:inc BYTE ptr[s8]
jmp s11
ss9:inc BYTE ptr[s9]
jmp s11
ss10:inc BYTE ptr[s10]

s11:
mov ax,0
mov sum,ax
pop dx
pop cx
pop bx
pop ax
mov ax,1
ret
pd endp

;---不用担心超过100
intTochar proc near
push ax
push bx
push cx
push dx
mov al,dl
mov ah,0
cmp ax,10
jb bs
mov bl,10
div bl
add al,30h
mov cl,al
add ah,30h
mov ch,ah
mov dl,cl
mov ah,2
int 21h
mov dl,ch
mov ah,2
int 21h

mov dl,al
jmp bs2

bs:
add dl,30h

mov ah,2
int 21h
bs2:
pop dx
pop cx
pop bx
pop ax
ret

ret
intTochar endp

code ends
end start




你可能感兴趣的:(汇编)