IDEAL
MODEL small
STACK 100h
jumps
p186
DATASEG
array dw 312, 340, 311, 300
CODESEG
proc example
pusha
mov al ,4 ;number of elements in array
mov bl, 0 ;index
label1:
mov cx, [array + bx] ;here, every second element ch and cl are swapped
inc bl
cmp bl, al
jb label1
popa
ret
endp example
start:
mov ax, @data
mov ds, ax
call example
exit:
mov ax, 4c00h
int 21h
END start
In my assembly code, cx is okay in the 1st and 3rd iterations but in the 2nd and 4th ones for some reason cl and ch swapped their values with each other. I'm really overwhelmed with this and I would appreciate some help, thanks!