1mod private {
5 use crate::{Code, IcedError, Instruction};
6
7 pub trait With1<T> {
8 fn with1(code: Code, op0: T) -> Result<Instruction, IcedError>;
9 }
10
11 pub trait With2<T, U> {
12 fn with2(code: Code, op0: T, op1: U) -> Result<Instruction, IcedError>;
13 }
14
15 pub trait With3<T, U, V> {
16 fn with3(code: Code, op0: T, op1: U, op2: V) -> Result<Instruction, IcedError>;
17 }
18
19 pub trait With4<T, U, V, W> {
20 fn with4(code: Code, op0: T, op1: U, op2: V, op3: W) -> Result<Instruction, IcedError>;
21 }
22
23 pub trait With5<T, U, V, W, X> {
24 fn with5(code: Code, op0: T, op1: U, op2: V, op3: W, op4: X) -> Result<Instruction, IcedError>;
25 }
26}
27
28use self::private::{With1, With2, With3, With4, With5};
29use crate::instruction_internal;
30use crate::{Code, IcedError, Instruction, MemoryOperand, OpKind, Register, RepPrefixKind};
31use core::{u16, u32, u64};
32
33impl Instruction {
34 fn init_memory_operand(instruction: &mut Instruction, memory: &MemoryOperand) {
35 instruction.set_memory_base(memory.base);
36 instruction.set_memory_index(memory.index);
37 instruction.set_memory_index_scale(memory.scale);
38 instruction.set_memory_displ_size(memory.displ_size);
39 instruction.set_memory_displacement64(memory.displacement as u64);
40 instruction.set_is_broadcast(memory.is_broadcast);
41 instruction.set_segment_prefix(memory.segment_prefix);
42 }
43
44 #[must_use]
50 #[inline]
51 #[rustfmt::skip]
52 pub fn with(code: Code) -> Self {
53 let mut instruction = Self::default();
54 instruction.set_code(code);
55
56 debug_assert_eq!(instruction.op_count(), 0);
57 instruction
58 }
59
60 #[inline]
86 pub fn with1<T>(code: Code, op0: T) -> Result<Instruction, IcedError>
87 where
88 Self: With1<T>,
89 {
90 <Self as With1<T>>::with1(code, op0)
91 }
92
93 #[inline]
120 pub fn with2<T, U>(code: Code, op0: T, op1: U) -> Result<Instruction, IcedError>
121 where
122 Self: With2<T, U>,
123 {
124 <Self as With2<T, U>>::with2(code, op0, op1)
125 }
126
127 #[inline]
155 pub fn with3<T, U, V>(code: Code, op0: T, op1: U, op2: V) -> Result<Instruction, IcedError>
156 where
157 Self: With3<T, U, V>,
158 {
159 <Self as With3<T, U, V>>::with3(code, op0, op1, op2)
160 }
161
162 #[inline]
191 pub fn with4<T, U, V, W>(code: Code, op0: T, op1: U, op2: V, op3: W) -> Result<Instruction, IcedError>
192 where
193 Self: With4<T, U, V, W>,
194 {
195 <Self as With4<T, U, V, W>>::with4(code, op0, op1, op2, op3)
196 }
197
198 #[inline]
228 pub fn with5<T, U, V, W, X>(code: Code, op0: T, op1: U, op2: V, op3: W, op4: X) -> Result<Instruction, IcedError>
229 where
230 Self: With5<T, U, V, W, X>,
231 {
232 <Self as With5<T, U, V, W, X>>::with5(code, op0, op1, op2, op3, op4)
233 }
234}
235
236impl With1<Register> for Instruction {
240 #[allow(clippy::missing_inline_in_public_items)]
241 #[rustfmt::skip]
242 fn with1(code: Code, register: Register) -> Result<Self, IcedError> {
243 let mut instruction = Self::default();
244 instruction.set_code(code);
245
246 const _: () = assert!(OpKind::Register as u32 == 0);
247 instruction.set_op0_register(register);
249
250 debug_assert_eq!(instruction.op_count(), 1);
251 Ok(instruction)
252 }
253}
254
255impl With1<i32> for Instruction {
256 #[allow(clippy::missing_inline_in_public_items)]
257 #[rustfmt::skip]
258 fn with1(code: Code, immediate: i32) -> Result<Self, IcedError> {
259 let mut instruction = Self::default();
260 instruction.set_code(code);
261
262 instruction_internal::initialize_signed_immediate(&mut instruction, 0, immediate as i64)?;
263
264 debug_assert_eq!(instruction.op_count(), 1);
265 Ok(instruction)
266 }
267}
268
269impl With1<u32> for Instruction {
270 #[allow(clippy::missing_inline_in_public_items)]
271 #[rustfmt::skip]
272 fn with1(code: Code, immediate: u32) -> Result<Self, IcedError> {
273 let mut instruction = Self::default();
274 instruction.set_code(code);
275
276 instruction_internal::initialize_unsigned_immediate(&mut instruction, 0, immediate as u64)?;
277
278 debug_assert_eq!(instruction.op_count(), 1);
279 Ok(instruction)
280 }
281}
282
283impl With1<MemoryOperand> for Instruction {
284 #[allow(clippy::missing_inline_in_public_items)]
285 #[rustfmt::skip]
286 fn with1(code: Code, memory: MemoryOperand) -> Result<Self, IcedError> {
287 let mut instruction = Self::default();
288 instruction.set_code(code);
289
290 instruction.set_op0_kind(OpKind::Memory);
291 Instruction::init_memory_operand(&mut instruction, &memory);
292
293 debug_assert_eq!(instruction.op_count(), 1);
294 Ok(instruction)
295 }
296}
297
298impl With2<Register, Register> for Instruction {
299 #[allow(clippy::missing_inline_in_public_items)]
300 #[rustfmt::skip]
301 fn with2(code: Code, register1: Register, register2: Register) -> Result<Self, IcedError> {
302 let mut instruction = Self::default();
303 instruction.set_code(code);
304
305 const _: () = assert!(OpKind::Register as u32 == 0);
306 instruction.set_op0_register(register1);
308
309 const _: () = assert!(OpKind::Register as u32 == 0);
310 instruction.set_op1_register(register2);
312
313 debug_assert_eq!(instruction.op_count(), 2);
314 Ok(instruction)
315 }
316}
317
318impl With2<Register, i32> for Instruction {
319 #[allow(clippy::missing_inline_in_public_items)]
320 #[rustfmt::skip]
321 fn with2(code: Code, register: Register, immediate: i32) -> Result<Self, IcedError> {
322 let mut instruction = Self::default();
323 instruction.set_code(code);
324
325 const _: () = assert!(OpKind::Register as u32 == 0);
326 instruction.set_op0_register(register);
328
329 instruction_internal::initialize_signed_immediate(&mut instruction, 1, immediate as i64)?;
330
331 debug_assert_eq!(instruction.op_count(), 2);
332 Ok(instruction)
333 }
334}
335
336impl With2<Register, u32> for Instruction {
337 #[allow(clippy::missing_inline_in_public_items)]
338 #[rustfmt::skip]
339 fn with2(code: Code, register: Register, immediate: u32) -> Result<Self, IcedError> {
340 let mut instruction = Self::default();
341 instruction.set_code(code);
342
343 const _: () = assert!(OpKind::Register as u32 == 0);
344 instruction.set_op0_register(register);
346
347 instruction_internal::initialize_unsigned_immediate(&mut instruction, 1, immediate as u64)?;
348
349 debug_assert_eq!(instruction.op_count(), 2);
350 Ok(instruction)
351 }
352}
353
354impl With2<Register, i64> for Instruction {
355 #[allow(clippy::missing_inline_in_public_items)]
356 #[rustfmt::skip]
357 fn with2(code: Code, register: Register, immediate: i64) -> Result<Self, IcedError> {
358 let mut instruction = Self::default();
359 instruction.set_code(code);
360
361 const _: () = assert!(OpKind::Register as u32 == 0);
362 instruction.set_op0_register(register);
364
365 instruction_internal::initialize_signed_immediate(&mut instruction, 1, immediate)?;
366
367 debug_assert_eq!(instruction.op_count(), 2);
368 Ok(instruction)
369 }
370}
371
372impl With2<Register, u64> for Instruction {
373 #[allow(clippy::missing_inline_in_public_items)]
374 #[rustfmt::skip]
375 fn with2(code: Code, register: Register, immediate: u64) -> Result<Self, IcedError> {
376 let mut instruction = Self::default();
377 instruction.set_code(code);
378
379 const _: () = assert!(OpKind::Register as u32 == 0);
380 instruction.set_op0_register(register);
382
383 instruction_internal::initialize_unsigned_immediate(&mut instruction, 1, immediate)?;
384
385 debug_assert_eq!(instruction.op_count(), 2);
386 Ok(instruction)
387 }
388}
389
390impl With2<Register, MemoryOperand> for Instruction {
391 #[allow(clippy::missing_inline_in_public_items)]
392 #[rustfmt::skip]
393 fn with2(code: Code, register: Register, memory: MemoryOperand) -> Result<Self, IcedError> {
394 let mut instruction = Self::default();
395 instruction.set_code(code);
396
397 const _: () = assert!(OpKind::Register as u32 == 0);
398 instruction.set_op0_register(register);
400
401 instruction.set_op1_kind(OpKind::Memory);
402 Instruction::init_memory_operand(&mut instruction, &memory);
403
404 debug_assert_eq!(instruction.op_count(), 2);
405 Ok(instruction)
406 }
407}
408
409impl With2<i32, Register> for Instruction {
410 #[allow(clippy::missing_inline_in_public_items)]
411 #[rustfmt::skip]
412 fn with2(code: Code, immediate: i32, register: Register) -> Result<Self, IcedError> {
413 let mut instruction = Self::default();
414 instruction.set_code(code);
415
416 instruction_internal::initialize_signed_immediate(&mut instruction, 0, immediate as i64)?;
417
418 const _: () = assert!(OpKind::Register as u32 == 0);
419 instruction.set_op1_register(register);
421
422 debug_assert_eq!(instruction.op_count(), 2);
423 Ok(instruction)
424 }
425}
426
427impl With2<u32, Register> for Instruction {
428 #[allow(clippy::missing_inline_in_public_items)]
429 #[rustfmt::skip]
430 fn with2(code: Code, immediate: u32, register: Register) -> Result<Self, IcedError> {
431 let mut instruction = Self::default();
432 instruction.set_code(code);
433
434 instruction_internal::initialize_unsigned_immediate(&mut instruction, 0, immediate as u64)?;
435
436 const _: () = assert!(OpKind::Register as u32 == 0);
437 instruction.set_op1_register(register);
439
440 debug_assert_eq!(instruction.op_count(), 2);
441 Ok(instruction)
442 }
443}
444
445impl With2<i32, i32> for Instruction {
446 #[allow(clippy::missing_inline_in_public_items)]
447 #[rustfmt::skip]
448 fn with2(code: Code, immediate1: i32, immediate2: i32) -> Result<Self, IcedError> {
449 let mut instruction = Self::default();
450 instruction.set_code(code);
451
452 instruction_internal::initialize_signed_immediate(&mut instruction, 0, immediate1 as i64)?;
453
454 instruction_internal::initialize_signed_immediate(&mut instruction, 1, immediate2 as i64)?;
455
456 debug_assert_eq!(instruction.op_count(), 2);
457 Ok(instruction)
458 }
459}
460
461impl With2<u32, u32> for Instruction {
462 #[allow(clippy::missing_inline_in_public_items)]
463 #[rustfmt::skip]
464 fn with2(code: Code, immediate1: u32, immediate2: u32) -> Result<Self, IcedError> {
465 let mut instruction = Self::default();
466 instruction.set_code(code);
467
468 instruction_internal::initialize_unsigned_immediate(&mut instruction, 0, immediate1 as u64)?;
469
470 instruction_internal::initialize_unsigned_immediate(&mut instruction, 1, immediate2 as u64)?;
471
472 debug_assert_eq!(instruction.op_count(), 2);
473 Ok(instruction)
474 }
475}
476
477impl With2<MemoryOperand, Register> for Instruction {
478 #[allow(clippy::missing_inline_in_public_items)]
479 #[rustfmt::skip]
480 fn with2(code: Code, memory: MemoryOperand, register: Register) -> Result<Self, IcedError> {
481 let mut instruction = Self::default();
482 instruction.set_code(code);
483
484 instruction.set_op0_kind(OpKind::Memory);
485 Instruction::init_memory_operand(&mut instruction, &memory);
486
487 const _: () = assert!(OpKind::Register as u32 == 0);
488 instruction.set_op1_register(register);
490
491 debug_assert_eq!(instruction.op_count(), 2);
492 Ok(instruction)
493 }
494}
495
496impl With2<MemoryOperand, i32> for Instruction {
497 #[allow(clippy::missing_inline_in_public_items)]
498 #[rustfmt::skip]
499 fn with2(code: Code, memory: MemoryOperand, immediate: i32) -> Result<Self, IcedError> {
500 let mut instruction = Self::default();
501 instruction.set_code(code);
502
503 instruction.set_op0_kind(OpKind::Memory);
504 Instruction::init_memory_operand(&mut instruction, &memory);
505
506 instruction_internal::initialize_signed_immediate(&mut instruction, 1, immediate as i64)?;
507
508 debug_assert_eq!(instruction.op_count(), 2);
509 Ok(instruction)
510 }
511}
512
513impl With2<MemoryOperand, u32> for Instruction {
514 #[allow(clippy::missing_inline_in_public_items)]
515 #[rustfmt::skip]
516 fn with2(code: Code, memory: MemoryOperand, immediate: u32) -> Result<Self, IcedError> {
517 let mut instruction = Self::default();
518 instruction.set_code(code);
519
520 instruction.set_op0_kind(OpKind::Memory);
521 Instruction::init_memory_operand(&mut instruction, &memory);
522
523 instruction_internal::initialize_unsigned_immediate(&mut instruction, 1, immediate as u64)?;
524
525 debug_assert_eq!(instruction.op_count(), 2);
526 Ok(instruction)
527 }
528}
529
530impl With3<Register, Register, Register> for Instruction {
531 #[allow(clippy::missing_inline_in_public_items)]
532 #[rustfmt::skip]
533 fn with3(code: Code, register1: Register, register2: Register, register3: Register) -> Result<Self, IcedError> {
534 let mut instruction = Self::default();
535 instruction.set_code(code);
536
537 const _: () = assert!(OpKind::Register as u32 == 0);
538 instruction.set_op0_register(register1);
540
541 const _: () = assert!(OpKind::Register as u32 == 0);
542 instruction.set_op1_register(register2);
544
545 const _: () = assert!(OpKind::Register as u32 == 0);
546 instruction.set_op2_register(register3);
548
549 debug_assert_eq!(instruction.op_count(), 3);
550 Ok(instruction)
551 }
552}
553
554impl With3<Register, Register, i32> for Instruction {
555 #[allow(clippy::missing_inline_in_public_items)]
556 #[rustfmt::skip]
557 fn with3(code: Code, register1: Register, register2: Register, immediate: i32) -> Result<Self, IcedError> {
558 let mut instruction = Self::default();
559 instruction.set_code(code);
560
561 const _: () = assert!(OpKind::Register as u32 == 0);
562 instruction.set_op0_register(register1);
564
565 const _: () = assert!(OpKind::Register as u32 == 0);
566 instruction.set_op1_register(register2);
568
569 instruction_internal::initialize_signed_immediate(&mut instruction, 2, immediate as i64)?;
570
571 debug_assert_eq!(instruction.op_count(), 3);
572 Ok(instruction)
573 }
574}
575
576impl With3<Register, Register, u32> for Instruction {
577 #[allow(clippy::missing_inline_in_public_items)]
578 #[rustfmt::skip]
579 fn with3(code: Code, register1: Register, register2: Register, immediate: u32) -> Result<Self, IcedError> {
580 let mut instruction = Self::default();
581 instruction.set_code(code);
582
583 const _: () = assert!(OpKind::Register as u32 == 0);
584 instruction.set_op0_register(register1);
586
587 const _: () = assert!(OpKind::Register as u32 == 0);
588 instruction.set_op1_register(register2);
590
591 instruction_internal::initialize_unsigned_immediate(&mut instruction, 2, immediate as u64)?;
592
593 debug_assert_eq!(instruction.op_count(), 3);
594 Ok(instruction)
595 }
596}
597
598impl With3<Register, Register, MemoryOperand> for Instruction {
599 #[allow(clippy::missing_inline_in_public_items)]
600 #[rustfmt::skip]
601 fn with3(code: Code, register1: Register, register2: Register, memory: MemoryOperand) -> Result<Self, IcedError> {
602 let mut instruction = Self::default();
603 instruction.set_code(code);
604
605 const _: () = assert!(OpKind::Register as u32 == 0);
606 instruction.set_op0_register(register1);
608
609 const _: () = assert!(OpKind::Register as u32 == 0);
610 instruction.set_op1_register(register2);
612
613 instruction.set_op2_kind(OpKind::Memory);
614 Instruction::init_memory_operand(&mut instruction, &memory);
615
616 debug_assert_eq!(instruction.op_count(), 3);
617 Ok(instruction)
618 }
619}
620
621impl With3<Register, i32, i32> for Instruction {
622 #[allow(clippy::missing_inline_in_public_items)]
623 #[rustfmt::skip]
624 fn with3(code: Code, register: Register, immediate1: i32, immediate2: i32) -> Result<Self, IcedError> {
625 let mut instruction = Self::default();
626 instruction.set_code(code);
627
628 const _: () = assert!(OpKind::Register as u32 == 0);
629 instruction.set_op0_register(register);
631
632 instruction_internal::initialize_signed_immediate(&mut instruction, 1, immediate1 as i64)?;
633
634 instruction_internal::initialize_signed_immediate(&mut instruction, 2, immediate2 as i64)?;
635
636 debug_assert_eq!(instruction.op_count(), 3);
637 Ok(instruction)
638 }
639}
640
641impl With3<Register, u32, u32> for Instruction {
642 #[allow(clippy::missing_inline_in_public_items)]
643 #[rustfmt::skip]
644 fn with3(code: Code, register: Register, immediate1: u32, immediate2: u32) -> Result<Self, IcedError> {
645 let mut instruction = Self::default();
646 instruction.set_code(code);
647
648 const _: () = assert!(OpKind::Register as u32 == 0);
649 instruction.set_op0_register(register);
651
652 instruction_internal::initialize_unsigned_immediate(&mut instruction, 1, immediate1 as u64)?;
653
654 instruction_internal::initialize_unsigned_immediate(&mut instruction, 2, immediate2 as u64)?;
655
656 debug_assert_eq!(instruction.op_count(), 3);
657 Ok(instruction)
658 }
659}
660
661impl With3<Register, MemoryOperand, Register> for Instruction {
662 #[allow(clippy::missing_inline_in_public_items)]
663 #[rustfmt::skip]
664 fn with3(code: Code, register1: Register, memory: MemoryOperand, register2: Register) -> Result<Self, IcedError> {
665 let mut instruction = Self::default();
666 instruction.set_code(code);
667
668 const _: () = assert!(OpKind::Register as u32 == 0);
669 instruction.set_op0_register(register1);
671
672 instruction.set_op1_kind(OpKind::Memory);
673 Instruction::init_memory_operand(&mut instruction, &memory);
674
675 const _: () = assert!(OpKind::Register as u32 == 0);
676 instruction.set_op2_register(register2);
678
679 debug_assert_eq!(instruction.op_count(), 3);
680 Ok(instruction)
681 }
682}
683
684impl With3<Register, MemoryOperand, i32> for Instruction {
685 #[allow(clippy::missing_inline_in_public_items)]
686 #[rustfmt::skip]
687 fn with3(code: Code, register: Register, memory: MemoryOperand, immediate: i32) -> Result<Self, IcedError> {
688 let mut instruction = Self::default();
689 instruction.set_code(code);
690
691 const _: () = assert!(OpKind::Register as u32 == 0);
692 instruction.set_op0_register(register);
694
695 instruction.set_op1_kind(OpKind::Memory);
696 Instruction::init_memory_operand(&mut instruction, &memory);
697
698 instruction_internal::initialize_signed_immediate(&mut instruction, 2, immediate as i64)?;
699
700 debug_assert_eq!(instruction.op_count(), 3);
701 Ok(instruction)
702 }
703}
704
705impl With3<Register, MemoryOperand, u32> for Instruction {
706 #[allow(clippy::missing_inline_in_public_items)]
707 #[rustfmt::skip]
708 fn with3(code: Code, register: Register, memory: MemoryOperand, immediate: u32) -> Result<Self, IcedError> {
709 let mut instruction = Self::default();
710 instruction.set_code(code);
711
712 const _: () = assert!(OpKind::Register as u32 == 0);
713 instruction.set_op0_register(register);
715
716 instruction.set_op1_kind(OpKind::Memory);
717 Instruction::init_memory_operand(&mut instruction, &memory);
718
719 instruction_internal::initialize_unsigned_immediate(&mut instruction, 2, immediate as u64)?;
720
721 debug_assert_eq!(instruction.op_count(), 3);
722 Ok(instruction)
723 }
724}
725
726impl With3<MemoryOperand, Register, Register> for Instruction {
727 #[allow(clippy::missing_inline_in_public_items)]
728 #[rustfmt::skip]
729 fn with3(code: Code, memory: MemoryOperand, register1: Register, register2: Register) -> Result<Self, IcedError> {
730 let mut instruction = Self::default();
731 instruction.set_code(code);
732
733 instruction.set_op0_kind(OpKind::Memory);
734 Instruction::init_memory_operand(&mut instruction, &memory);
735
736 const _: () = assert!(OpKind::Register as u32 == 0);
737 instruction.set_op1_register(register1);
739
740 const _: () = assert!(OpKind::Register as u32 == 0);
741 instruction.set_op2_register(register2);
743
744 debug_assert_eq!(instruction.op_count(), 3);
745 Ok(instruction)
746 }
747}
748
749impl With3<MemoryOperand, Register, i32> for Instruction {
750 #[allow(clippy::missing_inline_in_public_items)]
751 #[rustfmt::skip]
752 fn with3(code: Code, memory: MemoryOperand, register: Register, immediate: i32) -> Result<Self, IcedError> {
753 let mut instruction = Self::default();
754 instruction.set_code(code);
755
756 instruction.set_op0_kind(OpKind::Memory);
757 Instruction::init_memory_operand(&mut instruction, &memory);
758
759 const _: () = assert!(OpKind::Register as u32 == 0);
760 instruction.set_op1_register(register);
762
763 instruction_internal::initialize_signed_immediate(&mut instruction, 2, immediate as i64)?;
764
765 debug_assert_eq!(instruction.op_count(), 3);
766 Ok(instruction)
767 }
768}
769
770impl With3<MemoryOperand, Register, u32> for Instruction {
771 #[allow(clippy::missing_inline_in_public_items)]
772 #[rustfmt::skip]
773 fn with3(code: Code, memory: MemoryOperand, register: Register, immediate: u32) -> Result<Self, IcedError> {
774 let mut instruction = Self::default();
775 instruction.set_code(code);
776
777 instruction.set_op0_kind(OpKind::Memory);
778 Instruction::init_memory_operand(&mut instruction, &memory);
779
780 const _: () = assert!(OpKind::Register as u32 == 0);
781 instruction.set_op1_register(register);
783
784 instruction_internal::initialize_unsigned_immediate(&mut instruction, 2, immediate as u64)?;
785
786 debug_assert_eq!(instruction.op_count(), 3);
787 Ok(instruction)
788 }
789}
790
791impl With4<Register, Register, Register, Register> for Instruction {
792 #[allow(clippy::missing_inline_in_public_items)]
793 #[rustfmt::skip]
794 fn with4(code: Code, register1: Register, register2: Register, register3: Register, register4: Register) -> Result<Self, IcedError> {
795 let mut instruction = Self::default();
796 instruction.set_code(code);
797
798 const _: () = assert!(OpKind::Register as u32 == 0);
799 instruction.set_op0_register(register1);
801
802 const _: () = assert!(OpKind::Register as u32 == 0);
803 instruction.set_op1_register(register2);
805
806 const _: () = assert!(OpKind::Register as u32 == 0);
807 instruction.set_op2_register(register3);
809
810 const _: () = assert!(OpKind::Register as u32 == 0);
811 instruction.set_op3_register(register4);
813
814 debug_assert_eq!(instruction.op_count(), 4);
815 Ok(instruction)
816 }
817}
818
819impl With4<Register, Register, Register, i32> for Instruction {
820 #[allow(clippy::missing_inline_in_public_items)]
821 #[rustfmt::skip]
822 fn with4(code: Code, register1: Register, register2: Register, register3: Register, immediate: i32) -> Result<Self, IcedError> {
823 let mut instruction = Self::default();
824 instruction.set_code(code);
825
826 const _: () = assert!(OpKind::Register as u32 == 0);
827 instruction.set_op0_register(register1);
829
830 const _: () = assert!(OpKind::Register as u32 == 0);
831 instruction.set_op1_register(register2);
833
834 const _: () = assert!(OpKind::Register as u32 == 0);
835 instruction.set_op2_register(register3);
837
838 instruction_internal::initialize_signed_immediate(&mut instruction, 3, immediate as i64)?;
839
840 debug_assert_eq!(instruction.op_count(), 4);
841 Ok(instruction)
842 }
843}
844
845impl With4<Register, Register, Register, u32> for Instruction {
846 #[allow(clippy::missing_inline_in_public_items)]
847 #[rustfmt::skip]
848 fn with4(code: Code, register1: Register, register2: Register, register3: Register, immediate: u32) -> Result<Self, IcedError> {
849 let mut instruction = Self::default();
850 instruction.set_code(code);
851
852 const _: () = assert!(OpKind::Register as u32 == 0);
853 instruction.set_op0_register(register1);
855
856 const _: () = assert!(OpKind::Register as u32 == 0);
857 instruction.set_op1_register(register2);
859
860 const _: () = assert!(OpKind::Register as u32 == 0);
861 instruction.set_op2_register(register3);
863
864 instruction_internal::initialize_unsigned_immediate(&mut instruction, 3, immediate as u64)?;
865
866 debug_assert_eq!(instruction.op_count(), 4);
867 Ok(instruction)
868 }
869}
870
871impl With4<Register, Register, Register, MemoryOperand> for Instruction {
872 #[allow(clippy::missing_inline_in_public_items)]
873 #[rustfmt::skip]
874 fn with4(code: Code, register1: Register, register2: Register, register3: Register, memory: MemoryOperand) -> Result<Self, IcedError> {
875 let mut instruction = Self::default();
876 instruction.set_code(code);
877
878 const _: () = assert!(OpKind::Register as u32 == 0);
879 instruction.set_op0_register(register1);
881
882 const _: () = assert!(OpKind::Register as u32 == 0);
883 instruction.set_op1_register(register2);
885
886 const _: () = assert!(OpKind::Register as u32 == 0);
887 instruction.set_op2_register(register3);
889
890 instruction.set_op3_kind(OpKind::Memory);
891 Instruction::init_memory_operand(&mut instruction, &memory);
892
893 debug_assert_eq!(instruction.op_count(), 4);
894 Ok(instruction)
895 }
896}
897
898impl With4<Register, Register, i32, i32> for Instruction {
899 #[allow(clippy::missing_inline_in_public_items)]
900 #[rustfmt::skip]
901 fn with4(code: Code, register1: Register, register2: Register, immediate1: i32, immediate2: i32) -> Result<Self, IcedError> {
902 let mut instruction = Self::default();
903 instruction.set_code(code);
904
905 const _: () = assert!(OpKind::Register as u32 == 0);
906 instruction.set_op0_register(register1);
908
909 const _: () = assert!(OpKind::Register as u32 == 0);
910 instruction.set_op1_register(register2);
912
913 instruction_internal::initialize_signed_immediate(&mut instruction, 2, immediate1 as i64)?;
914
915 instruction_internal::initialize_signed_immediate(&mut instruction, 3, immediate2 as i64)?;
916
917 debug_assert_eq!(instruction.op_count(), 4);
918 Ok(instruction)
919 }
920}
921
922impl With4<Register, Register, u32, u32> for Instruction {
923 #[allow(clippy::missing_inline_in_public_items)]
924 #[rustfmt::skip]
925 fn with4(code: Code, register1: Register, register2: Register, immediate1: u32, immediate2: u32) -> Result<Self, IcedError> {
926 let mut instruction = Self::default();
927 instruction.set_code(code);
928
929 const _: () = assert!(OpKind::Register as u32 == 0);
930 instruction.set_op0_register(register1);
932
933 const _: () = assert!(OpKind::Register as u32 == 0);
934 instruction.set_op1_register(register2);
936
937 instruction_internal::initialize_unsigned_immediate(&mut instruction, 2, immediate1 as u64)?;
938
939 instruction_internal::initialize_unsigned_immediate(&mut instruction, 3, immediate2 as u64)?;
940
941 debug_assert_eq!(instruction.op_count(), 4);
942 Ok(instruction)
943 }
944}
945
946impl With4<Register, Register, MemoryOperand, Register> for Instruction {
947 #[allow(clippy::missing_inline_in_public_items)]
948 #[rustfmt::skip]
949 fn with4(code: Code, register1: Register, register2: Register, memory: MemoryOperand, register3: Register) -> Result<Self, IcedError> {
950 let mut instruction = Self::default();
951 instruction.set_code(code);
952
953 const _: () = assert!(OpKind::Register as u32 == 0);
954 instruction.set_op0_register(register1);
956
957 const _: () = assert!(OpKind::Register as u32 == 0);
958 instruction.set_op1_register(register2);
960
961 instruction.set_op2_kind(OpKind::Memory);
962 Instruction::init_memory_operand(&mut instruction, &memory);
963
964 const _: () = assert!(OpKind::Register as u32 == 0);
965 instruction.set_op3_register(register3);
967
968 debug_assert_eq!(instruction.op_count(), 4);
969 Ok(instruction)
970 }
971}
972
973impl With4<Register, Register, MemoryOperand, i32> for Instruction {
974 #[allow(clippy::missing_inline_in_public_items)]
975 #[rustfmt::skip]
976 fn with4(code: Code, register1: Register, register2: Register, memory: MemoryOperand, immediate: i32) -> Result<Self, IcedError> {
977 let mut instruction = Self::default();
978 instruction.set_code(code);
979
980 const _: () = assert!(OpKind::Register as u32 == 0);
981 instruction.set_op0_register(register1);
983
984 const _: () = assert!(OpKind::Register as u32 == 0);
985 instruction.set_op1_register(register2);
987
988 instruction.set_op2_kind(OpKind::Memory);
989 Instruction::init_memory_operand(&mut instruction, &memory);
990
991 instruction_internal::initialize_signed_immediate(&mut instruction, 3, immediate as i64)?;
992
993 debug_assert_eq!(instruction.op_count(), 4);
994 Ok(instruction)
995 }
996}
997
998impl With4<Register, Register, MemoryOperand, u32> for Instruction {
999 #[allow(clippy::missing_inline_in_public_items)]
1000 #[rustfmt::skip]
1001 fn with4(code: Code, register1: Register, register2: Register, memory: MemoryOperand, immediate: u32) -> Result<Self, IcedError> {
1002 let mut instruction = Self::default();
1003 instruction.set_code(code);
1004
1005 const _: () = assert!(OpKind::Register as u32 == 0);
1006 instruction.set_op0_register(register1);
1008
1009 const _: () = assert!(OpKind::Register as u32 == 0);
1010 instruction.set_op1_register(register2);
1012
1013 instruction.set_op2_kind(OpKind::Memory);
1014 Instruction::init_memory_operand(&mut instruction, &memory);
1015
1016 instruction_internal::initialize_unsigned_immediate(&mut instruction, 3, immediate as u64)?;
1017
1018 debug_assert_eq!(instruction.op_count(), 4);
1019 Ok(instruction)
1020 }
1021}
1022
1023impl With5<Register, Register, Register, Register, i32> for Instruction {
1024 #[allow(clippy::missing_inline_in_public_items)]
1025 #[rustfmt::skip]
1026 fn with5(code: Code, register1: Register, register2: Register, register3: Register, register4: Register, immediate: i32) -> Result<Self, IcedError> {
1027 let mut instruction = Self::default();
1028 instruction.set_code(code);
1029
1030 const _: () = assert!(OpKind::Register as u32 == 0);
1031 instruction.set_op0_register(register1);
1033
1034 const _: () = assert!(OpKind::Register as u32 == 0);
1035 instruction.set_op1_register(register2);
1037
1038 const _: () = assert!(OpKind::Register as u32 == 0);
1039 instruction.set_op2_register(register3);
1041
1042 const _: () = assert!(OpKind::Register as u32 == 0);
1043 instruction.set_op3_register(register4);
1045
1046 instruction_internal::initialize_signed_immediate(&mut instruction, 4, immediate as i64)?;
1047
1048 debug_assert_eq!(instruction.op_count(), 5);
1049 Ok(instruction)
1050 }
1051}
1052
1053impl With5<Register, Register, Register, Register, u32> for Instruction {
1054 #[allow(clippy::missing_inline_in_public_items)]
1055 #[rustfmt::skip]
1056 fn with5(code: Code, register1: Register, register2: Register, register3: Register, register4: Register, immediate: u32) -> Result<Self, IcedError> {
1057 let mut instruction = Self::default();
1058 instruction.set_code(code);
1059
1060 const _: () = assert!(OpKind::Register as u32 == 0);
1061 instruction.set_op0_register(register1);
1063
1064 const _: () = assert!(OpKind::Register as u32 == 0);
1065 instruction.set_op1_register(register2);
1067
1068 const _: () = assert!(OpKind::Register as u32 == 0);
1069 instruction.set_op2_register(register3);
1071
1072 const _: () = assert!(OpKind::Register as u32 == 0);
1073 instruction.set_op3_register(register4);
1075
1076 instruction_internal::initialize_unsigned_immediate(&mut instruction, 4, immediate as u64)?;
1077
1078 debug_assert_eq!(instruction.op_count(), 5);
1079 Ok(instruction)
1080 }
1081}
1082
1083impl With5<Register, Register, Register, MemoryOperand, i32> for Instruction {
1084 #[allow(clippy::missing_inline_in_public_items)]
1085 #[rustfmt::skip]
1086 fn with5(code: Code, register1: Register, register2: Register, register3: Register, memory: MemoryOperand, immediate: i32) -> Result<Self, IcedError> {
1087 let mut instruction = Self::default();
1088 instruction.set_code(code);
1089
1090 const _: () = assert!(OpKind::Register as u32 == 0);
1091 instruction.set_op0_register(register1);
1093
1094 const _: () = assert!(OpKind::Register as u32 == 0);
1095 instruction.set_op1_register(register2);
1097
1098 const _: () = assert!(OpKind::Register as u32 == 0);
1099 instruction.set_op2_register(register3);
1101
1102 instruction.set_op3_kind(OpKind::Memory);
1103 Instruction::init_memory_operand(&mut instruction, &memory);
1104
1105 instruction_internal::initialize_signed_immediate(&mut instruction, 4, immediate as i64)?;
1106
1107 debug_assert_eq!(instruction.op_count(), 5);
1108 Ok(instruction)
1109 }
1110}
1111
1112impl With5<Register, Register, Register, MemoryOperand, u32> for Instruction {
1113 #[allow(clippy::missing_inline_in_public_items)]
1114 #[rustfmt::skip]
1115 fn with5(code: Code, register1: Register, register2: Register, register3: Register, memory: MemoryOperand, immediate: u32) -> Result<Self, IcedError> {
1116 let mut instruction = Self::default();
1117 instruction.set_code(code);
1118
1119 const _: () = assert!(OpKind::Register as u32 == 0);
1120 instruction.set_op0_register(register1);
1122
1123 const _: () = assert!(OpKind::Register as u32 == 0);
1124 instruction.set_op1_register(register2);
1126
1127 const _: () = assert!(OpKind::Register as u32 == 0);
1128 instruction.set_op2_register(register3);
1130
1131 instruction.set_op3_kind(OpKind::Memory);
1132 Instruction::init_memory_operand(&mut instruction, &memory);
1133
1134 instruction_internal::initialize_unsigned_immediate(&mut instruction, 4, immediate as u64)?;
1135
1136 debug_assert_eq!(instruction.op_count(), 5);
1137 Ok(instruction)
1138 }
1139}
1140
1141impl With5<Register, Register, MemoryOperand, Register, i32> for Instruction {
1142 #[allow(clippy::missing_inline_in_public_items)]
1143 #[rustfmt::skip]
1144 fn with5(code: Code, register1: Register, register2: Register, memory: MemoryOperand, register3: Register, immediate: i32) -> Result<Self, IcedError> {
1145 let mut instruction = Self::default();
1146 instruction.set_code(code);
1147
1148 const _: () = assert!(OpKind::Register as u32 == 0);
1149 instruction.set_op0_register(register1);
1151
1152 const _: () = assert!(OpKind::Register as u32 == 0);
1153 instruction.set_op1_register(register2);
1155
1156 instruction.set_op2_kind(OpKind::Memory);
1157 Instruction::init_memory_operand(&mut instruction, &memory);
1158
1159 const _: () = assert!(OpKind::Register as u32 == 0);
1160 instruction.set_op3_register(register3);
1162
1163 instruction_internal::initialize_signed_immediate(&mut instruction, 4, immediate as i64)?;
1164
1165 debug_assert_eq!(instruction.op_count(), 5);
1166 Ok(instruction)
1167 }
1168}
1169
1170impl With5<Register, Register, MemoryOperand, Register, u32> for Instruction {
1171 #[allow(clippy::missing_inline_in_public_items)]
1172 #[rustfmt::skip]
1173 fn with5(code: Code, register1: Register, register2: Register, memory: MemoryOperand, register3: Register, immediate: u32) -> Result<Self, IcedError> {
1174 let mut instruction = Self::default();
1175 instruction.set_code(code);
1176
1177 const _: () = assert!(OpKind::Register as u32 == 0);
1178 instruction.set_op0_register(register1);
1180
1181 const _: () = assert!(OpKind::Register as u32 == 0);
1182 instruction.set_op1_register(register2);
1184
1185 instruction.set_op2_kind(OpKind::Memory);
1186 Instruction::init_memory_operand(&mut instruction, &memory);
1187
1188 const _: () = assert!(OpKind::Register as u32 == 0);
1189 instruction.set_op3_register(register3);
1191
1192 instruction_internal::initialize_unsigned_immediate(&mut instruction, 4, immediate as u64)?;
1193
1194 debug_assert_eq!(instruction.op_count(), 5);
1195 Ok(instruction)
1196 }
1197}
1198
1199impl Instruction {
1200 #[allow(clippy::missing_inline_in_public_items)]
1211 #[rustfmt::skip]
1212 pub fn with_branch(code: Code, target: u64) -> Result<Self, IcedError> {
1213 let mut instruction = Self::default();
1214 instruction.set_code(code);
1215
1216 instruction.set_op0_kind(instruction_internal::get_near_branch_op_kind(code, 0)?);
1217 instruction.set_near_branch64(target);
1218
1219 debug_assert_eq!(instruction.op_count(), 1);
1220 Ok(instruction)
1221 }
1222
1223 #[allow(clippy::missing_inline_in_public_items)]
1235 #[rustfmt::skip]
1236 pub fn with_far_branch(code: Code, selector: u16, offset: u32) -> Result<Self, IcedError> {
1237 let mut instruction = Self::default();
1238 instruction.set_code(code);
1239
1240 instruction.set_op0_kind(instruction_internal::get_far_branch_op_kind(code, 0)?);
1241 instruction.set_far_branch_selector(selector);
1242 instruction.set_far_branch32(offset);
1243
1244 debug_assert_eq!(instruction.op_count(), 1);
1245 Ok(instruction)
1246 }
1247
1248 #[allow(clippy::missing_inline_in_public_items)]
1259 #[rustfmt::skip]
1260 pub fn with_xbegin(bitness: u32, target: u64) -> Result<Self, IcedError> {
1261 let mut instruction = Self::default();
1262
1263 match bitness {
1264 16 => {
1265 instruction.set_code(Code::Xbegin_rel16);
1266 instruction.set_op0_kind(OpKind::NearBranch32);
1267 instruction.set_near_branch32(target as u32);
1268 }
1269
1270 32 => {
1271 instruction.set_code(Code::Xbegin_rel32);
1272 instruction.set_op0_kind(OpKind::NearBranch32);
1273 instruction.set_near_branch32(target as u32);
1274 }
1275
1276 64 => {
1277 instruction.set_code(Code::Xbegin_rel32);
1278 instruction.set_op0_kind(OpKind::NearBranch64);
1279 instruction.set_near_branch64(target);
1280 }
1281
1282 _ => return Err(IcedError::new("Invalid bitness")),
1283 }
1284
1285 debug_assert_eq!(instruction.op_count(), 1);
1286 Ok(instruction)
1287 }
1288
1289 #[inline]
1304 #[rustfmt::skip]
1305 pub fn with_outsb(address_size: u32, segment_prefix: Register, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1306 instruction_internal::with_string_reg_segrsi(Code::Outsb_DX_m8, address_size, Register::DX, segment_prefix, rep_prefix)
1307 }
1308
1309 #[inline]
1319 #[rustfmt::skip]
1320 pub fn with_rep_outsb(address_size: u32) -> Result<Self, IcedError> {
1321 instruction_internal::with_string_reg_segrsi(Code::Outsb_DX_m8, address_size, Register::DX, Register::None, RepPrefixKind::Repe)
1322 }
1323
1324 #[inline]
1339 #[rustfmt::skip]
1340 pub fn with_outsw(address_size: u32, segment_prefix: Register, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1341 instruction_internal::with_string_reg_segrsi(Code::Outsw_DX_m16, address_size, Register::DX, segment_prefix, rep_prefix)
1342 }
1343
1344 #[inline]
1354 #[rustfmt::skip]
1355 pub fn with_rep_outsw(address_size: u32) -> Result<Self, IcedError> {
1356 instruction_internal::with_string_reg_segrsi(Code::Outsw_DX_m16, address_size, Register::DX, Register::None, RepPrefixKind::Repe)
1357 }
1358
1359 #[inline]
1374 #[rustfmt::skip]
1375 pub fn with_outsd(address_size: u32, segment_prefix: Register, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1376 instruction_internal::with_string_reg_segrsi(Code::Outsd_DX_m32, address_size, Register::DX, segment_prefix, rep_prefix)
1377 }
1378
1379 #[inline]
1389 #[rustfmt::skip]
1390 pub fn with_rep_outsd(address_size: u32) -> Result<Self, IcedError> {
1391 instruction_internal::with_string_reg_segrsi(Code::Outsd_DX_m32, address_size, Register::DX, Register::None, RepPrefixKind::Repe)
1392 }
1393
1394 #[inline]
1409 #[rustfmt::skip]
1410 pub fn with_lodsb(address_size: u32, segment_prefix: Register, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1411 instruction_internal::with_string_reg_segrsi(Code::Lodsb_AL_m8, address_size, Register::AL, segment_prefix, rep_prefix)
1412 }
1413
1414 #[inline]
1424 #[rustfmt::skip]
1425 pub fn with_rep_lodsb(address_size: u32) -> Result<Self, IcedError> {
1426 instruction_internal::with_string_reg_segrsi(Code::Lodsb_AL_m8, address_size, Register::AL, Register::None, RepPrefixKind::Repe)
1427 }
1428
1429 #[inline]
1444 #[rustfmt::skip]
1445 pub fn with_lodsw(address_size: u32, segment_prefix: Register, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1446 instruction_internal::with_string_reg_segrsi(Code::Lodsw_AX_m16, address_size, Register::AX, segment_prefix, rep_prefix)
1447 }
1448
1449 #[inline]
1459 #[rustfmt::skip]
1460 pub fn with_rep_lodsw(address_size: u32) -> Result<Self, IcedError> {
1461 instruction_internal::with_string_reg_segrsi(Code::Lodsw_AX_m16, address_size, Register::AX, Register::None, RepPrefixKind::Repe)
1462 }
1463
1464 #[inline]
1479 #[rustfmt::skip]
1480 pub fn with_lodsd(address_size: u32, segment_prefix: Register, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1481 instruction_internal::with_string_reg_segrsi(Code::Lodsd_EAX_m32, address_size, Register::EAX, segment_prefix, rep_prefix)
1482 }
1483
1484 #[inline]
1494 #[rustfmt::skip]
1495 pub fn with_rep_lodsd(address_size: u32) -> Result<Self, IcedError> {
1496 instruction_internal::with_string_reg_segrsi(Code::Lodsd_EAX_m32, address_size, Register::EAX, Register::None, RepPrefixKind::Repe)
1497 }
1498
1499 #[inline]
1514 #[rustfmt::skip]
1515 pub fn with_lodsq(address_size: u32, segment_prefix: Register, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1516 instruction_internal::with_string_reg_segrsi(Code::Lodsq_RAX_m64, address_size, Register::RAX, segment_prefix, rep_prefix)
1517 }
1518
1519 #[inline]
1529 #[rustfmt::skip]
1530 pub fn with_rep_lodsq(address_size: u32) -> Result<Self, IcedError> {
1531 instruction_internal::with_string_reg_segrsi(Code::Lodsq_RAX_m64, address_size, Register::RAX, Register::None, RepPrefixKind::Repe)
1532 }
1533
1534 #[inline]
1547 #[rustfmt::skip]
1548 pub fn with_scasb(address_size: u32, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1549 instruction_internal::with_string_reg_esrdi(Code::Scasb_AL_m8, address_size, Register::AL, rep_prefix)
1550 }
1551
1552 #[inline]
1562 #[rustfmt::skip]
1563 pub fn with_repe_scasb(address_size: u32) -> Result<Self, IcedError> {
1564 instruction_internal::with_string_reg_esrdi(Code::Scasb_AL_m8, address_size, Register::AL, RepPrefixKind::Repe)
1565 }
1566
1567 #[inline]
1577 #[rustfmt::skip]
1578 pub fn with_repne_scasb(address_size: u32) -> Result<Self, IcedError> {
1579 instruction_internal::with_string_reg_esrdi(Code::Scasb_AL_m8, address_size, Register::AL, RepPrefixKind::Repne)
1580 }
1581
1582 #[inline]
1595 #[rustfmt::skip]
1596 pub fn with_scasw(address_size: u32, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1597 instruction_internal::with_string_reg_esrdi(Code::Scasw_AX_m16, address_size, Register::AX, rep_prefix)
1598 }
1599
1600 #[inline]
1610 #[rustfmt::skip]
1611 pub fn with_repe_scasw(address_size: u32) -> Result<Self, IcedError> {
1612 instruction_internal::with_string_reg_esrdi(Code::Scasw_AX_m16, address_size, Register::AX, RepPrefixKind::Repe)
1613 }
1614
1615 #[inline]
1625 #[rustfmt::skip]
1626 pub fn with_repne_scasw(address_size: u32) -> Result<Self, IcedError> {
1627 instruction_internal::with_string_reg_esrdi(Code::Scasw_AX_m16, address_size, Register::AX, RepPrefixKind::Repne)
1628 }
1629
1630 #[inline]
1643 #[rustfmt::skip]
1644 pub fn with_scasd(address_size: u32, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1645 instruction_internal::with_string_reg_esrdi(Code::Scasd_EAX_m32, address_size, Register::EAX, rep_prefix)
1646 }
1647
1648 #[inline]
1658 #[rustfmt::skip]
1659 pub fn with_repe_scasd(address_size: u32) -> Result<Self, IcedError> {
1660 instruction_internal::with_string_reg_esrdi(Code::Scasd_EAX_m32, address_size, Register::EAX, RepPrefixKind::Repe)
1661 }
1662
1663 #[inline]
1673 #[rustfmt::skip]
1674 pub fn with_repne_scasd(address_size: u32) -> Result<Self, IcedError> {
1675 instruction_internal::with_string_reg_esrdi(Code::Scasd_EAX_m32, address_size, Register::EAX, RepPrefixKind::Repne)
1676 }
1677
1678 #[inline]
1691 #[rustfmt::skip]
1692 pub fn with_scasq(address_size: u32, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1693 instruction_internal::with_string_reg_esrdi(Code::Scasq_RAX_m64, address_size, Register::RAX, rep_prefix)
1694 }
1695
1696 #[inline]
1706 #[rustfmt::skip]
1707 pub fn with_repe_scasq(address_size: u32) -> Result<Self, IcedError> {
1708 instruction_internal::with_string_reg_esrdi(Code::Scasq_RAX_m64, address_size, Register::RAX, RepPrefixKind::Repe)
1709 }
1710
1711 #[inline]
1721 #[rustfmt::skip]
1722 pub fn with_repne_scasq(address_size: u32) -> Result<Self, IcedError> {
1723 instruction_internal::with_string_reg_esrdi(Code::Scasq_RAX_m64, address_size, Register::RAX, RepPrefixKind::Repne)
1724 }
1725
1726 #[inline]
1739 #[rustfmt::skip]
1740 pub fn with_insb(address_size: u32, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1741 instruction_internal::with_string_esrdi_reg(Code::Insb_m8_DX, address_size, Register::DX, rep_prefix)
1742 }
1743
1744 #[inline]
1754 #[rustfmt::skip]
1755 pub fn with_rep_insb(address_size: u32) -> Result<Self, IcedError> {
1756 instruction_internal::with_string_esrdi_reg(Code::Insb_m8_DX, address_size, Register::DX, RepPrefixKind::Repe)
1757 }
1758
1759 #[inline]
1772 #[rustfmt::skip]
1773 pub fn with_insw(address_size: u32, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1774 instruction_internal::with_string_esrdi_reg(Code::Insw_m16_DX, address_size, Register::DX, rep_prefix)
1775 }
1776
1777 #[inline]
1787 #[rustfmt::skip]
1788 pub fn with_rep_insw(address_size: u32) -> Result<Self, IcedError> {
1789 instruction_internal::with_string_esrdi_reg(Code::Insw_m16_DX, address_size, Register::DX, RepPrefixKind::Repe)
1790 }
1791
1792 #[inline]
1805 #[rustfmt::skip]
1806 pub fn with_insd(address_size: u32, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1807 instruction_internal::with_string_esrdi_reg(Code::Insd_m32_DX, address_size, Register::DX, rep_prefix)
1808 }
1809
1810 #[inline]
1820 #[rustfmt::skip]
1821 pub fn with_rep_insd(address_size: u32) -> Result<Self, IcedError> {
1822 instruction_internal::with_string_esrdi_reg(Code::Insd_m32_DX, address_size, Register::DX, RepPrefixKind::Repe)
1823 }
1824
1825 #[inline]
1838 #[rustfmt::skip]
1839 pub fn with_stosb(address_size: u32, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1840 instruction_internal::with_string_esrdi_reg(Code::Stosb_m8_AL, address_size, Register::AL, rep_prefix)
1841 }
1842
1843 #[inline]
1853 #[rustfmt::skip]
1854 pub fn with_rep_stosb(address_size: u32) -> Result<Self, IcedError> {
1855 instruction_internal::with_string_esrdi_reg(Code::Stosb_m8_AL, address_size, Register::AL, RepPrefixKind::Repe)
1856 }
1857
1858 #[inline]
1871 #[rustfmt::skip]
1872 pub fn with_stosw(address_size: u32, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1873 instruction_internal::with_string_esrdi_reg(Code::Stosw_m16_AX, address_size, Register::AX, rep_prefix)
1874 }
1875
1876 #[inline]
1886 #[rustfmt::skip]
1887 pub fn with_rep_stosw(address_size: u32) -> Result<Self, IcedError> {
1888 instruction_internal::with_string_esrdi_reg(Code::Stosw_m16_AX, address_size, Register::AX, RepPrefixKind::Repe)
1889 }
1890
1891 #[inline]
1904 #[rustfmt::skip]
1905 pub fn with_stosd(address_size: u32, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1906 instruction_internal::with_string_esrdi_reg(Code::Stosd_m32_EAX, address_size, Register::EAX, rep_prefix)
1907 }
1908
1909 #[inline]
1919 #[rustfmt::skip]
1920 pub fn with_rep_stosd(address_size: u32) -> Result<Self, IcedError> {
1921 instruction_internal::with_string_esrdi_reg(Code::Stosd_m32_EAX, address_size, Register::EAX, RepPrefixKind::Repe)
1922 }
1923
1924 #[inline]
1937 #[rustfmt::skip]
1938 pub fn with_stosq(address_size: u32, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1939 instruction_internal::with_string_esrdi_reg(Code::Stosq_m64_RAX, address_size, Register::RAX, rep_prefix)
1940 }
1941
1942 #[inline]
1952 #[rustfmt::skip]
1953 pub fn with_rep_stosq(address_size: u32) -> Result<Self, IcedError> {
1954 instruction_internal::with_string_esrdi_reg(Code::Stosq_m64_RAX, address_size, Register::RAX, RepPrefixKind::Repe)
1955 }
1956
1957 #[inline]
1972 #[rustfmt::skip]
1973 pub fn with_cmpsb(address_size: u32, segment_prefix: Register, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
1974 instruction_internal::with_string_segrsi_esrdi(Code::Cmpsb_m8_m8, address_size, segment_prefix, rep_prefix)
1975 }
1976
1977 #[inline]
1987 #[rustfmt::skip]
1988 pub fn with_repe_cmpsb(address_size: u32) -> Result<Self, IcedError> {
1989 instruction_internal::with_string_segrsi_esrdi(Code::Cmpsb_m8_m8, address_size, Register::None, RepPrefixKind::Repe)
1990 }
1991
1992 #[inline]
2002 #[rustfmt::skip]
2003 pub fn with_repne_cmpsb(address_size: u32) -> Result<Self, IcedError> {
2004 instruction_internal::with_string_segrsi_esrdi(Code::Cmpsb_m8_m8, address_size, Register::None, RepPrefixKind::Repne)
2005 }
2006
2007 #[inline]
2022 #[rustfmt::skip]
2023 pub fn with_cmpsw(address_size: u32, segment_prefix: Register, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
2024 instruction_internal::with_string_segrsi_esrdi(Code::Cmpsw_m16_m16, address_size, segment_prefix, rep_prefix)
2025 }
2026
2027 #[inline]
2037 #[rustfmt::skip]
2038 pub fn with_repe_cmpsw(address_size: u32) -> Result<Self, IcedError> {
2039 instruction_internal::with_string_segrsi_esrdi(Code::Cmpsw_m16_m16, address_size, Register::None, RepPrefixKind::Repe)
2040 }
2041
2042 #[inline]
2052 #[rustfmt::skip]
2053 pub fn with_repne_cmpsw(address_size: u32) -> Result<Self, IcedError> {
2054 instruction_internal::with_string_segrsi_esrdi(Code::Cmpsw_m16_m16, address_size, Register::None, RepPrefixKind::Repne)
2055 }
2056
2057 #[inline]
2072 #[rustfmt::skip]
2073 pub fn with_cmpsd(address_size: u32, segment_prefix: Register, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
2074 instruction_internal::with_string_segrsi_esrdi(Code::Cmpsd_m32_m32, address_size, segment_prefix, rep_prefix)
2075 }
2076
2077 #[inline]
2087 #[rustfmt::skip]
2088 pub fn with_repe_cmpsd(address_size: u32) -> Result<Self, IcedError> {
2089 instruction_internal::with_string_segrsi_esrdi(Code::Cmpsd_m32_m32, address_size, Register::None, RepPrefixKind::Repe)
2090 }
2091
2092 #[inline]
2102 #[rustfmt::skip]
2103 pub fn with_repne_cmpsd(address_size: u32) -> Result<Self, IcedError> {
2104 instruction_internal::with_string_segrsi_esrdi(Code::Cmpsd_m32_m32, address_size, Register::None, RepPrefixKind::Repne)
2105 }
2106
2107 #[inline]
2122 #[rustfmt::skip]
2123 pub fn with_cmpsq(address_size: u32, segment_prefix: Register, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
2124 instruction_internal::with_string_segrsi_esrdi(Code::Cmpsq_m64_m64, address_size, segment_prefix, rep_prefix)
2125 }
2126
2127 #[inline]
2137 #[rustfmt::skip]
2138 pub fn with_repe_cmpsq(address_size: u32) -> Result<Self, IcedError> {
2139 instruction_internal::with_string_segrsi_esrdi(Code::Cmpsq_m64_m64, address_size, Register::None, RepPrefixKind::Repe)
2140 }
2141
2142 #[inline]
2152 #[rustfmt::skip]
2153 pub fn with_repne_cmpsq(address_size: u32) -> Result<Self, IcedError> {
2154 instruction_internal::with_string_segrsi_esrdi(Code::Cmpsq_m64_m64, address_size, Register::None, RepPrefixKind::Repne)
2155 }
2156
2157 #[inline]
2172 #[rustfmt::skip]
2173 pub fn with_movsb(address_size: u32, segment_prefix: Register, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
2174 instruction_internal::with_string_esrdi_segrsi(Code::Movsb_m8_m8, address_size, segment_prefix, rep_prefix)
2175 }
2176
2177 #[inline]
2187 #[rustfmt::skip]
2188 pub fn with_rep_movsb(address_size: u32) -> Result<Self, IcedError> {
2189 instruction_internal::with_string_esrdi_segrsi(Code::Movsb_m8_m8, address_size, Register::None, RepPrefixKind::Repe)
2190 }
2191
2192 #[inline]
2207 #[rustfmt::skip]
2208 pub fn with_movsw(address_size: u32, segment_prefix: Register, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
2209 instruction_internal::with_string_esrdi_segrsi(Code::Movsw_m16_m16, address_size, segment_prefix, rep_prefix)
2210 }
2211
2212 #[inline]
2222 #[rustfmt::skip]
2223 pub fn with_rep_movsw(address_size: u32) -> Result<Self, IcedError> {
2224 instruction_internal::with_string_esrdi_segrsi(Code::Movsw_m16_m16, address_size, Register::None, RepPrefixKind::Repe)
2225 }
2226
2227 #[inline]
2242 #[rustfmt::skip]
2243 pub fn with_movsd(address_size: u32, segment_prefix: Register, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
2244 instruction_internal::with_string_esrdi_segrsi(Code::Movsd_m32_m32, address_size, segment_prefix, rep_prefix)
2245 }
2246
2247 #[inline]
2257 #[rustfmt::skip]
2258 pub fn with_rep_movsd(address_size: u32) -> Result<Self, IcedError> {
2259 instruction_internal::with_string_esrdi_segrsi(Code::Movsd_m32_m32, address_size, Register::None, RepPrefixKind::Repe)
2260 }
2261
2262 #[inline]
2277 #[rustfmt::skip]
2278 pub fn with_movsq(address_size: u32, segment_prefix: Register, rep_prefix: RepPrefixKind) -> Result<Self, IcedError> {
2279 instruction_internal::with_string_esrdi_segrsi(Code::Movsq_m64_m64, address_size, segment_prefix, rep_prefix)
2280 }
2281
2282 #[inline]
2292 #[rustfmt::skip]
2293 pub fn with_rep_movsq(address_size: u32) -> Result<Self, IcedError> {
2294 instruction_internal::with_string_esrdi_segrsi(Code::Movsq_m64_m64, address_size, Register::None, RepPrefixKind::Repe)
2295 }
2296
2297 #[inline]
2312 #[rustfmt::skip]
2313 pub fn with_maskmovq(address_size: u32, register1: Register, register2: Register, segment_prefix: Register) -> Result<Self, IcedError> {
2314 instruction_internal::with_maskmov(Code::Maskmovq_rDI_mm_mm, address_size, register1, register2, segment_prefix)
2315 }
2316
2317 #[inline]
2332 #[rustfmt::skip]
2333 pub fn with_maskmovdqu(address_size: u32, register1: Register, register2: Register, segment_prefix: Register) -> Result<Self, IcedError> {
2334 instruction_internal::with_maskmov(Code::Maskmovdqu_rDI_xmm_xmm, address_size, register1, register2, segment_prefix)
2335 }
2336
2337 #[inline]
2352 #[rustfmt::skip]
2353 pub fn with_vmaskmovdqu(address_size: u32, register1: Register, register2: Register, segment_prefix: Register) -> Result<Self, IcedError> {
2354 instruction_internal::with_maskmov(Code::VEX_Vmaskmovdqu_rDI_xmm_xmm, address_size, register1, register2, segment_prefix)
2355 }
2356
2357 #[doc(hidden)]
2358 #[allow(clippy::missing_inline_in_public_items)]
2359 #[rustfmt::skip]
2360 pub fn try_with_declare_byte_1(b0: u8) -> Result<Self, IcedError> {
2361 let mut instruction = Self::default();
2362 instruction.set_code(Code::DeclareByte);
2363 instruction_internal::internal_set_declare_data_len(&mut instruction, 1);
2364
2365 instruction.try_set_declare_byte_value(0, b0)?;
2366
2367 debug_assert_eq!(instruction.op_count(), 0);
2368 Ok(instruction)
2369 }
2370
2371 #[allow(clippy::unwrap_used)]
2377 #[must_use]
2378 #[inline]
2379 #[rustfmt::skip]
2380 pub fn with_declare_byte_1(b0: u8) -> Self {
2381 Instruction::try_with_declare_byte_1(b0).unwrap()
2382 }
2383
2384 #[doc(hidden)]
2385 #[allow(clippy::missing_inline_in_public_items)]
2386 #[rustfmt::skip]
2387 pub fn try_with_declare_byte_2(b0: u8, b1: u8) -> Result<Self, IcedError> {
2388 let mut instruction = Self::default();
2389 instruction.set_code(Code::DeclareByte);
2390 instruction_internal::internal_set_declare_data_len(&mut instruction, 2);
2391
2392 instruction.try_set_declare_byte_value(0, b0)?;
2393 instruction.try_set_declare_byte_value(1, b1)?;
2394
2395 debug_assert_eq!(instruction.op_count(), 0);
2396 Ok(instruction)
2397 }
2398
2399 #[allow(clippy::unwrap_used)]
2406 #[must_use]
2407 #[inline]
2408 #[rustfmt::skip]
2409 pub fn with_declare_byte_2(b0: u8, b1: u8) -> Self {
2410 Instruction::try_with_declare_byte_2(b0, b1).unwrap()
2411 }
2412
2413 #[doc(hidden)]
2414 #[allow(clippy::missing_inline_in_public_items)]
2415 #[rustfmt::skip]
2416 pub fn try_with_declare_byte_3(b0: u8, b1: u8, b2: u8) -> Result<Self, IcedError> {
2417 let mut instruction = Self::default();
2418 instruction.set_code(Code::DeclareByte);
2419 instruction_internal::internal_set_declare_data_len(&mut instruction, 3);
2420
2421 instruction.try_set_declare_byte_value(0, b0)?;
2422 instruction.try_set_declare_byte_value(1, b1)?;
2423 instruction.try_set_declare_byte_value(2, b2)?;
2424
2425 debug_assert_eq!(instruction.op_count(), 0);
2426 Ok(instruction)
2427 }
2428
2429 #[allow(clippy::unwrap_used)]
2437 #[must_use]
2438 #[inline]
2439 #[rustfmt::skip]
2440 pub fn with_declare_byte_3(b0: u8, b1: u8, b2: u8) -> Self {
2441 Instruction::try_with_declare_byte_3(b0, b1, b2).unwrap()
2442 }
2443
2444 #[doc(hidden)]
2445 #[allow(clippy::missing_inline_in_public_items)]
2446 #[rustfmt::skip]
2447 pub fn try_with_declare_byte_4(b0: u8, b1: u8, b2: u8, b3: u8) -> Result<Self, IcedError> {
2448 let mut instruction = Self::default();
2449 instruction.set_code(Code::DeclareByte);
2450 instruction_internal::internal_set_declare_data_len(&mut instruction, 4);
2451
2452 instruction.try_set_declare_byte_value(0, b0)?;
2453 instruction.try_set_declare_byte_value(1, b1)?;
2454 instruction.try_set_declare_byte_value(2, b2)?;
2455 instruction.try_set_declare_byte_value(3, b3)?;
2456
2457 debug_assert_eq!(instruction.op_count(), 0);
2458 Ok(instruction)
2459 }
2460
2461 #[allow(clippy::unwrap_used)]
2470 #[must_use]
2471 #[inline]
2472 #[rustfmt::skip]
2473 pub fn with_declare_byte_4(b0: u8, b1: u8, b2: u8, b3: u8) -> Self {
2474 Instruction::try_with_declare_byte_4(b0, b1, b2, b3).unwrap()
2475 }
2476
2477 #[doc(hidden)]
2478 #[allow(clippy::missing_inline_in_public_items)]
2479 #[rustfmt::skip]
2480 pub fn try_with_declare_byte_5(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8) -> Result<Self, IcedError> {
2481 let mut instruction = Self::default();
2482 instruction.set_code(Code::DeclareByte);
2483 instruction_internal::internal_set_declare_data_len(&mut instruction, 5);
2484
2485 instruction.try_set_declare_byte_value(0, b0)?;
2486 instruction.try_set_declare_byte_value(1, b1)?;
2487 instruction.try_set_declare_byte_value(2, b2)?;
2488 instruction.try_set_declare_byte_value(3, b3)?;
2489 instruction.try_set_declare_byte_value(4, b4)?;
2490
2491 debug_assert_eq!(instruction.op_count(), 0);
2492 Ok(instruction)
2493 }
2494
2495 #[allow(clippy::unwrap_used)]
2505 #[must_use]
2506 #[inline]
2507 #[rustfmt::skip]
2508 pub fn with_declare_byte_5(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8) -> Self {
2509 Instruction::try_with_declare_byte_5(b0, b1, b2, b3, b4).unwrap()
2510 }
2511
2512 #[doc(hidden)]
2513 #[allow(clippy::missing_inline_in_public_items)]
2514 #[rustfmt::skip]
2515 pub fn try_with_declare_byte_6(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8) -> Result<Self, IcedError> {
2516 let mut instruction = Self::default();
2517 instruction.set_code(Code::DeclareByte);
2518 instruction_internal::internal_set_declare_data_len(&mut instruction, 6);
2519
2520 instruction.try_set_declare_byte_value(0, b0)?;
2521 instruction.try_set_declare_byte_value(1, b1)?;
2522 instruction.try_set_declare_byte_value(2, b2)?;
2523 instruction.try_set_declare_byte_value(3, b3)?;
2524 instruction.try_set_declare_byte_value(4, b4)?;
2525 instruction.try_set_declare_byte_value(5, b5)?;
2526
2527 debug_assert_eq!(instruction.op_count(), 0);
2528 Ok(instruction)
2529 }
2530
2531 #[allow(clippy::unwrap_used)]
2542 #[must_use]
2543 #[inline]
2544 #[rustfmt::skip]
2545 pub fn with_declare_byte_6(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8) -> Self {
2546 Instruction::try_with_declare_byte_6(b0, b1, b2, b3, b4, b5).unwrap()
2547 }
2548
2549 #[doc(hidden)]
2550 #[allow(clippy::missing_inline_in_public_items)]
2551 #[rustfmt::skip]
2552 pub fn try_with_declare_byte_7(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8) -> Result<Self, IcedError> {
2553 let mut instruction = Self::default();
2554 instruction.set_code(Code::DeclareByte);
2555 instruction_internal::internal_set_declare_data_len(&mut instruction, 7);
2556
2557 instruction.try_set_declare_byte_value(0, b0)?;
2558 instruction.try_set_declare_byte_value(1, b1)?;
2559 instruction.try_set_declare_byte_value(2, b2)?;
2560 instruction.try_set_declare_byte_value(3, b3)?;
2561 instruction.try_set_declare_byte_value(4, b4)?;
2562 instruction.try_set_declare_byte_value(5, b5)?;
2563 instruction.try_set_declare_byte_value(6, b6)?;
2564
2565 debug_assert_eq!(instruction.op_count(), 0);
2566 Ok(instruction)
2567 }
2568
2569 #[allow(clippy::unwrap_used)]
2581 #[must_use]
2582 #[inline]
2583 #[rustfmt::skip]
2584 pub fn with_declare_byte_7(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8) -> Self {
2585 Instruction::try_with_declare_byte_7(b0, b1, b2, b3, b4, b5, b6).unwrap()
2586 }
2587
2588 #[doc(hidden)]
2589 #[allow(clippy::missing_inline_in_public_items)]
2590 #[rustfmt::skip]
2591 pub fn try_with_declare_byte_8(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8, b7: u8) -> Result<Self, IcedError> {
2592 let mut instruction = Self::default();
2593 instruction.set_code(Code::DeclareByte);
2594 instruction_internal::internal_set_declare_data_len(&mut instruction, 8);
2595
2596 instruction.try_set_declare_byte_value(0, b0)?;
2597 instruction.try_set_declare_byte_value(1, b1)?;
2598 instruction.try_set_declare_byte_value(2, b2)?;
2599 instruction.try_set_declare_byte_value(3, b3)?;
2600 instruction.try_set_declare_byte_value(4, b4)?;
2601 instruction.try_set_declare_byte_value(5, b5)?;
2602 instruction.try_set_declare_byte_value(6, b6)?;
2603 instruction.try_set_declare_byte_value(7, b7)?;
2604
2605 debug_assert_eq!(instruction.op_count(), 0);
2606 Ok(instruction)
2607 }
2608
2609 #[allow(clippy::unwrap_used)]
2622 #[must_use]
2623 #[inline]
2624 #[rustfmt::skip]
2625 pub fn with_declare_byte_8(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8, b7: u8) -> Self {
2626 Instruction::try_with_declare_byte_8(b0, b1, b2, b3, b4, b5, b6, b7).unwrap()
2627 }
2628
2629 #[doc(hidden)]
2630 #[allow(clippy::missing_inline_in_public_items)]
2631 #[rustfmt::skip]
2632 pub fn try_with_declare_byte_9(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8, b7: u8, b8: u8) -> Result<Self, IcedError> {
2633 let mut instruction = Self::default();
2634 instruction.set_code(Code::DeclareByte);
2635 instruction_internal::internal_set_declare_data_len(&mut instruction, 9);
2636
2637 instruction.try_set_declare_byte_value(0, b0)?;
2638 instruction.try_set_declare_byte_value(1, b1)?;
2639 instruction.try_set_declare_byte_value(2, b2)?;
2640 instruction.try_set_declare_byte_value(3, b3)?;
2641 instruction.try_set_declare_byte_value(4, b4)?;
2642 instruction.try_set_declare_byte_value(5, b5)?;
2643 instruction.try_set_declare_byte_value(6, b6)?;
2644 instruction.try_set_declare_byte_value(7, b7)?;
2645 instruction.try_set_declare_byte_value(8, b8)?;
2646
2647 debug_assert_eq!(instruction.op_count(), 0);
2648 Ok(instruction)
2649 }
2650
2651 #[allow(clippy::unwrap_used)]
2665 #[must_use]
2666 #[inline]
2667 #[rustfmt::skip]
2668 pub fn with_declare_byte_9(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8, b7: u8, b8: u8) -> Self {
2669 Instruction::try_with_declare_byte_9(b0, b1, b2, b3, b4, b5, b6, b7, b8).unwrap()
2670 }
2671
2672 #[doc(hidden)]
2673 #[allow(clippy::missing_inline_in_public_items)]
2674 #[rustfmt::skip]
2675 pub fn try_with_declare_byte_10(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8, b7: u8, b8: u8, b9: u8) -> Result<Self, IcedError> {
2676 let mut instruction = Self::default();
2677 instruction.set_code(Code::DeclareByte);
2678 instruction_internal::internal_set_declare_data_len(&mut instruction, 10);
2679
2680 instruction.try_set_declare_byte_value(0, b0)?;
2681 instruction.try_set_declare_byte_value(1, b1)?;
2682 instruction.try_set_declare_byte_value(2, b2)?;
2683 instruction.try_set_declare_byte_value(3, b3)?;
2684 instruction.try_set_declare_byte_value(4, b4)?;
2685 instruction.try_set_declare_byte_value(5, b5)?;
2686 instruction.try_set_declare_byte_value(6, b6)?;
2687 instruction.try_set_declare_byte_value(7, b7)?;
2688 instruction.try_set_declare_byte_value(8, b8)?;
2689 instruction.try_set_declare_byte_value(9, b9)?;
2690
2691 debug_assert_eq!(instruction.op_count(), 0);
2692 Ok(instruction)
2693 }
2694
2695 #[allow(clippy::unwrap_used)]
2710 #[must_use]
2711 #[inline]
2712 #[rustfmt::skip]
2713 pub fn with_declare_byte_10(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8, b7: u8, b8: u8, b9: u8) -> Self {
2714 Instruction::try_with_declare_byte_10(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9).unwrap()
2715 }
2716
2717 #[doc(hidden)]
2718 #[allow(clippy::missing_inline_in_public_items)]
2719 #[rustfmt::skip]
2720 pub fn try_with_declare_byte_11(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8, b7: u8, b8: u8, b9: u8, b10: u8) -> Result<Self, IcedError> {
2721 let mut instruction = Self::default();
2722 instruction.set_code(Code::DeclareByte);
2723 instruction_internal::internal_set_declare_data_len(&mut instruction, 11);
2724
2725 instruction.try_set_declare_byte_value(0, b0)?;
2726 instruction.try_set_declare_byte_value(1, b1)?;
2727 instruction.try_set_declare_byte_value(2, b2)?;
2728 instruction.try_set_declare_byte_value(3, b3)?;
2729 instruction.try_set_declare_byte_value(4, b4)?;
2730 instruction.try_set_declare_byte_value(5, b5)?;
2731 instruction.try_set_declare_byte_value(6, b6)?;
2732 instruction.try_set_declare_byte_value(7, b7)?;
2733 instruction.try_set_declare_byte_value(8, b8)?;
2734 instruction.try_set_declare_byte_value(9, b9)?;
2735 instruction.try_set_declare_byte_value(10, b10)?;
2736
2737 debug_assert_eq!(instruction.op_count(), 0);
2738 Ok(instruction)
2739 }
2740
2741 #[allow(clippy::unwrap_used)]
2757 #[must_use]
2758 #[inline]
2759 #[rustfmt::skip]
2760 pub fn with_declare_byte_11(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8, b7: u8, b8: u8, b9: u8, b10: u8) -> Self {
2761 Instruction::try_with_declare_byte_11(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10).unwrap()
2762 }
2763
2764 #[doc(hidden)]
2765 #[allow(clippy::missing_inline_in_public_items)]
2766 #[rustfmt::skip]
2767 pub fn try_with_declare_byte_12(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8, b7: u8, b8: u8, b9: u8, b10: u8, b11: u8) -> Result<Self, IcedError> {
2768 let mut instruction = Self::default();
2769 instruction.set_code(Code::DeclareByte);
2770 instruction_internal::internal_set_declare_data_len(&mut instruction, 12);
2771
2772 instruction.try_set_declare_byte_value(0, b0)?;
2773 instruction.try_set_declare_byte_value(1, b1)?;
2774 instruction.try_set_declare_byte_value(2, b2)?;
2775 instruction.try_set_declare_byte_value(3, b3)?;
2776 instruction.try_set_declare_byte_value(4, b4)?;
2777 instruction.try_set_declare_byte_value(5, b5)?;
2778 instruction.try_set_declare_byte_value(6, b6)?;
2779 instruction.try_set_declare_byte_value(7, b7)?;
2780 instruction.try_set_declare_byte_value(8, b8)?;
2781 instruction.try_set_declare_byte_value(9, b9)?;
2782 instruction.try_set_declare_byte_value(10, b10)?;
2783 instruction.try_set_declare_byte_value(11, b11)?;
2784
2785 debug_assert_eq!(instruction.op_count(), 0);
2786 Ok(instruction)
2787 }
2788
2789 #[allow(clippy::unwrap_used)]
2806 #[must_use]
2807 #[inline]
2808 #[rustfmt::skip]
2809 pub fn with_declare_byte_12(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8, b7: u8, b8: u8, b9: u8, b10: u8, b11: u8) -> Self {
2810 Instruction::try_with_declare_byte_12(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11).unwrap()
2811 }
2812
2813 #[doc(hidden)]
2814 #[allow(clippy::missing_inline_in_public_items)]
2815 #[rustfmt::skip]
2816 pub fn try_with_declare_byte_13(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8, b7: u8, b8: u8, b9: u8, b10: u8, b11: u8, b12: u8) -> Result<Self, IcedError> {
2817 let mut instruction = Self::default();
2818 instruction.set_code(Code::DeclareByte);
2819 instruction_internal::internal_set_declare_data_len(&mut instruction, 13);
2820
2821 instruction.try_set_declare_byte_value(0, b0)?;
2822 instruction.try_set_declare_byte_value(1, b1)?;
2823 instruction.try_set_declare_byte_value(2, b2)?;
2824 instruction.try_set_declare_byte_value(3, b3)?;
2825 instruction.try_set_declare_byte_value(4, b4)?;
2826 instruction.try_set_declare_byte_value(5, b5)?;
2827 instruction.try_set_declare_byte_value(6, b6)?;
2828 instruction.try_set_declare_byte_value(7, b7)?;
2829 instruction.try_set_declare_byte_value(8, b8)?;
2830 instruction.try_set_declare_byte_value(9, b9)?;
2831 instruction.try_set_declare_byte_value(10, b10)?;
2832 instruction.try_set_declare_byte_value(11, b11)?;
2833 instruction.try_set_declare_byte_value(12, b12)?;
2834
2835 debug_assert_eq!(instruction.op_count(), 0);
2836 Ok(instruction)
2837 }
2838
2839 #[allow(clippy::unwrap_used)]
2857 #[must_use]
2858 #[inline]
2859 #[rustfmt::skip]
2860 pub fn with_declare_byte_13(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8, b7: u8, b8: u8, b9: u8, b10: u8, b11: u8, b12: u8) -> Self {
2861 Instruction::try_with_declare_byte_13(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12).unwrap()
2862 }
2863
2864 #[doc(hidden)]
2865 #[allow(clippy::missing_inline_in_public_items)]
2866 #[rustfmt::skip]
2867 pub fn try_with_declare_byte_14(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8, b7: u8, b8: u8, b9: u8, b10: u8, b11: u8, b12: u8, b13: u8) -> Result<Self, IcedError> {
2868 let mut instruction = Self::default();
2869 instruction.set_code(Code::DeclareByte);
2870 instruction_internal::internal_set_declare_data_len(&mut instruction, 14);
2871
2872 instruction.try_set_declare_byte_value(0, b0)?;
2873 instruction.try_set_declare_byte_value(1, b1)?;
2874 instruction.try_set_declare_byte_value(2, b2)?;
2875 instruction.try_set_declare_byte_value(3, b3)?;
2876 instruction.try_set_declare_byte_value(4, b4)?;
2877 instruction.try_set_declare_byte_value(5, b5)?;
2878 instruction.try_set_declare_byte_value(6, b6)?;
2879 instruction.try_set_declare_byte_value(7, b7)?;
2880 instruction.try_set_declare_byte_value(8, b8)?;
2881 instruction.try_set_declare_byte_value(9, b9)?;
2882 instruction.try_set_declare_byte_value(10, b10)?;
2883 instruction.try_set_declare_byte_value(11, b11)?;
2884 instruction.try_set_declare_byte_value(12, b12)?;
2885 instruction.try_set_declare_byte_value(13, b13)?;
2886
2887 debug_assert_eq!(instruction.op_count(), 0);
2888 Ok(instruction)
2889 }
2890
2891 #[allow(clippy::unwrap_used)]
2910 #[must_use]
2911 #[inline]
2912 #[rustfmt::skip]
2913 pub fn with_declare_byte_14(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8, b7: u8, b8: u8, b9: u8, b10: u8, b11: u8, b12: u8, b13: u8) -> Self {
2914 Instruction::try_with_declare_byte_14(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13).unwrap()
2915 }
2916
2917 #[doc(hidden)]
2918 #[allow(clippy::missing_inline_in_public_items)]
2919 #[rustfmt::skip]
2920 pub fn try_with_declare_byte_15(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8, b7: u8, b8: u8, b9: u8, b10: u8, b11: u8, b12: u8, b13: u8, b14: u8) -> Result<Self, IcedError> {
2921 let mut instruction = Self::default();
2922 instruction.set_code(Code::DeclareByte);
2923 instruction_internal::internal_set_declare_data_len(&mut instruction, 15);
2924
2925 instruction.try_set_declare_byte_value(0, b0)?;
2926 instruction.try_set_declare_byte_value(1, b1)?;
2927 instruction.try_set_declare_byte_value(2, b2)?;
2928 instruction.try_set_declare_byte_value(3, b3)?;
2929 instruction.try_set_declare_byte_value(4, b4)?;
2930 instruction.try_set_declare_byte_value(5, b5)?;
2931 instruction.try_set_declare_byte_value(6, b6)?;
2932 instruction.try_set_declare_byte_value(7, b7)?;
2933 instruction.try_set_declare_byte_value(8, b8)?;
2934 instruction.try_set_declare_byte_value(9, b9)?;
2935 instruction.try_set_declare_byte_value(10, b10)?;
2936 instruction.try_set_declare_byte_value(11, b11)?;
2937 instruction.try_set_declare_byte_value(12, b12)?;
2938 instruction.try_set_declare_byte_value(13, b13)?;
2939 instruction.try_set_declare_byte_value(14, b14)?;
2940
2941 debug_assert_eq!(instruction.op_count(), 0);
2942 Ok(instruction)
2943 }
2944
2945 #[allow(clippy::unwrap_used)]
2965 #[must_use]
2966 #[inline]
2967 #[rustfmt::skip]
2968 pub fn with_declare_byte_15(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8, b7: u8, b8: u8, b9: u8, b10: u8, b11: u8, b12: u8, b13: u8, b14: u8) -> Self {
2969 Instruction::try_with_declare_byte_15(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14).unwrap()
2970 }
2971
2972 #[doc(hidden)]
2973 #[allow(clippy::missing_inline_in_public_items)]
2974 #[rustfmt::skip]
2975 pub fn try_with_declare_byte_16(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8, b7: u8, b8: u8, b9: u8, b10: u8, b11: u8, b12: u8, b13: u8, b14: u8, b15: u8) -> Result<Self, IcedError> {
2976 let mut instruction = Self::default();
2977 instruction.set_code(Code::DeclareByte);
2978 instruction_internal::internal_set_declare_data_len(&mut instruction, 16);
2979
2980 instruction.try_set_declare_byte_value(0, b0)?;
2981 instruction.try_set_declare_byte_value(1, b1)?;
2982 instruction.try_set_declare_byte_value(2, b2)?;
2983 instruction.try_set_declare_byte_value(3, b3)?;
2984 instruction.try_set_declare_byte_value(4, b4)?;
2985 instruction.try_set_declare_byte_value(5, b5)?;
2986 instruction.try_set_declare_byte_value(6, b6)?;
2987 instruction.try_set_declare_byte_value(7, b7)?;
2988 instruction.try_set_declare_byte_value(8, b8)?;
2989 instruction.try_set_declare_byte_value(9, b9)?;
2990 instruction.try_set_declare_byte_value(10, b10)?;
2991 instruction.try_set_declare_byte_value(11, b11)?;
2992 instruction.try_set_declare_byte_value(12, b12)?;
2993 instruction.try_set_declare_byte_value(13, b13)?;
2994 instruction.try_set_declare_byte_value(14, b14)?;
2995 instruction.try_set_declare_byte_value(15, b15)?;
2996
2997 debug_assert_eq!(instruction.op_count(), 0);
2998 Ok(instruction)
2999 }
3000
3001 #[allow(clippy::unwrap_used)]
3022 #[must_use]
3023 #[inline]
3024 #[rustfmt::skip]
3025 pub fn with_declare_byte_16(b0: u8, b1: u8, b2: u8, b3: u8, b4: u8, b5: u8, b6: u8, b7: u8, b8: u8, b9: u8, b10: u8, b11: u8, b12: u8, b13: u8, b14: u8, b15: u8) -> Self {
3026 Instruction::try_with_declare_byte_16(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15).unwrap()
3027 }
3028
3029 #[allow(clippy::missing_inline_in_public_items)]
3039 #[rustfmt::skip]
3040 pub fn with_declare_byte(data: &[u8]) -> Result<Self, IcedError> {
3041 if data.len().wrapping_sub(1) > 16 - 1 {
3042 return Err(IcedError::new("Invalid slice length"));
3043 }
3044
3045 let mut instruction = Self::default();
3046 instruction.set_code(Code::DeclareByte);
3047 instruction_internal::internal_set_declare_data_len(&mut instruction, data.len() as u32);
3048
3049 for i in data.iter().enumerate() {
3050 instruction.try_set_declare_byte_value(i.0, *i.1)?;
3051 }
3052
3053 debug_assert_eq!(instruction.op_count(), 0);
3054 Ok(instruction)
3055 }
3056
3057 #[doc(hidden)]
3058 #[allow(clippy::missing_inline_in_public_items)]
3059 #[rustfmt::skip]
3060 pub fn try_with_declare_word_1(w0: u16) -> Result<Self, IcedError> {
3061 let mut instruction = Self::default();
3062 instruction.set_code(Code::DeclareWord);
3063 instruction_internal::internal_set_declare_data_len(&mut instruction, 1);
3064
3065 instruction.try_set_declare_word_value(0, w0)?;
3066
3067 debug_assert_eq!(instruction.op_count(), 0);
3068 Ok(instruction)
3069 }
3070
3071 #[allow(clippy::unwrap_used)]
3077 #[must_use]
3078 #[inline]
3079 #[rustfmt::skip]
3080 pub fn with_declare_word_1(w0: u16) -> Self {
3081 Instruction::try_with_declare_word_1(w0).unwrap()
3082 }
3083
3084 #[doc(hidden)]
3085 #[allow(clippy::missing_inline_in_public_items)]
3086 #[rustfmt::skip]
3087 pub fn try_with_declare_word_2(w0: u16, w1: u16) -> Result<Self, IcedError> {
3088 let mut instruction = Self::default();
3089 instruction.set_code(Code::DeclareWord);
3090 instruction_internal::internal_set_declare_data_len(&mut instruction, 2);
3091
3092 instruction.try_set_declare_word_value(0, w0)?;
3093 instruction.try_set_declare_word_value(1, w1)?;
3094
3095 debug_assert_eq!(instruction.op_count(), 0);
3096 Ok(instruction)
3097 }
3098
3099 #[allow(clippy::unwrap_used)]
3106 #[must_use]
3107 #[inline]
3108 #[rustfmt::skip]
3109 pub fn with_declare_word_2(w0: u16, w1: u16) -> Self {
3110 Instruction::try_with_declare_word_2(w0, w1).unwrap()
3111 }
3112
3113 #[doc(hidden)]
3114 #[allow(clippy::missing_inline_in_public_items)]
3115 #[rustfmt::skip]
3116 pub fn try_with_declare_word_3(w0: u16, w1: u16, w2: u16) -> Result<Self, IcedError> {
3117 let mut instruction = Self::default();
3118 instruction.set_code(Code::DeclareWord);
3119 instruction_internal::internal_set_declare_data_len(&mut instruction, 3);
3120
3121 instruction.try_set_declare_word_value(0, w0)?;
3122 instruction.try_set_declare_word_value(1, w1)?;
3123 instruction.try_set_declare_word_value(2, w2)?;
3124
3125 debug_assert_eq!(instruction.op_count(), 0);
3126 Ok(instruction)
3127 }
3128
3129 #[allow(clippy::unwrap_used)]
3137 #[must_use]
3138 #[inline]
3139 #[rustfmt::skip]
3140 pub fn with_declare_word_3(w0: u16, w1: u16, w2: u16) -> Self {
3141 Instruction::try_with_declare_word_3(w0, w1, w2).unwrap()
3142 }
3143
3144 #[doc(hidden)]
3145 #[allow(clippy::missing_inline_in_public_items)]
3146 #[rustfmt::skip]
3147 pub fn try_with_declare_word_4(w0: u16, w1: u16, w2: u16, w3: u16) -> Result<Self, IcedError> {
3148 let mut instruction = Self::default();
3149 instruction.set_code(Code::DeclareWord);
3150 instruction_internal::internal_set_declare_data_len(&mut instruction, 4);
3151
3152 instruction.try_set_declare_word_value(0, w0)?;
3153 instruction.try_set_declare_word_value(1, w1)?;
3154 instruction.try_set_declare_word_value(2, w2)?;
3155 instruction.try_set_declare_word_value(3, w3)?;
3156
3157 debug_assert_eq!(instruction.op_count(), 0);
3158 Ok(instruction)
3159 }
3160
3161 #[allow(clippy::unwrap_used)]
3170 #[must_use]
3171 #[inline]
3172 #[rustfmt::skip]
3173 pub fn with_declare_word_4(w0: u16, w1: u16, w2: u16, w3: u16) -> Self {
3174 Instruction::try_with_declare_word_4(w0, w1, w2, w3).unwrap()
3175 }
3176
3177 #[doc(hidden)]
3178 #[allow(clippy::missing_inline_in_public_items)]
3179 #[rustfmt::skip]
3180 pub fn try_with_declare_word_5(w0: u16, w1: u16, w2: u16, w3: u16, w4: u16) -> Result<Self, IcedError> {
3181 let mut instruction = Self::default();
3182 instruction.set_code(Code::DeclareWord);
3183 instruction_internal::internal_set_declare_data_len(&mut instruction, 5);
3184
3185 instruction.try_set_declare_word_value(0, w0)?;
3186 instruction.try_set_declare_word_value(1, w1)?;
3187 instruction.try_set_declare_word_value(2, w2)?;
3188 instruction.try_set_declare_word_value(3, w3)?;
3189 instruction.try_set_declare_word_value(4, w4)?;
3190
3191 debug_assert_eq!(instruction.op_count(), 0);
3192 Ok(instruction)
3193 }
3194
3195 #[allow(clippy::unwrap_used)]
3205 #[must_use]
3206 #[inline]
3207 #[rustfmt::skip]
3208 pub fn with_declare_word_5(w0: u16, w1: u16, w2: u16, w3: u16, w4: u16) -> Self {
3209 Instruction::try_with_declare_word_5(w0, w1, w2, w3, w4).unwrap()
3210 }
3211
3212 #[doc(hidden)]
3213 #[allow(clippy::missing_inline_in_public_items)]
3214 #[rustfmt::skip]
3215 pub fn try_with_declare_word_6(w0: u16, w1: u16, w2: u16, w3: u16, w4: u16, w5: u16) -> Result<Self, IcedError> {
3216 let mut instruction = Self::default();
3217 instruction.set_code(Code::DeclareWord);
3218 instruction_internal::internal_set_declare_data_len(&mut instruction, 6);
3219
3220 instruction.try_set_declare_word_value(0, w0)?;
3221 instruction.try_set_declare_word_value(1, w1)?;
3222 instruction.try_set_declare_word_value(2, w2)?;
3223 instruction.try_set_declare_word_value(3, w3)?;
3224 instruction.try_set_declare_word_value(4, w4)?;
3225 instruction.try_set_declare_word_value(5, w5)?;
3226
3227 debug_assert_eq!(instruction.op_count(), 0);
3228 Ok(instruction)
3229 }
3230
3231 #[allow(clippy::unwrap_used)]
3242 #[must_use]
3243 #[inline]
3244 #[rustfmt::skip]
3245 pub fn with_declare_word_6(w0: u16, w1: u16, w2: u16, w3: u16, w4: u16, w5: u16) -> Self {
3246 Instruction::try_with_declare_word_6(w0, w1, w2, w3, w4, w5).unwrap()
3247 }
3248
3249 #[doc(hidden)]
3250 #[allow(clippy::missing_inline_in_public_items)]
3251 #[rustfmt::skip]
3252 pub fn try_with_declare_word_7(w0: u16, w1: u16, w2: u16, w3: u16, w4: u16, w5: u16, w6: u16) -> Result<Self, IcedError> {
3253 let mut instruction = Self::default();
3254 instruction.set_code(Code::DeclareWord);
3255 instruction_internal::internal_set_declare_data_len(&mut instruction, 7);
3256
3257 instruction.try_set_declare_word_value(0, w0)?;
3258 instruction.try_set_declare_word_value(1, w1)?;
3259 instruction.try_set_declare_word_value(2, w2)?;
3260 instruction.try_set_declare_word_value(3, w3)?;
3261 instruction.try_set_declare_word_value(4, w4)?;
3262 instruction.try_set_declare_word_value(5, w5)?;
3263 instruction.try_set_declare_word_value(6, w6)?;
3264
3265 debug_assert_eq!(instruction.op_count(), 0);
3266 Ok(instruction)
3267 }
3268
3269 #[allow(clippy::unwrap_used)]
3281 #[must_use]
3282 #[inline]
3283 #[rustfmt::skip]
3284 pub fn with_declare_word_7(w0: u16, w1: u16, w2: u16, w3: u16, w4: u16, w5: u16, w6: u16) -> Self {
3285 Instruction::try_with_declare_word_7(w0, w1, w2, w3, w4, w5, w6).unwrap()
3286 }
3287
3288 #[doc(hidden)]
3289 #[allow(clippy::missing_inline_in_public_items)]
3290 #[rustfmt::skip]
3291 pub fn try_with_declare_word_8(w0: u16, w1: u16, w2: u16, w3: u16, w4: u16, w5: u16, w6: u16, w7: u16) -> Result<Self, IcedError> {
3292 let mut instruction = Self::default();
3293 instruction.set_code(Code::DeclareWord);
3294 instruction_internal::internal_set_declare_data_len(&mut instruction, 8);
3295
3296 instruction.try_set_declare_word_value(0, w0)?;
3297 instruction.try_set_declare_word_value(1, w1)?;
3298 instruction.try_set_declare_word_value(2, w2)?;
3299 instruction.try_set_declare_word_value(3, w3)?;
3300 instruction.try_set_declare_word_value(4, w4)?;
3301 instruction.try_set_declare_word_value(5, w5)?;
3302 instruction.try_set_declare_word_value(6, w6)?;
3303 instruction.try_set_declare_word_value(7, w7)?;
3304
3305 debug_assert_eq!(instruction.op_count(), 0);
3306 Ok(instruction)
3307 }
3308
3309 #[allow(clippy::unwrap_used)]
3322 #[must_use]
3323 #[inline]
3324 #[rustfmt::skip]
3325 pub fn with_declare_word_8(w0: u16, w1: u16, w2: u16, w3: u16, w4: u16, w5: u16, w6: u16, w7: u16) -> Self {
3326 Instruction::try_with_declare_word_8(w0, w1, w2, w3, w4, w5, w6, w7).unwrap()
3327 }
3328
3329 #[allow(clippy::missing_inline_in_public_items)]
3339 #[rustfmt::skip]
3340 #[allow(trivial_casts)]
3341 pub fn with_declare_word_slice_u8(data: &[u8]) -> Result<Self, IcedError> {
3342 if data.len().wrapping_sub(1) > 16 - 1 || (data.len() & 1) != 0 {
3343 return Err(IcedError::new("Invalid slice length"));
3344 }
3345
3346 let mut instruction = Self::default();
3347 instruction.set_code(Code::DeclareWord);
3348 instruction_internal::internal_set_declare_data_len(&mut instruction, data.len() as u32 / 2);
3349
3350 for i in 0..data.len() / 2 {
3351 let v = (data[i * 2] as u16) | ((data[i * 2 + 1] as u16) << 8);
3352 instruction.try_set_declare_word_value(i, v)?;
3353 }
3354
3355 debug_assert_eq!(instruction.op_count(), 0);
3356 Ok(instruction)
3357 }
3358
3359 #[allow(clippy::missing_inline_in_public_items)]
3369 #[rustfmt::skip]
3370 pub fn with_declare_word(data: &[u16]) -> Result<Self, IcedError> {
3371 if data.len().wrapping_sub(1) > 8 - 1 {
3372 return Err(IcedError::new("Invalid slice length"));
3373 }
3374
3375 let mut instruction = Self::default();
3376 instruction.set_code(Code::DeclareWord);
3377 instruction_internal::internal_set_declare_data_len(&mut instruction, data.len() as u32);
3378
3379 for i in data.iter().enumerate() {
3380 instruction.try_set_declare_word_value(i.0, *i.1)?;
3381 }
3382
3383 debug_assert_eq!(instruction.op_count(), 0);
3384 Ok(instruction)
3385 }
3386
3387 #[doc(hidden)]
3388 #[allow(clippy::missing_inline_in_public_items)]
3389 #[rustfmt::skip]
3390 pub fn try_with_declare_dword_1(d0: u32) -> Result<Self, IcedError> {
3391 let mut instruction = Self::default();
3392 instruction.set_code(Code::DeclareDword);
3393 instruction_internal::internal_set_declare_data_len(&mut instruction, 1);
3394
3395 instruction.try_set_declare_dword_value(0, d0)?;
3396
3397 debug_assert_eq!(instruction.op_count(), 0);
3398 Ok(instruction)
3399 }
3400
3401 #[allow(clippy::unwrap_used)]
3407 #[must_use]
3408 #[inline]
3409 #[rustfmt::skip]
3410 pub fn with_declare_dword_1(d0: u32) -> Self {
3411 Instruction::try_with_declare_dword_1(d0).unwrap()
3412 }
3413
3414 #[doc(hidden)]
3415 #[allow(clippy::missing_inline_in_public_items)]
3416 #[rustfmt::skip]
3417 pub fn try_with_declare_dword_2(d0: u32, d1: u32) -> Result<Self, IcedError> {
3418 let mut instruction = Self::default();
3419 instruction.set_code(Code::DeclareDword);
3420 instruction_internal::internal_set_declare_data_len(&mut instruction, 2);
3421
3422 instruction.try_set_declare_dword_value(0, d0)?;
3423 instruction.try_set_declare_dword_value(1, d1)?;
3424
3425 debug_assert_eq!(instruction.op_count(), 0);
3426 Ok(instruction)
3427 }
3428
3429 #[allow(clippy::unwrap_used)]
3436 #[must_use]
3437 #[inline]
3438 #[rustfmt::skip]
3439 pub fn with_declare_dword_2(d0: u32, d1: u32) -> Self {
3440 Instruction::try_with_declare_dword_2(d0, d1).unwrap()
3441 }
3442
3443 #[doc(hidden)]
3444 #[allow(clippy::missing_inline_in_public_items)]
3445 #[rustfmt::skip]
3446 pub fn try_with_declare_dword_3(d0: u32, d1: u32, d2: u32) -> Result<Self, IcedError> {
3447 let mut instruction = Self::default();
3448 instruction.set_code(Code::DeclareDword);
3449 instruction_internal::internal_set_declare_data_len(&mut instruction, 3);
3450
3451 instruction.try_set_declare_dword_value(0, d0)?;
3452 instruction.try_set_declare_dword_value(1, d1)?;
3453 instruction.try_set_declare_dword_value(2, d2)?;
3454
3455 debug_assert_eq!(instruction.op_count(), 0);
3456 Ok(instruction)
3457 }
3458
3459 #[allow(clippy::unwrap_used)]
3467 #[must_use]
3468 #[inline]
3469 #[rustfmt::skip]
3470 pub fn with_declare_dword_3(d0: u32, d1: u32, d2: u32) -> Self {
3471 Instruction::try_with_declare_dword_3(d0, d1, d2).unwrap()
3472 }
3473
3474 #[doc(hidden)]
3475 #[allow(clippy::missing_inline_in_public_items)]
3476 #[rustfmt::skip]
3477 pub fn try_with_declare_dword_4(d0: u32, d1: u32, d2: u32, d3: u32) -> Result<Self, IcedError> {
3478 let mut instruction = Self::default();
3479 instruction.set_code(Code::DeclareDword);
3480 instruction_internal::internal_set_declare_data_len(&mut instruction, 4);
3481
3482 instruction.try_set_declare_dword_value(0, d0)?;
3483 instruction.try_set_declare_dword_value(1, d1)?;
3484 instruction.try_set_declare_dword_value(2, d2)?;
3485 instruction.try_set_declare_dword_value(3, d3)?;
3486
3487 debug_assert_eq!(instruction.op_count(), 0);
3488 Ok(instruction)
3489 }
3490
3491 #[allow(clippy::unwrap_used)]
3500 #[must_use]
3501 #[inline]
3502 #[rustfmt::skip]
3503 pub fn with_declare_dword_4(d0: u32, d1: u32, d2: u32, d3: u32) -> Self {
3504 Instruction::try_with_declare_dword_4(d0, d1, d2, d3).unwrap()
3505 }
3506
3507 #[allow(clippy::missing_inline_in_public_items)]
3517 #[rustfmt::skip]
3518 #[allow(trivial_casts)]
3519 pub fn with_declare_dword_slice_u8(data: &[u8]) -> Result<Self, IcedError> {
3520 if data.len().wrapping_sub(1) > 16 - 1 || (data.len() & 3) != 0 {
3521 return Err(IcedError::new("Invalid slice length"));
3522 }
3523
3524 let mut instruction = Self::default();
3525 instruction.set_code(Code::DeclareDword);
3526 instruction_internal::internal_set_declare_data_len(&mut instruction, data.len() as u32 / 4);
3527
3528 for i in 0..data.len() / 4 {
3529 let v = (data[i * 4] as u32) | ((data[i * 4 + 1] as u32) << 8) | ((data[i * 4 + 2] as u32) << 16) | ((data[i * 4 + 3] as u32) << 24);
3530 instruction.try_set_declare_dword_value(i, v)?;
3531 }
3532
3533 debug_assert_eq!(instruction.op_count(), 0);
3534 Ok(instruction)
3535 }
3536
3537 #[allow(clippy::missing_inline_in_public_items)]
3547 #[rustfmt::skip]
3548 pub fn with_declare_dword(data: &[u32]) -> Result<Self, IcedError> {
3549 if data.len().wrapping_sub(1) > 4 - 1 {
3550 return Err(IcedError::new("Invalid slice length"));
3551 }
3552
3553 let mut instruction = Self::default();
3554 instruction.set_code(Code::DeclareDword);
3555 instruction_internal::internal_set_declare_data_len(&mut instruction, data.len() as u32);
3556
3557 for i in data.iter().enumerate() {
3558 instruction.try_set_declare_dword_value(i.0, *i.1)?;
3559 }
3560
3561 debug_assert_eq!(instruction.op_count(), 0);
3562 Ok(instruction)
3563 }
3564
3565 #[doc(hidden)]
3566 #[allow(clippy::missing_inline_in_public_items)]
3567 #[rustfmt::skip]
3568 pub fn try_with_declare_qword_1(q0: u64) -> Result<Self, IcedError> {
3569 let mut instruction = Self::default();
3570 instruction.set_code(Code::DeclareQword);
3571 instruction_internal::internal_set_declare_data_len(&mut instruction, 1);
3572
3573 instruction.try_set_declare_qword_value(0, q0)?;
3574
3575 debug_assert_eq!(instruction.op_count(), 0);
3576 Ok(instruction)
3577 }
3578
3579 #[allow(clippy::unwrap_used)]
3585 #[must_use]
3586 #[inline]
3587 #[rustfmt::skip]
3588 pub fn with_declare_qword_1(q0: u64) -> Self {
3589 Instruction::try_with_declare_qword_1(q0).unwrap()
3590 }
3591
3592 #[doc(hidden)]
3593 #[allow(clippy::missing_inline_in_public_items)]
3594 #[rustfmt::skip]
3595 pub fn try_with_declare_qword_2(q0: u64, q1: u64) -> Result<Self, IcedError> {
3596 let mut instruction = Self::default();
3597 instruction.set_code(Code::DeclareQword);
3598 instruction_internal::internal_set_declare_data_len(&mut instruction, 2);
3599
3600 instruction.try_set_declare_qword_value(0, q0)?;
3601 instruction.try_set_declare_qword_value(1, q1)?;
3602
3603 debug_assert_eq!(instruction.op_count(), 0);
3604 Ok(instruction)
3605 }
3606
3607 #[allow(clippy::unwrap_used)]
3614 #[must_use]
3615 #[inline]
3616 #[rustfmt::skip]
3617 pub fn with_declare_qword_2(q0: u64, q1: u64) -> Self {
3618 Instruction::try_with_declare_qword_2(q0, q1).unwrap()
3619 }
3620
3621 #[allow(clippy::missing_inline_in_public_items)]
3631 #[rustfmt::skip]
3632 #[allow(trivial_casts)]
3633 pub fn with_declare_qword_slice_u8(data: &[u8]) -> Result<Self, IcedError> {
3634 if data.len().wrapping_sub(1) > 16 - 1 || (data.len() & 7) != 0 {
3635 return Err(IcedError::new("Invalid slice length"));
3636 }
3637
3638 let mut instruction = Self::default();
3639 instruction.set_code(Code::DeclareQword);
3640 instruction_internal::internal_set_declare_data_len(&mut instruction, data.len() as u32 / 8);
3641
3642 for i in 0..data.len() / 8 {
3643 let v = (data[i * 8] as u64) | ((data[i * 8 + 1] as u64) << 8) | ((data[i * 8 + 2] as u64) << 16) | ((data[i * 8 + 3] as u64) << 24)
3644 | ((data[i * 8 + 4] as u64) << 32) | ((data[i * 8 + 5] as u64) << 40) | ((data[i * 8 + 6] as u64) << 48) | ((data[i * 8 + 7] as u64) << 56);
3645 instruction.try_set_declare_qword_value(i, v)?;
3646 }
3647
3648 debug_assert_eq!(instruction.op_count(), 0);
3649 Ok(instruction)
3650 }
3651
3652 #[allow(clippy::missing_inline_in_public_items)]
3662 #[rustfmt::skip]
3663 pub fn with_declare_qword(data: &[u64]) -> Result<Self, IcedError> {
3664 if data.len().wrapping_sub(1) > 2 - 1 {
3665 return Err(IcedError::new("Invalid slice length"));
3666 }
3667
3668 let mut instruction = Self::default();
3669 instruction.set_code(Code::DeclareQword);
3670 instruction_internal::internal_set_declare_data_len(&mut instruction, data.len() as u32);
3671
3672 for i in data.iter().enumerate() {
3673 instruction.try_set_declare_qword_value(i.0, *i.1)?;
3674 }
3675
3676 debug_assert_eq!(instruction.op_count(), 0);
3677 Ok(instruction)
3678 }
3679}
3680