在下面的代码中
data segment
; add your data here!
num db 0,0,0,0
sum db 0
str db "Sum is : $"
ends
stack segment
dw 128 dup(0)
ends
code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax
;;read array from input
mov cx,4;set loop counter
L1:
mov ah,7;interupt 7 use for reading character without echo
int 21h
mov num,al;mov al to num
add sum,al
inc num;nex element
LOOP L1
sub num,4;go to first position
;;;;;;;;;;;;;;;;;;;;;;;;
;;show sum
lea dx,str;;-----------------I'm changing this line-----------------------
mov ah,9;interupt 9 for writing string
int 21h
;;;;;;;;;;;
mov ax, 4c00h ; exit to operating system.
int 21h
ends
end start ; set entry point and stop the assembler.
如果我将 dx 更改为 ax
lea dx,str --> lea ax,str
输出变成1 'Sum is
但是如果我使用lea ax,str
它是正确的>Sum is :
我想不通原因!
为什么将 dx 更改为 ax 会导致错误的输出?