Class Flags

java.lang.Object
io.matita08.data.Flags

public class Flags extends Object
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    get()
    Get the string representation of all flags
    static boolean
    get(int flag)
    Gets the current state of flag(s) using a bitmask.
    static boolean
    Gets the current state of a specific flag.
    static void
    set(int flag, boolean value)
    Sets or unsets flag(s) using a bitmask.
    static void
    set(FlagsConstants flag, boolean value)
    Sets or unsets a specific flag.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Flags

      public Flags()
  • Method Details

    • get

      public static String 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

      public static boolean get(FlagsConstants flag)
      Gets the current state of a specific flag.
      Parameters:
      flag - the flag to 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

      public static void set(FlagsConstants flag, boolean value)
      Sets or unsets a specific flag. This method updates the flag state and marks the flag system as having been modified.
      Parameters:
      flag - the flag to modify
      value - 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 modify
      value - the new state of the flag(s) (true to set, false to unset)