cpu.x86: Add ghetto RDRAND support. Proper support wouldn't use alien-assembly and would take a count parameter.

db4
Doug Coleman 2012-09-20 11:54:44 -07:00
parent 88b196dc8c
commit ed83c87554
2 changed files with 22 additions and 0 deletions

View File

@ -451,6 +451,8 @@ PRIVATE>
: RDMSR ( -- ) 0x0f , 0x32 , ; ! Only available in privileged level 0
: RDPMC ( -- ) 0x0f , 0x33 , ;
: RDRAND ( dst -- ) { 0b110 t { 0x0f 0xc7 } } 1-operand ;
! x87 Floating Point Unit
: FSTPS ( operand -- ) { 0b011 f 0xd9 } 1-operand ;

View File

@ -141,6 +141,26 @@ HOOK: (cpuid) cpu ( rax rcx regs -- )
: tm1? ( -- ? ) 1 cpuid fourth 29 bit? ;
: tm2? ( -- ? ) 1 cpuid third 8 bit? ;
: rdrand8 ( -- x )
uchar { } cdecl [
AL RDRAND
] alien-assembly ;
: rdrand16 ( -- x )
ushort { } cdecl [
AX RDRAND
] alien-assembly ;
: rdrand32 ( -- x )
uint { } cdecl [
EAX RDRAND
] alien-assembly ;
: rdrand64 ( -- x )
ulonglong { } cdecl [
RAX RDRAND
] alien-assembly ;
MEMO: enable-popcnt? ( -- ? )
popcnt? "disable-popcnt" get not and ;