cpu.x86: Add ghetto RDRAND support. Proper support wouldn't use alien-assembly and would take a count parameter.
parent
88b196dc8c
commit
ed83c87554
|
@ -451,6 +451,8 @@ PRIVATE>
|
||||||
: RDMSR ( -- ) 0x0f , 0x32 , ; ! Only available in privileged level 0
|
: RDMSR ( -- ) 0x0f , 0x32 , ; ! Only available in privileged level 0
|
||||||
: RDPMC ( -- ) 0x0f , 0x33 , ;
|
: RDPMC ( -- ) 0x0f , 0x33 , ;
|
||||||
|
|
||||||
|
: RDRAND ( dst -- ) { 0b110 t { 0x0f 0xc7 } } 1-operand ;
|
||||||
|
|
||||||
! x87 Floating Point Unit
|
! x87 Floating Point Unit
|
||||||
|
|
||||||
: FSTPS ( operand -- ) { 0b011 f 0xd9 } 1-operand ;
|
: FSTPS ( operand -- ) { 0b011 f 0xd9 } 1-operand ;
|
||||||
|
|
|
@ -141,6 +141,26 @@ HOOK: (cpuid) cpu ( rax rcx regs -- )
|
||||||
: tm1? ( -- ? ) 1 cpuid fourth 29 bit? ;
|
: tm1? ( -- ? ) 1 cpuid fourth 29 bit? ;
|
||||||
: tm2? ( -- ? ) 1 cpuid third 8 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? ( -- ? )
|
MEMO: enable-popcnt? ( -- ? )
|
||||||
popcnt? "disable-popcnt" get not and ;
|
popcnt? "disable-popcnt" get not and ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue