I was looking through an Intel provided reference implementation of RDRAND instruction. The page is Intel Digital Random Number Generator (DRNG) Software Implementation Guide, and the code came from Intel Digital Random Number Generator software code examples.
RDRAND
The following is the relevant portion from Intel. It reads a random value and places it in val, and it sets the carry flag on success.
val
char rc; unsigned int val; __asm__ volatile( "rdrand %0 ; setc %1" : "=r" (val), "=qm" (rc) ); // 1 = success, 0 = underflow if(rc) { // use val ... }
Soory to have to ask. I don't think it was covered in GNU Extended Assembler, and searching for "=qm" is producing spurious hits.
What does the "=qm" mean in the extended assembler?
"=qm"
What you're looking at is an inline assembler constraint. The GCC documentation is at 6.47.3.1 Simple Constraints and 6.47.3.4 Constraints for Particular Machines under x86 family section. This one (=qm) combines three flags which indicate:
=qm
=
q
a
b
c
d
esi
m
2.1m questions
2.1m answers
60 comments
57.0k users