80x86 16 位 asm:lea cx,[cx*8+cx] 导致 NASM 出现错误(编译 .com 文件)
NASM 给出的错误(尽管我的操作系统正常)是“无效的有效地址”。
现在我已经看到了很多如何使用 LEA 的例子,我认为我做对了,但我的 NASM 不喜欢它。我尝试了 lea cx, [cx+9] 并成功了; lea cx,[bx+cx]
没有。
现在,如果我将寄存器扩展到 32 位(即 lea ecx, [ecx*8+ecx]
),一切都会好起来,但我只能使用 16 位和 8 位寄存器。
这里有知识渊博的人可以解释一下为什么我的汇编器不允许我按照我认为应该使用的方式使用 lea 吗?
The error NASM gives (despite my working OS) is "invalid effective address".
Now I've seen many examples of how to use LEA and I think I got it right but yet my NASM dislikes it. I tried lea cx, [cx+9]
and it worked; lea cx, [bx+cx]
didn't.
Now if I extended my registers to 32-bits (i.e. lea ecx, [ecx*8+ecx]
) everything would be well but i am restricted to use 16- and 8-bit registers only.
Is here anyone so knowledgeable who could explain me WHY my assembler doesn't let me use lea the way I supposed it should be used?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(3)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
下面用于构建后字节的表格显示了哪个寄存器可以用作地址寄存器,以及其中哪些可以与第二个地址寄存器(基址寄存器+索引寄存器以及可能的缩放)组合以用它构建地址。
(从 16 位地址模式观察,其中 D 标志未设置。)
Dirk
These following tables for to build a postbyte shows which register can be used as an addressregister and which of them can be combine with a second addressregister(baseregister+indexregister and maybe scaling) to build an address with it.
(Observed from the 16 bit address mode, where the D-flag is not set.)
Dirk