Questions tagged [x86]
x86 is an architecture derived from the Intel 8086 CPU. The x86 family includes the 32-bit IA-32 and 64-bit x86-64 architectures, as well as legacy 16-bit architectures. Questions about the latter should be tagged [x86-16] and/or [emu8086]. Use the [x86-64] tag if your question is specific to 64-bit x86-64. For the x86 FPU, use the tag [x87]. For SSE1/2/3/4 / AVX* also use [sse], and any of [avx] / [avx2] / [avx512] that apply
17,430
questions
0
votes
1
answer
42
views
Why does operand 1 in a modr/m byte change depending on the decoding mode
I'm trying to figure out why the instruction changes from add [eax], al to add [rax], al when changing the decoding mode from x86 to x64.
The instruction bytes are 00 00
I think it might be because ...
-3
votes
0
answers
72
views
function call crash on amd [closed]
I made a exe and a dll. Dll calling function in exe. it is fine in intel system but it is crash when amd system.
asm
{
push ebp -> crash here most of the time
mov esp,ebp -> crash here rarely
...
4
votes
0
answers
94
views
Run time depends on code after the measured part
Consider the following C++23 program (online).
#include <chrono>
#include <cstdio>
#include <print>
constexpr size_t NWrites = 10000000000;
#define DEST_STORAGE static
#define ...
0
votes
0
answers
47
views
Why is my array value not equal to a literal?
I am new to assembly and was trying to work with an array. However, I was geting caught when try to compare the array value to a constant stored in a register.
From the following code I was expecting ...
1
vote
0
answers
18
views
the Perf event issues of hardware prefetcher (all_pf_data_rd and pf_l2_data_rd)
My platform is 2nd generation scalable Xeon, equipped with a non-inclusive cache. I run a series of tests that had the L2 stream prefetcher aggressively prefetching.
I use Perf to monitor performance, ...
-1
votes
0
answers
47
views
How does SYSCALL save the userspace RSP?
On a x86 CPU running in long mode, how is the user-mode $RSP value saved after the SYSCALL instruction by the kernel's handler function?
When changing from user mode (CPL=3) to kernel mode (CPL=0), ...
4
votes
1
answer
159
views
Understanding the flow of the kernel upon receiving a SIGSEGV for null-dereference
I'm trying to figure out the sequence of things that occur inside the Linux kernel (x86_64, v6.9) when we write these two codes:
// Null-dereference + writing to page zero
*(char *)0 = 0;
// Null-...
1
vote
1
answer
55
views
gnu inline assembly constraint `i` for memory address
Recetly, this function rip_rel_ptr has been added to Linux kernel.
https://elixir.bootlin.com/linux/latest/source/arch/x86/include/asm/asm.h#L118.
I can compile the kernel, but when I copy this ...
1
vote
1
answer
36
views
REX encoding for instructions with the VEX prefix
[x64]
is there some generic algorithm using which I can determine relevant registers for the rex byte? I'm specifically interested in the calculation of REX for instructions with the VEX prefix (so ...
4
votes
0
answers
60
views
Why does Intel x86 manual use +rd instead of +ro or +rq for 64-bit registers?
The description of the PUSH instruction in the Intel manual (PDF, Volume 2, Chapter 4.3, PUSH) contains the line 50+rd PUSH r64. It seems +rd is used throughout most of the instruction descriptions ...
1
vote
0
answers
32
views
Link function calls against reverse engineered binary
I created an windows x86 .exe file that I reverse engineer. Imagine I only have the .exe file and I reverse engineered some functions.
The goal is to create a dll that links with this .exe so the dll ...
1
vote
1
answer
50
views
My bootloader isn't printing after switching to Protected Mode
I'm trying to print the character "C" after switching to the Protected Mode, but it isn't working, and I don't know why. I'm using Assembly AT&T/GAS syntax
Here is the code:
.code16
....
1
vote
1
answer
90
views
Why do I get multiple ASM instructions per addition? (Visual Studio 2022 Community)
Here's the C program, I use Visual Studio Community 2022 with MSVC compiler. What are all those mov instructions, I don't use any compiler optimization flags.
#include <stdio.h>
int main(void) {...
0
votes
1
answer
36
views
x86 NASM Crash - Iterate over string
How to iterate over individual characters of a string in x86 assembly and print them?
global _main ; declare _main entry point
extern _printf ; extern method
section ....
22
votes
2
answers
1k
views
How to prepare stack pointer for bare metal Rust?
I'm trying to write an x86 bootloader and operating system completely in Rust (no separate assembly files, only inline assembly within Rust).
My bootloader works completely as intended within the QEMU ...