diff --git a/hypervisor/src/arch/x86/emulator/instructions/cmp.rs b/hypervisor/src/arch/x86/emulator/instructions/cmp.rs index 497d0130c..fc0d73dad 100644 --- a/hypervisor/src/arch/x86/emulator/instructions/cmp.rs +++ b/hypervisor/src/arch/x86/emulator/instructions/cmp.rs @@ -14,23 +14,10 @@ extern crate iced_x86; use crate::arch::emulator::{EmulationError, PlatformEmulator}; use crate::arch::x86::emulator::instructions::*; +use crate::arch::x86::regs::*; use crate::arch::x86::Exception; // CMP affects OF, SF, ZF, AF, PF and CF -const CF_SHIFT: usize = 0; -const PF_SHIFT: usize = 2; -const AF_SHIFT: usize = 4; -const ZF_SHIFT: usize = 6; -const SF_SHIFT: usize = 7; -const OF_SHIFT: usize = 11; - -const CF: u64 = 1 << CF_SHIFT; -const PF: u64 = 1 << PF_SHIFT; -const AF: u64 = 1 << AF_SHIFT; -const ZF: u64 = 1 << ZF_SHIFT; -const SF: u64 = 1 << SF_SHIFT; -const OF: u64 = 1 << OF_SHIFT; - const FLAGS_MASK: u64 = CF | PF | AF | ZF | SF | OF; // TODO: Switch to inline asm when that's stable. Executing CMP (or any arthimetic instructions) diff --git a/hypervisor/src/arch/x86/regs.rs b/hypervisor/src/arch/x86/regs.rs index 3c31ed3e7..b0925c861 100644 --- a/hypervisor/src/arch/x86/regs.rs +++ b/hypervisor/src/arch/x86/regs.rs @@ -15,3 +15,18 @@ pub const CR0_PG: u64 = 0x80000000; // CR4 bits pub const CR4_PAE: u64 = 0x20; pub const CR4_LA57: u64 = 0x1000; + +// RFlags bits +pub const CF_SHIFT: usize = 0; +pub const PF_SHIFT: usize = 2; +pub const AF_SHIFT: usize = 4; +pub const ZF_SHIFT: usize = 6; +pub const SF_SHIFT: usize = 7; +pub const OF_SHIFT: usize = 11; + +pub const CF: u64 = 1 << CF_SHIFT; +pub const PF: u64 = 1 << PF_SHIFT; +pub const AF: u64 = 1 << AF_SHIFT; +pub const ZF: u64 = 1 << ZF_SHIFT; +pub const SF: u64 = 1 << SF_SHIFT; +pub const OF: u64 = 1 << OF_SHIFT;