Class DataSegmentWindow

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

public class DataSegmentWindow extends JInternalFrame implements SimulatorListener, Memory.Listener
Represents the Data Segment window, which is a type of JInternalFrame.
Author:
Sanderson and Bumgarner
See Also:
  • Field Details

  • Constructor Details

    • DataSegmentWindow

      public DataSegmentWindow(VenusUI gui, NumberDisplayBaseChooser[] choosers)
      Constructor for the Data Segment window.
      Parameters:
      choosers - an array of objects used by user to select number display base (10 or 16)
  • Method Details

    • updateBaseAddressComboBox

      public void updateBaseAddressComboBox()
    • selectCellForAddress

      public void selectCellForAddress(int address)
      Scroll the viewport so the cell at the given data segment address is visible, vertically centered if possible, and selected. Developed July 2007 for new feature that shows source code step where label is defined when that label is clicked on in the Label Window. Note there is a separate method to highlight the cell by setting its background color to a highlighting color. Thus one cell can be highlighted while a different cell is selected at the same time.
      Parameters:
      address - data segment address of word to be selected.
    • highlightCellForAddress

      public void highlightCellForAddress(int address)
      Scroll the viewport so the cell at the given data segment address is visible, vertically centered if possible, and highlighted (but not selected).
      Parameters:
      address - Data segment address of word to be selected.
    • displayCellForAddress

      public Point displayCellForAddress(int address)
      Given address, will compute table cell location, adjusting table if necessary to contain this cell, make sure that cell is visible, then return a Point containing row and column position of cell in the table. This private helper method is called by selectCellForAddress() and highlightCellForAddress(). This is the kind of design I tell my students to avoid! The method both translates address to table cell coordinates and adjusts the display to assure the cell is visible. The two operations are related because the address may fall in within address space not currently in the (display) table, including a different MIPS data segment (e.g. in kernel instead of user data segment).
    • setupTable

      public void setupTable()
      Generates and displays fresh table, typically done upon successful assembly.
    • clearWindow

      public void clearWindow()
      Removes the table from its frame, typically done when a file is closed.
    • clearHighlighting

      public void clearHighlighting()
      Clear highlight background color from any cell currently highlighted.
    • updateModelForMemoryRange

      public void updateModelForMemoryRange(int firstAddress)
      Update table model with contents of new memory "chunk". MARS supports megabytes of data segment space so we only plug a "chunk" at a time into the table.
      Parameters:
      firstAddress - The first address in the memory range to be placed in the model.
    • updateDataAddresses

      public void updateDataAddresses()
      Redisplay the addresses. This should only be done when address display base is modified (e.g. between base 16, hex, and base 10, dec).
    • updateValues

      public void updateValues()
      Update data display to show all values.
    • simulatorStarted

      public void simulatorStarted(SimulatorStartEvent event)
      Description copied from interface: SimulatorListener
      Called when the simulator begins execution of a program.
      Specified by:
      simulatorStarted in interface SimulatorListener
      Parameters:
      event - The event which occurred.
    • simulatorPaused

      public void simulatorPaused(SimulatorPauseEvent event)
      Description copied from interface: SimulatorListener
      Called when the simulator stops execution of a program due to pausing.
      Specified by:
      simulatorPaused in interface SimulatorListener
      Parameters:
      event - The event which occurred.
    • simulatorFinished

      public void simulatorFinished(SimulatorFinishEvent event)
      Description copied from interface: SimulatorListener
      Called when the simulator stops execution of a program due to termination or finishing.
      Specified by:
      simulatorFinished in interface SimulatorListener
      Parameters:
      event - The event which occurred.
    • simulatorStepped

      public void simulatorStepped()
      Description copied from interface: SimulatorListener
      Called when the simulator has finished executing an instruction, but only if the run speed is not unlimited.

      Note: For very fast run speeds, GUI listeners may not receive all step events. This is an intentional feature to prevent overloading of the GUI event queue.

      Specified by:
      simulatorStepped in interface SimulatorListener
    • updateUI

      public void updateUI()
      For whatever reason, FlatLaf seems to forget what the frame icon is set to after this method is called. So, this method has been overwritten to set the frame icon back to null as desired.
      Overrides:
      updateUI in class JInternalFrame
    • memoryWritten

      public void memoryWritten(int address, int length, int value, int wordAddress, int wordValue)
      Description copied from interface: Memory.Listener
      Invoked upon any write operation which is relevant to this listener's active range. Does nothing by default.
      Specified by:
      memoryWritten in interface Memory.Listener
      Parameters:
      address - The address which was written to.
      length - The number of bytes written. Will always be 1 (single byte), Memory.BYTES_PER_HALFWORD, or Memory.BYTES_PER_WORD.
      value - The value which was written.
      wordAddress - The address of the word affected by the operation.
      wordValue - The resulting value of the word.
    • startObservingMemory

      public void startObservingMemory()
      Convenience method to add this as a listener of all memory.
    • stopObservingMemory

      public void stopObservingMemory()
      Convenience method to remove this as a listener of memory.