题目描述:在首地址为data1的子数组中,存放了100H个16位补码数,编写一个程序求出它们的平均值放在地址aver中,并求出数组中有多少个数大于此数,将结果放进count.
代码:
data segment
data1 dw 100H dup(?)
aver dw 0
count dw 0
data ends
code segment
assume ds:data,cs:code
start:
mov ax,data
mov ds,ax
mov cx,100H
mov si,0
mov bx,0
mov di,0
mov dx,0
loop1:
mov ax,data1[si]
cwd
add bx,ax
adc di,dx
add si,2
loop loop1
mov dx,di
mov ax,bx
mov cx,100H
div cx
mov aver,ax
mov si,0
mov cx,100H
loop2:
cmp ax,data1[si]
jbe next
inc count
add si,2
loop loop2
next:
add si,2
loop loop2
mov ah,4Ch
int 21h
code ends
end start
本次内容没用使用100H作为测试,使用10个作为测试通过