0

I am trying to test for an error in RDRAND and RDSEED using MSVC-style inline assembly. If I remember correctly a flag for failure is stored in a register, but I cannot remember which one. I have seen an example on Intel's website

    asm volatile ("rdrand %0; setc %1"
    : "=r" (*rand), "=qm" (ok));

where "=qm" and "ok" indicate a failure if not equal to 1, but I am relatively unfamiliar with GCC-style inline assembly, so I do not know what "=qm" means, and I have not been able to figure it out. How can I determine success or failure in MSVC-style inline assembly?

Thanks in advance.

  • The status is in the `CF` (see the instruction set reference). That code just uses `setc` to transfer it to an output operand. PS: you should use the intrinsic instead, if available. – Jester Apr 02 '18 at 22:42
  • @Jester I also forgot to mention that I am very new to assembly in general, how do I read from CF? Also, the compiler I use does not have the RDRAND intrinsic functions. – FeeeshMeister Apr 02 '18 at 22:46
  • Use `setc` as in the code. Just give it an operand where you want the result. – Jester Apr 02 '18 at 22:47
  • 2
    Which compiler & version are you using? Using the intrinsic `_rdrand32_step` (or 16 or 64) would be better if it is available (in `immintrin.h`). – 1201ProgramAlarm Apr 02 '18 at 22:51

0 Answers0