急求一道汇编的题目,要求用最简单的方法编程

设计程序,实现10个字节的求和、求平均值。
用8086汇编语言编写

用什么编程语言追问

8086

追答

stack segment stack
db 1024 dup(0)
stack ends
data segment
shu db 10,20,55,65,75,87,57,55,44,13
count dw 10
data ends ;定义十个数
code segment 'code'
assume cs:code,ds:data, ss:stack ;定义代码逻辑段,段名code。
start: mov ax,data
mov ds,ax
lea si,shu

mov cx,count ;为计数跳转做准备

mov ax,0
mov bx,0
s:
mov bl,[si]
add ax,bx ;s程序段把十个数加起来保存到ax中。
inc si
loop s

mov cx,count
div cl ;ah --- yushu al ---- shang
mov bx,ax
mov ah,0
div cl ;ah ---- gewei al ---- shiwei
mov ch,ah
mov dl,al
mov ah,02h
add dl,30h
int 21h
mov dl,ch
add dl,30h
int 21h
mov dl,'.'
int 21h

mov cl,10
mov ax,0
mov al,bh
mul cl
div byte ptr count
mov dl,al
add dl,30h
mov ah,02h
int 21h

mov ah,4ch
int 21h
code ends
end start

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-04-13
最简单的方法:

MOV AX, 0
LEA BX, BUF ;取10个字节数的起始地址
MOV CX, 10
MOV DH, 0
HE:
MOV DL, [BX]
ADD AX, DX
INC BX
LOOP HE

MOV CX, AX ;和,存放到CX
MOV BL, 10
DIV BL ;平均值存放在AL

RET

END
第2个回答  2014-04-13
楼上是正解,采纳它吧
相似回答