asmkit/x86/features/XSS.rs
1use super::super::opcodes::*;
2use crate::core::emitter::*;
3use crate::core::operand::*;
4use crate::x86::assembler::*;
5use crate::x86::operands::*;
6
7/// A dummy operand that represents no register. Here just for simplicity.
8const NOREG: Operand = Operand::new();
9
10/// `XRSTORS`.
11///
12/// Supported operand variants:
13///
14/// ```text
15/// +---+----------+
16/// | # | Operands |
17/// +---+----------+
18/// | 1 | Mem |
19/// +---+----------+
20/// ```
21pub trait XrstorsEmitter<A> {
22 fn xrstors(&mut self, op0: A);
23}
24
25impl<'a> XrstorsEmitter<Mem> for Assembler<'a> {
26 fn xrstors(&mut self, op0: Mem) {
27 self.emit(XRSTORS32M, op0.as_operand(), &NOREG, &NOREG, &NOREG);
28 }
29}
30
31/// `XSAVES`.
32///
33/// Supported operand variants:
34///
35/// ```text
36/// +---+----------+
37/// | # | Operands |
38/// +---+----------+
39/// | 1 | Mem |
40/// +---+----------+
41/// ```
42pub trait XsavesEmitter<A> {
43 fn xsaves(&mut self, op0: A);
44}
45
46impl<'a> XsavesEmitter<Mem> for Assembler<'a> {
47 fn xsaves(&mut self, op0: Mem) {
48 self.emit(XSAVES32M, op0.as_operand(), &NOREG, &NOREG, &NOREG);
49 }
50}
51
52impl<'a> Assembler<'a> {
53 /// `XRSTORS`.
54 ///
55 /// Supported operand variants:
56 ///
57 /// ```text
58 /// +---+----------+
59 /// | # | Operands |
60 /// +---+----------+
61 /// | 1 | Mem |
62 /// +---+----------+
63 /// ```
64 #[inline]
65 pub fn xrstors<A>(&mut self, op0: A)
66 where
67 Assembler<'a>: XrstorsEmitter<A>,
68 {
69 <Self as XrstorsEmitter<A>>::xrstors(self, op0);
70 }
71 /// `XSAVES`.
72 ///
73 /// Supported operand variants:
74 ///
75 /// ```text
76 /// +---+----------+
77 /// | # | Operands |
78 /// +---+----------+
79 /// | 1 | Mem |
80 /// +---+----------+
81 /// ```
82 #[inline]
83 pub fn xsaves<A>(&mut self, op0: A)
84 where
85 Assembler<'a>: XsavesEmitter<A>,
86 {
87 <Self as XsavesEmitter<A>>::xsaves(self, op0);
88 }
89}