I want to write a assembly code that has 2 arrays and one variable then code search variable value into the first array if equal the index of this array write into the second array. i write this program but i have an issue . this code need double "inc DI" at the end but why?
.model small
.stack 100
.data
a dw 10 dup(4, 3, 4, 2, 8, 9, 4, 6, 7, 5)
x dw 4
b dw 10 dup(?)
.code
main proc far
push DS
push 0
mov AX,@data
mov DS,AX
;code start
;;;;;;;;;;
mov si,0
mov di,0
startloop:
cmp di,19
jnl endloop
mov ax,a[di]
cmp ax,x
jne endif
mov b[si],di
inc si
endif:
inc di
inc di
jmp startloop
endloop:
ret
main endp
end main