assume cs:code,ds:data,ss:stack
data segment
sum dw 0
score db 10 dup(80,70,60,90,90)
avg db 0
max db 0
min db 0FFh
msg1 db 'The average is',0ah,0dh,'$’
msg2 db 'The maxnum is',0ah,0dh,'$’
msg3 db 'The minnum is',0ah,0dh,'$’
data ends
stack segment
dw 10 dup (?)
stack ends
code segment
start:
mov ax,data
mov ds,ax
mov ax,0
mov di,ax
mov cx,50
mov bx,offset score
comp: mov ah,0
mov al,[bx+di]
inc di
cmp al,min
jc minc
iend: cmp al,max
jnc maxc
aend: add ax,sum
mov sum,ax
loop comp
mov ax,sum
mov bx,50
div bx
mov avg,al
mov cx,3
mov bx,0
jmp show
table dw offset msg1,offset msg2,offset msg3,offset avg,offset max,offset min
show:
mov dx,table[bx]
mov ah,09h
int 21h
sub dx,dx
mov dx,table[bx+3] ;--------------------------------这里出错,前面是筛选最大最小和求平均值,没问题
mov ax,dx
mov si,ax
mov al,[si] ;这里是显示数值,后面都是显示的命令 应该也没问题
mov ah,0
mov dl,10
div dl
mov dx,ax
add dl,30h
mov ah,02h
int 21h
mov dl,dh
add dl,30h
mov ah,02h
int 21h
inc bx
loop show
mov ax,4c00h
int 21h
minc: mov min,al
jmp iend
maxc: mov max,al
jmp aend
code ends
end start