x86在2字节字数组上进行迭代 [英] x86 iterate over a 2-byte word array

查看:61
本文介绍了x86在2字节字数组上进行迭代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用emu8086在8086游戏中编写一个循环,我想遍历单词值,而不要遍历这样声明的数组的字节;

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

但是我知道这是错误的.我还要写第ith个元素还是我应该用bx + si还是bx +(2 * si)引用它的问题?

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) ?

推荐答案

第ith个元素位于[base + 2 * register].

The ith element is located at [base + 2*register].

但是不能在80386寻址模式之前直接编写.在8086+上,您可以执行以下操作:

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

这篇关于x86在2字节字数组上进行迭代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆