Struct tartan_arch::x86_common::FlagRegister

source ·
pub struct FlagRegister(/* private fields */);
Available on x86 or x86-64 only.
Expand description

EFLAGS/RFLAGS: General flags, including control, status, and basic system flags.

Getters and setters for this structure only access a value in memory, not the register itself. Use the get and set methods to work with the actual register.

Implementations§

source§

impl FlagRegister

source

pub fn carry(&self) -> bool

CF: Indicates an arithmetic instruction generated a carry/borrow (unsigned overflow).

source

pub fn parity(&self) -> bool

PF: Indicates that the least-significant byte of the result has even parity.

source

pub fn aux_carry(&self) -> bool

AF: Indicates a carry/borrow/overflow out of bit 3 in binary-coded decimal (BCD) arithmetic.

source

pub fn zero(&self) -> bool

ZF: Indicates that the result of an instruction is zero.

source

pub fn sign(&self) -> bool

SF: Indicates that the most-significant bit of a result is 1.

source

pub fn trap(&self) -> bool

TF: Enable single-step debugging.

source

pub fn interrupt_enabled(&self) -> bool

IF: Enable non-maskable interrupts. Non-maskable interrupts are always enabled.

source

pub fn direction(&self) -> bool

DF: String instructions work on addresses high-to-low when set, low-to-high when clear.

source

pub fn signed_overflow(&self) -> bool

OF: Indicates that the result overflowed for signed arithmetic (carry/borrow for the second-most-significant bit).

source

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.

source

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.

source

pub fn resume(&self) -> bool

RF: Disable instruction breakpoints.

source

pub fn virtual_8086_mode(&self) -> bool

VM: Enable virtual real mode.

source

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.

source

pub fn virtual_interrupt_enabled(&self) -> bool

VIF: Virtual counterpart to the interrupt_enabled flag, used with VME or PVI.

source

pub fn virtual_interrupt_pending(&self) -> bool

VIP: Indicates an interrupt is pending for VME or PVI.

source

pub fn identification(&self) -> bool

ID: Indicates CPUID support when the flag is modifiable.

source

pub fn set_carry(&mut self, value: bool)

CF: Indicates an arithmetic instruction generated a carry/borrow (unsigned overflow).

source

pub fn with_carry(&mut self, value: bool) -> Self

CF: Indicates an arithmetic instruction generated a carry/borrow (unsigned overflow).

source

pub fn set_parity(&mut self, value: bool)

PF: Indicates that the least-significant byte of the result has even parity.

source

pub fn with_parity(&mut self, value: bool) -> Self

PF: Indicates that the least-significant byte of the result has even parity.

source

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.

source

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.

source

pub fn set_zero(&mut self, value: bool)

ZF: Indicates that the result of an instruction is zero.

source

pub fn with_zero(&mut self, value: bool) -> Self

ZF: Indicates that the result of an instruction is zero.

source

pub fn set_sign(&mut self, value: bool)

SF: Indicates that the most-significant bit of a result is 1.

source

pub fn with_sign(&mut self, value: bool) -> Self

SF: Indicates that the most-significant bit of a result is 1.

source

pub fn set_trap(&mut self, value: bool)

TF: Enable single-step debugging.

source

pub fn with_trap(&mut self, value: bool) -> Self

TF: Enable single-step debugging.

source

pub fn set_interrupt_enabled(&mut self, value: bool)

IF: Enable non-maskable interrupts. Non-maskable interrupts are always enabled.

source

pub fn with_interrupt_enabled(&mut self, value: bool) -> Self

IF: Enable non-maskable interrupts. Non-maskable interrupts are always enabled.

source

pub fn set_direction(&mut self, value: bool)

DF: String instructions work on addresses high-to-low when set, low-to-high when clear.

source

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.

source

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).

source

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).

source

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.

source

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.

source

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.

source

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.

source

pub fn set_resume(&mut self, value: bool)

RF: Disable instruction breakpoints.

source

pub fn with_resume(&mut self, value: bool) -> Self

RF: Disable instruction breakpoints.

source

pub fn set_virtual_8086_mode(&mut self, value: bool)

VM: Enable virtual real mode.

source

pub fn with_virtual_8086_mode(&mut self, value: bool) -> Self

VM: Enable virtual real mode.

source

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.

source

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.

source

pub fn set_virtual_interrupt_enabled(&mut self, value: bool)

VIF: Virtual counterpart to the interrupt_enabled flag, used with VME or PVI.

source

pub fn with_virtual_interrupt_enabled(&mut self, value: bool) -> Self

VIF: Virtual counterpart to the interrupt_enabled flag, used with VME or PVI.

source

pub fn set_virtual_interrupt_pending(&mut self, value: bool)

VIP: Indicates an interrupt is pending for VME or PVI.

source

pub fn with_virtual_interrupt_pending(&mut self, value: bool) -> Self

VIP: Indicates an interrupt is pending for VME or PVI.

source

pub fn set_identification(&mut self, value: bool)

ID: Indicates CPUID support when the flag is modifiable.

source

pub fn with_identification(&mut self, value: bool) -> Self

ID: Indicates CPUID support when the flag is modifiable.

source§

impl FlagRegister

source

pub fn get() -> Self

Retrieve the current value of the EFLAGS register.

source

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

§

fn new(value: T) -> Self

Construct a new bitfield type from its underlying representation
§

fn value(self) -> T

Unwrap the bitfield into its underlying representation
source§

impl Clone for FlagRegister

source§

fn clone(&self) -> FlagRegister

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for FlagRegister

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for FlagRegister

source§

fn default() -> FlagRegister

Returns the “default value” for a type. Read more
source§

impl From<FlagRegister> for usize

source§

fn from(val: FlagRegister) -> Self

Converts to this type from the input type.
source§

impl From<usize> for FlagRegister

source§

fn from(val: usize) -> Self

Converts to this type from the input type.
source§

impl PartialEq for FlagRegister

source§

fn eq(&self, other: &FlagRegister) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for FlagRegister

source§

impl Eq for FlagRegister

source§

impl StructuralPartialEq for FlagRegister

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.