0

I am trying to add Array elements and store in Ax I successfully did it but my loop is not terminating. when I execute the program loop does not end. please try to help me out.

Here is my code.

org 0x0100  
jmp start 
Arr: dw   16h,50h,30h
start: 
mov  bx, 1  
mov  ax, 0  
top1: 
cmp  bx, 3h      
 jne  end1                          
end1:   
add ax,[Arr+bx]
add  bx, 2            
loop top1
 INT 21h   
  • You didn't set `cx`, which the slow `loop` instruction uses implicitly. If `cx=0` at the start of your program, your loop will run 65536 iterations. – Peter Cordes May 05 '18 at 18:02
  • Your `jne` is a no-op because it either branches to the next instruction or falls through to the next instruction; you probably want to fix that too. – Joe White May 05 '18 at 18:03
  • Peter cordes please guide me where i need to put cx = 0. How to fix please give me an example i am new to assembly. – Mishal Rehaj May 05 '18 at 19:58

0 Answers0