Category "x86-64"

How to divide two unsigned long 64 bit values in x86 assembly and then returning the quotient and remainder to a C program

In a separate C program, I have passed 4 parameters to an x86 ASM program. dividend divisor Quotient pointer Remainder pointer dividend = 0xA divisor = 0x3 Whic

"There is no need to deallocate the stack at the end of the function when the inner-stack frame isn't modified", but it is being modified in this case

Here is a simple function #include <stdio.h> int foo() { int a = 3; int b = 4; int c = 5; return a * b * c; } int main() { int a = f

Documentation on MSI Address/Data register content expectations for AMD cpus?

Where I can find info on AMD Ryzen CPUs and how they expect MSI address/data to be programmed? The Intel manual is crystal clear in its description (pictured be

Are there any instructions (other than those that use RIP-relative addressing) that are position dependent?

(This question refers specifically to x86/x86_64) I'm working on an application that needs to insert a small block of instructions at specific points within ano

Writing a putchar in Assembly for x86_64 with 64 bit Linux?

I am trying to use the write syscall in order to reproduce the putchar function behavior which prints a single character. My code is as follows, asm_putchar:

Array addressing in AT&T GAS assembly. Register offset from RIP doesn't work

I'm trying to work with arrays in GNU assembly. In my opinion the following code must exit with value 3. But it exits with 13. .section __DATA,__data inArr:

Fast floating-point power of 2 on x86_64

Is there a fast way to take 2.0 to some floating-point degree x? I mean something faster than pow(2.0, x) and preferrably what vectorizes well with AVX2. The c

How can I get a string returned from a function executed from a byte array?

I have a working C program that has the simple function that returns a d character encoded in a byte array. char foo() { return 'd'; } char byte_array[] = {0

How can I get a string returned from a function executed from a byte array?

I have a working C program that has the simple function that returns a d character encoded in a byte array. char foo() { return 'd'; } char byte_array[] = {0

MASM SHA256 running from C#

I received a task in college to compare execution time for calculating SHA256 in C# and assembly. It is supposed to be a simple WPF app with file input and 2 bu

MOVZBQ equivalent in NASM

Background: I have been learning x86_64 assembly using NASM on a Linux system and was writing a subroutine for strlen(const char *str) I wanted to copy one byte

The most correct way to refer to 32-bit and 64-bit versions of programs for x86-related CPUs?

This question is about terminology for 32-bit vs. 64-bit x86. If I have 2 directories with source code of the same program - one for 32-bit Windows and another

Why are rbp and rsp called general purpose registers?

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.inte

how to run amd64 docker images on arm64 host platform

I have an m1 mac and I am trying to run a amd64 based docker image on my arm64 based host platform. However, when I try to do so (with docker run) I get the fol

Apparent no-op in Rust assembly output?

I was studying the x86_64 assembly for the following function: /// Returns the greatest power of two less than or equal to `self`, or 0 otherwise. pub const fn

executable file compiled by MinGW x86_64-w64-mingw32 in Ubuntu not working on Windows

I am trying to create a executable file works on Windows 64bit from linux. I am using MXE to cross compile c file on my ubuntu server. And after I compile c fil

Are RAX, RBX, RCX, RDX, RSI, RDI, RBP, RSP, R8-R15 interchangable?

Are x64 registers interchangable, in the sense that any instruction that works with one combination of them will work with any other? Is there performance diffe

How do you understand 'REX.W + B8+ rd io' form for x86-64 assembly?

I was originally trying to generate the bytes for an immediate move into a 64 bit register.The specific operation I wanted was mov rdi, 0x1337 Using https://ww

SIMD intrinsic and memory bus size - How CPU fetches all 128/256 bits in a single memory read?

Hello Forum – I have a few similar/related questions about SIMD intrinsic for which I searched online including stackoverflow but did not find good answer

How can I multiply 64 bit operands and get 128 bit result portably?

For x64 I can use this: { uint64_t hi, lo; // hi,lo = 64bit x 64bit multiply of c[0] and b[0] __asm__("mulq %3\n\t" : "=d" (hi), "=a" (lo)