作业题,题目要求是把ARY数组里的100个数求和,放在sum里。写了下面的程序,请高手帮忙挑错。sum是dw型的变量,请问各位有什么办法能把它显示出来,谢谢!
data segment
ARY dw 100 dup(1)
sum dw 0
data ends
code segment
assume ds:data,cs:code
start: sub ax,ax
mov ax,data
mov ds,ax
mov cx,99
mov di,0
LJ: mov bx,ARY[di]
add sum,bx
inc di
loopnz LJ
code ends
end start
------解决方案--------------------------------------------------------
你可以这样做
先把和放在ax中
然后mov cl,0ah
again: div cl
mov bl,ah
add bx,30h
push bx
cmp al,9
jg lp
mov bl,al
add bx,30h
push bx
jmp ou
lp:and ax,00ffh
jmp again
ou: pop dx
mov ah,02h
int 21h
cmp bp,sp
jg ou
这样做就可以显示你想要的结果了