问题标签 [addressing-mode]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
1162 浏览

linux - 确定 NASM 何时可以推断 mov 操作的大小

在 x86 汇编中有些东西让我困惑了一段时间,这是 NASM 如何/何时可以推断操作的大小,这是一个示例:

在这里,我们将存储在 eax 中保存的地址的 4 个字节移动到 ebx 中。由于寄存器是 32 位,因此操作的大小被推断为 4 个字节。

但是,此操作不会被推断并引发编译错误:

当然解决方案是这样的:

这会将数字 123456 的 32 表示移动到存储在 eax 中保存的地址的字节中。

但这让我很困惑,它肯定可以看到 eax 是 32 位的,所以不应该假设我想将它存储为 32 位值而无需在 mov 之后指定 dword 吗?

当然,如果我想将 12345 的 16 位表示(适合 16 位的较小数字)放入 eax 我会这样做:

0 投票
2 回答
2384 浏览

assembly - Error moving a constant byte value into %ebx

I'm working through Computer Systems, A Programmer's Perspective (3rd edition), and Practice Problem 3.3 contains the following line:

I'm supposed to find out what's wrong with this line of x86-64 assembly, and the answer key states: "Cannot use %ebx as address register", which doesn't make sense to me. My understanding is that this line intends to copy 0xF to a location in main memory, however %ebx is a 32-bit register, memory addresses are 64 bits wide on 64-bit machines, and so %ebx cannot hold a memory address, therefore it cannot be dereferenced (dereferencing is what the parentheses around %ebx represent, correct?). However, looking a few pages back in the book (page 183, if you have it) there is an example detailing the five mov operand--destination combinations, one of which is:

%esp is a 32-bit register just like %ebx! And this example shows a byte value being moved to a dereferenced 32-bit register! Which doesn't make sense to me, because how can %esp contain a 64-bit address? Do I completely misunderstand assembly?

0 投票
2 回答
512 浏览

assembly - 指令“mov ax,[ax]”不会编译

我使用一个名为“emu8086”的 x8086 模拟器。我写了简单的代码,当我运行它时,它给了我一个错误。我无法弄清楚是什么问题。 http://prntscr.com/8bpivm

0 投票
1 回答
467 浏览

assembly - 堆栈指针作为索引寄存器

为什么堆栈指针(esp / rsp)不能用作索引寄存器,例如[esi + esp*4]

0 投票
2 回答
1315 浏览

68000 - 寻址模式:区分绝对短和绝对长?

好的,所以我有以下说明:

移动.W $1234, $8000

现在我很困惑 1234 美元和 8000 美元的寻址模式是绝对短还是绝对长。

如果有人能解释如何区分绝对短和绝对长,我也将不胜感激。谢谢。

0 投票
2 回答
2909 浏览

assembly - 读取 RIP 寄存器给出下一条指令的地址?

我尝试读取 x86_64 register 的值rip。这是objdump显示的内容。

我希望在指令0x4017ec执行后,的值rsi应该是0x4017ec。然而0x4017f3,它是下一条指令的地址。

我使用 gdb 停止0x4017ec,当时的rip值为0x4017ec. 为什么rsi没有加载当时的值rip?处理器应该从中读取指令0x4017ec吗?

0 投票
2 回答
18508 浏览

assembly - 引用内存位置的内容。(x86 寻址模式)

我有一个内存位置,其中包含一个我想与另一个字符进行比较的字符(它不在堆栈的顶部,所以我不能只是pop它)。如何引用内存位置的内容以便进行比较?

基本上我如何在语法上做到这一点。

0 投票
2 回答
11305 浏览

x86 - 什么是有效地址?

在阅读Intel 64 and IA-32 Architectures Software Developer's Manual时,LEA 指令(加载有效地址)的操作部分使用了一个EffectiveAddress(SRC)在其他任何地方都没有定义的计算。

有效地址的定义是什么,有什么作用EffectiveAddress(SRC)

0 投票
1 回答
1561 浏览

assembly - 用 LEA 指令减去寄存器?

LEA 指令是否支持负位移?

当我在我的 asm 文件中使用上面的代码时,我得到了错误:

我知道我们可以在 C 中做这样的指针运算:

然后我假设:

将工作。

我还尝试使用以下方法查看 GCC 编译器的作用:

但我的 asm 知识不足以让我理解 GCC 编译器的 asm 输出。

谁能解释为什么:

不起作用。我正在使用这些来实现相同的目标:

或者

什么是更标准的做法?

我在 MAC OSX 10.11 上使用 2015 年 11 月 26 日编译的 NASM 版本 2.11.08

预先感谢您的帮助!

0 投票
1 回答
1738 浏览

assembly - ARM 程序集中带 [] 和不带 [] 的命令之间的区别

我注意到在 ARM 程序集中,有 3 种类型(据我所知,可能还有更多)加载/存储命令。到目前为止,我已经看到:

这些只是我见过的命令的示例。注意最后一个命令是如何加载而不是存储的,那是因为我还没有看到 STR R0、R1、#4,所以我不知道这样写是否会编译。

我知道 #4 意味着将 R1 增加 4(可能),但是与上述命令中的 [] 有什么区别?