osom_encoders_x86_64/encoders/mov.rs
1//! This module contains the encoders for the `mov` instruction group.
2#![allow(unused_imports)]
3
4// ** This file is automatically generated from x86.yaml schema. Do not modify! **
5
6use crate::models::{
7 EncodedX86_64Instruction, GPR, GPROrMemory, Immediate8, Immediate16, Immediate32, Immediate64, Memory, Offset,
8 Scale, Size,
9};
10
11/// Move 8-bit immediate to 8-bit register or memory.
12///
13/// # Safety
14///
15/// It is the caller's responsibility to ensure that the operands are valid.
16/// Otherwise the behavior is undefined.
17#[inline]
18pub const unsafe fn encode_rm8_imm8(rm8: GPROrMemory, imm8: Immediate8) -> EncodedX86_64Instruction {
19 unsafe { crate::partial_encoders::mi::encode_rm8_imm8([0xC6], 0x00, rm8, imm8) }
20}
21
22/// Move 16-bit immediate to 16-bit register or memory.
23///
24/// # Safety
25///
26/// It is the caller's responsibility to ensure that the operands are valid.
27/// Otherwise the behavior is undefined.
28#[inline]
29pub const unsafe fn encode_rm16_imm16(rm16: GPROrMemory, imm16: Immediate16) -> EncodedX86_64Instruction {
30 unsafe { crate::partial_encoders::mi::encode_rm16_imm16([0xC7], 0x00, rm16, imm16) }
31}
32
33/// Move 32-bit immediate to 32-bit register or memory.
34///
35/// # Safety
36///
37/// It is the caller's responsibility to ensure that the operands are valid.
38/// Otherwise the behavior is undefined.
39#[inline]
40pub const unsafe fn encode_rm32_imm32(rm32: GPROrMemory, imm32: Immediate32) -> EncodedX86_64Instruction {
41 unsafe { crate::partial_encoders::mi::encode_rm32_imm32([0xC7], 0x00, rm32, imm32) }
42}
43
44/// Move 32-bit immediate to 64-bit register or memory, sign extended.
45///
46/// # Safety
47///
48/// It is the caller's responsibility to ensure that the operands are valid.
49/// Otherwise the behavior is undefined.
50#[inline]
51pub const unsafe fn encode_rm64_imm32(rm64: GPROrMemory, imm32: Immediate32) -> EncodedX86_64Instruction {
52 unsafe { crate::partial_encoders::mi::encode_rm64_imm32([0xC7], 0x00, rm64, imm32) }
53}
54
55/// Move 8-bit immediate to 8-bit register.
56///
57/// # Safety
58///
59/// It is the caller's responsibility to ensure that the operands are valid.
60/// Otherwise the behavior is undefined.
61#[inline]
62pub const unsafe fn encode_reg8_imm8(reg8: GPR, imm8: Immediate8) -> EncodedX86_64Instruction {
63 unsafe { crate::partial_encoders::oi::encode_reg8_imm8(0xB0, reg8, imm8) }
64}
65
66/// Move 16-bit immediate to 16-bit register.
67///
68/// # Safety
69///
70/// It is the caller's responsibility to ensure that the operands are valid.
71/// Otherwise the behavior is undefined.
72#[inline]
73pub const unsafe fn encode_reg16_imm16(reg16: GPR, imm16: Immediate16) -> EncodedX86_64Instruction {
74 unsafe { crate::partial_encoders::oi::encode_reg16_imm16(0xB8, reg16, imm16) }
75}
76
77/// Move 32-bit immediate to 32-bit register.
78///
79/// # Safety
80///
81/// It is the caller's responsibility to ensure that the operands are valid.
82/// Otherwise the behavior is undefined.
83#[inline]
84pub const unsafe fn encode_reg32_imm32(reg32: GPR, imm32: Immediate32) -> EncodedX86_64Instruction {
85 unsafe { crate::partial_encoders::oi::encode_reg32_imm32(0xB8, reg32, imm32) }
86}
87
88/// Move 64-bit immediate to 64-bit register.
89///
90/// # Safety
91///
92/// It is the caller's responsibility to ensure that the operands are valid.
93/// Otherwise the behavior is undefined.
94#[inline]
95pub const unsafe fn encode_reg64_imm64(reg64: GPR, imm64: Immediate64) -> EncodedX86_64Instruction {
96 unsafe { crate::partial_encoders::oi::encode_reg64_imm64(0xB8, reg64, imm64) }
97}
98
99/// Move 8-bit register to 8-bit register or memory.
100///
101/// # Safety
102///
103/// It is the caller's responsibility to ensure that the operands are valid.
104/// Otherwise the behavior is undefined.
105#[inline]
106pub const unsafe fn encode_rm8_reg8(rm8: GPROrMemory, reg8: GPR) -> EncodedX86_64Instruction {
107 unsafe { crate::partial_encoders::mr::encode([0x88], rm8, reg8) }
108}
109
110/// Move 16-bit register to 16-bit register or memory.
111///
112/// # Safety
113///
114/// It is the caller's responsibility to ensure that the operands are valid.
115/// Otherwise the behavior is undefined.
116#[inline]
117pub const unsafe fn encode_rm16_reg16(rm16: GPROrMemory, reg16: GPR) -> EncodedX86_64Instruction {
118 unsafe { crate::partial_encoders::mr::encode([0x89], rm16, reg16) }
119}
120
121/// Move 32-bit register to 32-bit register or memory.
122///
123/// # Safety
124///
125/// It is the caller's responsibility to ensure that the operands are valid.
126/// Otherwise the behavior is undefined.
127#[inline]
128pub const unsafe fn encode_rm32_reg32(rm32: GPROrMemory, reg32: GPR) -> EncodedX86_64Instruction {
129 unsafe { crate::partial_encoders::mr::encode([0x89], rm32, reg32) }
130}
131
132/// Move 64-bit register to 64-bit register or memory.
133///
134/// # Safety
135///
136/// It is the caller's responsibility to ensure that the operands are valid.
137/// Otherwise the behavior is undefined.
138#[inline]
139pub const unsafe fn encode_rm64_reg64(rm64: GPROrMemory, reg64: GPR) -> EncodedX86_64Instruction {
140 unsafe { crate::partial_encoders::mr::encode([0x89], rm64, reg64) }
141}
142
143/// Move 8-bit register or memory to 8-bit register.
144///
145/// # Safety
146///
147/// It is the caller's responsibility to ensure that the operands are valid.
148/// Otherwise the behavior is undefined.
149#[inline]
150pub const unsafe fn encode_reg8_rm8(reg8: GPR, rm8: GPROrMemory) -> EncodedX86_64Instruction {
151 unsafe { crate::partial_encoders::mr::encode([0x8A], rm8, reg8) }
152}
153
154/// Move 16-bit register or memory to 16-bit register.
155///
156/// # Safety
157///
158/// It is the caller's responsibility to ensure that the operands are valid.
159/// Otherwise the behavior is undefined.
160#[inline]
161pub const unsafe fn encode_reg16_rm16(reg16: GPR, rm16: GPROrMemory) -> EncodedX86_64Instruction {
162 unsafe { crate::partial_encoders::mr::encode([0x8B], rm16, reg16) }
163}
164
165/// Move 32-bit register or memory to 32-bit register.
166///
167/// # Safety
168///
169/// It is the caller's responsibility to ensure that the operands are valid.
170/// Otherwise the behavior is undefined.
171#[inline]
172pub const unsafe fn encode_reg32_rm32(reg32: GPR, rm32: GPROrMemory) -> EncodedX86_64Instruction {
173 unsafe { crate::partial_encoders::mr::encode([0x8B], rm32, reg32) }
174}
175
176/// Move 64-bit register or memory to 64-bit register.
177///
178/// # Safety
179///
180/// It is the caller's responsibility to ensure that the operands are valid.
181/// Otherwise the behavior is undefined.
182#[inline]
183pub const unsafe fn encode_reg64_rm64(reg64: GPR, rm64: GPROrMemory) -> EncodedX86_64Instruction {
184 unsafe { crate::partial_encoders::mr::encode([0x8B], rm64, reg64) }
185}