Reputation: 117
I'm writing a loop in an 8086 game using emu8086 and I want to iterate over word values but not bytes of an array declared like this;
player_fire dw 320 dup(0)
; ...
mov bx, offset player_fire
mov cx, 320
fire_loop:
mov ax, [bx+si]
inc si
loop fire_loop
but I know that this is wrong. I also have problems writing to the ith element whether I should reference it with bx + si or bx + (2*si) ?
Upvotes: 1
Views: 2076
Reputation: 3
fire_loop:
mov ax,[bx+si];;mov to the next sell and put in ax
add si, 2; inc si
loop fire_loop;dex cx and loop
Upvotes: 0
Reputation: 20037
The ith element is located at [base + 2*register].
That can't however be written directly before 80386 addressing modes. On 8086+ you can do it with:
fire_loop:
mov ax,[bx+si]
add si, 2
loop fire_loop
Upvotes: 3