H5W3
当前位置:H5W3 > 问答 > 正文

AT&T 汇编问题

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

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

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

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

回答

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.

本文地址:H5W3 » AT&T 汇编问题

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址