asmkit/x86/features/RDTSCP.rs
1use crate::x86::assembler::*;
2use crate::x86::operands::*;
3use super::super::opcodes::*;
4use crate::core::emitter::*;
5use crate::core::operand::*;
6
7/// A dummy operand that represents no register. Here just for simplicity.
8const NOREG: Operand = Operand::new();
9
10/// `RDTSCP` (RDTSCP).
11/// Reads the current value of the processor’s time-stamp counter (a 64-bit MSR) into the EDX:EAX registers and also reads the value of the IA32_TSC_AUX MSR (address C0000103H) into the ECX register. The EDX register is loaded with the high-order 32 bits of the IA32_TSC MSR; the EAX register is loaded with the low-order 32 bits of the IA32_TSC MSR; and the ECX register is loaded with the low-order 32-bits of IA32_TSC_AUX MSR. On processors that support the Intel 64 architecture, the high-order 32 bits of each of RAX, RDX, and RCX are cleared.
12///
13///
14/// For more details, see the [Intel manual](https://www.felixcloutier.com/x86/RDTSCP.html).
15///
16/// Supported operand variants:
17///
18/// ```text
19/// +---+----------+
20/// | # | Operands |
21/// +---+----------+
22/// | 1 | (none) |
23/// +---+----------+
24/// ```
25pub trait RdtscpEmitter {
26 fn rdtscp(&mut self);
27}
28
29impl<'a> RdtscpEmitter for Assembler<'a> {
30 fn rdtscp(&mut self) {
31 self.emit(RDTSCP, &NOREG, &NOREG, &NOREG, &NOREG);
32 }
33}
34
35
36impl<'a> Assembler<'a> {
37 /// `RDTSCP` (RDTSCP).
38 /// Reads the current value of the processor’s time-stamp counter (a 64-bit MSR) into the EDX:EAX registers and also reads the value of the IA32_TSC_AUX MSR (address C0000103H) into the ECX register. The EDX register is loaded with the high-order 32 bits of the IA32_TSC MSR; the EAX register is loaded with the low-order 32 bits of the IA32_TSC MSR; and the ECX register is loaded with the low-order 32-bits of IA32_TSC_AUX MSR. On processors that support the Intel 64 architecture, the high-order 32 bits of each of RAX, RDX, and RCX are cleared.
39 ///
40 ///
41 /// For more details, see the [Intel manual](https://www.felixcloutier.com/x86/RDTSCP.html).
42 ///
43 /// Supported operand variants:
44 ///
45 /// ```text
46 /// +---+----------+
47 /// | # | Operands |
48 /// +---+----------+
49 /// | 1 | (none) |
50 /// +---+----------+
51 /// ```
52 #[inline]
53 pub fn rdtscp(&mut self)
54 where Assembler<'a>: RdtscpEmitter {
55 <Self as RdtscpEmitter>::rdtscp(self);
56 }
57}