Package mars.tools

Class FloatRepresentation

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants, Memory.Listener, Register.Listener, MarsTool

public class FloatRepresentation extends AbstractMarsTool implements Register.Listener
Tool to help students learn about the IEEE-754 representation of 32-bit floating point values. This representation is used by Coprocessor 1 instructions, and also the float data type in most programming languages in general. As written, it can almost be adapted to 64-bit by changing a few constants.
See Also:
  • Constructor Details

    • FloatRepresentation

      public FloatRepresentation()
      Construct an instance of this tool. This will be used by the ToolManager.
  • Method Details

    • getName

      public String getName()
      Fetch tool name (for display in MARS Tools menu)
      Specified by:
      getName in interface MarsTool
      Specified by:
      getName in class AbstractMarsTool
      Returns:
      String containing tool name
    • startObserving

      protected void startObserving()
      Override the inherited method, which registers us as an Observer over the static data segment (starting address 0x10010000) only. This version will register us as observer over the selected floating point register, if any. If no register is selected, it will not do anything. If you use the inherited GUI buttons, this method is invoked when you click "Connect" button on MarsTool or the "Assemble and Run" button on a Mars-based app.
      Overrides:
      startObserving in class AbstractMarsTool
      See Also:
    • stopObserving

      protected void stopObserving()
      Delete this app/tool as an Observer of the attached register. This overrides the inherited version which deletes only as an Observer of memory. This method is called when the default "Disconnect" button on a MarsTool is selected or when the MIPS program execution triggered by the default "Assemble and run" on a stand-alone Mars app terminates (e.g. when the button is re-enabled).
      Overrides:
      stopObserving in class AbstractMarsTool
      See Also:
    • buildMainDisplayArea

      protected JComponent buildMainDisplayArea()
      Method that constructs the main display area. This will be vertically sandwiched between the standard heading area at the top and the control area at the bottom.
      Specified by:
      buildMainDisplayArea in class AbstractMarsTool
      Returns:
      the GUI component containing the application/tool-specific part of the user interface
    • registerWritten

      public void registerWritten(Register register)
      Specified by:
      registerWritten in interface Register.Listener
    • reset

      protected void reset()
      Method to reset display values to 0 when the Reset button selected. If attached to a MIPS register at the time, the register will be reset as well. Overrides inherited method that does nothing.
      Overrides:
      reset in class AbstractMarsTool
    • buildDisplayArea

      protected JComponent buildDisplayArea()