Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.8k views
in Technique[技术] by (71.8m points)

AT&T 汇编问题

初学汇编遇到一个疑问,汇编指令:

    0x100002d5b <+11>: xorl   %ecx, %ecx   ; ecx = 0x00000000
    0x100002d5d <+13>: movl   %ecx, %edx   ; 把 ecx 移动到 edx

此时 edx0x00000000 可以理解,但为什么 rdx0x0000000000000000 呢。

在执行第二条汇编指令前 rdx 的值是 0x00007ffeefbff5b8。执行 movl 后前面的 0x00007ffe 为什么会丢失呢。感觉应该是和低位高位有关系,计算机基础不是很好希望能得到指点。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

intel 的文档:https://software.intel.com/co...

When in 64-bit mode, operand size determines the number of valid bits in the destination general-purpose register:

  • 64-bit operands generate a 64-bit result in the destination general-purpose register.
  • 32-bit operands generate a 32-bit result, zero-extended to a 64-bit result in the destination general-purpose register.
  • 8-bit and 16-bit operands generate an 8-bit or 16-bit result. The upper 56 bits or 48 bits (respectively) of the destination general-purpose register are not modified by the operation. If the result of an 8-bit or 16-bit operation is intended for 64-bit address calculation, explicitly sign-extend the register to the full 64-bits.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...