-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Open
Labels
Description
https://godbolt.org/z/3ffqeEvjP
#include <cstdint>
using u64 = std::uint64_t;
void test(u64 arg0, u64 arg1)
{
//u64 a,b;
asm volatile
(
"movb (%[a0]), %%al\n"
"movb (%[a1]), %%bl"
: //"=a"(a), "=b"(b) //tell compiler rax, and rbx are modified
: [a0]"abcdDS" (arg0), //use rax or rbx or rcx or rdx or rsi or rdi
[a1]"abcdDS" (arg1) //use rax or rbx or rcx or rdx or rsi or rdi
: "memory"
);
}clang x86-64: -std=c++26 -O3 -Wall -fno-exceptions
test(unsigned long, unsigned long):
mov rax, rsi
mov al, byte ptr [rax]
mov bl, byte ptr [rax]
retgcc x86-64: -std=c++26 -O3 -Wall -fno-exceptions
test(unsigned long, unsigned long):
movb (rdi), %al
movb (rsi), %bl
retreason i use "abcdDS" instead of "r" is to use exclusively rax or rbx or rcx or rdx or rsi or rdi, not r8,r9...
gcc seems to understand what i want
clang on the other hand is treating "abcdDS" like just "a", and its not even using arg0 from rdi
also, sorry for bad title. cant think of anything more descriptive