push rbx ; ebx is affected by CPUID
mov eax, 1 ; get version information
cpuid
; check RDRAND support
bt ecx, 30 ; RDRAND supported?
jnc .failed ; no: jump
.done:
mov rax, 1 ; indicate success
pop rbx
ret
.failed:
sub rax, rax ; indicate failure
jmp short .done
little oops, there
mov rax, 1 ; indicate success
.done:
pop rbx
ret
even better
mov rax,1
push rbx
cpuid
xor rax,rax
bt ecx,30
pop rbx
rcl rax,1
ret