从 32 位指令学习 64 位汇编

Learn 64bit Assembly from 32bit Instruction

我一直在尝试使用《黑客:欺骗的艺术》一书来学习汇编和编程。它有一个很棒的编程部分,可以让您更好地了解程序的内部工作原理,并让您更好地理解在编程时如何精确是很重要的。但是,我一直很难理解,因为这本书使用的是 32 位示例,而我使用的是 64 位系统。我知道如何用 gcc 编译到 32 位,或者我也调低到本书提供的 32 位 cd,但我想我宁愿学习 64 位,因为它可能比 32 位系统更相关(或者变得越来越相关? ).所以基本上我想问的是我是否应该费心尝试使用这本书来弄清楚 64 位汇编,因为我听说它有很大不同,或者我是否应该找到其他 material 来学习 64 位汇编分别地?如果有任何易于理解的涵盖 64 位英特尔汇编的书籍,我将不胜感激。

就像Lurker在上面的评论中所说的。既然你有一本 32 位的书,那就学习吧。 32 位仍然很重要。

一旦您了解了 32 位的工作原理,接下来对 64 位添加的内容的简要说明将变得轻而易举。

The number of registers has been doubled to 16.

All registers are 64 bits long. The 64-bit extensions of the IA32 registers are named %rax, %rcx, %rdx, %rbx, %rsi, %rdi, %rsp, and %rbp. The new registers are named %r8–%r15.

The low-order 32 bits of each register can be accessed directly. This gives us the familiar registers from IA32: %eax, %ecx, %edx, %ebx, %esi, %edi, %esp, and %ebp, as well as eight new 32-bit registers: %r8d–%r15d.

The low-order 16 bits of each register can be accessed directly, as is the case for IA32. The word-size versions of the new registers are named %r8w–%r15w.

The low-order 8 bits of each register can be accessed directly. This is true in IA32 only for the first four registers (%al, %cl, %dl, %bl). The byte-size versions of the other IA32 registers are named %sil, %dil, %spl, and %bpl. The byte-size versions of the new registers are named %r8b–%r15b.

For backward compatibility, the second byte of registers %rax, %rcx, %rdx, and %rbx can be directly accessed by instructions having single-byte operands.

文本来自计算机系统 一个程序员的视角