Skip to main content

asmkit/x86/features/
MOVDIRI.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/// `MOVDIRI` (MOVDIRI). 
11/// Moves the doubleword integer in the source operand (second operand) to the destination operand (first operand) using a direct-store operation. The source operand is a general purpose register. The destination operand is a 32-bit memory location. In 64-bit mode, the instruction’s default operation size is 32 bits. Use of the REX.R prefix permits access to additional registers (R8-R15). Use of the REX.W prefix promotes operation to 64 bits. See summary chart at the beginning of this section for encoding data and limits.
12///
13///
14/// For more details, see the [Intel manual](https://www.felixcloutier.com/x86/MOVDIRI.html).
15///
16/// Supported operand variants:
17///
18/// ```text
19/// +---+----------+
20/// | # | Operands |
21/// +---+----------+
22/// | 1 | Mem, Gpd |
23/// | 2 | Mem, Gpq |
24/// +---+----------+
25/// ```
26pub trait MovdiriEmitter<A, B> {
27    fn movdiri(&mut self, op0: A, op1: B);
28}
29
30impl<'a> MovdiriEmitter<Mem, Gpd> for Assembler<'a> {
31    fn movdiri(&mut self, op0: Mem, op1: Gpd) {
32        self.emit(MOVDIRI32MR, op0.as_operand(), op1.as_operand(), &NOREG, &NOREG);
33    }
34}
35
36impl<'a> MovdiriEmitter<Mem, Gpq> for Assembler<'a> {
37    fn movdiri(&mut self, op0: Mem, op1: Gpq) {
38        self.emit(MOVDIRI64MR, op0.as_operand(), op1.as_operand(), &NOREG, &NOREG);
39    }
40}
41
42
43impl<'a> Assembler<'a> {
44    /// `MOVDIRI` (MOVDIRI). 
45    /// Moves the doubleword integer in the source operand (second operand) to the destination operand (first operand) using a direct-store operation. The source operand is a general purpose register. The destination operand is a 32-bit memory location. In 64-bit mode, the instruction’s default operation size is 32 bits. Use of the REX.R prefix permits access to additional registers (R8-R15). Use of the REX.W prefix promotes operation to 64 bits. See summary chart at the beginning of this section for encoding data and limits.
46    ///
47    ///
48    /// For more details, see the [Intel manual](https://www.felixcloutier.com/x86/MOVDIRI.html).
49    ///
50    /// Supported operand variants:
51    ///
52    /// ```text
53    /// +---+----------+
54    /// | # | Operands |
55    /// +---+----------+
56    /// | 1 | Mem, Gpd |
57    /// | 2 | Mem, Gpq |
58    /// +---+----------+
59    /// ```
60    #[inline]
61    pub fn movdiri<A, B>(&mut self, op0: A, op1: B)
62    where Assembler<'a>: MovdiriEmitter<A, B> {
63        <Self as MovdiriEmitter<A, B>>::movdiri(self, op0, op1);
64    }
65}