X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/4d99c15efa500303c59a6e419634f2ed0123766d..1b07c4f340465551b7d12c3be3bcecd258a3c32d:/base/dispatch-x86ish.S diff --git a/base/dispatch-x86ish.S b/base/dispatch-x86ish.S index 94f44ee1..b3b6d1cb 100644 --- a/base/dispatch-x86ish.S +++ b/base/dispatch-x86ish.S @@ -158,22 +158,27 @@ ENDFUNC /// Checking `rdrand'. FUNC(dispatch_x86ish_rdrand) - // Enter with one argument: a pointer X_OUT to a 32-bit word. Try to - // generate a random word using `rdrand'. If successful, set *X_OUT - // to the generated word, and return zero; otherwise, return -1. + // Enter with two arguments: a code OP requesting `rdrand' (0), and a + // pointer X_OUT to a 32-bit word. Try to generate a random word + // using the requested instruction. If successful, set *X_OUT to the + // generated word, and return zero; otherwise, return -1. #if CPUFAM_X86 +# define OP eax # define X_OUT edx # define COUNT ecx - mov X_OUT, [SP + 4] + mov OP, [SP + 4] + mov X_OUT, [SP + 8] #endif #if CPUFAM_AMD64 && ABI_SYSV -# define X_OUT rdi +# define OP edi +# define X_OUT rsi # define COUNT ecx #endif #if CPUFAM_AMD64 && ABI_WIN -# define X_OUT rcx -# define COUNT edx +# define OP rcx +# define X_OUT rdx +# define COUNT r8d #endif endprologue @@ -182,9 +187,10 @@ FUNC(dispatch_x86ish_rdrand) jc 9f dec COUNT jnz 0b + jmp 8f // Failed to come up with a random value. - mov eax, -1 +8: mov eax, -1 ret // Success.