asmkit/x86/features/SERIALIZE.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/// `SERIALIZE` (SERIALIZE).
11/// Serializes instruction execution. Before the next instruction is fetched and executed, the SERIALIZE instruction ensures that all modifications to flags, registers, and memory by previous instructions are completed, draining all buffered writes to memory. This instruction is also a serializing instruction as defined in the section “Serializing Instructions” in Chapter 9 of the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 3A.
12///
13///
14/// For more details, see the [Intel manual](https://www.felixcloutier.com/x86/SERIALIZE.html).
15///
16/// Supported operand variants:
17///
18/// ```text
19/// +---+----------+
20/// | # | Operands |
21/// +---+----------+
22/// | 1 | (none) |
23/// +---+----------+
24/// ```
25pub trait SerializeEmitter {
26 fn serialize(&mut self);
27}
28
29impl<'a> SerializeEmitter for Assembler<'a> {
30 fn serialize(&mut self) {
31 self.emit(SERIALIZE, &NOREG, &NOREG, &NOREG, &NOREG);
32 }
33}
34
35
36impl<'a> Assembler<'a> {
37 /// `SERIALIZE` (SERIALIZE).
38 /// Serializes instruction execution. Before the next instruction is fetched and executed, the SERIALIZE instruction ensures that all modifications to flags, registers, and memory by previous instructions are completed, draining all buffered writes to memory. This instruction is also a serializing instruction as defined in the section “Serializing Instructions” in Chapter 9 of the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 3A.
39 ///
40 ///
41 /// For more details, see the [Intel manual](https://www.felixcloutier.com/x86/SERIALIZE.html).
42 ///
43 /// Supported operand variants:
44 ///
45 /// ```text
46 /// +---+----------+
47 /// | # | Operands |
48 /// +---+----------+
49 /// | 1 | (none) |
50 /// +---+----------+
51 /// ```
52 #[inline]
53 pub fn serialize(&mut self)
54 where Assembler<'a>: SerializeEmitter {
55 <Self as SerializeEmitter>::serialize(self);
56 }
57}