Skip to main content

osom_encoders_x86_64/encoders/
sub.rs

1//! This module contains the encoders for the `sub` 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/// Subtract 8-bit immediate from 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([0x2C], imm8) }
20}
21
22/// Subtract 16-bit immediate from 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([0x2D], imm16) }
31}
32
33/// Subtract 32-bit immediate from 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([0x2D], imm32) }
42}
43
44/// Subtract 32-bit immediate from RAX register (sign-extended to 64 bits).
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([0x2D], imm32) }
53}
54
55/// Subtract 8-bit immediate from 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], 0x05, rm8, imm8) }
64}
65
66/// Subtract 16-bit immediate from 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], 0x05, rm16, imm16) }
75}
76
77/// Subtract 32-bit immediate from 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], 0x05, rm32, imm32) }
86}
87
88/// Subtract 32-bit immediate from 64-bit register or memory (sign-extended to 64 bits).
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], 0x05, rm64, imm32) }
97}
98
99/// Subtract 8-bit immediate (sign-extended) from 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], 0x05, rm16, imm8) }
108}
109
110/// Subtract 8-bit immediate (sign-extended) from 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], 0x05, rm32, imm8) }
119}
120
121/// Subtract 8-bit immediate (sign-extended) from 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], 0x05, rm64, imm8) }
130}
131
132/// Subtract 8-bit register from 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([0x28], rm8, reg8) }
141}
142
143/// Subtract 16-bit register from 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([0x29], rm16, reg16) }
152}
153
154/// Subtract 32-bit register from 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([0x29], rm32, reg32) }
163}
164
165/// Subtract 64-bit register from 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([0x29], rm64, reg64) }
174}
175
176/// Subtract 8-bit register or memory from 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([0x2A], rm8, reg8) }
185}
186
187/// Subtract 16-bit register or memory from 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([0x2B], rm16, reg16) }
196}
197
198/// Subtract 32-bit register or memory from 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([0x2B], rm32, reg32) }
207}
208
209/// Subtract 64-bit register or memory from 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([0x2B], rm64, reg64) }
218}