On 1/20/22 02:49, Thomas Faber wrote:
Hi,
On 2022-01-19 12:06, Jinoh Kang wrote:
+#if defined(__GNUC__) +#if defined(__x86_64__) +static FORCEINLINE DECLSPEC_NORETURN void __fastfail(unsigned int code) +{ + register ULONGLONG val __asm__("rcx") = code; + __asm__ __volatile__( "int $0x29" :: "r" (val) : "memory" );
Any reason to prefer this "manual move" into a register over specifying r/ecx as an input into the assembly block?
It's just a style preference, nothing much. Since now that i see other code seems to use specific-register constraints, perhaps I should follow that instead...
I.e.
__asm__ __volatile__( "int $0x29" :: "c" ((ULONG_PTR)code) : "memory" );
As an added bonus, that would make the function identical between x64 and x86. (The cast to ULONG_PTR is to make the compiler aware that the upper bits of rcx _must_ be zero, rather than just letting it happen incidentally.)
Something similar might be applicable to ARM, too, but I'm not sure.
There's no such thing as specific-register constraints in ARM/ARM64.
Thanks, Thomas