Package io.matita08.data
Class Flags
java.lang.Object
io.matita08.data.Flags
CPU Flags Management System.
This class manages CPU flags that indicate the results of arithmetic and logic operations. Flags are used by conditional instructions and provide status information about the current CPU state.
Supported Flags:
- Zero Flag: Set when an operation result equals zero
- Overflow Flag: Set when an operation exceeds maximum value
Flags are stored as a bitmask int and accessed using FlagsConstants as indexes.
The flags system uses bitwise operations for efficient flag manipulation and supports
both individual flag operations and bulk flag queries.
Example usage:
// Set the zero flag Flags.set(FlagsConstants.ZERO, true); // Check if overflow occurred boolean overflow = Flags.get(FlagsConstants.OVERFLOW); // Get string representation of all flags String flagState = Flags.get();
- Since:
- 1.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringget()Get the string representation of all flagsstatic booleanget(int flag) Gets the current state of flag(s) using a bitmask.static booleanget(FlagsConstants flag) Gets the current state of a specific flag.static voidset(int flag, boolean value) Sets or unsets flag(s) using a bitmask.static voidset(FlagsConstants flag, boolean value) Sets or unsets a specific flag.
-
Constructor Details
-
Flags
public Flags()
-
-
Method Details
-
get
Get the string representation of all flags- Returns:
- the bitmask of all the flags if any flag was set as a string or a question mark if on flag was ever set/unset
-
get
Gets the current state of a specific flag.- Parameters:
flag- theflagto retrieve- Returns:
- the current flag status (true if set, false if not set)
-
get
public static boolean get(int flag) Gets the current state of flag(s) using a bitmask. This method allows checking multiple flags simultaneously by combining their bitmasks.- Parameters:
flag- the bitmask of the flag(s) to retrieve- Returns:
- true if all specified flags are set, false otherwise
-
set
Sets or unsets a specific flag. This method updates the flag state and marks the flag system as having been modified.- Parameters:
flag- theflagto modifyvalue- the new state of the flag (true to set, false to unset)
-
set
public static void set(int flag, boolean value) Sets or unsets flag(s) using a bitmask. This method allows setting multiple flags simultaneously by combining their bitmasks.- Parameters:
flag- the bitmask of the flag(s) to modifyvalue- the new state of the flag(s) (true to set, false to unset)
-