search
HomeOperation and MaintenanceLinux Operation and MaintenanceWhat is the difference between x64 and x86 in linux

Differences: 1. Different register allocation, x64 has 16 registers, x86 only has 8 registers; 2. Different assembly instructions; 3. Different function calls; 4. Different parameter passing; 5. Different stack frames, x64 does not have a stack frame pointer, while x86 uses ebp as the stack frame pointer; 6. The computing speed of x64 is higher than that of x86.

What is the difference between x64 and x86 in linux

#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

The difference between Linux x86 (32-bit) and x64 (64-bit)

##0x01: Difference in register allocation

(1) There are 16 registers in 64-bit and only 8 in 32-bit. However, the first 8 32-bit bits have different names, namely e _, while the first 8 64-bit bit bits use r instead of e, which is r _. Register naming starting with e can still be directly applied to the lower 32 bits of the corresponding register, while the remaining register names are from r8 - r15, and the lower bits are designated by d, w, and b respectively;

(2) 32 bits Use the stack frame as the storage location of the passed parameters, and use 64-bit registers, using rdi, rsi, rdx, rcx, r8, r9 as the 1-6 parameters respectively, and rax as the return value;
(3) 64-bit does not have a stack frame pointer, 32-bit uses ebp as the stack frame pointer, 64-bit cancels this setting, and rbp is used as a general register;
(4) 64-bit supports some forms of PC-related addressing, The 32-bit addressing method is only used when using jmp;

0x02: (New) Differences in assembly instructions

mov, push, and pop extend the movq series of mov, pushq, and popq to operate quad words.

Supplement:

(1) movabsq is not a 32-bit extension, it is a purely new instruction. Used to store a 64-bit literal value directly into a 64-bit register. Because movq can only store 32-bit values, a new instruction

(2) 64-bit assembly code may add a rep before ret, here Rep has no practical meaning. It is just for the reason of AMD processor to avoid that the place where jmp reaches is directly ret, which will make the processor run faster

0x03: Differences in function calls

(1) x_64 parameters are passed through registers (see above);

callq stores an 8-bit return address on the stack;
(2 ) Many functions no longer have stack frames. Only those that cannot place all local variables in registers will allocate space on the stack;
(3) Functions can obtain up to 128 bytes of stack space. In this way, the function can store information on the stack without changing the stack pointer (that is, the 128-byte space below rsp can be used in advance. This space is called the red zone. In x86-64, it is available at all times. );
(4) There is no longer a stack frame pointer, and the stack position is now related to the stack pointer. Most functions allocate all required stack space at the beginning of the call, and then keep the stack pointer unchanged;
(5) Some registers are designed to be callee-storage registers, and these must be changed when their values ​​need to be changed. Store them now and restore them later.

0x04: Different parameters passed

(1) 6 registers are used to pass parameters (see above);

(2) The remaining registers are passed as before (but they are related to rsp, ebp is no longer used as the stack frame pointer, and the 7th parameter starts from rsp, the 8th parameter starts from rsp 8, and so on);

(3) When called, rsp moves down 8 bits (stored in the return address). The register parameters have no effect. The 7th and subsequent parameters are now the 7th starting from rsp 8, rsp 16 Start with the 8th one, and so on;

0x05: Differences in stack frames

In many cases, stack frames are no longer needed, such as No other functions are called, and the register is enough to store the parameters, then only the return address needs to be stored.

Situations that require stack frames:

(1) Too many local variables and not enough registers;

(2) Some local variables are arrays or structures;
(3) Functions used The address operator is used to calculate the address of a local variable;
(4) The function must use the stack to transfer some parameters to another function;
(5) The function needs to save the state of some registers stored by the callee ( to facilitate recovery);

But today's stack frames are often of a fixed size, which is set at the beginning of the function call. During the entire call, the top pointer of the stack remains unchanged, so that it can be It is coupled with the offset to operate on the corresponding value, so EBP is no longer needed as a stack frame pointer. Although many times we think that there is no "stack frame", every function call must have a return address that is pushed onto the stack. We can also think of this address as a "stack frame" because it also saves the caller's state.

0x06: Different operating speeds

The data width of 64-bit CPU is 64 bits, and the 64-bit instruction set can run 64-bit data instructions, that is to say The processor can extract 64-bit data at a time, which is twice as high as 32-bit. In theory, the performance will be doubled accordingly.

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of What is the difference between x64 and x86 in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Heart of Linux: The 5 Core ComponentsThe Heart of Linux: The 5 Core ComponentsApr 13, 2025 am 12:15 AM

The five core components of Linux are kernel, shell, file system, system library and system tools. 1. The kernel manages hardware resources and provides services to the application. 2. Shell serves as the interface between the user and the system, interprets and executes commands. 3. The file system is responsible for the storage and organization of data. 4. The system library provides precompiled functions to provide program calls. 5. System tools are used for system management and maintenance. These components work together to give Linux powerful functionality and flexibility.

How to check Debian OpenSSL configurationHow to check Debian OpenSSL configurationApr 12, 2025 pm 11:57 PM

This article introduces several methods to check the OpenSSL configuration of the Debian system to help you quickly grasp the security status of the system. 1. Confirm the OpenSSL version First, verify whether OpenSSL has been installed and version information. Enter the following command in the terminal: If opensslversion is not installed, the system will prompt an error. 2. View the configuration file. The main configuration file of OpenSSL is usually located in /etc/ssl/openssl.cnf. You can use a text editor (such as nano) to view: sudonano/etc/ssl/openssl.cnf This file contains important configuration information such as key, certificate path, and encryption algorithm. 3. Utilize OPE

How to build a Hadoop development environment on DebianHow to build a Hadoop development environment on DebianApr 12, 2025 pm 11:54 PM

This guide details how to build a Hadoop development environment on a Debian system. 1. Install Java Development Kit (JDK) First, install OpenJDK: sudoaptupdatesudoaptininstallopenjdk-11-jdk-yConfigure JAVA_HOME environment variable: sudonano/etc/environment at the end of the file (adjust the path according to the actual JDK version): JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64" Save and exit, and then execute: source/etc

How to do Hadoop resource management on DebianHow to do Hadoop resource management on DebianApr 12, 2025 pm 11:51 PM

Effectively managing Hadoop resources on the Debian system requires the following steps: Hadoop deployment: First, complete the installation and configuration of Hadoop on the Debian system. This includes necessary operations such as downloading Hadoop distribution packages, decompressing, setting environment variables, etc. Cluster configuration: After the installation is completed, configure the Hadoop cluster, covering the settings of HDFS (Hadoop distributed file system) and YARN (YetAnotherResourceNegotiator). You need to modify the core configuration file, such as: core-site.xml, hdfs-site.xml, mapred-site.x

What are the security settings for Debian Tomcat logs?What are the security settings for Debian Tomcat logs?Apr 12, 2025 pm 11:48 PM

To improve the security of DebianTomcat logs, we need to pay attention to the following key policies: 1. Permission control and file management: Log file permissions: The default log file permissions (640) restricts access. It is recommended to modify the UMASK value in the catalina.sh script (for example, changing from 0027 to 0022), or directly set filePermissions in the log4j2 configuration file to ensure appropriate read and write permissions. Log file location: Tomcat logs are usually located in /opt/tomcat/logs (or similar path), and the permission settings of this directory need to be checked regularly. 2. Log rotation and format: Log rotation: Configure server.xml

How to interpret warnings in Tomcat logsHow to interpret warnings in Tomcat logsApr 12, 2025 pm 11:45 PM

Warning messages in the Tomcat server logs indicate potential problems that may affect application performance or stability. To effectively interpret these warning information, you need to pay attention to the following key points: Warning content: Carefully study the warning information to clarify the type, cause and possible solutions. Warning information usually provides a detailed description. Log level: Tomcat logs contain different levels of information, such as INFO, WARN, ERROR, etc. "WARN" level warnings are non-fatal issues, but they need attention. Timestamp: Record the time when the warning occurs so as to trace the time point when the problem occurs and analyze its relationship with a specific event or operation. Context information: view the log content before and after warning information, obtain

How Tomcat logs help troubleshoot memory leaksHow Tomcat logs help troubleshoot memory leaksApr 12, 2025 pm 11:42 PM

Tomcat logs are the key to diagnosing memory leak problems. By analyzing Tomcat logs, you can gain insight into memory usage and garbage collection (GC) behavior, effectively locate and resolve memory leaks. Here is how to troubleshoot memory leaks using Tomcat logs: 1. GC log analysis First, enable detailed GC logging. Add the following JVM options to the Tomcat startup parameters: -XX: PrintGCDetails-XX: PrintGCDateStamps-Xloggc:gc.log These parameters will generate a detailed GC log (gc.log), including information such as GC type, recycling object size and time. Analysis gc.log

What is the impact of Debian Apache log on server performanceWhat is the impact of Debian Apache log on server performanceApr 12, 2025 pm 11:39 PM

The impact of Apache logs on server performance under the Debian system is a double-edged sword, which has both positive effects and potential negative effects. Positive aspect: Problem diagnosis tool: Apache log records all requests and responses in detail on the server, and is a valuable resource for quickly locating faults. By analyzing the error log, configuration errors, permission issues, and other exceptions can be easily identified. Security Monitoring Sentinel: Access logs are able to track potential security threats, such as malicious attack attempts. By setting log audit rules, abnormal activities can be effectively detected. Performance Analysis Assistant: Access logging request frequency and resource consumption to help analyze which pages or services are most popular, thereby optimizing resource allocation. Combined with top or htop, etc.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Atom editor mac version download

Atom editor mac version download

The most popular open source editor