Questions tagged [x86-64]
x86-64 is a 64 bit extension to the Intel x86 architecture
x86-64
7,196
questions
1
vote
2
answers
28
views
Why does this assembly implementation of strcmp behave unexpectedly?
I've been writing my own naive implementation of the strcmp function in x86_64 assembly.
I've written a c test program to compare the behavior with the real strcmp from the C library.
Even if both ...
0
votes
0
answers
25
views
cc -o out out.s on macOS with M1 chip
I have been learning the chapter of 04_Assemblyhttps://github.com/DoctorWkt/acwj/tree/master/04_Assembly. According to the README.md, after I typed cc -o comp1 -g cg.c expr.c gen.c interp.c main.c ...
0
votes
0
answers
31
views
Create buffer on stack in x86_64 assembly to print number
when trying to print numbers in assembly instead of number i'm getting O=N84NioR/\_dsPfec IS/pRDNui/0SmL3lSegmentation fault
i'm using Linux with NASM
my code is:
_printNum: ;prints number stored ...
0
votes
1
answer
47
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 ...
1
vote
0
answers
55
views
Getting wrong CPU Processor ID with __cpuid() in Win 11 systems
I am facing an issue in getting CPU Processor ID with C++ code.
I used __cpuid() function as below:
#include <intrin.h>
int main()
{
unsigned __int32 regs[4];
__cpuid((int *)regs, 1);
...
3
votes
1
answer
87
views
Twice as slow SIMD performance without extra copy
I've been optimizing some code, and stumbled across some peculiar case.
Here are the two assembly codes:
; FAST
lea rcx,[rsp+50h]
call qword ptr [Random_get_float3] ;this function ...
1
vote
0
answers
32
views
Question about AVX-2, x86-64 function calls and Compilers [closed]
#pragma GCC optimize(3)
#include"immintrin.h"
char* SetOne(char* mat, unsigned long long length) { //Set char Mat[length+32] to all 0xFF, here I would initialize Mat as length+32 to ignore ...
0
votes
0
answers
36
views
While running a piece of driver code on an AMD64 machine, it appears that there are issues related to cache consistency or out-of-order execution
While running a piece of driver code on an AMD64 machine, it appears that there are issues related to cache consistency or out-of-order execution. Are there any experienced engineers who can help ...
-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), ...
1
vote
0
answers
32
views
Unable to compile NASM without -no_pie on macOS
I'm trying to follow the tutorial for NASM and I made a few adjustments (like changing the entrypoint function from "start" to "_main") to get the following hello.asm to compile ...
0
votes
0
answers
49
views
How can I get this STDIN to work in GAS Assembler running on Linux?
I am new to Assembler and am currently reading a book about it by Jonathan Bartlett called 'Learn to Program with Assembly'. On pages 160-1 he gives the following sample program to demonstrate the use ...
0
votes
0
answers
30
views
Why is my assembly code giving extra output? [duplicate]
Before I start, it's important to say I am a complete beginner to Assembly, so I might be missing something very obvious.
I was trying to make an Assembly program where it prints the following output ...
1
vote
0
answers
48
views
Assembly jump instructions don't seem to work
bits 64
default rel
section .data
fmt db "%s", 0xd, 0xa, 0
err db "Correct usage: echo <string>"
section .text
extern printf
extern ExitProcess
global ...
-1
votes
0
answers
31
views
Adding ACPI into qemu and finding it in memory regions using 0xE820
I am working on an OS and I am trying to find the ACPI tables using the 0xE820 to find regions and find the ACPI reclaimable region
qemu-system-x86_64 -cpu qemu64 -machine q35 -m 128M -drive file=...
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 ...