汇编中的内存与ptr之间的差异

问题描述 投票:0回答:1

回到另一个组装问题。我很难看到方括号和汇编中的ptr有什么区别。

mov dword ptr eax, 1234 ; this should write 1234 to the memory address stored at eax right?
mov dword ptr [eax], 1234; this writes to the memory address that is stored at the memory address that is stored in eax?
mov [eax], 1234 ; this does the same as the first one right? it writes 1234 to the memory address that is stored in eax?

任何人都可以阐明这个话题吗?

assembly masm addressing-mode
1个回答
1
投票

dword PTR只是后面的大小说明符。由于eax的大小是已知的,因此dword PTR在第一种情况下是多余的。

即,mov dword ptr eax, 1234与仅写入mov eax, 1234相同。

[mov dword ptr [eax], 1234意味着eax给定的地址处的内存中的双字中写入1234

mov [eax], 1234模棱两可,甚至不应该汇编。汇编器无法知道您打算存储一个字还是一个双字。

© www.soinside.com 2019 - 2024. All rights reserved.