📄 6-24.asm
字号:
;统计分数求平均分
data segment
num1 db 15h
db 0
db 15h dup(0)
num2 db 7h dup(0)
num3 db 0
num4 db 0
num5 db 0
string1 db 0ah,0dh,'$'
string2 db 'Please enter the scores:','$'
string3 db 'The average is:','$'
string4 db 'the number you dial is incorroct!!!!',0ah,0dh,'$'
data ends
stack1 segment para stack
db 20h dup(0)
stack1 ends
coseg segment
assume cs:coseg,ds:data,ss:stack1
start: mov ax,data
mov ds,ax
mov dx,offset string2
mov ah,09h
int 21h
mov dx,seg num1
mov ds,dx
mov dx,offset num1
mov ah,0ah
int 21h
mov dx,offset string1
mov ah,09h
int 21h
mov si,2
xor cx,cx
mov cl,14h
dec30: sub num1[si],30h
inc si
loop dec30
mov si,1
mov di,0
mov cx,7h
hebin: inc si
mov al,0ah
mul num1[si]
inc si
add al,num1[si]
mov num2[di],al
cmp num2[di],0ah
js error
cmp num2[di],15h
jns error
inc si
inc di
loop hebin
mov cx,7
mov si,0
mov ah,num2[si]
jmp jia
error: mov dx,offset string4
mov ah,09h
int 21h
jmp start
jia: inc si
mov al,num2[si]
add ah,al
loop jia
mov num3,ah
mov dx,offset string3
mov ah,09h
int 21h
mov cx,7
mov si,0
mov bh,num2[si]
lop1: dec cx
lop2: jcxz next1
inc si
cmp bh,num2[si]
jnc lop1
xchg num2[si],bh
loop lop2
next1: sub num3,bh
mov cx,7
mov si,0
mov bh,num2[si]
lop3: dec cx
lop4: jcxz next2
inc si
cmp bh,num2[si]
jc lop3
xchg num2[si],bh
loop lop4
next2: sub num3,bh
xor ax,ax
mov cl,5
mov al,num3
div cl
cmp al,14h
je jiac
add al,6
jmp next3
jiac: add al,0ch
next3: mov num4,al
mov num5,ah
mov cl,4
shr al,cl
add al,30h
mov dl,al
mov ah,02h
int 21h
mov al,num4
and al,0fh
add al,30h
mov dl,al
mov ah,02h
int 21h
mov dl,'.'
mov ah,02h
int 21h
mov dl,num5
mov al,02h
mul dl
mov dl,al
add dl,30h
mov ah,02h
int 21h
mov ah,4ch
int 21h
coseg ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -