0

This is the code I want to run

unsigned int val = 0;
for(unsigned int i = 0; i < 10; i++) {

    _asm {

    lbl:
        rdseed eax;
        jnc lbl;
        mov val, eax;
    }
    std::cout << val << "\n";
}

It breaks on the second line and says illegal instruction like the compiler doesn't recognize it

Peter Cordes
  • 286,368
  • 41
  • 520
  • 731
  • 1
    Is it a 64 bit application? because as far as i know, [its not supported](https://stackoverflow.com/questions/6166437/64bit-applications-and-inline-assembly) – Borgleader May 16 '22 at 01:18
  • MSVC compiler targeting 64-bit doesn't support inline assembly. I believe if you use the Intel C/C++ Compiler as a back end in Visual Studio that is a potential solution. – Michael Petch May 16 '22 at 01:24
  • You don't, except with 32-bit x86. Use intrinsics whenever possible (`while(!_rdseed64_step(&val)) {}` in this case), even with better compilers that do support inline asm. – Peter Cordes May 16 '22 at 01:26

0 Answers0