Skip to main content

osom_encoders_x86_64/encoders/
cmp.rs

1//! This module contains the encoders for the `cmp` 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/// Compare 8-bit immediate with AL register.
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_al_imm8(imm8: Immediate8) -> EncodedX86_64Instruction {
19    unsafe { crate::partial_encoders::i::encode_imm8([0x3C], imm8) }
20}
21
22/// Compare 16-bit immediate with AX register.
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_ax_imm16(imm16: Immediate16) -> EncodedX86_64Instruction {
30    unsafe { crate::partial_encoders::i::encode_imm16_oso([0x3D], imm16) }
31}
32
33/// Compare 32-bit immediate with EAX register.
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_eax_imm32(imm32: Immediate32) -> EncodedX86_64Instruction {
41    unsafe { crate::partial_encoders::i::encode_imm32([0x3D], imm32) }
42}
43
44/// Compare 32-bit immediate sign-extended with RAX register.
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_rax_imm32(imm32: Immediate32) -> EncodedX86_64Instruction {
52    unsafe { crate::partial_encoders::i::encode_imm32_rexw([0x3D], imm32) }
53}
54
55/// Compare 8-bit immediate with 8-bit register or memory.
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_rm8_imm8(rm8: GPROrMemory, imm8: Immediate8) -> EncodedX86_64Instruction {
63    unsafe { crate::partial_encoders::mi::encode_rm8_imm8([0x80], 0x07, rm8, imm8) }
64}
65
66/// Compare 16-bit immediate with 16-bit register or memory.
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_rm16_imm16(rm16: GPROrMemory, imm16: Immediate16) -> EncodedX86_64Instruction {
74    unsafe { crate::partial_encoders::mi::encode_rm16_imm16([0x81], 0x07, rm16, imm16) }
75}
76
77/// Compare 32-bit immediate with 32-bit register or memory.
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_rm32_imm32(rm32: GPROrMemory, imm32: Immediate32) -> EncodedX86_64Instruction {
85    unsafe { crate::partial_encoders::mi::encode_rm32_imm32([0x81], 0x07, rm32, imm32) }
86}
87
88/// Compare 32-bit immediate with 64-bit register or memory.
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_rm64_imm32(rm64: GPROrMemory, imm32: Immediate32) -> EncodedX86_64Instruction {
96    unsafe { crate::partial_encoders::mi::encode_rm64_imm32([0x81], 0x07, rm64, imm32) }
97}
98
99/// Compare 8-bit immediate (sign-extended) with 16-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_rm16_imm8(rm16: GPROrMemory, imm8: Immediate8) -> EncodedX86_64Instruction {
107    unsafe { crate::partial_encoders::mi::encode_rm16_imm8([0x83], 0x07, rm16, imm8) }
108}
109
110/// Compare 8-bit immediate (sign-extended) with 32-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_rm32_imm8(rm32: GPROrMemory, imm8: Immediate8) -> EncodedX86_64Instruction {
118    unsafe { crate::partial_encoders::mi::encode_rm32_imm8([0x83], 0x07, rm32, imm8) }
119}
120
121/// Compare 8-bit immediate (sign-extended) with 64-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_rm64_imm8(rm64: GPROrMemory, imm8: Immediate8) -> EncodedX86_64Instruction {
129    unsafe { crate::partial_encoders::mi::encode_rm64_imm8([0x83], 0x07, rm64, imm8) }
130}
131
132/// Compare 8-bit register with 8-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_rm8_reg8(rm8: GPROrMemory, reg8: GPR) -> EncodedX86_64Instruction {
140    unsafe { crate::partial_encoders::mr::encode([0x38], rm8, reg8) }
141}
142
143/// Compare 16-bit register with 16-bit register or memory.
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_rm16_reg16(rm16: GPROrMemory, reg16: GPR) -> EncodedX86_64Instruction {
151    unsafe { crate::partial_encoders::mr::encode([0x39], rm16, reg16) }
152}
153
154/// Compare 32-bit register with 32-bit register or memory.
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_rm32_reg32(rm32: GPROrMemory, reg32: GPR) -> EncodedX86_64Instruction {
162    unsafe { crate::partial_encoders::mr::encode([0x39], rm32, reg32) }
163}
164
165/// Compare 64-bit register with 64-bit register or memory.
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_rm64_reg64(rm64: GPROrMemory, reg64: GPR) -> EncodedX86_64Instruction {
173    unsafe { crate::partial_encoders::mr::encode([0x39], rm64, reg64) }
174}
175
176/// Compare 8-bit register or memory with 8-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_reg8_rm8(reg8: GPR, rm8: GPROrMemory) -> EncodedX86_64Instruction {
184    unsafe { crate::partial_encoders::mr::encode([0x3A], rm8, reg8) }
185}
186
187/// Compare 16-bit register or memory with 16-bit register.
188///
189/// # Safety
190///
191/// It is the caller's responsibility to ensure that the operands are valid.
192/// Otherwise the behavior is undefined.
193#[inline]
194pub const unsafe fn encode_reg16_rm16(reg16: GPR, rm16: GPROrMemory) -> EncodedX86_64Instruction {
195    unsafe { crate::partial_encoders::mr::encode([0x3B], rm16, reg16) }
196}
197
198/// Compare 32-bit register or memory with 32-bit register.
199///
200/// # Safety
201///
202/// It is the caller's responsibility to ensure that the operands are valid.
203/// Otherwise the behavior is undefined.
204#[inline]
205pub const unsafe fn encode_reg32_rm32(reg32: GPR, rm32: GPROrMemory) -> EncodedX86_64Instruction {
206    unsafe { crate::partial_encoders::mr::encode([0x3B], rm32, reg32) }
207}
208
209/// Compare 64-bit register or memory with 64-bit register.
210///
211/// # Safety
212///
213/// It is the caller's responsibility to ensure that the operands are valid.
214/// Otherwise the behavior is undefined.
215#[inline]
216pub const unsafe fn encode_reg64_rm64(reg64: GPR, rm64: GPROrMemory) -> EncodedX86_64Instruction {
217    unsafe { crate::partial_encoders::mr::encode([0x3B], rm64, reg64) }
218}