Skip to main content

asmkit/x86/features/
MOVDIRI.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/// `MOVDIRI`.
11///
12/// Supported operand variants:
13///
14/// ```text
15/// +---+----------+
16/// | # | Operands |
17/// +---+----------+
18/// | 1 | Mem, Gpd |
19/// | 2 | Mem, Gpq |
20/// +---+----------+
21/// ```
22pub trait MovdiriEmitter<A, B> {
23    fn movdiri(&mut self, op0: A, op1: B);
24}
25
26impl<'a> MovdiriEmitter<Mem, Gpd> for Assembler<'a> {
27    fn movdiri(&mut self, op0: Mem, op1: Gpd) {
28        self.emit(
29            MOVDIRI32MR,
30            op0.as_operand(),
31            op1.as_operand(),
32            &NOREG,
33            &NOREG,
34        );
35    }
36}
37
38impl<'a> MovdiriEmitter<Mem, Gpq> for Assembler<'a> {
39    fn movdiri(&mut self, op0: Mem, op1: Gpq) {
40        self.emit(
41            MOVDIRI64MR,
42            op0.as_operand(),
43            op1.as_operand(),
44            &NOREG,
45            &NOREG,
46        );
47    }
48}
49
50impl<'a> Assembler<'a> {
51    /// `MOVDIRI`.
52    ///
53    /// Supported operand variants:
54    ///
55    /// ```text
56    /// +---+----------+
57    /// | # | Operands |
58    /// +---+----------+
59    /// | 1 | Mem, Gpd |
60    /// | 2 | Mem, Gpq |
61    /// +---+----------+
62    /// ```
63    #[inline]
64    pub fn movdiri<A, B>(&mut self, op0: A, op1: B)
65    where
66        Assembler<'a>: MovdiriEmitter<A, B>,
67    {
68        <Self as MovdiriEmitter<A, B>>::movdiri(self, op0, op1);
69    }
70}