osom_encoders_x86_64/encoders/encoding_funcs/
enc.rs1#![allow(clippy::wildcard_imports)]
6use crate::models::EncodedX86_64Instruction;
7
8pub mod miscellaneous {
10 use super::*;
11
12 #[inline]
25 pub const fn encode_nop_with_length(length: u8) -> EncodedX86_64Instruction {
26 unsafe {
27 match length {
28 1 => EncodedX86_64Instruction::from_array([0x90]),
29 2 => EncodedX86_64Instruction::from_array([0x66, 0x90]),
30 3 => EncodedX86_64Instruction::from_array([0x0F, 0x1F, 0x00]),
31 4 => EncodedX86_64Instruction::from_array([0x0F, 0x1F, 0x40, 0x00]),
32 5 => EncodedX86_64Instruction::from_array([0x0F, 0x1F, 0x44, 0x00, 0x00]),
33 6 => EncodedX86_64Instruction::from_array([0x66, 0x0F, 0x1F, 0x44, 0x00, 0x00]),
34 7 => EncodedX86_64Instruction::from_array([0x0F, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00]),
35 8 => EncodedX86_64Instruction::from_array([0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00]),
36 9 => EncodedX86_64Instruction::from_array([0x66, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00]),
37 _ => panic!("Invalid length for encode_nop_with_length call. Expected u8 in 1..=9 range."),
38 }
39 }
40 }
41}