Struct tartan_arch::x86_common::FlagRegister
source · pub struct FlagRegister(/* private fields */);
Expand description
Implementations§
source§impl FlagRegister
impl FlagRegister
sourcepub fn carry(&self) -> bool
pub fn carry(&self) -> bool
CF
: Indicates an arithmetic instruction generated a carry/borrow (unsigned
overflow).
sourcepub fn parity(&self) -> bool
pub fn parity(&self) -> bool
PF
: Indicates that the least-significant byte of the result has even
parity.
sourcepub fn aux_carry(&self) -> bool
pub fn aux_carry(&self) -> bool
AF
: Indicates a carry/borrow/overflow out of bit 3 in binary-coded decimal
(BCD) arithmetic.
sourcepub fn interrupt_enabled(&self) -> bool
pub fn interrupt_enabled(&self) -> bool
IF
: Enable non-maskable interrupts. Non-maskable interrupts are always
enabled.
sourcepub fn direction(&self) -> bool
pub fn direction(&self) -> bool
DF
: String instructions work on addresses high-to-low when set, low-to-high
when clear.
sourcepub fn signed_overflow(&self) -> bool
pub fn signed_overflow(&self) -> bool
OF
: Indicates that the result overflowed for signed arithmetic (carry/borrow
for the second-most-significant bit).
sourcepub fn io_privilege_level(&self) -> u8
pub fn io_privilege_level(&self) -> u8
IOPL
: Sets the privilege threshold for a task to access I/O address space.
Smaller numbers are higher privilege.
Individual I/O ports may still be accessible at lower privilege levels
(greater numeric values) if allowed by IOPermissionBitmap
for the current
task.
sourcepub fn nested_task(&self) -> bool
pub fn nested_task(&self) -> bool
NT
: Indicates that the processor should switch back to a parent task when it
executes an IRET
instruction.
Only supported in 32-bit mode. If this is set in 64-bit mode, IRET
will
trigger an exception.
sourcepub fn virtual_8086_mode(&self) -> bool
pub fn virtual_8086_mode(&self) -> bool
VM
: Enable virtual real mode.
sourcepub fn alignment_check_or_access_control(&self) -> bool
pub fn alignment_check_or_access_control(&self) -> bool
AC
: Enable strict alignment checks for memory accesses in privilege level 3.
In privilege levels 0–2, allow access to pages assigned to lower privilege
levels.
Alignment checking requires ControlRegister0::alignment_check_mask
. Access
protection requires ControlRegister4::supervisor_access_prevention
.
sourcepub fn virtual_interrupt_enabled(&self) -> bool
pub fn virtual_interrupt_enabled(&self) -> bool
sourcepub fn virtual_interrupt_pending(&self) -> bool
pub fn virtual_interrupt_pending(&self) -> bool
sourcepub fn identification(&self) -> bool
pub fn identification(&self) -> bool
ID
: Indicates CPUID
support when the flag is modifiable.
sourcepub fn set_carry(&mut self, value: bool)
pub fn set_carry(&mut self, value: bool)
CF
: Indicates an arithmetic instruction generated a carry/borrow (unsigned
overflow).
sourcepub fn with_carry(&mut self, value: bool) -> Self
pub fn with_carry(&mut self, value: bool) -> Self
CF
: Indicates an arithmetic instruction generated a carry/borrow (unsigned
overflow).
sourcepub fn set_parity(&mut self, value: bool)
pub fn set_parity(&mut self, value: bool)
PF
: Indicates that the least-significant byte of the result has even
parity.
sourcepub fn with_parity(&mut self, value: bool) -> Self
pub fn with_parity(&mut self, value: bool) -> Self
PF
: Indicates that the least-significant byte of the result has even
parity.
sourcepub fn set_aux_carry(&mut self, value: bool)
pub fn set_aux_carry(&mut self, value: bool)
AF
: Indicates a carry/borrow/overflow out of bit 3 in binary-coded decimal
(BCD) arithmetic.
sourcepub fn with_aux_carry(&mut self, value: bool) -> Self
pub fn with_aux_carry(&mut self, value: bool) -> Self
AF
: Indicates a carry/borrow/overflow out of bit 3 in binary-coded decimal
(BCD) arithmetic.
sourcepub fn set_zero(&mut self, value: bool)
pub fn set_zero(&mut self, value: bool)
ZF
: Indicates that the result of an instruction is zero.
sourcepub fn with_zero(&mut self, value: bool) -> Self
pub fn with_zero(&mut self, value: bool) -> Self
ZF
: Indicates that the result of an instruction is zero.
sourcepub fn set_sign(&mut self, value: bool)
pub fn set_sign(&mut self, value: bool)
SF
: Indicates that the most-significant bit of a result is 1.
sourcepub fn with_sign(&mut self, value: bool) -> Self
pub fn with_sign(&mut self, value: bool) -> Self
SF
: Indicates that the most-significant bit of a result is 1.
sourcepub fn set_interrupt_enabled(&mut self, value: bool)
pub fn set_interrupt_enabled(&mut self, value: bool)
IF
: Enable non-maskable interrupts. Non-maskable interrupts are always
enabled.
sourcepub fn with_interrupt_enabled(&mut self, value: bool) -> Self
pub fn with_interrupt_enabled(&mut self, value: bool) -> Self
IF
: Enable non-maskable interrupts. Non-maskable interrupts are always
enabled.
sourcepub fn set_direction(&mut self, value: bool)
pub fn set_direction(&mut self, value: bool)
DF
: String instructions work on addresses high-to-low when set, low-to-high
when clear.
sourcepub fn with_direction(&mut self, value: bool) -> Self
pub fn with_direction(&mut self, value: bool) -> Self
DF
: String instructions work on addresses high-to-low when set, low-to-high
when clear.
sourcepub fn set_signed_overflow(&mut self, value: bool)
pub fn set_signed_overflow(&mut self, value: bool)
OF
: Indicates that the result overflowed for signed arithmetic (carry/borrow
for the second-most-significant bit).
sourcepub fn with_signed_overflow(&mut self, value: bool) -> Self
pub fn with_signed_overflow(&mut self, value: bool) -> Self
OF
: Indicates that the result overflowed for signed arithmetic (carry/borrow
for the second-most-significant bit).
sourcepub fn set_io_privilege_level(&mut self, value: u8)
pub fn set_io_privilege_level(&mut self, value: u8)
IOPL
: Sets the privilege threshold for a task to access I/O address space.
Smaller numbers are higher privilege.
Individual I/O ports may still be accessible at lower privilege levels
(greater numeric values) if allowed by IOPermissionBitmap
for the current
task.
sourcepub fn with_io_privilege_level(&self, value: u8) -> Self
pub fn with_io_privilege_level(&self, value: u8) -> Self
IOPL
: Sets the privilege threshold for a task to access I/O address space.
Smaller numbers are higher privilege.
Individual I/O ports may still be accessible at lower privilege levels
(greater numeric values) if allowed by IOPermissionBitmap
for the current
task.
sourcepub fn set_nested_task(&mut self, value: bool)
pub fn set_nested_task(&mut self, value: bool)
NT
: Indicates that the processor should switch back to a parent task when it
executes an IRET
instruction.
Only supported in 32-bit mode. If this is set in 64-bit mode, IRET
will
trigger an exception.
sourcepub fn with_nested_task(&mut self, value: bool) -> Self
pub fn with_nested_task(&mut self, value: bool) -> Self
NT
: Indicates that the processor should switch back to a parent task when it
executes an IRET
instruction.
Only supported in 32-bit mode. If this is set in 64-bit mode, IRET
will
trigger an exception.
sourcepub fn set_resume(&mut self, value: bool)
pub fn set_resume(&mut self, value: bool)
RF
: Disable instruction breakpoints.
sourcepub fn with_resume(&mut self, value: bool) -> Self
pub fn with_resume(&mut self, value: bool) -> Self
RF
: Disable instruction breakpoints.
sourcepub fn set_virtual_8086_mode(&mut self, value: bool)
pub fn set_virtual_8086_mode(&mut self, value: bool)
VM
: Enable virtual real mode.
sourcepub fn with_virtual_8086_mode(&mut self, value: bool) -> Self
pub fn with_virtual_8086_mode(&mut self, value: bool) -> Self
VM
: Enable virtual real mode.
sourcepub fn set_alignment_check_or_access_control(&mut self, value: bool)
pub fn set_alignment_check_or_access_control(&mut self, value: bool)
AC
: Enable strict alignment checks for memory accesses in privilege level 3.
In privilege levels 0–2, allow access to pages assigned to lower privilege
levels.
Alignment checking requires ControlRegister0::alignment_check_mask
. Access
protection requires ControlRegister4::supervisor_access_prevention
.
sourcepub fn with_alignment_check_or_access_control(&mut self, value: bool) -> Self
pub fn with_alignment_check_or_access_control(&mut self, value: bool) -> Self
AC
: Enable strict alignment checks for memory accesses in privilege level 3.
In privilege levels 0–2, allow access to pages assigned to lower privilege
levels.
Alignment checking requires ControlRegister0::alignment_check_mask
. Access
protection requires ControlRegister4::supervisor_access_prevention
.
sourcepub fn set_virtual_interrupt_enabled(&mut self, value: bool)
pub fn set_virtual_interrupt_enabled(&mut self, value: bool)
sourcepub fn with_virtual_interrupt_enabled(&mut self, value: bool) -> Self
pub fn with_virtual_interrupt_enabled(&mut self, value: bool) -> Self
sourcepub fn set_virtual_interrupt_pending(&mut self, value: bool)
pub fn set_virtual_interrupt_pending(&mut self, value: bool)
sourcepub fn with_virtual_interrupt_pending(&mut self, value: bool) -> Self
pub fn with_virtual_interrupt_pending(&mut self, value: bool) -> Self
sourcepub fn set_identification(&mut self, value: bool)
pub fn set_identification(&mut self, value: bool)
ID
: Indicates CPUID
support when the flag is modifiable.
sourcepub fn with_identification(&mut self, value: bool) -> Self
pub fn with_identification(&mut self, value: bool) -> Self
ID
: Indicates CPUID
support when the flag is modifiable.
source§impl FlagRegister
impl FlagRegister
sourcepub unsafe fn set(value: Self)
pub unsafe fn set(value: Self)
Update the EFLAGS
register with the given value, as permission level allows.
Some flags will be unaffected depending on the processor mode and permission level flags. See the reference for the POPF instruction in the Intel 64 and IA-32 Architectures Software Developer’s Manual, volume 2.
§Safety
Altering certain system flags can have dramatic effects on the execution of this and other programs, including memory safety. See volume 1 §3.4.3 (“EFLAGS Register”) and volume 3 §2.3 (“System Flags and Fields in the EFLAGS Register”) of the Intel 64 and IA-32 Architectures Software Developer’s Manual.
Trait Implementations§
source§impl Bitfield<usize> for FlagRegister
impl Bitfield<usize> for FlagRegister
source§impl Clone for FlagRegister
impl Clone for FlagRegister
source§fn clone(&self) -> FlagRegister
fn clone(&self) -> FlagRegister
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for FlagRegister
impl Debug for FlagRegister
source§impl Default for FlagRegister
impl Default for FlagRegister
source§fn default() -> FlagRegister
fn default() -> FlagRegister
source§impl From<FlagRegister> for usize
impl From<FlagRegister> for usize
source§fn from(val: FlagRegister) -> Self
fn from(val: FlagRegister) -> Self
source§impl From<usize> for FlagRegister
impl From<usize> for FlagRegister
source§impl PartialEq for FlagRegister
impl PartialEq for FlagRegister
impl Copy for FlagRegister
impl Eq for FlagRegister
impl StructuralPartialEq for FlagRegister
Auto Trait Implementations§
impl Freeze for FlagRegister
impl RefUnwindSafe for FlagRegister
impl Send for FlagRegister
impl Sync for FlagRegister
impl Unpin for FlagRegister
impl UnwindSafe for FlagRegister
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)