gpt4 book ai didi

64 位架构中的汇编寄存器

转载 作者:行者123 更新时间:2023-12-02 09:13:15 25 4
gpt4 key购买 nike

关注 answer about assembly registers' sizes :

  • 一、尺寸是什么eax , ax , ah和他们的同行,在 64 位架构?如何访问单个寄存器的字节以及如何访问所有 64 位寄存器的八个字节?
    我希望两者都受到关注 x86-64 (x64) 安腾 处理器。
  • 二、在the new calling convention中的函数调用中,使用四个寄存器保存前四个参数的正确方法是什么? ?
  • 最佳答案

    用老字号所有寄存器的大小保持不变 ,就像 x86-16 扩展到 x86-32 时一样。要访问 64 位寄存器,请使用带有 R-prefix 的新名称。例如 rax、rbx...

    寄存器名称不会改变,因此您只需像以前一样使用字节寄存器(al、bl、cl、dl、ah、bh、ch、dh)作为 ax、bx、cx、dx 的 LSB 和 MSB。

    还有 8 个新寄存器 称为 r8-r15。您可以通过添加后缀 b 来访问它们的 LSB。 (或 l if you're using AMD)。例如 r8b, r9b... 你也可以使用 esi, edi, esp, ebp 的 LSB 名称为 sil, dil, spl, bpl 和新的 REX prefix ,但不能与 ah、bh、ch 或 dh 同时使用。

    同样,可以通过后缀 w 访问新寄存器的最低字或双字。或 d .

    x86_64 registers

    What are the names of the new X86_64 processors registers?

    关于调用约定,在特定系统上有 只有一个约定 1.

  • On Windows :
  • RCX、RDX、R8、R9 用于前四个整数或指针参数
  • XMM0、XMM1、XMM2、XMM3 用于浮点参数

  • 1自 MSVC 2013 以来,还有一个 新的扩展约定在 Windows 上调用 __vectorcall 所以“单一公约政策”不再适用。
  • 在 Linux 和其他遵循 System V AMD64 ABI 的系统上,可以在寄存器上传递更多参数,并且有一个 128 字节的 red zone在堆栈下方,这可能会使函数调用更快。
  • 前六个整数或指针参数在寄存器 RDI、RSI、RDX、RCX、R8 和 R9 中传递
  • 浮点参数在 XMM0 到 XMM7 中传递

  • 更多信息请阅读 x86-64x86-64 calling conventions

    Plan 9 中也使用了一个约定在哪里

    • All registers are caller-saved
    • All parameters are passed on the stack
    • Return values are also returned on the stack, in space reserved below (stack-wise; higher addresses on amd64) the arguments.


    事实上,Plan 9 一直是个怪人。例如,它在没有硬件零寄存器的 RISC 架构上强制寄存器为 0。其上的 x86 寄存器名称在 16、32 和 64 位 x86 体系结构中也是一致的,操作数大小由助记符后缀指示。这意味着 ax 可以是 16、32 或 64 位寄存器,具体取决于指令后缀。如果你对此感到好奇,请阅读
  • A Manual for the Plan 9 assembler
  • Go/plan9’s assembler is weird


  • 奥托 Itanium完全不同的架构并且与 x86-64 没有任何关系。它是一个纯 64 位架构,所以所有普通寄存器都是 64 位,没有 32 位或更小的版本可用。里面有很多寄存器:

    • 128 general-purpose integer registers r0 through r127, each carrying 64 value bits and a trap bit. We'll learn more about the trap bit later.
    • 128 floating point registers f0 through f127.
    • 64 predicate registers p0 through p63.
    • 8 branch registers b0 through b7.
    • An instruction pointer, which the Windows debugging engine for some reason calls iip. (The extra "i" is for "insane"?)
    • 128 special-purpose registers, not all of which have been given meanings. These are called "application registers" (ar) for some reason. I will cover selected register as they arise during the discussion.
    • Other miscellaneous registers we will not cover in this series.

    The Itanium processor, part 1: Warming up



    阅读更多 What is the difference between x64 and IA-64?

    关于64 位架构中的汇编寄存器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20637569/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com