#include <stdio.h>
int main() {
unsigned long a, d;
__asm__ volatile (
"\n\t"
"movl $0x77777777, %%eax\n\t"
"movl $0xffffffff, %%ecx\n\t"
"xorl %%edx, %%edx\n\t"
"divl %%ecx\n\t"
"cwtd\n\t"
"movq %%rax, %0\n\t"
"movq %%rdx, %1\n\t"
: "=r"(a), "=r"(d)
:: "rax", "rdx"
);
printf("rax: %lx, rdx, %lx", a, d);
}
The minimal program above was expected to give rax: 0, rdx: 77770000 but on macOS with Rosetta 2 it gave rax: 0, rdx, 0. It causes specfic programs (e.g. Genshin Impact) to crash.