为什么 rbp 和 rsp 被称为通用寄存器? [英] Why are rbp and rsp called general purpose registers?

查看:42
本文介绍了为什么 rbp 和 rsp 被称为通用寄存器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 x64 中的 Intel,以下寄存器称为通用寄存器(RAX、RBX、RCX、RDX、RBP、RSI、RDI、RSP 和 R8-R15)https://software.intel.com/en-us/articles/introduction-to-x64-assembly.

According to Intel in x64 the following registers are called general purpose registers (RAX, RBX, RCX, RDX, RBP, RSI, RDI, RSP and R8-R15) https://software.intel.com/en-us/articles/introduction-to-x64-assembly.

在下面的文章中,写到 RBP 和 RSP 是专用寄存器(RBP 指向当前堆栈帧的底部,RSP 指向当前堆栈帧的顶部).https://www.recurse.com/blog/7-understanding-c-by-learning-assembly

In the following article, it's written that RBP and RSP are special purpose registers (RBP point to the base of the current stack frame and RSP point to the top of the current stack frame). https://www.recurse.com/blog/7-understanding-c-by-learning-assembly

现在我有两个相互矛盾的陈述.英特尔声明应该是可信的,但什么是正确的,为什么 RBP 和 RSP 被称为通用?

Now I have two contradictory statements. The Intel statement should be the trusted one, but what is correct and why is RBP and RSP called general purpose at all ?

感谢您的帮助.

推荐答案

通用意味着所有这些寄存器都可以与任何使用通用寄存器进行计算的指令一起使用,而例如,您不能对指令做任何想做的事指针 (RIP) 或标志寄存器 (RFLAGS).

General purpose means all of these registers might be used with any instructions doing computation with general purpose registers while, for example, you cannot do whatever you want with the instruction pointer (RIP) or the flags register (RFLAGS).

其中一些寄存器被设想用于特定用途,并且通常是这样.最关键的是 RSP 和 RBP.

Some of these registers were envisioned to be used for specific use, and commonly are. The most critical ones are the RSP and RBP.

如果您需要将它们用于自己的目的,您应该先保存它们的内容,然后再将其他东西存储在其中,并在完成后将它们恢复到原始值.

Should you need to use them for your own purpose, you should save their contents before storing something else inside, and restore them to their original value when done.

这篇关于为什么 rbp 和 rsp 被称为通用寄存器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆