So I'm trying to messe with x86 float control register using the ldmxcsr instruction like so:
void square(int mode) {
asm volatile ("ldmxcsr %[b]" :: [b] "m" (mode));
}
This c snippet compiles just fine using gcc and clang.
But with zig:
pub export fn restoreFloat(mode: u32) void {
asm volatile ("ldmxcsr %[b]" :: [b] "m" (mode));
}
The output of the function above is just crazy, it first stores edi to an offset into the stack and uses a diffrent offset in the acctual ldmxcsr instruction
I can get a sane assembly output with this:
pub export fn restoreFloat(mode: u32) void {
var temp: u32 = undefined;
asm volatile (
\\movl %[mode], %[temp]
\\ldmxcsr %[temp]
: [temp] "=m" (temp)
: [mode] "r" (mode)
);
}
Heres the output:
https://godbolt.org/z/WEGK8aqv9