In the following code
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.
if I change dx to ax
lea dx,str --> lea ax,str
The out put become 1 'Sum is
But if I use lea ax,str
It is correct > Sum is :
I cant figure out the reason !
Why changing dx to ax causes the wrong output ?