use ::{Mnemonic, Operand, Reg, OperandSize, SegmentReg, MaskReg, BroadcastMode, MergeMode, RoundingMode, RegScale};
use ::test::{encode32_helper2};
#[test]
fn encode_direct() {
encode32_helper2(Mnemonic::ROL, Operand::Direct(Reg::EAX), Operand::Literal8(0x1), &vec![0xD1, 0xC0]); encode32_helper2(Mnemonic::ROL, Operand::Direct(Reg::EBX), Operand::Literal8(0x1), &vec![0xD1, 0xC3]); encode32_helper2(Mnemonic::ROL, Operand::Direct(Reg::ECX), Operand::Literal8(0x1), &vec![0xD1, 0xC1]); encode32_helper2(Mnemonic::ROL, Operand::Direct(Reg::EDX), Operand::Literal8(0x1), &vec![0xD1, 0xC2]); encode32_helper2(Mnemonic::ROL, Operand::Direct(Reg::ESI), Operand::Literal8(0x1), &vec![0xD1, 0xC6]); encode32_helper2(Mnemonic::ROL, Operand::Direct(Reg::EDI), Operand::Literal8(0x1), &vec![0xD1, 0xC7]); encode32_helper2(Mnemonic::ROL, Operand::Direct(Reg::ESP), Operand::Literal8(0x1), &vec![0xD1, 0xC4]); encode32_helper2(Mnemonic::ROL, Operand::Direct(Reg::EBP), Operand::Literal8(0x1), &vec![0xD1, 0xC5]); }
#[test]
fn encode_indirect() {
encode32_helper2(Mnemonic::ADD, Operand::Indirect(Reg::EAX, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x00, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::Indirect(Reg::EBX, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x03, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::Indirect(Reg::ECX, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x01, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::Indirect(Reg::EDX, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x02, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::Indirect(Reg::ESI, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x06, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::Indirect(Reg::EDI, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x07, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::Indirect(Reg::ESP, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x04, 0x24, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::Direct(Reg::EAX), Operand::Memory(0x12345678, Some(OperandSize::Dword), None), &vec![0x03, 0x05, 0x78, 0x56, 0x34, 0x12]); }
#[test]
fn encode_disp8() {
encode32_helper2(Mnemonic::ADD, Operand::IndirectDisplaced(Reg::EAX, 0x12, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x40, 0x12, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::IndirectDisplaced(Reg::EBX, 0x12, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x43, 0x12, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::IndirectDisplaced(Reg::ECX, 0x12, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x41, 0x12, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::IndirectDisplaced(Reg::EDX, 0x12, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x42, 0x12, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::IndirectDisplaced(Reg::EDI, 0x12, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x47, 0x12, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::IndirectDisplaced(Reg::ESI, 0x12, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x46, 0x12, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::IndirectDisplaced(Reg::ESP, 0x12, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x44, 0x24, 0x12, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::IndirectDisplaced(Reg::EBP, 0x12, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x45, 0x12, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::Indirect(Reg::EBP, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x45, 0x00, 0x01]); }
#[test]
fn encode_disp32() {
encode32_helper2(Mnemonic::ADD, Operand::IndirectDisplaced(Reg::EAX, 0x12345678, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x80, 0x78, 0x56, 0x34, 0x12, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::IndirectDisplaced(Reg::EBX, 0x12345678, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x83, 0x78, 0x56, 0x34, 0x12, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::IndirectDisplaced(Reg::ECX, 0x12345678, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x81, 0x78, 0x56, 0x34, 0x12, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::IndirectDisplaced(Reg::EDX, 0x12345678, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x82, 0x78, 0x56, 0x34, 0x12, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::IndirectDisplaced(Reg::ESI, 0x12345678, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x86, 0x78, 0x56, 0x34, 0x12, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::IndirectDisplaced(Reg::EDI, 0x12345678, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x87, 0x78, 0x56, 0x34, 0x12, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::IndirectDisplaced(Reg::ESP, 0x12345678, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x84, 0x24, 0x78, 0x56, 0x34, 0x12, 0x01]); encode32_helper2(Mnemonic::ADD, Operand::IndirectDisplaced(Reg::EBP, 0x12345678, Some(OperandSize::Byte), None), Operand::Literal8(0x1), &vec![0x80, 0x85, 0x78, 0x56, 0x34, 0x12, 0x01]); }
#[test]
fn encode_sib() {
encode32_helper2(Mnemonic::ADD, Operand::Direct(Reg::EAX), Operand::IndirectScaledIndexed(Reg::EBX, Reg::EDX, RegScale::Two, Some(OperandSize::Dword), None), &vec![0x03, 0x04, 0x53]); encode32_helper2(Mnemonic::ADD, Operand::Direct(Reg::EAX), Operand::IndirectScaledIndexed(Reg::EBP, Reg::EBX, RegScale::Four, Some(OperandSize::Dword), None), &vec![0x03, 0x44, 0x9D, 0x00]); encode32_helper2(Mnemonic::ADD, Operand::Direct(Reg::EAX), Operand::Indirect(Reg::ESP, Some(OperandSize::Dword), None), &vec![0x03, 0x04, 0x24]); encode32_helper2(Mnemonic::ADD, Operand::Direct(Reg::EAX), Operand::IndirectScaledDisplaced(Reg::EBP, RegScale::Four, 0x12345678, Some(OperandSize::Dword), None), &vec![0x03, 0x04, 0xAD, 0x78, 0x56, 0x34, 0x12]); encode32_helper2(Mnemonic::ADD, Operand::Direct(Reg::EAX), Operand::IndirectDisplaced(Reg::ESP, 0x12, Some(OperandSize::Dword), None), &vec![0x03, 0x44, 0x24, 0x12]); encode32_helper2(Mnemonic::ADD, Operand::Direct(Reg::EAX), Operand::IndirectScaledIndexedDisplaced(Reg::EBX, Reg::ECX, RegScale::Eight, 0x12, Some(OperandSize::Dword), None), &vec![0x03, 0x44, 0xCB, 0x12]); encode32_helper2(Mnemonic::ADD, Operand::Direct(Reg::EAX), Operand::IndirectScaledIndexedDisplaced(Reg::EBX, Reg::ECX, RegScale::Eight, 0x12345678, Some(OperandSize::Dword), None), &vec![0x03, 0x84, 0xCB, 0x78, 0x56, 0x34, 0x12]); encode32_helper2(Mnemonic::ADD, Operand::Direct(Reg::EAX), Operand::IndirectDisplaced(Reg::EDX, 0x12345678, Some(OperandSize::Dword), None), &vec![0x03, 0x82, 0x78, 0x56, 0x34, 0x12]); encode32_helper2(Mnemonic::ADD, Operand::Direct(Reg::EAX), Operand::IndirectScaledIndexedDisplaced(Reg::EBX, Reg::ESI, RegScale::One, 0x12345678, Some(OperandSize::Dword), None), &vec![0x03, 0x84, 0x33, 0x78, 0x56, 0x34, 0x12]); }