asmkit/x86/features/FRED.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/// `ERETS`.
11///
12/// Supported operand variants:
13///
14/// ```text
15/// +---+----------+
16/// | # | Operands |
17/// +---+----------+
18/// | 1 | (none) |
19/// +---+----------+
20/// ```
21pub trait EretsEmitter {
22 fn erets(&mut self);
23}
24
25impl<'a> EretsEmitter for Assembler<'a> {
26 fn erets(&mut self) {
27 self.emit(ERETS, &NOREG, &NOREG, &NOREG, &NOREG);
28 }
29}
30
31/// `ERETU`.
32///
33/// Supported operand variants:
34///
35/// ```text
36/// +---+----------+
37/// | # | Operands |
38/// +---+----------+
39/// | 1 | (none) |
40/// +---+----------+
41/// ```
42pub trait EretuEmitter {
43 fn eretu(&mut self);
44}
45
46impl<'a> EretuEmitter for Assembler<'a> {
47 fn eretu(&mut self) {
48 self.emit(ERETU, &NOREG, &NOREG, &NOREG, &NOREG);
49 }
50}
51
52/// `LKGS`.
53///
54/// Supported operand variants:
55///
56/// ```text
57/// +---+----------+
58/// | # | Operands |
59/// +---+----------+
60/// | 1 | Gpd |
61/// | 2 | Mem |
62/// +---+----------+
63/// ```
64pub trait LkgsEmitter<A> {
65 fn lkgs(&mut self, op0: A);
66}
67
68impl<'a> LkgsEmitter<Gpd> for Assembler<'a> {
69 fn lkgs(&mut self, op0: Gpd) {
70 self.emit(LKGSR, op0.as_operand(), &NOREG, &NOREG, &NOREG);
71 }
72}
73
74impl<'a> LkgsEmitter<Mem> for Assembler<'a> {
75 fn lkgs(&mut self, op0: Mem) {
76 self.emit(LKGSM, op0.as_operand(), &NOREG, &NOREG, &NOREG);
77 }
78}
79
80
81impl<'a> Assembler<'a> {
82 /// `ERETS`.
83 ///
84 /// Supported operand variants:
85 ///
86 /// ```text
87 /// +---+----------+
88 /// | # | Operands |
89 /// +---+----------+
90 /// | 1 | (none) |
91 /// +---+----------+
92 /// ```
93 #[inline]
94 pub fn erets(&mut self)
95 where Assembler<'a>: EretsEmitter {
96 <Self as EretsEmitter>::erets(self);
97 }
98 /// `ERETU`.
99 ///
100 /// Supported operand variants:
101 ///
102 /// ```text
103 /// +---+----------+
104 /// | # | Operands |
105 /// +---+----------+
106 /// | 1 | (none) |
107 /// +---+----------+
108 /// ```
109 #[inline]
110 pub fn eretu(&mut self)
111 where Assembler<'a>: EretuEmitter {
112 <Self as EretuEmitter>::eretu(self);
113 }
114 /// `LKGS`.
115 ///
116 /// Supported operand variants:
117 ///
118 /// ```text
119 /// +---+----------+
120 /// | # | Operands |
121 /// +---+----------+
122 /// | 1 | Gpd |
123 /// | 2 | Mem |
124 /// +---+----------+
125 /// ```
126 #[inline]
127 pub fn lkgs<A>(&mut self, op0: A)
128 where Assembler<'a>: LkgsEmitter<A> {
129 <Self as LkgsEmitter<A>>::lkgs(self, op0);
130 }
131}