META-INF/MANIFEST.MF
PseudoOps.txt
Config.properties
Syscall.properties
Settings.properties
MARSlicense.txt
mainclass.txt
MipsXRayOpcode.xml
registerDatapath.xml
controlDatapath.xml
ALUcontrolDatapath.xml
CreateMarsJar.bat
Mars.java
Mars.class
docs/allclasses-frame.html
docs/allclasses-noframe.html
docs/constant-values.html
docs/deprecated-list.html
docs/help-doc.html
docs/index-all.html
docs/index.html
docs/mars/assembler/Assembler.html
docs/mars/assembler/DataTypes.html
docs/mars/assembler/Directives.html
docs/mars/assembler/Macro.html
docs/mars/assembler/MacroPool.html
docs/mars/assembler/OperandFormat.html
docs/mars/assembler/package-frame.html
docs/mars/assembler/package-summary.html
docs/mars/assembler/package-tree.html
docs/mars/assembler/SourceLine.html
docs/mars/assembler/Symbol.html
docs/mars/assembler/SymbolTable.html
docs/mars/assembler/Token.html
docs/mars/assembler/Tokenizer.html
docs/mars/assembler/TokenList.html
docs/mars/assembler/TokenTypes.html
docs/mars/assembler/TranslationCode.html
docs/mars/ErrorList.html
docs/mars/ErrorMessage.html
docs/mars/Globals.html
docs/mars/MarsLaunch.html
docs/mars/MarsSplashScreen.html
docs/mars/mips/dump/AbstractDumpFormat.html
docs/mars/mips/dump/AsciiTextDumpFormat.html
docs/mars/mips/dump/BinaryDumpFormat.html
docs/mars/mips/dump/BinaryTextDumpFormat.html
docs/mars/mips/dump/DumpFormat.html
docs/mars/mips/dump/DumpFormatLoader.html
docs/mars/mips/dump/HexTextDumpFormat.html
docs/mars/mips/dump/IntelHexDumpFormat.html
docs/mars/mips/dump/MIFDumpFormat.html
docs/mars/mips/dump/package-frame.html
docs/mars/mips/dump/package-summary.html
docs/mars/mips/dump/package-tree.html
docs/mars/mips/dump/SegmentWindowDumpFormat.html
docs/mars/mips/hardware/AccessNotice.html
docs/mars/mips/hardware/AddressErrorException.html
docs/mars/mips/hardware/Coprocessor0.html
docs/mars/mips/hardware/Coprocessor1.html
docs/mars/mips/hardware/InvalidRegisterAccessException.html
docs/mars/mips/hardware/Memory.html
docs/mars/mips/hardware/MemoryAccessNotice.html
docs/mars/mips/hardware/MemoryConfiguration.html
docs/mars/mips/hardware/MemoryConfigurations.html
docs/mars/mips/hardware/package-frame.html
docs/mars/mips/hardware/package-summary.html
docs/mars/mips/hardware/package-tree.html
docs/mars/mips/hardware/Register.html
docs/mars/mips/hardware/RegisterAccessNotice.html
docs/mars/mips/hardware/RegisterFile.html
docs/mars/mips/instructions/BasicInstruction.html
docs/mars/mips/instructions/BasicInstructionFormat.html
docs/mars/mips/instructions/ExtendedInstruction.html
docs/mars/mips/instructions/Instruction.html
docs/mars/mips/instructions/InstructionSet.html
docs/mars/mips/instructions/package-frame.html
docs/mars/mips/instructions/package-summary.html
docs/mars/mips/instructions/package-tree.html
docs/mars/mips/instructions/SimulationCode.html
docs/mars/mips/instructions/syscalls/AbstractSyscall.html
docs/mars/mips/instructions/syscalls/package-frame.html
docs/mars/mips/instructions/syscalls/package-summary.html
docs/mars/mips/instructions/syscalls/package-tree.html
docs/mars/mips/instructions/syscalls/RandomStreams.html
docs/mars/mips/instructions/syscalls/Syscall.html
docs/mars/mips/instructions/syscalls/SyscallClose.html
docs/mars/mips/instructions/syscalls/SyscallConfirmDialog.html
docs/mars/mips/instructions/syscalls/SyscallExit.html
docs/mars/mips/instructions/syscalls/SyscallExit2.html
docs/mars/mips/instructions/syscalls/SyscallInputDialogDouble.html
docs/mars/mips/instructions/syscalls/SyscallInputDialogFloat.html
docs/mars/mips/instructions/syscalls/SyscallInputDialogInt.html
docs/mars/mips/instructions/syscalls/SyscallInputDialogString.html
docs/mars/mips/instructions/syscalls/SyscallMessageDialog.html
docs/mars/mips/instructions/syscalls/SyscallMessageDialogDouble.html
docs/mars/mips/instructions/syscalls/SyscallMessageDialogFloat.html
docs/mars/mips/instructions/syscalls/SyscallMessageDialogInt.html
docs/mars/mips/instructions/syscalls/SyscallMessageDialogString.html
docs/mars/mips/instructions/syscalls/SyscallMidiOut.html
docs/mars/mips/instructions/syscalls/SyscallMidiOutSync.html
docs/mars/mips/instructions/syscalls/SyscallNumberOverride.html
docs/mars/mips/instructions/syscalls/SyscallOpen.html
docs/mars/mips/instructions/syscalls/SyscallPrintChar.html
docs/mars/mips/instructions/syscalls/SyscallPrintDouble.html
docs/mars/mips/instructions/syscalls/SyscallPrintFloat.html
docs/mars/mips/instructions/syscalls/SyscallPrintInt.html
docs/mars/mips/instructions/syscalls/SyscallPrintIntBinary.html
docs/mars/mips/instructions/syscalls/SyscallPrintIntHex.html
docs/mars/mips/instructions/syscalls/SyscallPrintIntUnsigned.html
docs/mars/mips/instructions/syscalls/SyscallPrintString.html
docs/mars/mips/instructions/syscalls/SyscallRandDouble.html
docs/mars/mips/instructions/syscalls/SyscallRandFloat.html
docs/mars/mips/instructions/syscalls/SyscallRandInt.html
docs/mars/mips/instructions/syscalls/SyscallRandIntRange.html
docs/mars/mips/instructions/syscalls/SyscallRandSeed.html
docs/mars/mips/instructions/syscalls/SyscallRead.html
docs/mars/mips/instructions/syscalls/SyscallReadChar.html
docs/mars/mips/instructions/syscalls/SyscallReadDouble.html
docs/mars/mips/instructions/syscalls/SyscallReadFloat.html
docs/mars/mips/instructions/syscalls/SyscallReadInt.html
docs/mars/mips/instructions/syscalls/SyscallReadString.html
docs/mars/mips/instructions/syscalls/SyscallSbrk.html
docs/mars/mips/instructions/syscalls/SyscallSleep.html
docs/mars/mips/instructions/syscalls/SyscallTime.html
docs/mars/mips/instructions/syscalls/SyscallWrite.html
docs/mars/MIPSprogram.html
docs/mars/package-frame.html
docs/mars/package-summary.html
docs/mars/package-tree.html
docs/mars/ProcessingException.html
docs/mars/ProgramStatement.html
docs/mars/Settings.html
docs/mars/simulator/BackStepper.html
docs/mars/simulator/DelayedBranch.html
docs/mars/simulator/Exceptions.html
docs/mars/simulator/package-frame.html
docs/mars/simulator/package-summary.html
docs/mars/simulator/package-tree.html
docs/mars/simulator/ProgramArgumentList.html
docs/mars/simulator/Simulator.html
docs/mars/simulator/Simulator.StopListener.html
docs/mars/simulator/SimulatorNotice.html
docs/mars/simulator/SwingWorker.html
docs/mars/tools/AbstractMarsToolAndApplication.ConnectButton.html
docs/mars/tools/AbstractMarsToolAndApplication.EnterKeyListener.html
docs/mars/tools/AbstractMarsToolAndApplication.html
docs/mars/tools/BHTableModel.html
docs/mars/tools/BHTEntry.html
docs/mars/tools/BHTSimGUI.html
docs/mars/tools/BHTSimulator.html
docs/mars/tools/BitmapDisplay.html
docs/mars/tools/CacheSimulator.html
docs/mars/tools/DigitalLabSim.HexaKeyboard.EcouteurClick.html
docs/mars/tools/DigitalLabSim.HexaKeyboard.html
docs/mars/tools/DigitalLabSim.html
docs/mars/tools/DigitalLabSim.OneSecondCounter.html
docs/mars/tools/DigitalLabSim.SevenSegmentDisplay.html
docs/mars/tools/DigitalLabSim.SevenSegmentPanel.html
docs/mars/tools/FloatRepresentation.html
docs/mars/tools/InstructionCounter.html
docs/mars/tools/InstructionStatistics.html
docs/mars/tools/IntroToTools.html
docs/mars/tools/KeyboardAndDisplaySimulator.html
docs/mars/tools/MarsBot.html
docs/mars/tools/MarsTool.html
docs/mars/tools/MemoryReferenceVisualization.html
docs/mars/tools/package-frame.html
docs/mars/tools/package-summary.html
docs/mars/tools/package-tree.html
docs/mars/tools/ScavengerHunt.html
docs/mars/tools/ScreenMagnifier.html
docs/mars/util/Binary.html
docs/mars/util/EditorFont.html
docs/mars/util/FilenameFinder.html
docs/mars/util/MemoryDump.html
docs/mars/util/package-frame.html
docs/mars/util/package-summary.html
docs/mars/util/package-tree.html
docs/mars/util/PropertiesFile.html
docs/mars/util/SystemIO.html
docs/mars/venus/AbstractFontSettingDialog.html
docs/mars/venus/Coprocessor0Window.html
docs/mars/venus/Coprocessor1Window.html
docs/mars/venus/DataSegmentWindow.html
docs/mars/venus/EditCopyAction.html
docs/mars/venus/EditCutAction.html
docs/mars/venus/EditFindReplaceAction.html
docs/mars/venus/Editor.html
docs/mars/venus/editors/generic/GenericTextArea.html
docs/mars/venus/editors/generic/package-frame.html
docs/mars/venus/editors/generic/package-summary.html
docs/mars/venus/editors/generic/package-tree.html
docs/mars/venus/editors/jeditsyntax/DefaultInputHandler.html
docs/mars/venus/editors/jeditsyntax/InputHandler.backspace.html
docs/mars/venus/editors/jeditsyntax/InputHandler.backspace_word.html
docs/mars/venus/editors/jeditsyntax/InputHandler.clip_copy.html
docs/mars/venus/editors/jeditsyntax/InputHandler.clip_cut.html
docs/mars/venus/editors/jeditsyntax/InputHandler.clip_paste.html
docs/mars/venus/editors/jeditsyntax/InputHandler.delete.html
docs/mars/venus/editors/jeditsyntax/InputHandler.delete_word.html
docs/mars/venus/editors/jeditsyntax/InputHandler.document_end.html
docs/mars/venus/editors/jeditsyntax/InputHandler.document_home.html
docs/mars/venus/editors/jeditsyntax/InputHandler.end.html
docs/mars/venus/editors/jeditsyntax/InputHandler.home.html
docs/mars/venus/editors/jeditsyntax/InputHandler.html
docs/mars/venus/editors/jeditsyntax/InputHandler.insert_break.html
docs/mars/venus/editors/jeditsyntax/InputHandler.insert_char.html
docs/mars/venus/editors/jeditsyntax/InputHandler.insert_tab.html
docs/mars/venus/editors/jeditsyntax/InputHandler.MacroRecorder.html
docs/mars/venus/editors/jeditsyntax/InputHandler.next_char.html
docs/mars/venus/editors/jeditsyntax/InputHandler.next_line.html
docs/mars/venus/editors/jeditsyntax/InputHandler.next_page.html
docs/mars/venus/editors/jeditsyntax/InputHandler.next_word.html
docs/mars/venus/editors/jeditsyntax/InputHandler.NonRecordable.html
docs/mars/venus/editors/jeditsyntax/InputHandler.NonRepeatable.html
docs/mars/venus/editors/jeditsyntax/InputHandler.overwrite.html
docs/mars/venus/editors/jeditsyntax/InputHandler.prev_char.html
docs/mars/venus/editors/jeditsyntax/InputHandler.prev_line.html
docs/mars/venus/editors/jeditsyntax/InputHandler.prev_page.html
docs/mars/venus/editors/jeditsyntax/InputHandler.prev_word.html
docs/mars/venus/editors/jeditsyntax/InputHandler.repeat.html
docs/mars/venus/editors/jeditsyntax/InputHandler.select_all.html
docs/mars/venus/editors/jeditsyntax/InputHandler.toggle_rect.html
docs/mars/venus/editors/jeditsyntax/InputHandler.Wrapper.html
docs/mars/venus/editors/jeditsyntax/JEditBasedTextArea.html
docs/mars/venus/editors/jeditsyntax/JEditTextArea.html
docs/mars/venus/editors/jeditsyntax/KeywordMap.html
docs/mars/venus/editors/jeditsyntax/package-frame.html
docs/mars/venus/editors/jeditsyntax/package-summary.html
docs/mars/venus/editors/jeditsyntax/package-tree.html
docs/mars/venus/editors/jeditsyntax/PopupHelpItem.html
docs/mars/venus/editors/jeditsyntax/SyntaxDocument.html
docs/mars/venus/editors/jeditsyntax/SyntaxStyle.html
docs/mars/venus/editors/jeditsyntax/SyntaxUtilities.html
docs/mars/venus/editors/jeditsyntax/TextAreaDefaults.html
docs/mars/venus/editors/jeditsyntax/TextAreaPainter.Highlight.html
docs/mars/venus/editors/jeditsyntax/TextAreaPainter.html
docs/mars/venus/editors/jeditsyntax/TextUtilities.html
docs/mars/venus/editors/jeditsyntax/tokenmarker/MIPSTokenMarker.html
docs/mars/venus/editors/jeditsyntax/tokenmarker/package-frame.html
docs/mars/venus/editors/jeditsyntax/tokenmarker/package-summary.html
docs/mars/venus/editors/jeditsyntax/tokenmarker/package-tree.html
docs/mars/venus/editors/jeditsyntax/tokenmarker/Token.html
docs/mars/venus/editors/jeditsyntax/tokenmarker/TokenMarker.html
docs/mars/venus/editors/jeditsyntax/tokenmarker/TokenMarker.LineInfo.html
docs/mars/venus/editors/MARSTextEditingArea.html
docs/mars/venus/editors/package-frame.html
docs/mars/venus/editors/package-summary.html
docs/mars/venus/editors/package-tree.html
docs/mars/venus/EditPane.html
docs/mars/venus/EditPasteAction.html
docs/mars/venus/EditRedoAction.html
docs/mars/venus/EditSelectAllAction.html
docs/mars/venus/EditTabbedPane.html
docs/mars/venus/EditUndoAction.html
docs/mars/venus/ExecutePane.html
docs/mars/venus/FileCloseAction.html
docs/mars/venus/FileCloseAllAction.html
docs/mars/venus/FileDumpMemoryAction.html
docs/mars/venus/FileExitAction.html
docs/mars/venus/FileNewAction.html
docs/mars/venus/FileOpenAction.html
docs/mars/venus/FilePrintAction.html
docs/mars/venus/FileSaveAction.html
docs/mars/venus/FileSaveAllAction.html
docs/mars/venus/FileSaveAsAction.html
docs/mars/venus/FileStatus.html
docs/mars/venus/GuiAction.html
docs/mars/venus/HardcopyWriter.html
docs/mars/venus/HardcopyWriter.PrintCanceledException.html
docs/mars/venus/HelpAboutAction.html
docs/mars/venus/HelpHelpAction.html
docs/mars/venus/LabelsWindow.html
docs/mars/venus/MainPane.html
docs/mars/venus/MessagesPane.html
docs/mars/venus/NumberDisplayBaseChooser.html
docs/mars/venus/package-frame.html
docs/mars/venus/package-summary.html
docs/mars/venus/package-tree.html
docs/mars/venus/PopupListener.html
docs/mars/venus/RegistersPane.html
docs/mars/venus/RegistersWindow.html
docs/mars/venus/RepeatButton.html
docs/mars/venus/RunAssembleAction.html
docs/mars/venus/RunBackstepAction.html
docs/mars/venus/RunClearBreakpointsAction.html
docs/mars/venus/RunGoAction.html
docs/mars/venus/RunPauseAction.html
docs/mars/venus/RunResetAction.html
docs/mars/venus/RunSpeedPanel.html
docs/mars/venus/RunStepAction.html
docs/mars/venus/RunStopAction.html
docs/mars/venus/RunToggleBreakpointsAction.html
docs/mars/venus/SettingsAddressDisplayBaseAction.html
docs/mars/venus/SettingsAssembleAllAction.html
docs/mars/venus/SettingsAssembleOnOpenAction.html
docs/mars/venus/SettingsDelayedBranchingAction.html
docs/mars/venus/SettingsEditorAction.html
docs/mars/venus/SettingsExceptionHandlerAction.html
docs/mars/venus/SettingsExtendedAction.html
docs/mars/venus/SettingsHighlightingAction.html
docs/mars/venus/SettingsLabelAction.html
docs/mars/venus/SettingsMemoryConfigurationAction.html
docs/mars/venus/SettingsPopupInputAction.html
docs/mars/venus/SettingsProgramArgumentsAction.html
docs/mars/venus/SettingsSelfModifyingCodeAction.html
docs/mars/venus/SettingsStartAtMainAction.html
docs/mars/venus/SettingsValueDisplayBaseAction.html
docs/mars/venus/SettingsWarningsAreErrorsAction.html
docs/mars/venus/TextSegmentWindow.html
docs/mars/venus/ToolAction.html
docs/mars/venus/ToolLoader.html
docs/mars/venus/VenusUI.html
docs/Mars.html
docs/overview-frame.html
docs/overview-summary.html
docs/overview-tree.html
docs/package-frame.html
docs/package-list
docs/package-summary.html
docs/package-tree.html
docs/resources/inherit.gif
docs/serialized-form.html
docs/stylesheet.css
help/Acknowledgements.html
help/BugReportingHelp.html
help/ExceptionsHelp.html
help/HTML_of_links_for_posting_to_MARS_website.html
help/MacrosHelp.html
help/MarsHelpCommand.html
help/MarsHelpDebugging.html
help/MarsHelpHistory.html
help/MarsHelpIDE.html
help/MarsHelpIntro.html
help/MarsHelpLimits.html
help/MarsHelpSettings.html
help/MarsHelpTools.html
help/MIPSInstructionSetSong.html
help/mipsref.pdf
help/SyscallHelp.html
help/SyscallMessageDialogError.gif
help/SyscallMessageDialogInformation.gif
help/SyscallMessageDialogQuestion.gif
help/SyscallMessageDialogWarning.gif
images/ALUcontrol.png
images/Assemble16.png
images/Assemble22.png
images/control.png
images/Copy16.png
images/Copy22.png
images/Cut16.gif
images/Cut22.gif
images/Cut24.gif
images/datapath.png
images/Dump16.png
images/Dump22.png
images/Edit_tab.jpg
images/Execute_tab.jpg
images/Find16.png
images/Find22.png
images/Help16.png
images/Help22.png
images/mars.ico
images/mars32.ico
images/MarsSurfacePathfinder.jpg
images/MarsThumbnail.gif
images/MyBlank16.gif
images/MyBlank24.gif
images/New16.png
images/New22.png
images/Next22.png
images/Open16.png
images/Open22.png
images/Paste16.png
images/Paste22.png
images/Pause16.png
images/Pause22.png
images/Play16.png
images/Play22.png
images/Previous22.png
images/Print16.gif
images/Print22.gif
images/Print24.gif
images/RedMars16.gif
images/RedMars32.GIF
images/RedMars50.gif
images/Redo16.png
images/Redo22.png
images/register.png
images/Reset16.png
images/Reset22.png
images/Save16.png
images/Save22.png
images/SaveAs16.png
images/SaveAs22.png
images/StepBack16.png
images/StepBack22.png
images/StepForward16.png
images/StepForward22.png
images/Stop16.png
images/Stop22.png
images/Undo16.png
images/Undo22.png
mars/assembler/Assembler$1.class
mars/assembler/Assembler$DataSegmentForwardReferences$DataSegmentForwardReference.class
mars/assembler/Assembler$DataSegmentForwardReferences.class
mars/assembler/Assembler$ProgramStatementComparator.class
mars/assembler/Assembler$UserKernelAddressSpace.class
mars/assembler/Assembler.class
mars/assembler/Assembler.java
mars/assembler/DataTypes.class
mars/assembler/DataTypes.java
mars/assembler/Directives.class
mars/assembler/Directives.java
mars/assembler/Macro.class
mars/assembler/Macro.java
mars/assembler/MacroPool.class
mars/assembler/MacroPool.java
mars/assembler/OperandFormat.class
mars/assembler/OperandFormat.java
mars/assembler/SourceLine.class
mars/assembler/SourceLine.java
mars/assembler/Symbol.class
mars/assembler/Symbol.java
mars/assembler/SymbolTable.class
mars/assembler/SymbolTable.java
mars/assembler/Token.class
mars/assembler/Token.java
mars/assembler/Tokenizer.class
mars/assembler/Tokenizer.java
mars/assembler/TokenList.class
mars/assembler/TokenList.java
mars/assembler/TokenTypes.class
mars/assembler/TokenTypes.java
mars/assembler/TranslationCode.class
mars/assembler/TranslationCode.java
mars/ErrorList.class
mars/ErrorList.java
mars/ErrorMessage.class
mars/ErrorMessage.java
mars/Globals.class
mars/Globals.java
mars/MarsLaunch$1.class
mars/MarsLaunch$2.class
mars/MarsLaunch.class
mars/MarsLaunch.java
mars/MarsSplashScreen$ImageBackgroundPanel.class
mars/MarsSplashScreen.class
mars/MarsSplashScreen.java
mars/mips/dump/AbstractDumpFormat.class
mars/mips/dump/AbstractDumpFormat.java
mars/mips/dump/AsciiTextDumpFormat.class
mars/mips/dump/AsciiTextDumpFormat.java
mars/mips/dump/BinaryDumpFormat.class
mars/mips/dump/BinaryDumpFormat.java
mars/mips/dump/BinaryTextDumpFormat.class
mars/mips/dump/BinaryTextDumpFormat.java
mars/mips/dump/DumpFormat.class
mars/mips/dump/DumpFormat.java
mars/mips/dump/DumpFormatLoader.class
mars/mips/dump/DumpFormatLoader.java
mars/mips/dump/HexTextDumpFormat.class
mars/mips/dump/HexTextDumpFormat.java
mars/mips/dump/IntelHexDumpFormat.class
mars/mips/dump/IntelHexDumpFormat.java
mars/mips/dump/MIFDumpFormat.class
mars/mips/dump/MIFDumpFormat.java
mars/mips/dump/SegmentWindowDumpFormat.class
mars/mips/dump/SegmentWindowDumpFormat.java
mars/mips/hardware/AccessNotice.class
mars/mips/hardware/AccessNotice.java
mars/mips/hardware/AddressErrorException.class
mars/mips/hardware/AddressErrorException.java
mars/mips/hardware/Coprocessor0.class
mars/mips/hardware/Coprocessor0.java
mars/mips/hardware/Coprocessor1.class
mars/mips/hardware/Coprocessor1.java
mars/mips/hardware/InvalidRegisterAccessException.class
mars/mips/hardware/InvalidRegisterAccessException.java
mars/mips/hardware/Memory$MemoryObservable.class
mars/mips/hardware/Memory.class
mars/mips/hardware/Memory.java
mars/mips/hardware/MemoryAccessNotice.class
mars/mips/hardware/MemoryAccessNotice.java
mars/mips/hardware/MemoryConfiguration.class
mars/mips/hardware/MemoryConfiguration.java
mars/mips/hardware/MemoryConfigurations.class
mars/mips/hardware/MemoryConfigurations.java
mars/mips/hardware/Register.class
mars/mips/hardware/Register.java
mars/mips/hardware/RegisterAccessNotice.class
mars/mips/hardware/RegisterAccessNotice.java
mars/mips/hardware/RegisterFile.class
mars/mips/hardware/RegisterFile.java
mars/mips/instructions/BasicInstruction.class
mars/mips/instructions/BasicInstruction.java
mars/mips/instructions/BasicInstructionFormat.class
mars/mips/instructions/BasicInstructionFormat.java
mars/mips/instructions/ExtendedInstruction.class
mars/mips/instructions/ExtendedInstruction.java
mars/mips/instructions/Instruction.class
mars/mips/instructions/Instruction.java
mars/mips/instructions/InstructionSet$1.class
mars/mips/instructions/InstructionSet$10.class
mars/mips/instructions/InstructionSet$100.class
mars/mips/instructions/InstructionSet$101.class
mars/mips/instructions/InstructionSet$102.class
mars/mips/instructions/InstructionSet$103.class
mars/mips/instructions/InstructionSet$104.class
mars/mips/instructions/InstructionSet$105.class
mars/mips/instructions/InstructionSet$106.class
mars/mips/instructions/InstructionSet$107.class
mars/mips/instructions/InstructionSet$108.class
mars/mips/instructions/InstructionSet$109.class
mars/mips/instructions/InstructionSet$11.class
mars/mips/instructions/InstructionSet$110.class
mars/mips/instructions/InstructionSet$111.class
mars/mips/instructions/InstructionSet$112.class
mars/mips/instructions/InstructionSet$113.class
mars/mips/instructions/InstructionSet$114.class
mars/mips/instructions/InstructionSet$115.class
mars/mips/instructions/InstructionSet$116.class
mars/mips/instructions/InstructionSet$117.class
mars/mips/instructions/InstructionSet$118.class
mars/mips/instructions/InstructionSet$119.class
mars/mips/instructions/InstructionSet$12.class
mars/mips/instructions/InstructionSet$120.class
mars/mips/instructions/InstructionSet$121.class
mars/mips/instructions/InstructionSet$122.class
mars/mips/instructions/InstructionSet$123.class
mars/mips/instructions/InstructionSet$124.class
mars/mips/instructions/InstructionSet$125.class
mars/mips/instructions/InstructionSet$126.class
mars/mips/instructions/InstructionSet$127.class
mars/mips/instructions/InstructionSet$128.class
mars/mips/instructions/InstructionSet$129.class
mars/mips/instructions/InstructionSet$13.class
mars/mips/instructions/InstructionSet$130.class
mars/mips/instructions/InstructionSet$131.class
mars/mips/instructions/InstructionSet$132.class
mars/mips/instructions/InstructionSet$133.class
mars/mips/instructions/InstructionSet$134.class
mars/mips/instructions/InstructionSet$135.class
mars/mips/instructions/InstructionSet$136.class
mars/mips/instructions/InstructionSet$137.class
mars/mips/instructions/InstructionSet$138.class
mars/mips/instructions/InstructionSet$139.class
mars/mips/instructions/InstructionSet$14.class
mars/mips/instructions/InstructionSet$140.class
mars/mips/instructions/InstructionSet$141.class
mars/mips/instructions/InstructionSet$142.class
mars/mips/instructions/InstructionSet$143.class
mars/mips/instructions/InstructionSet$144.class
mars/mips/instructions/InstructionSet$145.class
mars/mips/instructions/InstructionSet$146.class
mars/mips/instructions/InstructionSet$147.class
mars/mips/instructions/InstructionSet$148.class
mars/mips/instructions/InstructionSet$149.class
mars/mips/instructions/InstructionSet$15.class
mars/mips/instructions/InstructionSet$150.class
mars/mips/instructions/InstructionSet$151.class
mars/mips/instructions/InstructionSet$152.class
mars/mips/instructions/InstructionSet$153.class
mars/mips/instructions/InstructionSet$154.class
mars/mips/instructions/InstructionSet$155.class
mars/mips/instructions/InstructionSet$16.class
mars/mips/instructions/InstructionSet$17.class
mars/mips/instructions/InstructionSet$18.class
mars/mips/instructions/InstructionSet$19.class
mars/mips/instructions/InstructionSet$2.class
mars/mips/instructions/InstructionSet$20.class
mars/mips/instructions/InstructionSet$21.class
mars/mips/instructions/InstructionSet$22.class
mars/mips/instructions/InstructionSet$23.class
mars/mips/instructions/InstructionSet$24.class
mars/mips/instructions/InstructionSet$25.class
mars/mips/instructions/InstructionSet$26.class
mars/mips/instructions/InstructionSet$27.class
mars/mips/instructions/InstructionSet$28.class
mars/mips/instructions/InstructionSet$29.class
mars/mips/instructions/InstructionSet$3.class
mars/mips/instructions/InstructionSet$30.class
mars/mips/instructions/InstructionSet$31.class
mars/mips/instructions/InstructionSet$32.class
mars/mips/instructions/InstructionSet$33.class
mars/mips/instructions/InstructionSet$34.class
mars/mips/instructions/InstructionSet$35.class
mars/mips/instructions/InstructionSet$36.class
mars/mips/instructions/InstructionSet$37.class
mars/mips/instructions/InstructionSet$38.class
mars/mips/instructions/InstructionSet$39.class
mars/mips/instructions/InstructionSet$4.class
mars/mips/instructions/InstructionSet$40.class
mars/mips/instructions/InstructionSet$41.class
mars/mips/instructions/InstructionSet$42.class
mars/mips/instructions/InstructionSet$43.class
mars/mips/instructions/InstructionSet$44.class
mars/mips/instructions/InstructionSet$45.class
mars/mips/instructions/InstructionSet$46.class
mars/mips/instructions/InstructionSet$47.class
mars/mips/instructions/InstructionSet$48.class
mars/mips/instructions/InstructionSet$49.class
mars/mips/instructions/InstructionSet$5.class
mars/mips/instructions/InstructionSet$50.class
mars/mips/instructions/InstructionSet$51.class
mars/mips/instructions/InstructionSet$52.class
mars/mips/instructions/InstructionSet$53.class
mars/mips/instructions/InstructionSet$54.class
mars/mips/instructions/InstructionSet$55.class
mars/mips/instructions/InstructionSet$56.class
mars/mips/instructions/InstructionSet$57.class
mars/mips/instructions/InstructionSet$58.class
mars/mips/instructions/InstructionSet$59.class
mars/mips/instructions/InstructionSet$6.class
mars/mips/instructions/InstructionSet$60.class
mars/mips/instructions/InstructionSet$61.class
mars/mips/instructions/InstructionSet$62.class
mars/mips/instructions/InstructionSet$63.class
mars/mips/instructions/InstructionSet$64.class
mars/mips/instructions/InstructionSet$65.class
mars/mips/instructions/InstructionSet$66.class
mars/mips/instructions/InstructionSet$67.class
mars/mips/instructions/InstructionSet$68.class
mars/mips/instructions/InstructionSet$69.class
mars/mips/instructions/InstructionSet$7.class
mars/mips/instructions/InstructionSet$70.class
mars/mips/instructions/InstructionSet$71.class
mars/mips/instructions/InstructionSet$72.class
mars/mips/instructions/InstructionSet$73.class
mars/mips/instructions/InstructionSet$74.class
mars/mips/instructions/InstructionSet$75.class
mars/mips/instructions/InstructionSet$76.class
mars/mips/instructions/InstructionSet$77.class
mars/mips/instructions/InstructionSet$78.class
mars/mips/instructions/InstructionSet$79.class
mars/mips/instructions/InstructionSet$8.class
mars/mips/instructions/InstructionSet$80.class
mars/mips/instructions/InstructionSet$81.class
mars/mips/instructions/InstructionSet$82.class
mars/mips/instructions/InstructionSet$83.class
mars/mips/instructions/InstructionSet$84.class
mars/mips/instructions/InstructionSet$85.class
mars/mips/instructions/InstructionSet$86.class
mars/mips/instructions/InstructionSet$87.class
mars/mips/instructions/InstructionSet$88.class
mars/mips/instructions/InstructionSet$89.class
mars/mips/instructions/InstructionSet$9.class
mars/mips/instructions/InstructionSet$90.class
mars/mips/instructions/InstructionSet$91.class
mars/mips/instructions/InstructionSet$92.class
mars/mips/instructions/InstructionSet$93.class
mars/mips/instructions/InstructionSet$94.class
mars/mips/instructions/InstructionSet$95.class
mars/mips/instructions/InstructionSet$96.class
mars/mips/instructions/InstructionSet$97.class
mars/mips/instructions/InstructionSet$98.class
mars/mips/instructions/InstructionSet$99.class
mars/mips/instructions/InstructionSet$MatchMap.class
mars/mips/instructions/InstructionSet.class
mars/mips/instructions/InstructionSet.java
mars/mips/instructions/SimulationCode.class
mars/mips/instructions/SimulationCode.java
mars/mips/instructions/SyscallLoader.class
mars/mips/instructions/SyscallLoader.java
mars/mips/instructions/syscalls/AbstractSyscall.class
mars/mips/instructions/syscalls/AbstractSyscall.java
mars/mips/instructions/syscalls/EndOfTrackListener.class
mars/mips/instructions/syscalls/RandomStreams.class
mars/mips/instructions/syscalls/RandomStreams.java
mars/mips/instructions/syscalls/Syscall.class
mars/mips/instructions/syscalls/Syscall.java
mars/mips/instructions/syscalls/SyscallClose.class
mars/mips/instructions/syscalls/SyscallClose.java
mars/mips/instructions/syscalls/SyscallConfirmDialog.class
mars/mips/instructions/syscalls/SyscallConfirmDialog.java
mars/mips/instructions/syscalls/SyscallExit.class
mars/mips/instructions/syscalls/SyscallExit.java
mars/mips/instructions/syscalls/SyscallExit2.class
mars/mips/instructions/syscalls/SyscallExit2.java
mars/mips/instructions/syscalls/SyscallInputDialogDouble.class
mars/mips/instructions/syscalls/SyscallInputDialogDouble.java
mars/mips/instructions/syscalls/SyscallInputDialogFloat.class
mars/mips/instructions/syscalls/SyscallInputDialogFloat.java
mars/mips/instructions/syscalls/SyscallInputDialogInt.class
mars/mips/instructions/syscalls/SyscallInputDialogInt.java
mars/mips/instructions/syscalls/SyscallInputDialogString.class
mars/mips/instructions/syscalls/SyscallInputDialogString.java
mars/mips/instructions/syscalls/SyscallMessageDialog.class
mars/mips/instructions/syscalls/SyscallMessageDialog.java
mars/mips/instructions/syscalls/SyscallMessageDialogDouble.class
mars/mips/instructions/syscalls/SyscallMessageDialogDouble.java
mars/mips/instructions/syscalls/SyscallMessageDialogFloat.class
mars/mips/instructions/syscalls/SyscallMessageDialogFloat.java
mars/mips/instructions/syscalls/SyscallMessageDialogInt.class
mars/mips/instructions/syscalls/SyscallMessageDialogInt.java
mars/mips/instructions/syscalls/SyscallMessageDialogString.class
mars/mips/instructions/syscalls/SyscallMessageDialogString.java
mars/mips/instructions/syscalls/SyscallMidiOut.class
mars/mips/instructions/syscalls/SyscallMidiOut.java
mars/mips/instructions/syscalls/SyscallMidiOutSync.class
mars/mips/instructions/syscalls/SyscallMidiOutSync.java
mars/mips/instructions/syscalls/SyscallNumberOverride.class
mars/mips/instructions/syscalls/SyscallNumberOverride.java
mars/mips/instructions/syscalls/SyscallOpen.class
mars/mips/instructions/syscalls/SyscallOpen.java
mars/mips/instructions/syscalls/SyscallPrintChar.class
mars/mips/instructions/syscalls/SyscallPrintChar.java
mars/mips/instructions/syscalls/SyscallPrintDouble.class
mars/mips/instructions/syscalls/SyscallPrintDouble.java
mars/mips/instructions/syscalls/SyscallPrintFloat.class
mars/mips/instructions/syscalls/SyscallPrintFloat.java
mars/mips/instructions/syscalls/SyscallPrintInt.class
mars/mips/instructions/syscalls/SyscallPrintInt.java
mars/mips/instructions/syscalls/SyscallPrintIntBinary.class
mars/mips/instructions/syscalls/SyscallPrintIntBinary.java
mars/mips/instructions/syscalls/SyscallPrintIntHex.class
mars/mips/instructions/syscalls/SyscallPrintIntHex.java
mars/mips/instructions/syscalls/SyscallPrintIntUnsigned.class
mars/mips/instructions/syscalls/SyscallPrintIntUnsigned.java
mars/mips/instructions/syscalls/SyscallPrintString.class
mars/mips/instructions/syscalls/SyscallPrintString.java
mars/mips/instructions/syscalls/SyscallRandDouble.class
mars/mips/instructions/syscalls/SyscallRandDouble.java
mars/mips/instructions/syscalls/SyscallRandFloat.class
mars/mips/instructions/syscalls/SyscallRandFloat.java
mars/mips/instructions/syscalls/SyscallRandInt.class
mars/mips/instructions/syscalls/SyscallRandInt.java
mars/mips/instructions/syscalls/SyscallRandIntRange.class
mars/mips/instructions/syscalls/SyscallRandIntRange.java
mars/mips/instructions/syscalls/SyscallRandSeed.class
mars/mips/instructions/syscalls/SyscallRandSeed.java
mars/mips/instructions/syscalls/SyscallRead.class
mars/mips/instructions/syscalls/SyscallRead.java
mars/mips/instructions/syscalls/SyscallReadChar.class
mars/mips/instructions/syscalls/SyscallReadChar.java
mars/mips/instructions/syscalls/SyscallReadDouble.class
mars/mips/instructions/syscalls/SyscallReadDouble.java
mars/mips/instructions/syscalls/SyscallReadFloat.class
mars/mips/instructions/syscalls/SyscallReadFloat.java
mars/mips/instructions/syscalls/SyscallReadInt.class
mars/mips/instructions/syscalls/SyscallReadInt.java
mars/mips/instructions/syscalls/SyscallReadString.class
mars/mips/instructions/syscalls/SyscallReadString.java
mars/mips/instructions/syscalls/SyscallSbrk.class
mars/mips/instructions/syscalls/SyscallSbrk.java
mars/mips/instructions/syscalls/SyscallSleep.class
mars/mips/instructions/syscalls/SyscallSleep.java
mars/mips/instructions/syscalls/SyscallTime.class
mars/mips/instructions/syscalls/SyscallTime.java
mars/mips/instructions/syscalls/SyscallWrite.class
mars/mips/instructions/syscalls/SyscallWrite.java
mars/mips/instructions/syscalls/Tone.class
mars/mips/instructions/syscalls/ToneGenerator.class
mars/mips/instructions/syscalls/ToneGenerator.java
mars/MIPSprogram.class
mars/MIPSprogram.java
mars/ProcessingException.class
mars/ProcessingException.java
mars/ProgramStatement$BasicStatementList$ListElement.class
mars/ProgramStatement$BasicStatementList.class
mars/ProgramStatement.class
mars/ProgramStatement.java
mars/Settings.class
mars/Settings.java
mars/simulator/BackStepper$1.class
mars/simulator/BackStepper$BackStep.class
mars/simulator/BackStepper$BackstepStack.class
mars/simulator/BackStepper.class
mars/simulator/BackStepper.java
mars/simulator/DelayedBranch.class
mars/simulator/DelayedBranch.java
mars/simulator/Exceptions.class
mars/simulator/Exceptions.java
mars/simulator/ProgramArgumentList.class
mars/simulator/ProgramArgumentList.java
mars/simulator/Simulator$1.class
mars/simulator/Simulator$SimThread.class
mars/simulator/Simulator$StopListener.class
mars/simulator/Simulator$UpdateGUI.class
mars/simulator/Simulator.class
mars/simulator/Simulator.java
mars/simulator/SimulatorNotice.class
mars/simulator/SimulatorNotice.java
mars/simulator/SwingWorker$1.class
mars/simulator/SwingWorker$2.class
mars/simulator/SwingWorker$ThreadVar.class
mars/simulator/SwingWorker.class
mars/simulator/SwingWorker.java
mars/tools/AbstractMarsToolAndApplication$1.class
mars/tools/AbstractMarsToolAndApplication$10.class
mars/tools/AbstractMarsToolAndApplication$2.class
mars/tools/AbstractMarsToolAndApplication$3.class
mars/tools/AbstractMarsToolAndApplication$4.class
mars/tools/AbstractMarsToolAndApplication$5.class
mars/tools/AbstractMarsToolAndApplication$6.class
mars/tools/AbstractMarsToolAndApplication$7.class
mars/tools/AbstractMarsToolAndApplication$8.class
mars/tools/AbstractMarsToolAndApplication$9.class
mars/tools/AbstractMarsToolAndApplication$ConnectButton.class
mars/tools/AbstractMarsToolAndApplication$CreateAssembleRunMIPSprogram.class
mars/tools/AbstractMarsToolAndApplication$EnterKeyListener.class
mars/tools/AbstractMarsToolAndApplication$GUIUpdater.class
mars/tools/AbstractMarsToolAndApplication$MessageField$MessageWriter.class
mars/tools/AbstractMarsToolAndApplication$MessageField.class
mars/tools/AbstractMarsToolAndApplication.class
mars/tools/AbstractMarsToolAndApplication.java
mars/tools/BHTableModel.class
mars/tools/BHTableModel.java
mars/tools/BHTEntry.class
mars/tools/BHTEntry.java
mars/tools/BHTSimGUI$1.class
mars/tools/BHTSimGUI.class
mars/tools/BHTSimGUI.java
mars/tools/BHTSimulator.class
mars/tools/BHTSimulator.java
mars/tools/BitmapDisplay$1.class
mars/tools/BitmapDisplay$2.class
mars/tools/BitmapDisplay$3.class
mars/tools/BitmapDisplay$4.class
mars/tools/BitmapDisplay$5.class
mars/tools/BitmapDisplay$6.class
mars/tools/BitmapDisplay$GraphicsPanel.class
mars/tools/BitmapDisplay$Grid.class
mars/tools/BitmapDisplay.class
mars/tools/BitmapDisplay.java
mars/tools/CacheSimulator$1.class
mars/tools/CacheSimulator$2.class
mars/tools/CacheSimulator$3.class
mars/tools/CacheSimulator$4.class
mars/tools/CacheSimulator$5.class
mars/tools/CacheSimulator$AbstractCache.class
mars/tools/CacheSimulator$Animation.class
mars/tools/CacheSimulator$AnyCache.class
mars/tools/CacheSimulator$CacheAccessResult.class
mars/tools/CacheSimulator$CacheBlock.class
mars/tools/CacheSimulator.class
mars/tools/CacheSimulator.java
mars/tools/CaptureDisplayAlignmentStrategy.class
mars/tools/CaptureDisplayCentered.class
mars/tools/CaptureDisplayUpperleft.class
mars/tools/CaptureMagnifierRectangle.class
mars/tools/CaptureModel.class
mars/tools/CaptureRectangleStrategy.class
mars/tools/CaptureScaledRectangle.class
mars/tools/DigitalLabSim$1.class
mars/tools/DigitalLabSim$HexaKeyboard$EcouteurClick.class
mars/tools/DigitalLabSim$HexaKeyboard.class
mars/tools/DigitalLabSim$OneSecondCounter.class
mars/tools/DigitalLabSim$SevenSegmentDisplay.class
mars/tools/DigitalLabSim$SevenSegmentPanel.class
mars/tools/DigitalLabSim.class
mars/tools/DigitalLabSim.java
mars/tools/FloatRepresentation$1.class
mars/tools/FloatRepresentation$BinaryDisplayKeystrokeListener.class
mars/tools/FloatRepresentation$BinaryFractionDisplayTextField.class
mars/tools/FloatRepresentation$BinaryToDecimalFormulaGraphic.class
mars/tools/FloatRepresentation$DecimalDisplayKeystokeListenter.class
mars/tools/FloatRepresentation$FlavorsOfFloat.class
mars/tools/FloatRepresentation$HexDisplayKeystrokeListener.class
mars/tools/FloatRepresentation$HexToBinaryGraphicPanel.class
mars/tools/FloatRepresentation$InstructionsPane.class
mars/tools/FloatRepresentation.class
mars/tools/FloatRepresentation.java
mars/tools/FunctionUnitVisualization.class
mars/tools/FunctionUnitVisualization.java
mars/tools/InstructionCounter.class
mars/tools/InstructionCounter.java
mars/tools/InstructionStatistics.class
mars/tools/InstructionStatistics.java
mars/tools/IntroToTools.class
mars/tools/IntroToTools.java
mars/tools/KeyboardAndDisplaySimulator$1$1.class
mars/tools/KeyboardAndDisplaySimulator$1.class
mars/tools/KeyboardAndDisplaySimulator$2.class
mars/tools/KeyboardAndDisplaySimulator$3.class
mars/tools/KeyboardAndDisplaySimulator$4.class
mars/tools/KeyboardAndDisplaySimulator$DelayLengthPanel$DelayLengthListener.class
mars/tools/KeyboardAndDisplaySimulator$DelayLengthPanel.class
mars/tools/KeyboardAndDisplaySimulator$DisplayResizeAdapter.class
mars/tools/KeyboardAndDisplaySimulator$FixedLengthDelay.class
mars/tools/KeyboardAndDisplaySimulator$FontChanger.class
mars/tools/KeyboardAndDisplaySimulator$FontSettingDialog$1.class
mars/tools/KeyboardAndDisplaySimulator$FontSettingDialog$2.class
mars/tools/KeyboardAndDisplaySimulator$FontSettingDialog$3.class
mars/tools/KeyboardAndDisplaySimulator$FontSettingDialog.class
mars/tools/KeyboardAndDisplaySimulator$KeyboardKeyListener.class
mars/tools/KeyboardAndDisplaySimulator$NormallyDistributedDelay.class
mars/tools/KeyboardAndDisplaySimulator$TransmitterDelayTechnique.class
mars/tools/KeyboardAndDisplaySimulator$UniformlyDistributedDelay.class
mars/tools/KeyboardAndDisplaySimulator.class
mars/tools/KeyboardAndDisplaySimulator.java
mars/tools/Magnifier$1.class
mars/tools/Magnifier$2.class
mars/tools/Magnifier$3.class
mars/tools/Magnifier$4.class
mars/tools/Magnifier$5.class
mars/tools/Magnifier.class
mars/tools/MagnifierImage$1.class
mars/tools/MagnifierImage$2.class
mars/tools/MagnifierImage$Scribbler.class
mars/tools/MagnifierImage.class
mars/tools/MarsBot$BotRunnable$1.class
mars/tools/MarsBot$BotRunnable$2.class
mars/tools/MarsBot$BotRunnable.class
mars/tools/MarsBot$MarsBotDisplay.class
mars/tools/MarsBot.class
mars/tools/MarsBot.java
mars/tools/MarsTool.class
mars/tools/MarsTool.java
mars/tools/MemoryReferenceVisualization$1.class
mars/tools/MemoryReferenceVisualization$2.class
mars/tools/MemoryReferenceVisualization$3.class
mars/tools/MemoryReferenceVisualization$4.class
mars/tools/MemoryReferenceVisualization$5.class
mars/tools/MemoryReferenceVisualization$6.class
mars/tools/MemoryReferenceVisualization$7.class
mars/tools/MemoryReferenceVisualization$8.class
mars/tools/MemoryReferenceVisualization$ColorChooserControls$1.class
mars/tools/MemoryReferenceVisualization$ColorChooserControls$ColorChooserListener.class
mars/tools/MemoryReferenceVisualization$ColorChooserControls.class
mars/tools/MemoryReferenceVisualization$CounterColor.class
mars/tools/MemoryReferenceVisualization$CounterColorScale.class
mars/tools/MemoryReferenceVisualization$GraphicsPanel.class
mars/tools/MemoryReferenceVisualization$Grid.class
mars/tools/MemoryReferenceVisualization.class
mars/tools/MemoryReferenceVisualization.java
mars/tools/MipsXray$1.class
mars/tools/MipsXray$DatapathAnimation.class
mars/tools/MipsXray$Vertex.class
mars/tools/MipsXray.class
mars/tools/MipsXray.java
mars/tools/ScavengerHunt$1.class
mars/tools/ScavengerHunt$Location.class
mars/tools/ScavengerHunt$PlayerData.class
mars/tools/ScavengerHunt$ScavengerHuntDisplay.class
mars/tools/ScavengerHunt$ScavengerHuntRunnable$1.class
mars/tools/ScavengerHunt$ScavengerHuntRunnable$2.class
mars/tools/ScavengerHunt$ScavengerHuntRunnable.class
mars/tools/ScavengerHunt.class
mars/tools/ScavengerHunt.java
mars/tools/ScreenMagnifier$1.class
mars/tools/ScreenMagnifier.class
mars/tools/ScreenMagnifier.java
mars/tools/ScribblerSettings.class
mars/tools/SettingsDialog$1.class
mars/tools/SettingsDialog$2.class
mars/tools/SettingsDialog$3.class
mars/tools/SettingsDialog.class
mars/tools/UnitAnimation$Vertex.class
mars/tools/UnitAnimation.class
mars/tools/UnitAnimation.java
mars/util/Binary.class
mars/util/Binary.java
mars/util/EditorFont.class
mars/util/EditorFont.java
mars/util/FilenameFinder$1.class
mars/util/FilenameFinder$MarsFileFilter.class
mars/util/FilenameFinder.class
mars/util/FilenameFinder.java
mars/util/MemoryDump.class
mars/util/MemoryDump.java
mars/util/PropertiesFile.class
mars/util/PropertiesFile.java
mars/util/SystemIO$FileIOData.class
mars/util/SystemIO.class
mars/util/SystemIO.java
mars/venus/AbstractFontSettingDialog$1.class
mars/venus/AbstractFontSettingDialog$2.class
mars/venus/AbstractFontSettingDialog$3.class
mars/venus/AbstractFontSettingDialog$4.class
mars/venus/AbstractFontSettingDialog$BlockComboListener.class
mars/venus/AbstractFontSettingDialog$ComboBoxRenderer.class
mars/venus/AbstractFontSettingDialog.class
mars/venus/AbstractFontSettingDialog.java
mars/venus/ColorSelectButton.class
mars/venus/Coprocessor0Window$MyTippedJTable$1.class
mars/venus/Coprocessor0Window$MyTippedJTable.class
mars/venus/Coprocessor0Window$RegisterCellRenderer.class
mars/venus/Coprocessor0Window$RegTableModel.class
mars/venus/Coprocessor0Window.class
mars/venus/Coprocessor0Window.java
mars/venus/Coprocessor1Window$MyTippedJTable$1.class
mars/venus/Coprocessor1Window$MyTippedJTable.class
mars/venus/Coprocessor1Window$RegisterCellRenderer.class
mars/venus/Coprocessor1Window$RegTableModel.class
mars/venus/Coprocessor1Window.class
mars/venus/Coprocessor1Window.java
mars/venus/DataSegmentWindow$1.class
mars/venus/DataSegmentWindow$10.class
mars/venus/DataSegmentWindow$2.class
mars/venus/DataSegmentWindow$3.class
mars/venus/DataSegmentWindow$4.class
mars/venus/DataSegmentWindow$5.class
mars/venus/DataSegmentWindow$6.class
mars/venus/DataSegmentWindow$7.class
mars/venus/DataSegmentWindow$8.class
mars/venus/DataSegmentWindow$9.class
mars/venus/DataSegmentWindow$AddressCellRenderer.class
mars/venus/DataSegmentWindow$CustomComboBoxModel.class
mars/venus/DataSegmentWindow$DataTableModel.class
mars/venus/DataSegmentWindow$MyTippedJTable$1.class
mars/venus/DataSegmentWindow$MyTippedJTable.class
mars/venus/DataSegmentWindow$NextButton.class
mars/venus/DataSegmentWindow$PrevButton.class
mars/venus/DataSegmentWindow.class
mars/venus/DataSegmentWindow.java
mars/venus/EditCopyAction.class
mars/venus/EditCopyAction.java
mars/venus/EditCutAction.class
mars/venus/EditCutAction.java
mars/venus/EditFindReplaceAction$FindReplaceDialog$1.class
mars/venus/EditFindReplaceAction$FindReplaceDialog$2.class
mars/venus/EditFindReplaceAction$FindReplaceDialog$3.class
mars/venus/EditFindReplaceAction$FindReplaceDialog$4.class
mars/venus/EditFindReplaceAction$FindReplaceDialog$5.class
mars/venus/EditFindReplaceAction$FindReplaceDialog.class
mars/venus/EditFindReplaceAction.class
mars/venus/EditFindReplaceAction.java
mars/venus/Editor.class
mars/venus/Editor.java
mars/venus/editors/generic/GenericTextArea$1.class
mars/venus/editors/generic/GenericTextArea$2.class
mars/venus/editors/generic/GenericTextArea.class
mars/venus/editors/generic/GenericTextArea.java
mars/venus/editors/jeditsyntax/DefaultInputHandler.class
mars/venus/editors/jeditsyntax/DefaultInputHandler.java
mars/venus/editors/jeditsyntax/InputHandler$backspace.class
mars/venus/editors/jeditsyntax/InputHandler$backspace_word.class
mars/venus/editors/jeditsyntax/InputHandler$clip_copy.class
mars/venus/editors/jeditsyntax/InputHandler$clip_cut.class
mars/venus/editors/jeditsyntax/InputHandler$clip_paste.class
mars/venus/editors/jeditsyntax/InputHandler$delete.class
mars/venus/editors/jeditsyntax/InputHandler$delete_word.class
mars/venus/editors/jeditsyntax/InputHandler$document_end.class
mars/venus/editors/jeditsyntax/InputHandler$document_home.class
mars/venus/editors/jeditsyntax/InputHandler$end.class
mars/venus/editors/jeditsyntax/InputHandler$home.class
mars/venus/editors/jeditsyntax/InputHandler$insert_break.class
mars/venus/editors/jeditsyntax/InputHandler$insert_char.class
mars/venus/editors/jeditsyntax/InputHandler$insert_tab.class
mars/venus/editors/jeditsyntax/InputHandler$MacroRecorder.class
mars/venus/editors/jeditsyntax/InputHandler$next_char.class
mars/venus/editors/jeditsyntax/InputHandler$next_line.class
mars/venus/editors/jeditsyntax/InputHandler$next_page.class
mars/venus/editors/jeditsyntax/InputHandler$next_word.class
mars/venus/editors/jeditsyntax/InputHandler$NonRecordable.class
mars/venus/editors/jeditsyntax/InputHandler$NonRepeatable.class
mars/venus/editors/jeditsyntax/InputHandler$overwrite.class
mars/venus/editors/jeditsyntax/InputHandler$prev_char.class
mars/venus/editors/jeditsyntax/InputHandler$prev_line.class
mars/venus/editors/jeditsyntax/InputHandler$prev_page.class
mars/venus/editors/jeditsyntax/InputHandler$prev_word.class
mars/venus/editors/jeditsyntax/InputHandler$repeat.class
mars/venus/editors/jeditsyntax/InputHandler$select_all.class
mars/venus/editors/jeditsyntax/InputHandler$toggle_rect.class
mars/venus/editors/jeditsyntax/InputHandler$Wrapper.class
mars/venus/editors/jeditsyntax/InputHandler.class
mars/venus/editors/jeditsyntax/InputHandler.java
mars/venus/editors/jeditsyntax/InstructionMouseEvent.class
mars/venus/editors/jeditsyntax/JEditBasedTextArea$1.class
mars/venus/editors/jeditsyntax/JEditBasedTextArea.class
mars/venus/editors/jeditsyntax/JEditBasedTextArea.java
mars/venus/editors/jeditsyntax/JEditTextArea$1.class
mars/venus/editors/jeditsyntax/JEditTextArea$2.class
mars/venus/editors/jeditsyntax/JEditTextArea$AdjustHandler$1.class
mars/venus/editors/jeditsyntax/JEditTextArea$AdjustHandler.class
mars/venus/editors/jeditsyntax/JEditTextArea$CaretBlinker.class
mars/venus/editors/jeditsyntax/JEditTextArea$CaretUndo.class
mars/venus/editors/jeditsyntax/JEditTextArea$ComponentHandler.class
mars/venus/editors/jeditsyntax/JEditTextArea$DocumentHandler.class
mars/venus/editors/jeditsyntax/JEditTextArea$DragHandler.class
mars/venus/editors/jeditsyntax/JEditTextArea$FocusHandler.class
mars/venus/editors/jeditsyntax/JEditTextArea$MouseHandler.class
mars/venus/editors/jeditsyntax/JEditTextArea$MouseWheelHandler.class
mars/venus/editors/jeditsyntax/JEditTextArea$MutableCaretEvent.class
mars/venus/editors/jeditsyntax/JEditTextArea$PopupHelpActionListener.class
mars/venus/editors/jeditsyntax/JEditTextArea$ScrollLayout.class
mars/venus/editors/jeditsyntax/JEditTextArea.class
mars/venus/editors/jeditsyntax/JEditTextArea.java
mars/venus/editors/jeditsyntax/KeywordMap$Keyword.class
mars/venus/editors/jeditsyntax/KeywordMap.class
mars/venus/editors/jeditsyntax/KeywordMap.java
mars/venus/editors/jeditsyntax/PopupHelpItem.class
mars/venus/editors/jeditsyntax/PopupHelpItem.java
mars/venus/editors/jeditsyntax/SyntaxDocument.class
mars/venus/editors/jeditsyntax/SyntaxDocument.java
mars/venus/editors/jeditsyntax/SyntaxStyle.class
mars/venus/editors/jeditsyntax/SyntaxStyle.java
mars/venus/editors/jeditsyntax/SyntaxUtilities.class
mars/venus/editors/jeditsyntax/SyntaxUtilities.java
mars/venus/editors/jeditsyntax/TextAreaDefaults.class
mars/venus/editors/jeditsyntax/TextAreaDefaults.java
mars/venus/editors/jeditsyntax/TextAreaPainter$Highlight.class
mars/venus/editors/jeditsyntax/TextAreaPainter.class
mars/venus/editors/jeditsyntax/TextAreaPainter.java
mars/venus/editors/jeditsyntax/TextUtilities.class
mars/venus/editors/jeditsyntax/TextUtilities.java
mars/venus/editors/jeditsyntax/tokenmarker/MIPSTokenMarker.class
mars/venus/editors/jeditsyntax/tokenmarker/MIPSTokenMarker.java
mars/venus/editors/jeditsyntax/tokenmarker/Token.class
mars/venus/editors/jeditsyntax/tokenmarker/Token.java
mars/venus/editors/jeditsyntax/tokenmarker/TokenMarker$LineInfo.class
mars/venus/editors/jeditsyntax/tokenmarker/TokenMarker.class
mars/venus/editors/jeditsyntax/tokenmarker/TokenMarker.java
mars/venus/editors/MARSTextEditingArea.class
mars/venus/editors/MARSTextEditingArea.java
mars/venus/EditPane$1.class
mars/venus/EditPane$2.class
mars/venus/EditPane.class
mars/venus/EditPane.java
mars/venus/EditPasteAction.class
mars/venus/EditPasteAction.java
mars/venus/EditRedoAction.class
mars/venus/EditRedoAction.java
mars/venus/EditSelectAllAction.class
mars/venus/EditSelectAllAction.java
mars/venus/EditTabbedPane$1.class
mars/venus/EditTabbedPane$FileOpener$ChoosableFileFilterChangeListener.class
mars/venus/EditTabbedPane$FileOpener.class
mars/venus/EditTabbedPane.class
mars/venus/EditTabbedPane.java
mars/venus/EditUndoAction.class
mars/venus/EditUndoAction.java
mars/venus/ExecutePane.class
mars/venus/ExecutePane.java
mars/venus/FileCloseAction.class
mars/venus/FileCloseAction.java
mars/venus/FileCloseAllAction.class
mars/venus/FileCloseAllAction.java
mars/venus/FileDumpMemoryAction$1.class
mars/venus/FileDumpMemoryAction$2.class
mars/venus/FileDumpMemoryAction$3.class
mars/venus/FileDumpMemoryAction$4.class
mars/venus/FileDumpMemoryAction$DumpFormatComboBoxRenderer.class
mars/venus/FileDumpMemoryAction.class
mars/venus/FileDumpMemoryAction.java
mars/venus/FileExitAction.class
mars/venus/FileExitAction.java
mars/venus/FileNewAction.class
mars/venus/FileNewAction.java
mars/venus/FileOpenAction.class
mars/venus/FileOpenAction.java
mars/venus/FilePrintAction.class
mars/venus/FilePrintAction.java
mars/venus/FileSaveAction.class
mars/venus/FileSaveAction.java
mars/venus/FileSaveAllAction.class
mars/venus/FileSaveAllAction.java
mars/venus/FileSaveAsAction.class
mars/venus/FileSaveAsAction.java
mars/venus/FileStatus.class
mars/venus/FileStatus.java
mars/venus/GuiAction.class
mars/venus/GuiAction.java
mars/venus/HardcopyWriter$PrintCanceledException.class
mars/venus/HardcopyWriter.class
mars/venus/HardcopyWriter.java
mars/venus/HelpAboutAction.class
mars/venus/HelpAboutAction.java
mars/venus/HelpHelpAction$1.class
mars/venus/HelpHelpAction$2.class
mars/venus/HelpHelpAction$HelpHyperlinkListener$1.class
mars/venus/HelpHelpAction$HelpHyperlinkListener$2.class
mars/venus/HelpHelpAction$HelpHyperlinkListener.class
mars/venus/HelpHelpAction$MyCellRenderer.class
mars/venus/HelpHelpAction.class
mars/venus/HelpHelpAction.java
mars/venus/LabelsWindow$1.class
mars/venus/LabelsWindow$DescendingComparator.class
mars/venus/LabelsWindow$LabelAddressAscendingComparator.class
mars/venus/LabelsWindow$LabelDisplayMouseListener.class
mars/venus/LabelsWindow$LabelItemListener.class
mars/venus/LabelsWindow$LabelNameAscendingComparator.class
mars/venus/LabelsWindow$LabelsForSymbolTable.class
mars/venus/LabelsWindow$LabelTableModel.class
mars/venus/LabelsWindow$MyTippedJTable$SymbolTableHeader$SymbolTableHeaderMouseListener.class
mars/venus/LabelsWindow$MyTippedJTable$SymbolTableHeader.class
mars/venus/LabelsWindow$MyTippedJTable.class
mars/venus/LabelsWindow.class
mars/venus/LabelsWindow.java
mars/venus/MainPane$1.class
mars/venus/MainPane.class
mars/venus/MainPane.java
mars/venus/MessagesPane$1.class
mars/venus/MessagesPane$2.class
mars/venus/MessagesPane$3.class
mars/venus/MessagesPane$4.class
mars/venus/MessagesPane$Asker$1$1.class
mars/venus/MessagesPane$Asker$1$2.class
mars/venus/MessagesPane$Asker$1.class
mars/venus/MessagesPane$Asker$2.class
mars/venus/MessagesPane$Asker$3.class
mars/venus/MessagesPane$Asker$4.class
mars/venus/MessagesPane$Asker.class
mars/venus/MessagesPane.class
mars/venus/MessagesPane.java
mars/venus/MonoRightCellRenderer.class
mars/venus/MonoRightCellRenderer.java
mars/venus/NumberDisplayBaseChooser$1.class
mars/venus/NumberDisplayBaseChooser.class
mars/venus/NumberDisplayBaseChooser.java
mars/venus/PopupListener.class
mars/venus/PopupListener.java
mars/venus/RegistersPane.class
mars/venus/RegistersPane.java
mars/venus/RegistersWindow$MyTippedJTable$1.class
mars/venus/RegistersWindow$MyTippedJTable.class
mars/venus/RegistersWindow$RegisterCellRenderer.class
mars/venus/RegistersWindow$RegTableModel.class
mars/venus/RegistersWindow.class
mars/venus/RegistersWindow.java
mars/venus/RepeatButton.class
mars/venus/RepeatButton.java
mars/venus/RunAssembleAction.class
mars/venus/RunAssembleAction.java
mars/venus/RunBackstepAction.class
mars/venus/RunBackstepAction.java
mars/venus/RunClearBreakpointsAction.class
mars/venus/RunClearBreakpointsAction.java
mars/venus/RunGoAction.class
mars/venus/RunGoAction.java
mars/venus/RunPauseAction.class
mars/venus/RunPauseAction.java
mars/venus/RunResetAction.class
mars/venus/RunResetAction.java
mars/venus/RunSpeedPanel$1.class
mars/venus/RunSpeedPanel$RunSpeedListener.class
mars/venus/RunSpeedPanel.class
mars/venus/RunSpeedPanel.java
mars/venus/RunStepAction.class
mars/venus/RunStepAction.java
mars/venus/RunStopAction.class
mars/venus/RunStopAction.java
mars/venus/RunToggleBreakpointsAction.class
mars/venus/RunToggleBreakpointsAction.java
mars/venus/SettingsAddressDisplayBaseAction.class
mars/venus/SettingsAddressDisplayBaseAction.java
mars/venus/SettingsAssembleAllAction.class
mars/venus/SettingsAssembleAllAction.java
mars/venus/SettingsAssembleOnOpenAction.class
mars/venus/SettingsAssembleOnOpenAction.java
mars/venus/SettingsDelayedBranchingAction.class
mars/venus/SettingsDelayedBranchingAction.java
mars/venus/SettingsEditorAction$EditorFontDialog$1.class
mars/venus/SettingsEditorAction$EditorFontDialog$2.class
mars/venus/SettingsEditorAction$EditorFontDialog$3.class
mars/venus/SettingsEditorAction$EditorFontDialog$4.class
mars/venus/SettingsEditorAction$EditorFontDialog$5.class
mars/venus/SettingsEditorAction$EditorFontDialog$6.class
mars/venus/SettingsEditorAction$EditorFontDialog$7.class
mars/venus/SettingsEditorAction$EditorFontDialog$8.class
mars/venus/SettingsEditorAction$EditorFontDialog$9.class
mars/venus/SettingsEditorAction$EditorFontDialog$BoldItalicChanger.class
mars/venus/SettingsEditorAction$EditorFontDialog$DefaultChanger.class
mars/venus/SettingsEditorAction$EditorFontDialog$ForegroundChanger.class
mars/venus/SettingsEditorAction$EditorFontDialog.class
mars/venus/SettingsEditorAction.class
mars/venus/SettingsEditorAction.java
mars/venus/SettingsExceptionHandlerAction$1.class
mars/venus/SettingsExceptionHandlerAction$2.class
mars/venus/SettingsExceptionHandlerAction$3.class
mars/venus/SettingsExceptionHandlerAction$ExceptionHandlerSelectionAction.class
mars/venus/SettingsExceptionHandlerAction$ExceptionHandlerSettingAction.class
mars/venus/SettingsExceptionHandlerAction.class
mars/venus/SettingsExceptionHandlerAction.java
mars/venus/SettingsExtendedAction.class
mars/venus/SettingsExtendedAction.java
mars/venus/SettingsHighlightingAction$1.class
mars/venus/SettingsHighlightingAction$2.class
mars/venus/SettingsHighlightingAction$3.class
mars/venus/SettingsHighlightingAction$4.class
mars/venus/SettingsHighlightingAction$5.class
mars/venus/SettingsHighlightingAction$6.class
mars/venus/SettingsHighlightingAction$7.class
mars/venus/SettingsHighlightingAction$8.class
mars/venus/SettingsHighlightingAction$BackgroundChanger.class
mars/venus/SettingsHighlightingAction$DefaultChanger.class
mars/venus/SettingsHighlightingAction$FontChanger.class
mars/venus/SettingsHighlightingAction$FontSettingDialog$1.class
mars/venus/SettingsHighlightingAction$FontSettingDialog$2.class
mars/venus/SettingsHighlightingAction$FontSettingDialog$3.class
mars/venus/SettingsHighlightingAction$FontSettingDialog.class
mars/venus/SettingsHighlightingAction$ForegroundChanger.class
mars/venus/SettingsHighlightingAction.class
mars/venus/SettingsHighlightingAction.java
mars/venus/SettingsLabelAction.class
mars/venus/SettingsLabelAction.java
mars/venus/SettingsMemoryConfigurationAction$ConfigurationButton.class
mars/venus/SettingsMemoryConfigurationAction$MemoryConfigurationDialog$1.class
mars/venus/SettingsMemoryConfigurationAction$MemoryConfigurationDialog$2.class
mars/venus/SettingsMemoryConfigurationAction$MemoryConfigurationDialog$3.class
mars/venus/SettingsMemoryConfigurationAction$MemoryConfigurationDialog$4.class
mars/venus/SettingsMemoryConfigurationAction$MemoryConfigurationDialog$5.class
mars/venus/SettingsMemoryConfigurationAction$MemoryConfigurationDialog.class
mars/venus/SettingsMemoryConfigurationAction.class
mars/venus/SettingsMemoryConfigurationAction.java
mars/venus/SettingsPopupInputAction.class
mars/venus/SettingsPopupInputAction.java
mars/venus/SettingsProgramArgumentsAction.class
mars/venus/SettingsProgramArgumentsAction.java
mars/venus/SettingsSelfModifyingCodeAction.class
mars/venus/SettingsSelfModifyingCodeAction.java
mars/venus/SettingsStartAtMainAction.class
mars/venus/SettingsStartAtMainAction.java
mars/venus/SettingsValueDisplayBaseAction.class
mars/venus/SettingsValueDisplayBaseAction.java
mars/venus/SettingsWarningsAreErrorsAction.class
mars/venus/SettingsWarningsAreErrorsAction.java
mars/venus/TextSegmentWindow$1.class
mars/venus/TextSegmentWindow$CheckBoxTableCellRenderer.class
mars/venus/TextSegmentWindow$CodeCellRenderer.class
mars/venus/TextSegmentWindow$MachineCodeCellRenderer.class
mars/venus/TextSegmentWindow$ModifiedCode.class
mars/venus/TextSegmentWindow$MyTableColumnMovingListener.class
mars/venus/TextSegmentWindow$MyTippedJTable$TextTableHeader$TextTableHeaderMouseListener.class
mars/venus/TextSegmentWindow$MyTippedJTable$TextTableHeader.class
mars/venus/TextSegmentWindow$MyTippedJTable.class
mars/venus/TextSegmentWindow$TextTableModel.class
mars/venus/TextSegmentWindow.class
mars/venus/TextSegmentWindow.java
mars/venus/ToolAction.class
mars/venus/ToolAction.java
mars/venus/ToolLoader$MarsToolClassAndInstance.class
mars/venus/ToolLoader.class
mars/venus/ToolLoader.java
mars/venus/VenusUI$1.class
mars/venus/VenusUI$2.class
mars/venus/VenusUI.class
mars/venus/VenusUI.java
Manifest-Version: 1.0
Class-Path: .
Created-By: 1.8.0_101 (Oracle Corporation)
Main-Class: Mars
# Copyright (c) 2003-2010, Pete Sanderson and Kenneth Vollmar
#
# Developed by Pete Sanderson (psanderson@otterbein.edu)
# and Kenneth Vollmar (kenvollmar@missouristate.edu)
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# “Software”), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject
# to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# (MIT license, http://www.opensource.org/licenses/mit-license.html)
# File containing definitions of MIPS pseudo-ops
# File format:
# Each line contains specification for one pseudo-op, including optional description.
# First item is source statement syntax, specified in same “example” parser format used for regular instructions.
# Source statement specification ends with a tab. It is followed by a tab-separated list of basic instruction
# templates to complete and substitute for the pseudo-op.
# Format for specifying syntax of templates is different from specifying syntax of source statement:
# (n=0,1,2,3,…) is token position in source statement (operator is token 0, parentheses are tokens but commas aren’t)
# RGn means substitute register found in n’th token of source statement
# NRn means substitute next higher register than the one in n’th token of source code
# OPn means substitute n’th token of source code as is
# LLn means substitute low order 16-bits from label address in source token n.
# LLnU means substitute low order 16-bits (unsigned) from label address in source token n.
# LLnPm (m=1,2,3,4) means substitute low order 16-bits from label address in source token n, after adding m.
# LHn means substitute high order 16-bits from label address in source token n. Must add 1 if address bit 15 is 1.
# LHnPm (m=1,2,3,4) means substitute high order 16-bits from label address in source token n, after adding m. Must then add 1 if bit 15 is 1.
# VLn means substitute low order 16-bits from 32-bit value in source token n.
# VLnU means substitute low order 16-bits (unsigned) from 32-bit value in source token n.
# VLnPm (m=1,2,3,4) means substitute low order 16-bits from 32-bit value in source token n, after adding m to value.
# VLnPmU (m=1,2,3,4) means substitute low order 16-bits(unsigned) from 32-bit value in source token n, after adding m to value.
# VHLn means substitute high order 16-bits from 32-bit value in source token n. Use this if later combined with low order 16-bits using “ori $1,$1,VLnU”. See logical and branch operations.
# VHn means substitute high order 16-bits from 32-bit value in source token n, then add 1 if value’s bit 15 is 1. Use this only if later instruction uses VLn($1) to calculate 32-bit address. See loads and stores.
# VHLnPm (m=1,2,3,4) means substitute high order 16-bits from 32-bit value in source token n, after adding m. See VHLn.
# VHnPm (m=1,2,3,4) means substitute high order 16-bits from 32-bit value in source token n, after adding m. Must then add 1 if bit 15 is 1. See VHn.
# LLP is similar to LLn, but is needed for “label+100000” address offset. Immediate is added before taking low order 16.
# LLPU is similar to LLn, but is needed for “label+100000” address offset. Immediate is added before taking low order 16 (unsigned).
# LLPPm (m=1,2,3,4) is similar to LLP except m is added along with immediate before taking low order 16.
# LHPA is similar to LHn, but is needed for “label+100000” address offset. Immediate is added before taking high order 16.
# LHPN is similar to LHPA, used only by “la” instruction. Address resolved by “ori” so do not add 1 if bit 15 is 1.
# LHPAPm (m=1,2,3,4) is similar to LHPA except value m is added along with immediate before taking high order 16.
# LHL means substitute high order 16-bits from label address in token 2 of “la” (load address) source statement.
# LAB means substitute textual label from last token of source statement. Used for various branches.
# S32 means substitute the result of subtracting the constant value in last token from 32. Used by “ror”, “rol”.
# DBNOP means Delayed Branching NOP – generate a “nop” instruction but only if delayed branching is enabled. Added in 3.4.1 release.
# BROFFnm means substitute n if delayed branching is NOT enabled otherwise substitute m. n and m are single digit numbers indicating constant branch offset (in words). Added in 3.4.1 release.
# COMPACT is a marker to separate the default template from a second template optimized for 16-bit addresses. See loads and stores having (data) label operands.
# Everything else is copied as is into the generated statement (you must use register numbers not mnemonics)
# The list of basic instruction templates is optionally followed a description of the instruction for help purposes.
# To add optional description, append a tab then the ‘#’ character followed immediately (no spaces) by the description.
#
# See documentation for ExtendedInstruction.makeTemplateSubstitutions() for more details.
#
# Matching for a given instruction mnemonic is first-fit not best-fit. If an instruction has both 16 and 32-bit
# immediate operand options, they should be listed in that order (16-bit version first). Otherwise the 16-bit
# version will never be matched since the 32-bit version fits small immediate values first.
#
# The pseudo-op specification must start in the first column. If first column is blank, the line will be skipped!
#
# When specifying the example instruction (first item on line), the conventions I follow are:
# – for a register operand, specify a numbered register (e.g. $t1 or $f1) to represent any register in the set.
# The numerical value is not significant. This is NOT the case when writing the templates that follow!
# In the templates, numbered registers are parsed as is (use only $0 and $1, which are $zero and $at).
# – for an immediate operand, specify a positive value indicative of the expected range. I use 10 to represent
# a 5 bit value, 100 to represent a 16-bit value, and 100000 to represent a 32-bit value.
# – for a label operand, I use the string “label” (without the quotes).
# The idea is to give the parser an example that will be parsed into the desired token sequence. Syntax checking
# is done by comparing the source token sequence to list of token sequences generated from the examples.
# IMPORTANT NOTE: The use of $t1,$t2, etc in the instruction sample means that any CPU register reference
# can be used in that position. It is simply a placeholder. By contrast, when
# $1 is used in the template specification, $1 ($at) is literally placed into the generated
# instruction! If you want the generated code to echo the source register, use RG1,RG2, etc.
####################### arithmetic and branch pseudo-ops #####################
not $t1,$t2 nor RG1, RG2, $0 #Bitwise NOT (bit inversion)
# Here are some “convenience” arithmetic pseduo-ops. But do they encourage sloppy programming?
add $t1,$t2,-100 addi RG1, RG2, VL3 #ADDition : set $t1 to ($t2 plus 16-bit immediate)
add $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U add RG1, RG2, $1 #ADDition : set $t1 to ($t2 plus 32-bit immediate)
addu $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U addu RG1, RG2, $1 #ADDition Unsigned : set $t1 to ($t2 plus 32-bit immediate), no overflow
addi $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U add RG1, RG2, $1 #ADDition Immediate : set $t1 to ($t2 plus 32-bit immediate)
addiu $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U addu RG1, RG2, $1 #ADDition Immediate Unsigned: set $t1 to ($t2 plus 32-bit immediate), no overflow
sub $t1,$t2,-100 addi $1, $0, VL3 sub RG1, RG2, $1 #SUBtraction : set $t1 to ($t2 minus 16-bit immediate)
sub $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U sub RG1, RG2, $1 #SUBtraction : set $t1 to ($t2 minus 32-bit immediate)
subu $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U subu RG1, RG2, $1 #SUBtraction Unsigned : set $t1 to ($t2 minus 32-bit immediate), no overflow
subi $t1,$t2,-100 addi $1, $0, VL3 sub RG1, RG2, $1 #SUBtraction Immediate : set $t1 to ($t2 minus 16-bit immediate)
subi $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U sub RG1, RG2, $1 #SUBtraction Immediate : set $t1 to ($t2 minus 32-bit immediate)
subiu $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U subu RG1, RG2, $1 #SUBtraction Immediate Unsigned : set $t1 to ($t2 minus 32-bit immediate), no overflow
# feel free to add more convenience arithmetic pseduo-ops.
# convenience logical operations can be added too,
andi $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U and RG1, RG2, $1 #AND Immediate : set $t1 to ($t2 bitwise-AND 32-bit immediate)
ori $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U or RG1, RG2, $1 #OR Immediate : set $t1 to ($t2 bitwise-OR 32-bit immediate)
xori $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U xor RG1, RG2, $1 #XOR Immediate : set $t1 to ($t2 bitwise-exclusive-OR 32-bit immediate)
and $t1,$t2,100 andi RG1, RG2, VL3U #AND : set $t1 to ($t2 bitwise-AND 16-bit unsigned immediate)
or $t1,$t2,100 ori RG1, RG2, VL3U #OR : set $t1 to ($t2 bitwise-OR 16-bit unsigned immediate)
xor $t1,$t2,100 xori RG1, RG2, VL3U #XOR : set $t1 to ($t2 bitwise-exclusive-OR 16-bit unsigned immediate)
and $t1,100 andi RG1, RG1, VL2U #AND : set $t1 to ($t1 bitwise-AND 16-bit unsigned immediate)
or $t1,100 ori RG1, RG1, VL2U #OR : set $t1 to ($t1 bitwise-OR 16-bit unsigned immediate)
xor $t1,100 xori RG1, RG1, VL2U #XOR : set $t1 to ($t1 bitwise-exclusive-OR 16-bit unsigned immediate)
andi $t1,100 andi RG1, RG1, VL2U #AND Immediate : set $t1 to ($t1 bitwise-AND 16-bit unsigned immediate)
ori $t1,100 ori RG1, RG1, VL2U #OR Immediate : set $t1 to ($t1 bitwise-OR 16-bit unsigned immediate)
xori $t1,100 xori RG1, RG1, VL2U #XOR Immediate : set $t1 to ($t1 bitwise-exclusive-OR 16-bit unsigned immediate)
andi $t1,100000 lui $1, VHL2 ori $1, $1, VL2U and RG1, RG1, $1 #AND Immediate : set $t1 to ($t1 bitwise-AND 32-bit immediate)
ori $t1,100000 lui $1, VHL2 ori $1, $1, VL2U or RG1, RG1, $1 #OR Immediate : set $t1 to ($t1 bitwise-OR 32-bit immediate)
xori $t1,100000 lui $1, VHL2 ori $1, $1, VL2U xor RG1, RG1, $1 #XOR Immediate : set $t1 to ($t1 bitwise-exclusive-OR 32-bit immediate)
# Note: most of the expansions in this group were rewritten for Release 3.4.1 to remove internal branching.
seq $t1,$t2,$t3 subu RG1, RG2, RG3 ori $1, $0, 1 sltu RG1, RG1, $1 #Set EQual : if $t2 equal to $t3 then set $t1 to 1 else 0
seq $t1,$t2,-100 addi $1, $0, VL3 subu RG1, RG2, $1 ori $1, $0, 1 sltu RG1, RG1, $1 #Set EQual : if $t2 equal to 16-bit immediate then set $t1 to 1 else 0
seq $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U subu RG1, RG2, $1 ori $1, $0, 1 sltu RG1, RG1, $1 #Set EQual : if $t2 equal to 32-bit immediate then set $t1 to 1 else 0
sne $t1,$t2,$t3 subu RG1, RG2, RG3 sltu RG1, $0, RG1 #Set Not Equal : if $t2 not equal to $t3 then set $t1 to 1 else 0
sne $t1,$t2,-100 addi $1, $0, VL3 subu RG1, RG2, $1 sltu RG1, $0, RG1 #Set Not Equal : if $t2 not equal to 16-bit immediate then set $t1 to 1 else 0
sne $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U subu RG1, RG2, $1 sltu RG1, $0, RG1 #Set Not Equal : if $t2 not equal to 32-bit immediate then set $t1 to 1 else 0
sge $t1,$t2,$t3 slt RG1, RG2, RG3 ori $1, $0, 1 subu RG1, $1, RG1 #Set Greater or Equal : if $t2 greater or equal to $t3 then set $t1 to 1 else 0
sge $t1,$t2,-100 addi $1, $0, VL3 slt RG1, RG2, $1 ori $1, $0, 1 subu RG1, $1, RG1 #Set Greater or Equal : if $t2 greater or equal to 16-bit immediate then set $t1 to 1 else 0
sge $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U slt RG1, RG2, $1 ori $1, $0, 1 subu RG1, $1, RG1 #Set Greater or Equal : if $t2 greater or equal to 32-bit immediate then set $t1 to 1 else 0
sgeu $t1,$t2,$t3 sltu RG1, RG2, RG3 ori $1, $0, 1 subu RG1, $1, RG1 #Set Greater or Equal Unsigned : if $t2 greater or equal to $t3 (unsigned compare) then set $t1 to 1 else 0
sgeu $t1,$t2,-100 addi $1, $0, VL3 sltu RG1, RG2, $1 ori $1, $0, 1 subu RG1, $1, RG1 #Set Greater or Equal Unsigned : if $t2 greater or equal to 16-bit immediate (unsigned compare) then set $t1 to 1 else 0
sgeu $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U sltu RG1, RG2, $1 ori $1, $0, 1 subu RG1, $1, RG1 #Set Greater or Equal Unsigned : if $t2 greater or equal to 32-bit immediate (unsigned compare) then set $t1 to 1 else 0
sgt $t1,$t2,$t3 slt RG1, RG3, RG2 #Set Greater Than : if $t2 greater than $t3 then set $t1 to 1 else 0
sgt $t1,$t2,-100 addi $1, $0, VL3 slt RG1, $1, RG2 #Set Greater Than : if $t2 greater than 16-bit immediate then set $t1 to 1 else 0
sgt $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U slt RG1, $1, RG2 #Set Greater Than : if $t2 greater than 32-bit immediate then set $t1 to 1 else 0
sgtu $t1,$t2,$t3 sltu RG1, RG3, RG2 #Set Greater Than Unsigned : if $t2 greater than $t3 (unsigned compare) then set $t1 to 1 else 0
sgtu $t1,$t2,-100 addi $1, $0, VL3 sltu RG1, $1, RG2 #Set Greater Than Unsigned : if $t2 greater than 16-bit immediate (unsigned compare) then set $t1 to 1 else 0
sgtu $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U sltu RG1, $1, RG2 #Set Greater Than Unsigned : if $t2 greater than 32-bit immediate (unsigned compare) then set $t1 to 1 else 0
sle $t1,$t2,$t3 slt RG1, RG3, RG2 ori $1, $0, 1 subu RG1, $1, RG1 #Set Less or Equal : if $t2 less or equal to $t3 then set $t1 to 1 else 0
sle $t1,$t2,-100 addi $1, $0, VL3 slt RG1, $1, RG2 ori $1, $0, 1 subu RG1, $1, RG1 #Set Less or Equal : if $t2 less or equal to 16-bit immediate then set $t1 to 1 else 0
sle $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U slt RG1, $1, RG2 ori $1, $0, 1 subu RG1, $1, RG1 #Set Less or Equal : if $t2 less or equal to 32-bit immediate then set $t1 to 1 else 0
sleu $t1,$t2,$t3 sltu RG1, RG3, RG2 ori $1, $0, 1 subu RG1, $1, RG1 #Set Less or Equal Unsigned: if $t2 less or equal to $t3 (unsigned compare) then set $t1 to 1 else 0
sleu $t1,$t2,-100 addi $1, $0, VL3 sltu RG1, $1, RG2 ori $1, $0, 1 subu RG1, $1, RG1 #Set Less or Equal Unsigned: if $t2 less or equal to 16-bit immediate (unsigned compare) then set $t1 to 1 else 0
sleu $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U sltu RG1, $1, RG2 ori $1, $0, 1 subu RG1, $1, RG1 #Set Less or Equal Unsigned: if $t2 less or equal to 32-bit immediate (unsigned compare) then set $t1 to 1 else 0
move $t1,$t2 addu RG1, $0, RG2 #MOVE : Set $t1 to contents of $t2
abs $t1,$t2 sra $1, RG2, 31 xor RG1, $1, RG2 subu RG1, RG1, $1 #ABSolute value : Set $t1 to absolute value of $t2 (algorithm from Hacker’s Delight)
neg $t1,$t2 sub RG1, $0, RG2 #NEGate : Set $t1 to negation of $t2
negu $t1,$t2 subu RG1, $0, RG2 #NEGate Unsigned : Set $t1 to negation of $t2, no overflow
b label bgez $0, LAB #Branch : Branch to statement at label unconditionally
beqz $t1,label beq RG1, $0, LAB #Branch if EQual Zero : Branch to statement at label if $t1 is equal to zero
bnez $t1,label bne RG1, $0, LAB #Branch if Not Equal Zero : Branch to statement at label if $t1 is not equal to zero
beq $t1,-100,label addi $1, $0, VL2 beq $1, RG1, LAB #Branch if EQual : Branch to statement at label if $t1 is equal to 16-bit immediate
beq $t1,100000,label lui $1, VHL2 ori $1, $1, VL2U beq $1, RG1, LAB #Branch if EQual : Branch to statement at label if $t1 is equal to 32-bit immediate
bne $t1,-100,label addi $1, $0, VL2 bne $1, RG1, LAB #Branch if Not Equal : Branch to statement at label if $t1 is not equal to 16-bit immediate
bne $t1,100000,label lui $1, VHL2 ori $1, $1, VL2U bne $1, RG1, LAB #Branch if Not Equal : Branch to statement at label if $t1 is not equal to 32-bit immediate
bge $t1,$t2,label slt $1, RG1, RG2 beq $1, $0, LAB #Branch if Greater or Equal : Branch to statement at label if $t1 is greater or equal to $t2
bge $t1,-100,label slti $1, RG1, VL2 beq $1, $0, LAB #Branch if Greater or Equal : Branch to statement at label if $t1 is greater or equal to 16-bit immediate
bge $t1,100000,label lui $1, VHL2 ori $1, $1, VL2U slt $1, RG1, $1 beq $1, $0, LAB #Branch if Greater or Equal : Branch to statement at label if $t1 is greater or equal to 32-bit immediate
bgeu $t1,$t2,label sltu $1, RG1, RG2 beq $1, $0, LAB #Branch if Greater or Equal Unsigned : Branch to statement at label if $t1 is greater or equal to $t2 (unsigned compare)
bgeu $t1,-100,label sltiu $1, RG1, VL2 beq $1, $0, LAB #Branch if Greater or Equal Unsigned : Branch to statement at label if $t1 is greater or equal to 16-bit immediate (unsigned compare)
bgeu $t1,100000,label lui $1, VHL2 ori $1, $1, VL2U sltu $1, RG1, $1 beq $1, $0, LAB #Branch if Greater or Equal Unsigned : Branch to statement at label if $t1 is greater or equal to 32-bit immediate (unsigned compare)
bgt $t1,$t2,label slt $1, RG2, RG1 bne $1, $0, LAB #Branch if Greater Than : Branch to statement at label if $t1 is greater than $t2
bgt $t1,-100,label addi $1, $0, VL2 slt $1, $1, RG1 bne $1, $0, LAB #Branch if Greater Than : Branch to statement at label if $t1 is greater than 16-bit immediate
bgt $t1,100000,label lui $1, VHL2P1 ori $1, $1, VL2P1U slt $1, RG1, $1 beq $1, $0, LAB #Branch if Greater Than : Branch to statement at label if $t1 is greater than 32-bit immediate
bgtu $t1,$t2,label sltu $1, RG2, RG1 bne $1, $0, LAB #Branch if Greater Than Unsigned: Branch to statement at label if $t1 is greater than $t2 (unsigned compare)
bgtu $t1,-100,label addi $1, $0, VL2 sltu $1, $1, RG1 bne $1, $0, LAB #Branch if Greater Than Unsigned: Branch to statement at label if $t1 is greater than 16-bit immediate (unsigned compare)
bgtu $t1,100000,label lui $1, VHL2 ori $1, $1, VL2U sltu $1, $1, RG1 bne $1, $0, LAB #Branch if Greater Than Unsigned: Branch to statement at label if $t1 is greater than 16-bit immediate (unsigned compare)
ble $t1,$t2,label slt $1, RG2, RG1 beq $1, $0, LAB #Branch if Less or Equal : Branch to statement at label if $t1 is less than or equal to $t2
ble $t1,-100,label addi $1, RG1, -1 slti $1, $1, VL2 bne $1, $0, LAB #Branch if Less or Equal : Branch to statement at label if $t1 is less than or equal to 16-bit immediate
ble $t1,100000,label lui $1, VHL2P1 ori $1, $1, VL2P1U slt $1, RG1, $1 bne $1, $0, LAB #Branch if Less or Equal : Branch to statement at label if $t1 is less than or equal to 32-bit immediate
bleu $t1,$t2,label sltu $1, RG2, RG1 beq $1, $0, LAB #Branch if Less or Equal Unsigned : Branch to statement at label if $t1 is less than or equal to $t2 (unsigned compare)
bleu $t1,-100,label addi $1, $0, VL2 sltu $1, $1, RG1 beq $1, $0, LAB #Branch if Less or Equal Unsigned : Branch to statement at label if $t1 is less than or equal to 16-bit immediate (unsigned compare)
bleu $t1,100000,label lui $1, VHL2 ori $1, $1, VL2U sltu $1, $1, RG1 beq $1, $0, LAB #Branch if Less or Equal Unsigned : Branch to statement at label if $t1 is less than or equal to 32-bit immediate (unsigned compare)
blt $t1,$t2,label slt $1, RG1, RG2 bne $1, $0, LAB #Branch if Less Than : Branch to statement at label if $t1 is less than $t2
blt $t1,-100,label slti $1, RG1, VL2 bne $1, $0, LAB #Branch if Less Than : Branch to statement at label if $t1 is less than 16-bit immediate
blt $t1,100000,label lui $1, VHL2 ori $1, $1, VL2U slt $1, RG1, $1 bne $1, $0, LAB #Branch if Less Than : Branch to statement at label if $t1 is less than 32-bit immediate
bltu $t1,$t2,label sltu $1, RG1, RG2 bne $1, $0, LAB #Branch if Less Than Unsigned : Branch to statement at label if $t1 is less than $t2
bltu $t1,-100,label sltiu $1, RG1, VL2 bne $1, $0, LAB #Branch if Less Than Unsigned : Branch to statement at label if $t1 is less than 16-bit immediate
bltu $t1,100000,label lui $1, VHL2 ori $1, $1, VL2U sltu $1, RG1, $1 bne $1, $0, LAB #Branch if Less Than Unsigned : Branch to statement at label if $t1 is less than 32-bit immediate
rol $t1,$t2,$t3 subu $1, $0, RG3 srlv $1, RG2, $1 sllv RG1, RG2, RG3 or RG1, RG1, $1 #ROtate Left : Set $t1 to ($t2 rotated left by number of bit positions specified in $t3)
rol $t1,$t2,10 srl $1, RG2, S32 sll RG1, RG2, OP3 or RG1, RG1, $1 #ROtate Left : Set $t1 to ($t2 rotated left by number of bit positions specified in 5-bit immediate)
ror $t1,$t2,$t3 subu $1, $0, RG3 sllv $1, RG2, $1 srlv RG1, RG2, RG3 or RG1, RG1, $1 #ROtate Right : Set $t1 to ($t2 rotated right by number of bit positions specified in $t3)
ror $t1,$t2,10 sll $1, RG2, S32 srl RG1, RG2, OP3 or RG1, RG1, $1 #ROtate Right : Set $t1 to ($t2 rotated right by number of bit positions specified in 5-bit immediate)
mfc1.d $t1,$f2 mfc1 RG1, RG2 mfc1 NR1, NR2 #Move From Coprocessor 1 Double : Set $t1 to contents of $f2, set next higher register from $t1 to contents of next higher register from $f2
mtc1.d $t1,$f2 mtc1 RG1, RG2 mtc1 NR1, NR2 #Move To Coprocessor 1 Double : Set $f2 to contents of $t1, set next higher register from $f2 to contents of next higher register from $t1
mul $t1,$t2,-100 addi $1, $0, VL3 mul RG1, RG2, $1 #MULtiplication : Set HI to high-order 32 bits, LO and $t1 to low-order 32 bits of the product of $t2 and 16-bit signed immediate (use mfhi to access HI, mflo to access LO)
mul $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U mul RG1, RG2, $1 #MULtiplication : Set HI to high-order 32 bits, LO and $t1 to low-order 32 bits of the product of $t2 and 32-bit immediate (use mfhi to access HI, mflo to access LO)
mulu $t1,$t2,$t3 multu RG2, RG3 mflo RG1 #MULtiplication Unsigned : Set HI to high-order 32 bits, LO and $t1 to low-order 32 bits of ($t2 multiplied by $t3, unsigned multiplication)
mulu $t1,$t2,-100 addi $1, $0, VL3 multu RG2, $1 mflo RG1 #MULtiplication Unsigned : Set HI to high-order 32 bits, LO and $t1 to low-order 32 bits of ($t2 multiplied by 16-bit immediate, unsigned multiplication)
mulu $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U multu RG2, $1 mflo RG1 #MULtiplication Unsigned : Set HI to high-order 32 bits, LO and $t1 to low-order 32 bits of ($t2 multiplied by 32-bit immediate, unsigned multiplication)
mulo $t1,$t2,$t3 mult RG2, RG3 mfhi $1 mflo RG1 sra RG1, RG1, 31 beq $1, RG1, BROFF12 DBNOP break mflo RG1 #MULtiplication with Overflow : Set $t1 to low-order 32 bits of the product of $t2 and $t3
mulo $t1,$t2,-100 addi $1, $0, VL3 mult RG2, $1 mfhi $1 mflo RG1 sra RG1, RG1, 31 beq $1, RG1, BROFF12 DBNOP break mflo RG1 #MULtiplication with Overflow : Set $t1 to low-order 32 bits of the product of $t2 and signed 16-bit immediate
mulo $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U mult RG2, $1 mfhi $1 mflo RG1 sra RG1, RG1, 31 beq $1, RG1, BROFF12 DBNOP break mflo RG1 #MULtiplication with Overflow : Set $t1 to low-order 32 bits of the product of $t2 and 32-bit immediate
mulou $t1,$t2,$t3 multu RG2, RG3 mfhi $1 beq $1,$0, BROFF12 DBNOP break mflo RG1 #MULtiplication with Overflow Unsigned : Set $t1 to low-order 32 bits of the product of $t2 and $t3
mulou $t1,$t2,-100 addi $1, $0, VL3 multu RG2, $1 mfhi $1 beq $1,$0, BROFF12 DBNOP break mflo RG1 #MULtiplication with Overflow Unsigned : Set $t1 to low-order 32 bits of the product of $t2 and signed 16-bit immediate
mulou $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U multu RG2, $1 mfhi $1 beq $1,$0, BROFF12 DBNOP break mflo RG1 #MULtiplication with Overflow Unsigned : Set $t1 to low-order 32 bits of the product of $t2 and 32-bit immediate
div $t1,$t2,$t3 bne RG3, $0, BROFF12 DBNOP break div RG2, RG3 mflo RG1 #DIVision : Set $t1 to ($t2 divided by $t3, integer division)
div $t1,$t2,-100 addi $1, $0, VL3 div RG2, $1 mflo RG1 #DIVision : Set $t1 to ($t2 divided by 16-bit immediate, integer division)
div $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U div RG2, $1 mflo RG1 #DIVision : Set $t1 to ($t2 divided by 32-bit immediate, integer division)
divu $t1,$t2,$t3 bne RG3, $0, BROFF12 DBNOP break divu RG2, RG3 mflo RG1 #DIVision Unsigned : Set $t1 to ($t2 divided by $t3, unsigned integer division)
divu $t1,$t2,-100 addi $1, $0, VL3 divu RG2, $1 mflo RG1 #DIVision Unsigned : Set $t1 to ($t2 divided by 16-bit immediate, unsigned integer division)
divu $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U divu RG2, $1 mflo RG1 #DIVision Unsigned : Set $t1 to ($t2 divided by 32-bit immediate, unsigned integer division)
rem $t1,$t2,$t3 bne RG3, $0, BROFF12 DBNOP break div RG2, RG3 mfhi RG1 #REMainder : Set $t1 to (remainder of $t2 divided by $t3)
rem $t1,$t2,-100 addi $1, $0, VL3 div RG2, $1 mfhi RG1 #REMainder : Set $t1 to (remainder of $t2 divided by 16-bit immediate)
rem $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U div RG2, $1 mfhi RG1 #REMainder : Set $t1 to (remainder of $t2 divided by 32-bit immediate)
remu $t1,$t2,$t3 bne RG3, $0, BROFF12 DBNOP break divu RG2, RG3 mfhi RG1 #REMainder : Set $t1 to (remainder of $t2 divided by $t3, unsigned division)
remu $t1,$t2,-100 addi $1, $0, VL3 divu RG2, $1 mfhi RG1 #REMainder : Set $t1 to (remainder of $t2 divided by 16-bit immediate, unsigned division)
remu $t1,$t2,100000 lui $1, VHL3 ori $1, $1, VL3U divu RG2, $1 mfhi RG1 #REMainder : Set $t1 to (remainder of $t2 divided by 32-bit immediate, unsigned division)
######################### load/store pseudo-ops start here ##########################
#
# Most of these simply provide a variety of convenient memory addressing modes for
# specifying load/store address.
#
li $t1,-100 addiu RG1, $0, VL2 #Load Immediate : Set $t1 to 16-bit immediate (sign-extended)
li $t1,100 ori RG1, $0, VL2U #Load Immediate : Set $t1 to unsigned 16-bit immediate (zero-extended)
li $t1,100000 lui $1, VHL2 ori RG1, $1, VL2U #Load Immediate : Set $t1 to 32-bit immediate
la $t1,($t2) addi RG1, RG3, 0 #Load Address : Set $t1 to contents of $t2
la $t1,-100 addiu RG1, $0, VL2 #Load Address : Set $t1 to 16-bit immediate (sign-extended)
la $t1,100 ori RG1, $0, VL2U #Load Address : Set $t1 to 16-bit immediate (zero-extended)
la $t1,100000 lui $1, VHL2 ori RG1, $1, VL2U #Load Address : Set $t1 to 32-bit immediate
la $t1,100($t2) ori $1, $0, VL2U add RG1, RG4, $1 #Load Address : Set $t1 to sum (of $t2 and 16-bit immediate)
la $t1,100000($t2) lui $1, VHL2 ori $1, $1, VL2U add RG1, RG4, $1 #Load Address : Set $t1 to sum (of $t2 and 32-bit immediate)
la $t1,label lui $1, LHL ori RG1, $1, LL2U COMPACT addi RG1, $0, LL2 #Load Address : Set $t1 to label’s address
la $t1,label($t2) lui $1, LHL ori $1, $1, LL2U add RG1, RG4, $1 COMPACT addi RG1, RG4, LL2 #Load Address : Set $t1 to sum (of $t2 and label’s address)
la $t1,label+100000 lui $1, LHPN ori RG1, $1, LLPU #Load Address : Set $t1 to sum (of label’s address and 32-bit immediate)
la $t1,label+100000($t2) lui $1, LHPN ori $1, $1, LLPU add RG1, RG6, $1 #Load Address : Set $t1 to sum (of label’s address, 32-bit immediate, and $t2)
lw $t1,($t2) lw RG1,0(RG3) #Load Word : Set $t1 to contents of effective memory word address
lw $t1,-100 lw RG1, VL2($0) #Load Word : Set $t1 to contents of effective memory word address
lw $t1,100 ori $1, $0, VL2U lw RG1, 0($1) #Load Word : Set $t1 to contents of effective memory word address
lw $t1,100000 lui $1, VH2 lw RG1,VL2($1) #Load Word : Set $t1 to contents of effective memory word address
lw $t1,100($t2) ori $1, $0, VL2U addu $1, $1, RG4 lw RG1, 0($1) #Load Word : Set $t1 to contents of effective memory word address
lw $t1,100000($t2) lui $1, VH2 addu $1, $1, RG4 lw RG1, VL2($1) #Load Word : Set $t1 to contents of effective memory word address
lw $t1,label lui $1, LH2 lw RG1, LL2($1) COMPACT lw RG1, LL2($0) #Load Word : Set $t1 to contents of memory word at label’s address
lw $t1,label($t2) lui $1, LH2 addu $1, $1, RG4 lw RG1, LL2($1) COMPACT lw RG1, LL2(RG4) #Load Word : Set $t1 to contents of effective memory word address
lw $t1,label+100000 lui $1, LHPA lw RG1, LLP($1) #Load Word : Set $t1 to contents of effective memory word address
lw $t1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 lw RG1, LLP($1) #Load Word : Set $t1 to contents of effective memory word address
sw $t1,($t2) sw RG1,0(RG3) #Store Word : Store $t1 contents into effective memory word address
sw $t1,-100 sw RG1, VL2($0) #Store Word : Store $t1 contents into effective memory word address
sw $t1,100 ori $1, $0, VL2U sw RG1, 0($1) #Store Word : Store $t1 contents into effective memory word address
sw $t1,100000 lui $1, VH2 sw RG1,VL2($1) #Store Word : Store $t1 contents into effective memory word address
sw $t1,100($t2) ori $1, $0, VL2U addu $1, $1, RG4 sw RG1, 0($1) #Store Word : Store $t1 contents into effective memory word address
sw $t1,100000($t2) lui $1, VH2 addu $1, $1, RG4 sw RG1, VL2($1) #Store Word : Store $t1 contents into effective memory word address
sw $t1,label lui $1, LH2 sw RG1, LL2($1) COMPACT sw RG1, LL2($0) #Store Word : Store $t1 contents into memory word at label’s address
sw $t1,label($t2) lui $1, LH2 addu $1, $1, RG4 sw RG1, LL2($1) COMPACT sw RG1, LL2(RG4) #Store Word : Store $t1 contents into effective memory word address
sw $t1,label+100000 lui $1, LHPA sw RG1, LLP($1) #Store Word : Store $t1 contents into effective memory word address
sw $t1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 sw RG1, LLP($1) #Store Word : Store $t1 contents into effective memory word address
lh $t1,($t2) lh RG1,0(RG3) #Load Halfword : Set $t1 to sign-extended 16-bit value from effective memory halfword address
lh $t1,-100 lh RG1, VL2($0) #Load Halfword : Set $t1 to sign-extended 16-bit value from effective memory halfword address
lh $t1,100 ori $1, $0, VL2U lh RG1, 0($1) #Load Halfword : Set $t1 to sign-extended 16-bit value from effective memory halfword address
lh $t1,100000 lui $1, VH2 lh RG1,VL2($1) #Load Halfword : Set $t1 to sign-extended 16-bit value from effective memory halfword address
lh $t1,100($t2) ori $1, $0, VL2U addu $1, $1, RG4 lh RG1, 0($1) #Load Halfword : Set $t1 to sign-extended 16-bit value from effective memory halfword address
lh $t1,100000($t2) lui $1, VH2 addu $1, $1, RG4 lh RG1, VL2($1) #Load Halfword : Set $t1 to sign-extended 16-bit value from effective memory halfword address
lh $t1,label lui $1, LH2 lh RG1, LL2($1) COMPACT lh RG1, LL2($0) #Load Halfword : Set $t1 to sign-extended 16-bit value from effective memory halfword address
lh $t1,label($t2) lui $1, LH2 addu $1, $1, RG4 lh RG1, LL2($1) COMPACT lh RG1, LL2(RG4) #Load Halfword : Set $t1 to sign-extended 16-bit value from effective memory halfword address
lh $t1,label+100000 lui $1, LHPA lh RG1, LLP($1) #Load Halfword : Set $t1 to sign-extended 16-bit value from effective memory halfword address
lh $t1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 lh RG1, LLP($1) #Load Halfword : Set $t1 to sign-extended 16-bit value from effective memory halfword address
sh $t1,($t2) sh RG1,0(RG3) #Store Halfword : Store the low-order 16 bits of $t1 into the effective memory halfword address
sh $t1,-100 sh RG1, VL2($0) #Store Halfword : Store the low-order 16 bits of $t1 into the effective memory halfword address
sh $t1,100 ori $1, $0, VL2U sh RG1, 0($1) #Store Halfword : Store the low-order 16 bits of $t1 into the effective memory halfword address
sh $t1,100000 lui $1, VH2 sh RG1,VL2($1) #Store Halfword : Store the low-order 16 bits of $t1 into the effective memory halfword address
sh $t1,100($t2) ori $1, $0, VL2U addu $1, $1, RG4 sh RG1, 0($1) #Store Halfword : Store the low-order 16 bits of $t1 into the effective memory halfword address
sh $t1,100000($t2) lui $1, VH2 addu $1, $1, RG4 sh RG1, VL2($1) #Store Halfword : Store the low-order 16 bits of $t1 into the effective memory halfword address
sh $t1,label lui $1, LH2 sh RG1, LL2($1) COMPACT sh RG1, LL2($0) #Store Halfword : Store the low-order 16 bits of $t1 into the effective memory halfword address
sh $t1,label($t2) lui $1, LH2 addu $1, $1, RG4 sh RG1, LL2($1) COMPACT sh RG1, LL2(RG4) #Store Halfword : Store the low-order 16 bits of $t1 into the effective memory halfword address
sh $t1,label+100000 lui $1, LHPA sh RG1, LLP($1) #Store Halfword : Store the low-order 16 bits of $t1 into the effective memory halfword address
sh $t1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 sh RG1, LLP($1) #Store Halfword : Store the low-order 16 bits of $t1 into the effective memory halfword address
lb $t1,($t2) lb RG1,0(RG3) #Load Byte : Set $t1 to sign-extended 8-bit value from effective memory byte address
lb $t1,-100 lb RG1, VL2($0) #Load Byte : Set $t1 to sign-extended 8-bit value from effective memory byte address
lb $t1,100 ori $1, $0, VL2U lb RG1, 0($1) #Load Byte : Set $t1 to sign-extended 8-bit value from effective memory byte address
lb $t1,100000 lui $1, VH2 lb RG1,VL2($1) #Load Byte : Set $t1 to sign-extended 8-bit value from effective memory byte address
lb $t1,100($t2) ori $1, $0, VL2U addu $1, $1, RG4 lb RG1, 0($1) #Load Byte : Set $t1 to sign-extended 8-bit value from effective memory byte address
lb $t1,100000($t2) lui $1, VH2 addu $1, $1, RG4 lb RG1, VL2($1) #Load Byte : Set $t1 to sign-extended 8-bit value from effective memory byte address
lb $t1,label lui $1, LH2 lb RG1, LL2($1) COMPACT lb RG1, LL2($0) #Load Byte : Set $t1 to sign-extended 8-bit value from effective memory byte address
lb $t1,label($t2) lui $1, LH2 addu $1, $1, RG4 lb RG1, LL2($1) COMPACT lb RG1, LL2(RG4) #Load Byte : Set $t1 to sign-extended 8-bit value from effective memory byte address
lb $t1,label+100000 lui $1, LHPA lb RG1, LLP($1) #Load Byte : Set $t1 to sign-extended 8-bit value from effective memory byte address
lb $t1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 lb RG1, LLP($1) #Load Byte : Set $t1 to sign-extended 8-bit value from effective memory byte address
sb $t1,($t2) sb RG1,0(RG3) #Store Byte : Store the low-order 8 bits of $t1 into the effective memory byte address
sb $t1,-100 sb RG1, VL2($0) #Store Byte : Store the low-order 8 bits of $t1 into the effective memory byte address
sb $t1,100 ori $1, $0, VL2U sb RG1, 0($1) #Store Byte : Store the low-order 8 bits of $t1 into the effective memory byte address
sb $t1,100000 lui $1, VH2 sb RG1,VL2($1) #Store Byte : Store the low-order 8 bits of $t1 into the effective memory byte address
sb $t1,100($t2) ori $1, $0, VL2U addu $1, $1, RG4 sb RG1, 0($1) #Store Byte : Store the low-order 8 bits of $t1 into the effective memory byte address
sb $t1,100000($t2) lui $1, VH2 addu $1, $1, RG4 sb RG1, VL2($1) #Store Byte : Store the low-order 8 bits of $t1 into the effective memory byte address
sb $t1,label lui $1, LH2 sb RG1, LL2($1) COMPACT sb RG1, LL2($0) #Store Byte : Store the low-order 8 bits of $t1 into the effective memory byte address
sb $t1,label($t2) lui $1, LH2 addu $1, $1, RG4 sb RG1, LL2($1) COMPACT sb RG1, LL2(RG4) #Store Byte : Store the low-order 8 bits of $t1 into the effective memory byte address
sb $t1,label+100000 lui $1, LHPA sb RG1, LLP($1) #Store Byte : Store the low-order 8 bits of $t1 into the effective memory byte address
sb $t1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 sb RG1, LLP($1) #Store Byte : Store the low-order 8 bits of $t1 into the effective memory byte address
lhu $t1,($t2) lhu RG1,0(RG3) #Load Halfword Unsigned : Set $t1 to zero-extended 16-bit value from effective memory halfword address
lhu $t1,-100 lhu RG1,VL2($0) #Load Halfword Unsigned : Set $t1 to zero-extended 16-bit value from effective memory halfword address
lhu $t1,100 ori $1, $0, VL2U lhu RG1, 0($1) #Load Halfword Unsigned : Set $t1 to zero-extended 16-bit value from effective memory halfword address
lhu $t1,100000 lui $1, VH2 lhu RG1,VL2($1) #Load Halfword Unsigned : Set $t1 to zero-extended 16-bit value from effective memory halfword address
lhu $t1,100($t2) ori $1, $0, VL2U addu $1, $1, RG4 lhu RG1, 0($1) #Load Halfword Unsigned : Set $t1 to zero-extended 16-bit value from effective memory halfword address
lhu $t1,100000($t2) lui $1, VH2 addu $1, $1, RG4 lhu RG1, VL2($1) #Load Halfword Unsigned : Set $t1 to zero-extended 16-bit value from effective memory halfword address
lhu $t1,label lui $1, LH2 lhu RG1, LL2($1) COMPACT lhu RG1, LL2($0) #Load Halfword Unsigned : Set $t1 to zero-extended 16-bit value from effective memory halfword address
lhu $t1,label($t2) lui $1, LH2 addu $1, $1, RG4 lhu RG1, LL2($1) COMPACT lhu RG1, LL2(RG4) #Load Halfword Unsigned : Set $t1 to zero-extended 16-bit value from effective memory halfword address
lhu $t1,label+100000 lui $1, LHPA lhu RG1, LLP($1) #Load Halfword Unsigned : Set $t1 to zero-extended 16-bit value from effective memory halfword address
lhu $t1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 lhu RG1, LLP($1) #Load Halfword Unsigned : Set $t1 to zero-extended 16-bit value from effective memory halfword address
lbu $t1,($t2) lbu RG1,0(RG3) #Load Byte Unsigned : Set $t1 to zero-extended 8-bit value from effective memory byte address
lbu $t1,-100 lbu RG1,VL2($0) #Load Byte Unsigned : Set $t1 to zero-extended 8-bit value from effective memory byte address
lbu $t1,100 ori $1, $0, VL2U lbu RG1, 0($1) #Load Byte Unsigned : Set $t1 to zero-extended 8-bit value from effective memory byte address
lbu $t1,100000 lui $1, VH2 lbu RG1,VL2($1) #Load Byte Unsigned : Set $t1 to zero-extended 8-bit value from effective memory byte address
lbu $t1,100($t2) ori $1, $0, VL2U addu $1, $1, RG4 lbu RG1, 0($1) #Load Byte Unsigned : Set $t1 to zero-extended 8-bit value from effective memory byte address
lbu $t1,100000($t2) lui $1, VH2 addu $1, $1, RG4 lbu RG1, VL2($1) #Load Byte Unsigned : Set $t1 to zero-extended 8-bit value from effective memory byte address
lbu $t1,label lui $1, LH2 lbu RG1, LL2($1) COMPACT lbu RG1, LL2($0) #Load Byte Unsigned : Set $t1 to zero-extended 8-bit value from effective memory byte address
lbu $t1,label($t2) lui $1, LH2 addu $1, $1, RG4 lbu RG1, LL2($1) COMPACT lbu RG1, LL2(RG4) #Load Byte Unsigned : Set $t1 to zero-extended 8-bit value from effective memory byte address
lbu $t1,label+100000 lui $1, LHPA lbu RG1, LLP($1) #Load Byte Unsigned : Set $t1 to zero-extended 8-bit value from effective memory byte address
lbu $t1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 lbu RG1, LLP($1) #Load Byte Unsigned : Set $t1 to zero-extended 8-bit value from effective memory byte address
lwl $t1,($t2) lwl RG1,0(RG3) #Load Word Left : Load from 1 to 4 bytes left-justified into $t1, starting with effective memory byte address and continuing through the low-order byte of its word
lwl $t1,-100 lwl RG1,VL2($0) #Load Word Left : Load from 1 to 4 bytes left-justified into $t1, starting with effective memory byte address and continuing through the low-order byte of its word
lwl $t1,100 ori $1, $0, VL2U lwl RG1, 0($1) #Load Word Left : Load from 1 to 4 bytes left-justified into $t1, starting with effective memory byte address and continuing through the low-order byte of its word
lwl $t1,100000 lui $1, VH2 lwl RG1,VL2($1) #Load Word Left : Load from 1 to 4 bytes left-justified into $t1, starting with effective memory byte address and continuing through the low-order byte of its word
lwl $t1,100($t2) ori $1, $0, VL2U addu $1, $1, RG4 lwl RG1, 0($1) #Load Word Left : Load from 1 to 4 bytes left-justified into $t1, starting with effective memory byte address and continuing through the low-order byte of its word
lwl $t1,100000($t2) lui $1, VH2 addu $1, $1, RG4 lwl RG1, VL2($1) #Load Word Left : Load from 1 to 4 bytes left-justified into $t1, starting with effective memory byte address and continuing through the low-order byte of its word
lwl $t1,label lui $1, LH2 lwl RG1, LL2($1) COMPACT lwl RG1, LL2($0) #Load Word Left : Load from 1 to 4 bytes left-justified into $t1, starting with effective memory byte address and continuing through the low-order byte of its word
lwl $t1,label($t2) lui $1, LH2 addu $1, $1, RG4 lwl RG1, LL2($1) COMPACT lwl RG1, LL2(RG4) #Load Word Left : Load from 1 to 4 bytes left-justified into $t1, starting with effective memory byte address and continuing through the low-order byte of its word
lwl $t1,label+100000 lui $1, LHPA lwl RG1, LLP($1) #Load Word Left : Load from 1 to 4 bytes left-justified into $t1, starting with effective memory byte address and continuing through the low-order byte of its word
lwl $t1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 lwl RG1, LLP($1) #Load Word Left : Load from 1 to 4 bytes left-justified into $t1, starting with effective memory byte address and continuing through the low-order byte of its word
swl $t1,($t2) swl RG1,0(RG3) #Store Word Left : Store high-order 1 to 4 bytes of $t1 into memory, starting with effective memory byte address and continuing through the low-order byte of its word
swl $t1,-100 swl RG1,VL2($0) #Store Word Left : Store high-order 1 to 4 bytes of $t1 into memory, starting with effective memory byte address and continuing through the low-order byte of its word
swl $t1,100 ori $1, $0, VL2U swl RG1, 0($1) #Store Word Left : Store high-order 1 to 4 bytes of $t1 into memory, starting with effective memory byte address and continuing through the low-order byte of its word
swl $t1,100000 lui $1, VH2 swl RG1,VL2($1) #Store Word Left : Store high-order 1 to 4 bytes of $t1 into memory, starting with effective memory byte address and continuing through the low-order byte of its word
swl $t1,100($t2) ori $1, $0, VL2U addu $1, $1, RG4 swl RG1, 0($1) #Store Word Left : Store high-order 1 to 4 bytes of $t1 into memory, starting with effective memory byte address and continuing through the low-order byte of its word
swl $t1,100000($t2) lui $1, VH2 addu $1, $1, RG4 swl RG1, VL2($1) #Store Word Left : Store high-order 1 to 4 bytes of $t1 into memory, starting with effective memory byte address and continuing through the low-order byte of its word
swl $t1,label lui $1, LH2 swl RG1, LL2($1) COMPACT swl RG1, LL2($0) #Store Word Left : Store high-order 1 to 4 bytes of $t1 into memory, starting with effective memory byte address and continuing through the low-order byte of its word
swl $t1,label($t2) lui $1, LH2 addu $1, $1, RG4 swl RG1, LL2($1) COMPACT swl RG1, LL2(RG4) #Store Word Left : Store high-order 1 to 4 bytes of $t1 into memory, starting with effective memory byte address and continuing through the low-order byte of its word
swl $t1,label+100000 lui $1, LHPA swl RG1, LLP($1) #Store Word Left : Store high-order 1 to 4 bytes of $t1 into memory, starting with effective memory byte address and continuing through the low-order byte of its word
swl $t1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 swl RG1, LLP($1) #Store Word Left : Store high-order 1 to 4 bytes of $t1 into memory, starting with effective memory byte address and continuing through the low-order byte of its word
lwr $t1,($t2) lwr RG1,0(RG3) #Load Word Right : Load from 1 to 4 bytes right-justified into $t1, starting with effective memory byte address and continuing through the high-order byte of its word
lwr $t1,-100 lwr RG1,VL2($0) #Load Word Right : Load from 1 to 4 bytes right-justified into $t1, starting with effective memory byte address and continuing through the high-order byte of its word
lwr $t1,100 ori $1, $0, VL2U lwr RG1, 0($1) #Load Word Right : Load from 1 to 4 bytes right-justified into $t1, starting with effective memory byte address and continuing through the high-order byte of its word
lwr $t1,100000 lui $1, VH2 lwr RG1,VL2($1) #Load Word Right : Load from 1 to 4 bytes right-justified into $t1, starting with effective memory byte address and continuing through the high-order byte of its word
lwr $t1,100($t2) ori $1, $0, VL2U addu $1, $1, RG4 lwr RG1, 0($1) #Load Word Right : Load from 1 to 4 bytes right-justified into $t1, starting with effective memory byte address and continuing through the high-order byte of its word
lwr $t1,100000($t2) lui $1, VH2 addu $1, $1, RG4 lwr RG1, VL2($1) #Load Word Right : Load from 1 to 4 bytes right-justified into $t1, starting with effective memory byte address and continuing through the high-order byte of its word
lwr $t1,label lui $1, LH2 lwr RG1, LL2($1) COMPACT lwr RG1, LL2($0) #Load Word Right : Load from 1 to 4 bytes right-justified into $t1, starting with effective memory byte address and continuing through the high-order byte of its word
lwr $t1,label($t2) lui $1, LH2 addu $1, $1, RG4 lwr RG1, LL2($1) COMPACT lwr RG1, LL2(RG4) #Load Word Right : Load from 1 to 4 bytes right-justified into $t1, starting with effective memory byte address and continuing through the high-order byte of its word
lwr $t1,label+100000 lui $1, LHPA lwr RG1, LLP($1) #Load Word Right : Load from 1 to 4 bytes right-justified into $t1, starting with effective memory byte address and continuing through the high-order byte of its word
lwr $t1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 lwr RG1, LLP($1) #Load Word Right : Load from 1 to 4 bytes right-justified into $t1, starting with effective memory byte address and continuing through the high-order byte of its word
swr $t1,($t2) swr RG1,0(RG3) #Store Word Right : Store low-order 1 to 4 bytes of $t1 into memory, starting with high-order byte of word containing effective memory byte address and continuing through that byte address
swr $t1,-100 swr RG1,VL2($0) #Store Word Right : Store low-order 1 to 4 bytes of $t1 into memory, starting with high-order byte of word containing effective memory byte address and continuing through that byte address
swr $t1,100 ori $1, $0, VL2U swr RG1, 0 #Store Word Right : Store low-order 1 to 4 bytes of $t1 into memory, starting with high-order byte of word containing effective memory byte address and continuing through that byte address
swr $t1,100000 lui $1, VH2 swr RG1,VL2($1) #Store Word Right : Store low-order 1 to 4 bytes of $t1 into memory, starting with high-order byte of word containing effective memory byte address and continuing through that byte address
swr $t1,100($t2) ori $1, $0, VL2U addu $1, $1, RG4 swr RG1, 0($1) #Store Word Right : Store low-order 1 to 4 bytes of $t1 into memory, starting with high-order byte of word containing effective memory byte address and continuing through that byte address
swr $t1,100000($t2) lui $1, VH2 addu $1, $1, RG4 swr RG1, VL2($1) #Store Word Right : Store low-order 1 to 4 bytes of $t1 into memory, starting with high-order byte of word containing effective memory byte address and continuing through that byte address
swr $t1,label lui $1, LH2 swr RG1, LL2($1) COMPACT swr RG1, LL2($0) #Store Word Right : Store low-order 1 to 4 bytes of $t1 into memory, starting with high-order byte of word containing effective memory byte address and continuing through that byte address
swr $t1,label($t2) lui $1, LH2 addu $1, $1, RG4 swr RG1, LL2($1) COMPACT swr RG1, LL2(RG4) #Store Word Right : Store low-order 1 to 4 bytes of $t1 into memory, starting with high-order byte of word containing effective memory byte address and continuing through that byte address
swr $t1,label+100000 lui $1, LHPA swr RG1, LLP($1) #Store Word Right : Store low-order 1 to 4 bytes of $t1 into memory, starting with high-order byte of word containing effective memory byte address and continuing through that byte address
swr $t1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 swr RG1, LLP($1) #Store Word Right : Store low-order 1 to 4 bytes of $t1 into memory, starting with high-order byte of word containing effective memory byte address and continuing through that byte address
ll $t1,($t2) ll RG1,0(RG3) #Load Linked : Paired with Store Conditional (sc) to perform atomic read-modify-write. Treated as equivalent to Load Word (lw) because MARS does not simulate multiple processors.
ll $t1,-100 ll RG1,VL2($0) #Load Linked : Paired with Store Conditional (sc) to perform atomic read-modify-write. Treated as equivalent to Load Word (lw) because MARS does not simulate multiple processors.
ll $t1,100 ori $1, $0, VL2U ll RG1, 0($1) #Load Linked : Paired with Store Conditional (sc) to perform atomic read-modify-write. Treated as equivalent to Load Word (lw) because MARS does not simulate multiple processors.
ll $t1,100000 lui $1, VH2 ll RG1,VL2($1) #Load Linked : Paired with Store Conditional (sc) to perform atomic read-modify-write. Treated as equivalent to Load Word (lw) because MARS does not simulate multiple processors.
ll $t1,100($t2) ori $1, $0, VL2U addu $1, $1, RG4 ll RG1, 0($1) #Load Linked : Paired with Store Conditional (sc) to perform atomic read-modify-write. Treated as equivalent to Load Word (lw) because MARS does not simulate multiple processors.
ll $t1,100000($t2) lui $1, VH2 addu $1, $1, RG4 ll RG1, VL2($1) #Load Linked : Paired with Store Conditional (sc) to perform atomic read-modify-write. Treated as equivalent to Load Word (lw) because MARS does not simulate multiple processors.
ll $t1,label lui $1, LH2 ll RG1, LL2($1) COMPACT ll RG1, LL2($0) #Load Linked : Paired with Store Conditional (sc) to perform atomic read-modify-write. Treated as equivalent to Load Word (lw) because MARS does not simulate multiple processors.
ll $t1,label($t2) lui $1, LH2 addu $1, $1, RG4 ll RG1, LL2($1) COMPACT ll RG1, LL2(RG4) #Load Linked : Paired with Store Conditional (sc) to perform atomic read-modify-write. Treated as equivalent to Load Word (lw) because MARS does not simulate multiple processors.
ll $t1,label+100000 lui $1, LHPA ll RG1, LLP($1) #Load Linked : Paired with Store Conditional (sc) to perform atomic read-modify-write. Treated as equivalent to Load Word (lw) because MARS does not simulate multiple processors.
ll $t1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 ll RG1, LLP($1) #Load Linked : Paired with Store Conditional (sc) to perform atomic read-modify-write. Treated as equivalent to Load Word (lw) because MARS does not simulate multiple processors.
sc $t1,($t2) sc RG1,0(RG3) #Store Conditional : Paired with Load Linked (ll) to perform atomic read-modify-write. Treated as equivalent to Store Word (sw) because MARS does not simulate multiple processors.
sc $t1,-100 sc RG1,VL2($0) #Store Conditional : Paired with Load Linked (ll) to perform atomic read-modify-write. Treated as equivalent to Store Word (sw) because MARS does not simulate multiple processors.
sc $t1,100 ori $1, $0, VL2U sc RG1, 0($1) #Store Conditional : Paired with Load Linked (ll) to perform atomic read-modify-write. Treated as equivalent to Store Word (sw) because MARS does not simulate multiple processors.
sc $t1,100000 lui $1, VH2 sc RG1,VL2($1) #Store Conditional : Paired with Load Linked (ll) to perform atomic read-modify-write. Treated as equivalent to Store Word (sw) because MARS does not simulate multiple processors.
sc $t1,100($t2) ori $1, $0, VL2U addu $1, $1, RG4 sc RG1, 0($1) #Store Conditional : Paired with Load Linked (ll) to perform atomic read-modify-write. Treated as equivalent to Store Word (sw) because MARS does not simulate multiple processors.
sc $t1,100000($t2) lui $1, VH2 addu $1, $1, RG4 sc RG1, VL2($1) #Store Conditional : Paired with Load Linked (ll) to perform atomic read-modify-write. Treated as equivalent to Store Word (sw) because MARS does not simulate multiple processors.
sc $t1,label lui $1, LH2 sc RG1, LL2($1) COMPACT sc RG1, LL2($0) #Store Conditional : Paired with Load Linked (ll) to perform atomic read-modify-write. Treated as equivalent to Store Word (sw) because MARS does not simulate multiple processors.
sc $t1,label($t2) lui $1, LH2 addu $1, $1, RG4 sc RG1, LL2($1) COMPACT sc RG1, LL2(RG4) #Store Conditional : Paired with Load Linked (ll) to perform atomic read-modify-write. Treated as equivalent to Store Word (sw) because MARS does not simulate multiple processors.
sc $t1,label+100000 lui $1, LHPA sc RG1, LLP($1) #Store Conditional : Paired with Load Linked (ll) to perform atomic read-modify-write. Treated as equivalent to Store Word (sw) because MARS does not simulate multiple processors.
sc $t1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 sc RG1, LLP($1) #Store Conditional : Paired with Load Linked (ll) to perform atomic read-modify-write. Treated as equivalent to Store Word (sw) because MARS does not simulate multiple processors.
# Unaligned and double loads and stores. All the them require assembler to add a constant
# byte offset (from 1 to 4 bytes) to the given or calculated address.
# NOTE: I have abandoned the “accepted” expansion of immed16($reg) addressing form for the
# unaligned and double load/store pseudo-instructions because they produce what I consider
# incorrect results for immediate values at the upper edge of the signed 16-bit range
# (32765 through 32767). The expansion of these pseudo’s requires adding an additional
# byte offset (from 1 to 4 bytes) to the immediate value, which overflows the signed 16
# bit range and results in a large negative offset with no counterbalancing increment
# to the high order 16-bits. Thus if the two pieces of unaligned data end up in different
# words, they are stored 64K bytes apart! For example, the normal expansion of
# “usw $8,32767($9)” would be “swl $8,-32766($9)”, “swr $8, 32767($9)” Both SPIM and
# Britten’s text do this but I consider it incorrect. My compromise is the following:
# since each of the expansion calls for two calculated offsets, one of which can possibly
# overflow due to the addition but the other will not (because there is no addition),
# I’ll code the expansion to treat the at-risk calculated offset as 32-bits (it will generate
# the lui and addu, which is unnecessary in almost every case but is always correct)
# and the second as 16-bits. I’ll group all instructions for this addressing mode together.
# ulw $t1,-100($t2) lwl RG1, VL2P3(RG4) lwr RG1, VL2(RG4) — used by SPIM but not me.
# usw $t1,-100($t2) swl RG1, VL2P3(RG4) swr RG1, VL2(RG4) — used by SPIM but not me.
ulw $t1,-100($t2) lui $1, VH2P3 addu $1, $1, RG4 lwl RG1, VL2P3($1) lwr RG1, VL2(RG4) #Unaligned Load Word : Set $t1 to the 32 bits starting at effective memory byte address
ulh $t1,-100($t2) lui $1, VH2P1 addu $1, $1, RG4 lb RG1, VL2P1($1) lbu $1, VL2(RG4) sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Load Halfword : Set $t1 to the 16 bits, sign-extended, starting at effective memory byte address
ulhu $t1,-100($t2) lui $1, VH2P1 addu $1, $1, RG4 lbu RG1, VL2P1($1) lbu $1, VL2(RG4) sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Load Halfword : Set $t1 to the 16 bits, zero-extended, starting at effective memory byte address
ld $t1,-100($t2) lw RG1, VL2(RG4) lui $1, VH2P4 addu $1, $1, RG4 lw NR1, VL2P4($1) #Load Doubleword : Set $t1 and the next register to the 64 bits starting at effective memory byte address
usw $t1,-100($t2) lui $1, VH2P3 addu $1, $1, RG4 swl RG1, VL2P3($1) swr RG1, VL2(RG4) #Unaligned Store Word : Store $t1 contents into the 32 bits starting at effective memory byte address
ush $t1,-100($t2) sb RG1, VL2(RG4) sll $1, RG1, 24 srl RG1, RG1, 8 or RG1, RG1, $1 lui $1, VH2P1 addu $1, $1, RG4 sb RG1, VL2P1($1) srl $1, RG1, 24 sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Store Halfword: Store low-order halfword $t1 contents into the 16 bits starting at effective memory byte address
sd $t1,-100($t2) sw RG1, VL2(RG4) lui $1, VH2P4 addu $1, $1, RG4 sw NR1, VL2P4($1) #Store Doubleword : Store contents of $t1 and the next register to the 64 bits starting at effective memory byte address
# here are the remaining addressing modes, grouped by instruction.
ulw $t1,100000 lui $1, VH2P3 lwl RG1, VL2P3($1) lui $1, VH2 lwr RG1, VL2($1) #Unaligned Load Word : Set $t1 to the 32 bits starting at effective memory byte address
ulw $t1,label lui $1, LH2P3 lwl RG1, LL2P3($1) lui $1, LH2 lwr RG1, LL2($1) #Unaligned Load Word : Set $t1 to the 32 bits starting at effective memory byte address
ulw $t1,label+100000 lui $1, LHPAP3 lwl RG1, LLPP3($1) lui $1, LHPA lwr RG1, LLP($1) #Unaligned Load Word : Set $t1 to the 32 bits starting at effective memory byte address
ulw $t1,($t2) lwl RG1, 3(RG3) lwr RG1, 0(RG3) #Unaligned Load Word : Set $t1 to the 32 bits starting at effective memory byte address
ulw $t1,100000($t2) lui $1, VH2P3 addu $1, $1, RG4 lwl RG1, VL2P3($1) lui $1, VH2 addu $1, $1, RG4 lwr RG1, VL2($1) #Unaligned Load Word : Set $t1 to the 32 bits starting at effective memory byte address
ulw $t1,label($t2) lui $1, LH2P3 addu $1, $1, RG4 lwl RG1, LL2P3($1) lui $1, LH2 addu $1, $1, RG4 lwr RG1, LL2($1) #Unaligned Load Word : Set $t1 to the 32 bits starting at effective memory byte address
ulw $t1,label+100000($t2) lui $1, LHPAP3 addu $1, $1, RG6 lwl RG1, LLPP3($1) lui $1, LHPA addu $1, $1, RG6 lwr RG1, LLP($1) #Unaligned Load Word : Set $t1 to the 32 bits starting at effective memory byte address
ulh $t1,100000 lui $1, VH2P1 lb RG1, VL2P1($1) lui $1, VH2 lbu $1, VL2($1) sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Load Halfword : Set $t1 to the 16 bits, sign-extended, starting at effective memory byte address
ulh $t1,label lui $1, LH2P1 lb RG1, LL2P1($1) lui $1, LH2 lbu $1, LL2($1) sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Load Halfword : Set $t1 to the 16 bits, sign-extended, starting at effective memory byte address
ulh $t1,label+100000 lui $1, LHPAP1 lb RG1, LLPP1($1) lui $1, LHPA lbu $1, LLP($1) sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Load Halfword : Set $t1 to the 16 bits, sign-extended, starting at effective memory byte address
ulh $t1,($t2) lb RG1, 1(RG3) lbu $1, 0(RG3) sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Load Halfword : Set $t1 to the 16 bits, sign-extended, starting at effective memory byte address
ulh $t1,100000($t2) lui $1, VH2P1 addu $1, $1, RG4 lb RG1, VL2P1($1) lui $1, VH2 addu $1, $1, RG4 lbu $1, VL2($1) sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Load Halfword : Set $t1 to the 16 bits, sign-extended, starting at effective memory byte address
ulh $t1,label($t2) lui $1, LH2P1 addu $1, $1, RG4 lb RG1, LL2P1($1) lui $1, LH2 addu $1, $1, RG4 lbu $1, LL2($1) sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Load Halfword : Set $t1 to the 16 bits, sign-extended, starting at effective memory byte address
ulh $t1,label+100000($t2) lui $1, LHPAP1 addu $1, $1, RG6 lb RG1, LLPP1($1) lui $1, LHPA addu $1, $1, RG6 lbu $1, LLP($1) sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Load Halfword : Set $t1 to the 16 bits, sign-extended, starting at effective memory byte address
ulhu $t1,100000 lui $1, VH2P1 lbu RG1, VL2P1($1) lui $1, VH2 lbu $1, VL2($1) sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Load Halfword : Set $t1 to the 16 bits, zero-extended, starting at effective memory byte address
ulhu $t1,label lui $1, LH2P1 lbu RG1, LL2P1($1) lui $1, LH2 lbu $1, LL2($1) sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Load Halfword : Set $t1 to the 16 bits, zero-extended, starting at effective memory byte address
ulhu $t1,label+100000 lui $1, LHPAP1 lbu RG1, LLPP1($1) lui $1, LHPA lbu $1, LLP($1) sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Load Halfword : Set $t1 to the 16 bits, zero-extended, starting at effective memory byte address
ulhu $t1,($t2) lbu RG1, 1(RG3) lbu $1, 0(RG3) sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Load Halfword : Set $t1 to the 16 bits, zero-extended, starting at effective memory byte address
ulhu $t1,100000($t2) lui $1, VH2P1 addu $1, $1, RG4 lbu RG1, VL2P1($1) lui $1, VH2 addu $1, $1, RG4 lbu $1, VL2($1) sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Load Halfword : Set $t1 to the 16 bits, zero-extended, starting at effective memory byte address
ulhu $t1,label($t2) lui $1, LH2P1 addu $1, $1, RG4 lbu RG1, LL2P1($1) lui $1, LH2 addu $1, $1, RG4 lbu $1, LL2($1) sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Load Halfword : Set $t1 to the 16 bits, zero-extended, starting at effective memory byte address
ulhu $t1,label+100000($t2) lui $1, LHPAP1 addu $1, $1, RG6 lbu RG1, LLPP1($1) lui $1, LHPA addu $1, $1, RG6 lbu $1, LLP($1) sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Load Halfword : Set $t1 to the 16 bits, zero-extended, starting at effective memory byte address
ld $t1,100000 lui $1, VH2 lw RG1, VL2($1) lui $1, VH2P4 lw NR1, VL2P4($1) #Load Doubleword : Set $t1 and the next register to the 64 bits starting at effective memory word address
ld $t1,label lui $1, LH2 lw RG1, LL2($1) lui $1, LH2P4 lw NR1, LL2P4($1) #Load Doubleword : Set $t1 and the next register to the 64 bits starting at effective memory word address
ld $t1,label+100000 lui $1, LHPA lw RG1, LLP($1) lui $1, LHPAP4 lw NR1, LLPP4($1) #Load Doubleword : Set $t1 and the next register to the 64 bits starting at effective memory word address
ld $t1,($t2) lw RG1, 0(RG3) lw NR1, 4(RG3) #Load Doubleword : Set $t1 and the next register to the 64 bits starting at effective memory word address
ld $t1,100000($t2) lui $1, VH2 addu $1, $1, RG4 lw RG1, VL2($1) lui $1, VH2P4 addu $1, $1, RG4 lw NR1, VL2P4($1) #Load Doubleword : Set $t1 and the next register to the 64 bits starting at effective memory word address
ld $t1,label($t2) lui $1, LH2 addu $1, $1, RG4 lw RG1, LL2($1) lui $1, LH2P4 addu $1, $1, RG4 lw NR1, LL2P4($1) #Load Doubleword : Set $t1 and the next register to the 64 bits starting at effective memory word address
ld $t1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 lw RG1, LLP($1) lui $1, LHPAP4 addu $1, $1, RG6 lw NR1, LLPP4($1) #Load Doubleword : Set $t1 and the next register to the 64 bits starting at effective memory word address
usw $t1,100000 lui $1, VH2P3 swl RG1, VL2P3($1) lui $1, VH2 swr RG1, VL2($1) #Unaligned Store Word : Store $t1 contents into the 32 bits starting at effective memory byte address
usw $t1,label lui $1, LH2P3 swl RG1, LL2P3($1) lui $1, LH2 swr RG1, LL2($1) #Unaligned Store Word : Store $t1 contents into the 32 bits starting at effective memory byte address
usw $t1,label+100000 lui $1, LHPAP3 swl RG1, LLPP3($1) lui $1, LHPA swr RG1, LLP($1) #Unaligned Store Word : Store $t1 contents into the 32 bits starting at effective memory byte address
usw $t1,($t2) swl RG1, 3(RG3) swr RG1, 0(RG3) #Unaligned Store Word : Store $t1 contents into the 32 bits starting at effective memory byte address
usw $t1,100000($t2) lui $1, VH2P3 addu $1, $1, RG4 swl RG1, VL2P3($1) lui $1, VH2 addu $1, $1, RG4 swr RG1, VL2($1) #Unaligned Store Word : Store $t1 contents into the 32 bits starting at effective memory byte address
usw $t1,label($t2) lui $1, LH2P3 addu $1, $1, RG4 swl RG1, LL2P3($1) lui $1, LH2 addu $1, $1, RG4 swr RG1, LL2($1) #Unaligned Store Word : Store $t1 contents into the 32 bits starting at effective memory byte address
usw $t1,label+100000($t2) lui $1, LHPAP3 addu $1, $1, RG6 swl RG1, LLPP3($1) lui $1, LHPA addu $1, $1, RG6 swr RG1, LLP($1) #Unaligned Store Word : Store $t1 contents into the 32 bits starting at effective memory byte address
ush $t1,100000 lui $1, VH2 sb RG1, VL2($1) sll $1, RG1, 24 srl RG1, RG1, 8 or RG1, RG1, $1 lui $1, VH2P1 sb RG1, VL2P1($1) srl $1, RG1, 24 sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Store Halfword: Store low-order halfword $t1 contents into the 16 bits starting at effective memory byte address
ush $t1,label lui $1, LH2 sb RG1, LL2($1) sll $1, RG1, 24 srl RG1, RG1, 8 or RG1, RG1, $1 lui $1, LH2P1 sb RG1, LL2P1($1) srl $1, RG1, 24 sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Store Halfword: Store low-order halfword $t1 contents into the 16 bits starting at effective memory byte address
ush $t1,label+100000 lui $1, LHPA sb RG1, LLP($1) sll $1, RG1, 24 srl RG1, RG1, 8 or RG1, RG1, $1 lui $1, LHPAP1 sb RG1, LLPP1($1) srl $1, RG1, 24 sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Store Halfword: Store low-order halfword $t1 contents into the 16 bits starting at effective memory byte address
ush $t1,($t2) sb RG1, 0(RG3) sll $1, RG1, 24 srl RG1, RG1, 8 or RG1, RG1, $1 sb RG1, 1(RG3) srl $1, RG1, 24 sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Store Halfword: Store low-order halfword $t1 contents into the 16 bits starting at effective memory byte address
ush $t1,100000($t2) lui $1, VH2 addu $1, $1, RG4 sb RG1, VL2($1) sll $1, RG1, 24 srl RG1, RG1, 8 or RG1, RG1, $1 lui $1, VH2P1 addu $1, $1, RG4 sb RG1, VL2P1($1) srl $1, RG1, 24 sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Store Halfword: Store low-order halfword $t1 contents into the 16 bits starting at effective memory byte address
ush $t1,label($t2) lui $1, LH2 addu $1, $1, RG4 sb RG1, LL2($1) sll $1, RG1, 24 srl RG1, RG1, 8 or RG1, RG1, $1 lui $1, LH2P1 addu $1, $1, RG4 sb RG1, LL2P1($1) srl $1, RG1, 24 sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Store Halfword: Store low-order halfword $t1 contents into the 16 bits starting at effective memory byte address
ush $t1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 sb RG1, LLP($1) sll $1, RG1, 24 srl RG1, RG1, 8 or RG1, RG1, $1 lui $1, LHPAP1 addu $1, $1, RG6 sb RG1, LLPP1($1) srl $1, RG1, 24 sll RG1, RG1, 8 or RG1, RG1, $1 #Unaligned Store Halfword: Store low-order halfword $t1 contents into the 16 bits starting at effective memory byte address
sd $t1,100000 lui $1, VH2 sw RG1, VL2($1) lui $1, VH2P4 sw NR1, VL2P4($1) #Store Doubleword : Store contents of $t1 and the next register to the 64 bits starting at effective memory word address
sd $t1,label lui $1, LH2 sw RG1, LL2($1) lui $1, LH2P4 sw NR1, LL2P4($1) #Store Doubleword : Store contents of $t1 and the next register to the 64 bits starting at effective memory word address
sd $t1,label+100000 lui $1, LHPA sw RG1, LLP($1) lui $1, LHPAP4 sw NR1, LLPP4($1) #Store Doubleword : Store contents of $t1 and the next register to the 64 bits starting at effective memory word address
sd $t1,($t2) sw RG1, 0(RG3) sw NR1, 4(RG3) #Store Doubleword : Store contents of $t1 and the next register to the 64 bits starting at effective memory word address
sd $t1,100000($t2) lui $1, VH2 addu $1, $1, RG4 sw RG1, VL2($1) lui $1, VH2P4 addu $1, $1, RG4 sw NR1, VL2P4($1) #Store Doubleword : Store contents of $t1 and the next register to the 64 bits starting at effective memory word address
sd $t1,label($t2) lui $1, LH2 addu $1, $1, RG4 sw RG1, LL2($1) lui $1, LH2P4 addu $1, $1, RG4 sw NR1, LL2P4($1) #Store Doubleword : Store contents of $t1 and the next register to the 64 bits starting at effective memory word address
sd $t1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 sw RG1, LLP($1) lui $1, LHPAP4 addu $1, $1, RG6 sw NR1, LLPP4($1) #Store Doubleword : Store contents of $t1 and the next register to the 64 bits starting at effective memory word address
# load and store pseudo-instructions for floating point (coprocessor 1) registers
lwc1 $f1,($t2) lwc1 RG1,0(RG3) #Load Word Coprocessor 1 : Set $f1 to 32-bit value from effective memory word address
lwc1 $f1,-100 lwc1 RG1,VL2($0) #Load Word Coprocessor 1 : Set $f1 to 32-bit value from effective memory word address
lwc1 $f1,100000 lui $1, VH2 lwc1 RG1,VL2($1) #Load Word Coprocessor 1 : Set $f1 to 32-bit value from effective memory word address
lwc1 $f1,100000($t2) lui $1, VH2 addu $1, $1, RG4 lwc1 RG1, VL2($1) #Load Word Coprocessor 1 : Set $f1 to 32-bit value from effective memory word address
lwc1 $f1,label lui $1, LH2 lwc1 RG1, LL2($1) COMPACT lwc1 RG1, LL2($0) #Load Word Coprocessor 1 : Set $f1 to 32-bit value from effective memory word address
lwc1 $f1,label($t2) lui $1, LH2 addu $1, $1, RG4 lwc1 RG1, LL2($1) COMPACT lwc1 RG1, LL2(RG4) #Load Word Coprocessor 1 : Set $f1 to 32-bit value from effective memory word address
lwc1 $f1,label+100000 lui $1, LHPA lwc1 RG1, LLP($1) #Load Word Coprocessor 1 : Set $f1 to 32-bit value from effective memory word address
lwc1 $f1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 lwc1 RG1, LLP($1) #Load Word Coprocessor 1 : Set $f1 to 32-bit value from effective memory word address
ldc1 $f2,($t2) ldc1 RG1,0(RG3) #Load Doubleword Coprocessor 1 : Set $f2 and $f3 register pair to 64-bit value at effective memory doubleword address
ldc1 $f2,-100 ldc1 RG1,VL2($0) #Load Doubleword Coprocessor 1 : Set $f2 and $f3 register pair to 64-bit value at effective memory doubleword address
ldc1 $f2,100000 lui $1, VH2 ldc1 RG1,VL2($1) #Load Doubleword Coprocessor 1 : Set $f2 and $f3 register pair to 64-bit value at effective memory doubleword address
ldc1 $f2,100000($t2) lui $1, VH2 addu $1, $1, RG4 ldc1 RG1, VL2($1) #Load Doubleword Coprocessor 1 : Set $f2 and $f3 register pair to 64-bit value at effective memory doubleword address
ldc1 $f2,label lui $1, LH2 ldc1 RG1, LL2($1) COMPACT ldc1 RG1, LL2($0) #Load Doubleword Coprocessor 1 : Set $f2 and $f3 register pair to 64-bit value at effective memory doubleword address
ldc1 $f2,label($t2) lui $1, LH2 addu $1, $1, RG4 ldc1 RG1, LL2($1) COMPACT ldc1 RG1, LL2(RG4) #Load Doubleword Coprocessor 1 : Set $f2 and $f3 register pair to 64-bit value at effective memory doubleword address
ldc1 $f2,label+100000 lui $1, LHPA ldc1 RG1, LLP($1) #Load Doubleword Coprocessor 1 : Set $f2 and $f3 register pair to 64-bit value at effective memory doubleword address
ldc1 $f2,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 ldc1 RG1, LLP($1) #Load Doubleword Coprocessor 1 : Set $f2 and $f3 register pair to 64-bit value at effective memory doubleword address
swc1 $f1,($t2) swc1 RG1,0(RG3) #Store Word Coprocessor 1 : Store 32-bit value from $f1 to effective memory word address
swc1 $f1,-100 swc1 RG1,VL2($0) #Store Word Coprocessor 1 : Store 32-bit value from $f1 to effective memory word address
swc1 $f1,100000 lui $1, VH2 swc1 RG1,VL2($1) #Store Word Coprocessor 1 : Store 32-bit value from $f1 to effective memory word address
swc1 $f1,100000($t2) lui $1, VH2 addu $1, $1, RG4 swc1 RG1, VL2($1) #Store Word Coprocessor 1 : Store 32-bit value from $f1 to effective memory word address
swc1 $f1,label lui $1, LH2 swc1 RG1, LL2($1) COMPACT swc1 RG1, LL2($0) #Store Word Coprocessor 1 : Store 32-bit value from $f1 to effective memory word address
swc1 $f1,label($t2) lui $1, LH2 addu $1, $1, RG4 swc1 RG1, LL2($1) COMPACT swc1 RG1, LL2(RG4) #Store Word Coprocessor 1 : Store 32-bit value from $f1 to effective memory word address
swc1 $f1,label+100000 lui $1, LHPA swc1 RG1, LLP($1) #Store Word Coprocessor 1 : Store 32-bit value from $f1 to effective memory word address
swc1 $f1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 swc1 RG1, LLP($1) #Store Word Coprocessor 1 : Store 32-bit value from $f1 to effective memory word address
sdc1 $f2,($t2) sdc1 RG1,0(RG3) #Store Doubleword Coprocessor 1 : Store 64 bits from $f2 and $f3 register pair to effective memory doubleword address
sdc1 $f2,-100 sdc1 RG1,VL2($0) #Store Doubleword Coprocessor 1 : Store 64 bits from $f2 and $f3 register pair to effective memory doubleword address
sdc1 $f2,100000 lui $1, VH2 sdc1 RG1,VL2($1) #Store Doubleword Coprocessor 1 : Store 64 bits from $f2 and $f3 register pair to effective memory doubleword address
sdc1 $f2,100000($t2) lui $1, VH2 addu $1, $1, RG4 sdc1 RG1, VL2($1) #Store Doubleword Coprocessor 1 : Store 64 bits from $f2 and $f3 register pair to effective memory doubleword address
sdc1 $f2,label lui $1, LH2 sdc1 RG1, LL2($1) COMPACT sdc1 RG1, LL2($0) #Store Doubleword Coprocessor 1 : Store 64 bits from $f2 and $f3 register pair to effective memory doubleword address
sdc1 $f2,label($t2) lui $1, LH2 addu $1, $1, RG4 sdc1 RG1, LL2($1) COMPACT sdc1 RG1, LL2(RG4) #Store Doubleword Coprocessor 1 : Store 64 bits from $f2 and $f3 register pair to effective memory doubleword address
sdc1 $f2,label+100000 lui $1, LHPA sdc1 RG1, LLP($1) #Store Doubleword Coprocessor 1 : Store 64 bits from $f2 and $f3 register pair to effective memory doubleword address
sdc1 $f2,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 sdc1 RG1, LLP($1) #Store Doubleword Coprocessor 1 : Store 64 bits from $f2 and $f3 register pair to effective memory doubleword address
l.s $f1,($t2) lwc1 RG1,0(RG3) #Load floating point Single precision : Set $f1 to 32-bit value at effective memory word address
l.s $f1,-100 lwc1 RG1,VL2($0) #Load floating point Single precision : Set $f1 to 32-bit value at effective memory word address
l.s $f1,100000 lui $1, VH2 lwc1 RG1,VL2($1) #Load floating point Single precision : Set $f1 to 32-bit value at effective memory word address
l.s $f1,100000($t2) lui $1, VH2 addu $1, $1, RG4 lwc1 RG1, VL2($1) #Load floating point Single precision : Set $f1 to 32-bit value at effective memory word address
l.s $f1,label lui $1, LH2 lwc1 RG1, LL2($1) COMPACT lwc1 RG1, LL2($0) #Load floating point Single precision : Set $f1 to 32-bit value at effective memory word address
l.s $f1,label($t2) lui $1, LH2 addu $1, $1, RG4 lwc1 RG1, LL2($1) COMPACT lwc1 RG1, LL2(RG4) #Load floating point Single precision : Set $f1 to 32-bit value at effective memory word address
l.s $f1,label+100000 lui $1, LHPA lwc1 RG1, LLP($1) #Load floating point Single precision : Set $f1 to 32-bit value at effective memory word address
l.s $f1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 lwc1 RG1, LLP($1) #Load floating point Single precision : Set $f1 to 32-bit value at effective memory word address
s.s $f1,($t2) swc1 RG1,0(RG3) #Store floating point Single precision : Store 32-bit value from $f1 to effective memory word address
s.s $f1,-100 swc1 RG1,VL2($0) #Store floating point Single precision : Store 32-bit value from $f1 to effective memory word address
s.s $f1,100000 lui $1, VH2 swc1 RG1,VL2($1) #Store floating point Single precision : Store 32-bit value from $f1 to effective memory word address
s.s $f1,100000($t2) lui $1, VH2 addu $1, $1, RG4 swc1 RG1, VL2($1) #Store floating point Single precision : Store 32-bit value from $f1 to effective memory word address
s.s $f1,label lui $1, LH2 swc1 RG1, LL2($1) COMPACT swc1 RG1, LL2($0) #Store floating point Single precision : Store 32-bit value from $f1 to effective memory word address
s.s $f1,label($t2) lui $1, LH2 addu $1, $1, RG4 swc1 RG1, LL2($1) COMPACT swc1 RG1, LL2(RG4) #Store floating point Single precision : Store 32-bit value from $f1 to effective memory word address
s.s $f1,label+100000 lui $1, LHPA swc1 RG1, LLP($1) #Store floating point Single precision : Store 32-bit value from $f1 to effective memory word address
s.s $f1,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 swc1 RG1, LLP($1) #Store floating point Single precision : Store 32-bit value from $f1 to effective memory word address
l.d $f2,($t2) ldc1 RG1,0(RG3) #Load floating point Double precision : Set $f2 and $f3 register pair to 64-bit value at effective memory doubleword address
l.d $f2,-100 ldc1 RG1,VL2($0) #Load floating point Double precision : Set $f2 and $f3 register pair to 64-bit value at effective memory doubleword address
l.d $f2,100000 lui $1, VH2 ldc1 RG1,VL2($1) #Load floating point Double precision : Set $f2 and $f3 register pair to 64-bit value at effective memory doubleword address
l.d $f2,100000($t2) lui $1, VH2 addu $1, $1, RG4 ldc1 RG1, VL2($1) #Load floating point Double precision : Set $f2 and $f3 register pair to 64-bit value at effective memory doubleword address
l.d $f2,label lui $1, LH2 ldc1 RG1, LL2($1) COMPACT ldc1 RG1, LL2($0) #Load floating point Double precision : Set $f2 and $f3 register pair to 64-bit value at effective memory doubleword address
l.d $f2,label($t2) lui $1, LH2 addu $1, $1, RG4 ldc1 RG1, LL2($1) COMPACT ldc1 RG1, LL2(RG4) #Load floating point Double precision : Set $f2 and $f3 register pair to 64-bit value at effective memory doubleword address
l.d $f2,label+100000 lui $1, LHPA ldc1 RG1, LLP($1) #Load floating point Double precision : Set $f2 and $f3 register pair to 64-bit value at effective memory doubleword address
l.d $f2,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 ldc1 RG1, LLP($1) #Load floating point Double precision : Set $f2 and $f3 register pair to 64-bit value at effective memory doubleword address
s.d $f2,($t2) sdc1 RG1,0(RG3) #Store floating point Double precision : Store 64 bits from $f2 and $f3 register pair to effective memory doubleword address
s.d $f2,-100 sdc1 RG1,VL2($0) #Store floating point Double precision : Store 64 bits from $f2 and $f3 register pair to effective memory doubleword address
s.d $f2,100000 lui $1, VH2 sdc1 RG1,VL2($1) #Store floating point Double precision : Store 64 bits from $f2 and $f3 register pair to effective memory doubleword address
s.d $f2,100000($t2) lui $1, VH2 addu $1, $1, RG4 sdc1 RG1, VL2($1) #Store floating point Double precision : Store 64 bits from $f2 and $f3 register pair to effective memory doubleword address
s.d $f2,label lui $1, LH2 sdc1 RG1, LL2($1) COMPACT sdc1 RG1, LL2($0) #Store floating point Double precision : Store 64 bits from $f2 and $f3 register pair to effective memory doubleword address
s.d $f2,label($t2) lui $1, LH2 addu $1, $1, RG4 sdc1 RG1, LL2($1) COMPACT sdc1 RG1, LL2(RG4) #Store floating point Double precision : Store 64 bits from $f2 and $f3 register pair to effective memory doubleword address
s.d $f2,label+100000 lui $1, LHPA sdc1 RG1, LLP($1) #Store floating point Double precision : Store 64 bits from $f2 and $f3 register pair to effective memory doubleword address
s.d $f2,label+100000($t2) lui $1, LHPA addu $1, $1, RG6 sdc1 RG1, LLP($1) #Store floating point Double precision : Store 64 bits from $f2 and $f3 register pair to effective memory doubleword address
# maximum length of scrolled text in Mars Message and Run I/O tabs, in bytes.
MessageLimit = 1000000
# Maximum number of errors that can be recorded in one assemble operation.
ErrorLimit = 200
# Maximum number of “backstep” operations that can be taken. An instruction
# may produce more than one (e.g. trap instruction may set several registers)
BackstepLimit = 2000
# Acceptable file extensions for MIPS assembly files. Separate with spaces.
Extensions = asm s
# The set of ASCII strings to use for ASCII display or print
# of data segment contents. This covers 8-bit ASCII codes 0-255.
# The space character (decimal 32, hex 20) is encoded here as
# “space” without the quotes. It will be converted upon reading.
# All non-printable codes are encoded here as “null” without
# the quotes. They will be converted upon reading, to the value
# of variable AsciiNonPrint. If you wish to have non-printing
# codes be displayed as their octal value (see unix od) then
# replace all these null with the codes.
# 0 1 2 3 4 5 6 7 8 9
AsciiTable = \
\\0 null null null null null null null \\b \\t \
\\n \\v \\f \\r null null null null null null \
null null null null null null null null null null \
null null space ! ” # $ % & ‘ \
( ) * + , – . / 0 1 \
2 3 4 5 6 7 8 9 : ; \
< = > ? @ A B C D E \
F G H I J K L M N O \
P Q R S T U V W X Y \
Z [ \\ ] ^ _ ` a b c \
d e f g h i j k l m \
n o p q r s t u v w \
x y z { | } ~ null null null \
null null null null null null null null null null \
null null null null null null null null null null \
null null null null null null null null null null \
null null null null null null null null null null \
null null null null null null null null null null \
null null null null null null null null null null \
null null null null null null null null null null \
null null null null null null null null null null \
null null null null null null null null null null \
null null null null null null null null null null \
null null null null null null null null null null \
null null null null null null null null null null \
null null null null null null
# Use AsciiNonPrint as placeholder for non-printing ASCII codes.
# To use space character, specify AsciiNonPrint = space.
# The value of this variable will be substituted for the
# string “null” for any element in the Ascii list (above)
# having “null” as its value.
AsciiNonPrint = .
# Example of re-assign syscall number. Remove leading “#” to activate.
# I re-assign to same number since I don’t really want to change them.
# None are necessary here since number is assigned as constructor arg.
# Re-assignment here will override constructor arg though.
# The syscall names must match constructor arg exactly, case-sensitive.
# Re-assignment useful if numbering conflict should someday occur.
PrintInt = 1
PrintFloat = 2
PrintDouble = 3
PrintString = 4
ReadInt = 5
ReadFloat = 6
ReadDouble = 7
ReadString = 8
Sbrk = 9
Exit = 10
PrintChar = 11
ReadChar = 12
Open = 13
Read = 14
Write = 15
Close = 16
Exit2 = 17
Time = 30
MidiOut = 31
Sleep = 32
MidiOutSync = 33
PrintIntHex = 34
PrintIntBinary = 35
PrintIntUnsigned = 36
RandSeed = 40
RandInt = 41
RandIntRange = 42
RandFloat = 43
RandDouble = 44
ConfirmDialog = 50
InputDialogInt = 51
InputDialogFloat = 52
InputDialogDouble = 53
InputDialogString = 54
MessageDialog = 55
MessageDialogInt = 56
MessageDialogFloat = 57
MessageDialogDouble = 58
MessageDialogString = 59
# NOTE: These are defaults only. The values of these keys are maintained by Java Preferences
# objects, which store key-value pairs in a system-dependent way (Windows uses Registry).
AssembleAll = false
AssembleOnOpen = false
BareMachine = false
DataSegmentHighlighting = true
DelayedBranching = false
DisplayAddressesInHex = true
DisplayValuesInHex = true
EditorCurrentLineHighlighting = true
EditorLineNumbersDisplayed = true
ExtendedAssembler = true
LabelWindowVisibility = false
LoadExceptionHandler = false
ProgramArguments = false
RegistersHighlighting = true
StartAtMain = false
WarningsAreErrors = false
PopupInstructionGuidance = true
EditorPopupPrefixLength = 2
EvenRowBackground = 0x00e0e0e0
EvenRowForeground = 0
OddRowBackground = 0x00ffffff
OddRowForeground = 0
TextSegmentHighlightBackground = 0x00ffff99
TextSegmentHighlightForeground = 0
TextSegmentDelaySlotHighlightBackground = 0x33ff00
TextSegmentDelaySlotHighlightForeground = 0
DataSegmentHighlightBackground = 0x0099ccff
DataSegmentHighlightForeground = 0
RegisterHighlightBackground = 0x0099cc55
RegisterHighlightForeground = 0
Copyright (c) 2003-2013, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
Main-Class: Mars
Class-Path: .
001000
addi
001001
addiu
001010
slti
001011
sltiu
001100
andi
001101
ori
001110
xori
001111
lui
100000
lb
100001
lh
100010
lwl
100011
lw
100100
lbu
100101
lhu
100110
lwr
110001
l1
110001
lwc1
110010
lwc2
110011
pref
110101
ldc1
110110
ldc2
101111
CACHE
111000
sc
111001
swc1
111010
swc2
111101
sdc1
111110
sdc2
101000
sb
101001
sh
101010
swl
101011
sw
101110
swr
000100
beq
000110
blez
000111
bgtz
000101
bne
000010
j
000011
jal
010000
–
010001
–
010010
–
010011
–
000001
SUB.F
010100
–
010101
–
010110
–
010111
–
011000
–
011001
–
011010
–
011011
–
011100
–
011101
–
011110
–
011111
–
101100
–
101101
–
111100
–
111111
–
100111
–
110100
–
110111
–
110111
–
111011
–
000000
r-type
000000
sll
000010
srl
000011
sra
000100
sllv
000110
srlv
000111
srav
001000
jr
001001
jalr
001010
movz
001011
movn
001100
SYSCALL
001101
BREAK
010000
mfhi
010001
mthi
010010
mflo
010011
mtlo
011000
mult
011001
multu
011010
div
011011
divu
100000
add
100001
addu
100010
sub
100011
subu
100100
and
100101
or
100110
xor
100111
nor
101010
slt
101011
sltu
110000
tge
110001
tgeu
110010
tlt
110011
tltu
110100
teq
110110
tne
00000
$zero
00001
at
00010
$v0
00011
$v1
00100
$a0
00101
$a1
00110
$a2
00111
$a3
01000
$t0
01001
$t1
01010
$t2
01011
$t3
01100
$t4
01101
$t5
01110
$t6
01111
$t7
10000
$s0
10001
$s1
10010
$s2
10011
$s3
10100
$s4
10101
$s5
11000
$s6
10111
$s7
11000
$t8
11001
$t9
11010
$k0
11011
$k1
11100
$gp
11101
$sp
11110
$fp
11111
$ra
0
*Program_counter
161
188
255#255#0
255#255#0
255#255#0
255#255#0
255#255#0
255#255#0
362
true
1#6
false
1
*nodeADD1input1A
358
95
255#255#0
255#255#0
255#255#0
255#255#0
255#255#0
255#255#0
192
false
2#3
false
2
*ADD1input1B
192
253
255#255#0
255#255#0
255#255#0
255#255#0
255#255#0
255#255#0
94
true
0
false
3
*ADDA1input2
210
253
255#255#0
255#255#0
255#255#0
255#255#0
255#255#0
255#255#0
144
true
5
false
4
outputDATAMEM1
400
415
16#78#139
16#78#139
100#100#100
30#144#255
100#100#100
100#100#100
414
true
101
false
5
*node1ADD2
311
493
238#221#130
238#221#130
238#221#130
238#221#130
238#221#130
238#221#130
119
true
13#14
false
6
*instruction_Memory
198
215
255#255#0
255#255#0
255#255#0
255#255#0
255#255#0
255#255#0
362
true
7
false
7
*nodeIMrepeated
311
315
255#0#255
255#0#255
255#0#255
255#0#255
255#0#255
255#0#255
378
true
8
false
8
nodeIM
311
315
255#0#255
255#0#255
255#0#255
255#0#255
255#0#255
255#0#255
378
true
9#10
false
9
nodeSHIFTLEFT1
375
75
255#185#15
255#185#15
255#185#15
255#185#15
255#185#15
255#185#15
317
false
11
false
10
*nodeIM2
322
325
255#0#255
255#0#255
255#0#255
255#0#255
255#0#255
255#0#255
378
true
19#20
false
11
*SHIFTLEFT1
317
388
255#185#15
255#185#15
255#185#15
255#185#15
255#185#15
255#185#15
75
true
12
false
12
*nodeMUXC
440
485
255#185#15
255#185#15
255#185#15
255#185#15
255#185#15
255#185#15
75
true
0
false
13
*nodeMUXC1
115
88
238#221#130
238#221#130
238#221#130
238#221#130
238#221#130
238#221#130
497
false
18
false
14
node2ADD2
503
595
238#221#130
238#221#130
238#221#130
238#221#130
238#221#130
238#221#130
119
true
15#16
false
15
*nodeMUXB
115
100
238#221#130
238#221#130
238#221#130
238#221#130
238#221#130
238#221#130
600
false
17
false
16
*ADD2input1
605
650
238#221#130
238#221#130
238#221#130
238#221#130
238#221#130
238#221#130
119
true
0
false
17
*MUXB
600
762
238#221#130
238#221#130
238#221#130
238#221#130
238#221#130
238#221#130
100
true
87
false
18
*nodeMUXC1
502
793
205#149#15
205#149#15
205#149#15
205#149#15
205#149#15
205#149#15
75
true
42
false
19
*nodeREG2
376
360
255#0#255
255#0#255
255#0#255
255#0#255
255#0#255
255#0#255
329
false
24#26
false
20
*nodeMUXA1
385
395
255#127#36
0#191#255
100#100#100
255#127#36
255#127#36
255#127#36
329
false
21#22
false
21
MUXA2
334
365
255#127#36
0#191#255
100#100#100
255#127#36
255#127#36
255#127#36
399
true
0
false
22
*nodeSIGN_EXT
403
461
0#255#255
255#127#36
100#100#100
255#127#36
255#127#36
255#127#36
329
false
23#33
false
23
*SIGN_EXT
333
425
0#255#255
100#100#100
100#100#100
255#127#36
255#127#36
255#127#36
466
true
37
false
24
*nodeREG2A
354
339
255#0#255
255#0#255
255#0#255
255#0#255
255#0#255
255#0#255
328
false
30#31
false
25
notUsed
331
415
255#255#0
255#255#0
255#255#0
255#255#0
255#255#0
255#255#0
336
true
0
false
26
*nodeREGB
334
344
0#0#255
0#0#255
100#100#100
0#0#255
0#0#255
0#0#255
358
true
27#29
false
27
*nodeMUXA
363
371
0#0#255
0#0#255
100#100#100
0#0#255
0#0#255
0#0#255
348
false
28
false
28
*nodeMUXA
348
362
0#0#255
0#0#255
100#100#100
0#0#255
0#0#255
0#0#255
371
true
0
false
29
*REGB
352
416
0#0#255
0#0#255
100#100#100
0#0#255
0#0#255
0#0#255
358
true
0
false
30
*nodeCTRL2
329
230
255#0#255
255#0#255
255#0#255
255#0#255
255#0#255
255#0#255
328
false
32
false
31
*REGinput1
333
415
0#255#0
0#255#0
100#100#100
0#255#0
0#255#0
0#255#0
335
true
0
false
32
*CTRL
328
348
255#0#255
255#0#255
255#0#255
255#0#255
255#0#255
255#0#255
230
true
44#45#46#47#48#49#50#51#52
false
33
*nodeALU_CTRL
467
503
205#91#69
205#91#69
100#100#100
205#91#69
205#91#69
255#127#36
329
false
34
false
34
*ALU_CTRL
329
562
205#91#69
205#91#69
100#100#100
205#91#69
205#91#69
255#127#36
503
true
0
false
35
*nodeALUcontrol1
617
650
205#91#69
205#91#69
100#100#100
205#91#69
205#91#69
255#127#36
501
true
36
false
36
*nodeALUcontrol2
501
385
205#91#69
205#91#69
100#100#100
205#91#69
205#91#69
255#127#36
650
false
99
false
37
*nodeSIGN_EXT
500
536
139#115#85
100#100#100
100#100#100
139#115#85
139#115#85
139#115#85
466
true
38
false
38
*nodeSHIFT_LEFT2
466
404
139#115#85
100#100#100
100#100#100
139#115#85
139#115#85
139#115#85
535
false
39#73
false
39
*nodeSHIFT_LEFT2A
395
153
139#115#85
100#100#100
100#100#100
139#115#85
139#115#85
139#115#85
535
false
40
false
40
*SHIFT_LEFT2
535
550
139#115#85
100#100#100
100#100#100
139#115#85
139#115#85
139#115#85
153
true
41
false
41
ADD2
605
652
139#115#85
100#100#100
100#100#100
139#115#85
139#115#85
139#115#85
170
true
72
false
42
*nodeMUXC2
75
108
205#149#15
205#149#15
205#149#15
205#149#15
205#149#15
205#149#15
794
false
43
false
43
*nodeMUXC3
794
804
205#149#15
205#149#15
205#149#15
205#149#15
205#149#15
205#149#15
108
true
0
false
44
*SIG_CTRL_MUXA1
364
341
255#000#000
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
267
true
53
false
45
*SIG_CTRL_AND1
405
723
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
187
true
0
false
46
*SIG_CTRL_MUXB
414
779
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
209
true
86
false
47
*SIG_CTRL_MEMA1
417
939
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
220
true
62
false
48
*SIG_CTRL_MUXE
417
856
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
235
true
58
false
49
*SIG_CTRL_DATAMEMB1
415
762
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
243
true
61
false
50
*SIG_CTRL_ALUCRTL
412
591
255#0#0
255#0#0
100#100#100
255#0#0
255#0#0
100#100#100
255
true
60
false
51
*SIG_CTRL_MUXD
410
565
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
263
true
59
false
52
*SIG_CTRL_REG
402
472
255#0#0
255#0#0
100#100#100
255#0#0
100#100#100
100#100#100
275
true
57
false
53
*SIG_CTRL_MUXA2
267
439
255#000#000
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
341
false
54
false
54
*SIG_CTRL_MUXA3
341
382
255#000#000
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
440
true
55
false
55
*SIG_CTRL_MUXA4
440
410
255#000#000
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
382
false
56
false
56
*REG3
390
415
255#127#36
0#191#255
100#100#100
0#0#255
0#0#255
0#0#255
387
true
98
false
57
*SIG_CTRL_REG2
275
295
255#0#0
255#0#0
100#100#100
255#0#0
100#100#100
100#100#100
472
false
0
false
58
*SIG_CTRL_MUXE2
235
340
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
856
false
0
false
59
*SIG_CTRL_MUXD2
263
365
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
565
false
0
false
60
*SIG_CTRL_ALUCRTL2
255
453
255#0#0
255#0#0
100#100#100
255#0#0
255#0#0
100#100#100
591
false
35
false
61
*SIG_CTRL_DATAMEMB2
243
315
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
762
false
0
false
62
*SIG_CTRL_MEMA2
220
456
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
939
false
63
false
63
*SIG_CTRL_MEMA3
939
773
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
456
true
64
false
64
*SIG_CTRL_MEMA3
456
407
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
773
false
93
false
65
*REG_OUTPUT1
523
594
0#205#0
0#205#0
100#100#100
0#205#0
0#205#0
0#205#0
320
true
0
false
66
*REG_OUTPUT2
523
524
100#100#100
255#255#0
100#100#100
100#100#100
100#100#100
100#100#100
379
true
67#68
false
67
*REG_OUTPUT2A
531
545
100#100#100
255#255#0
100#100#100
100#100#100
100#100#100
100#100#100
379
true
74
false
68
nodeMEMDATAINPUT1
382
437
100#100#100
255#255#0
100#100#100
100#100#100
100#100#100
100#100#100
526
false
69
false
69
nodeMEMDATAINPUT2
526
680
100#100#100
255#255#0
100#100#100
100#100#100
100#100#100
100#100#100
437
true
70
false
70
nodeMEMDATAINPUT2
437
387
100#100#100
255#255#0
100#100#100
100#100#100
100#100#100
100#100#100
680
false
71
false
71
nodeMEMDATAINPUT2
680
712
100#100#100
255#255#0
100#100#100
100#100#100
100#100#100
100#100#100
387
true
0
false
72
*MUXC
710
762
255#218#185
255#218#185
255#218#185
255#218#185
255#218#185
255#218#185
133
true
0
false
73
nodeMUXD
538
545
139#115#85
100#100#100
100#100#100
139#115#85
139#115#85
139#115#85
400
true
0
false
74
ALUinput2
575
593
139#115#85
255#255#0
100#100#100
139#115#85
139#115#85
139#115#85
388
true
0
false
75
nodeMEMDATAINPUT1A
670
690
16#78#139
16#78#139
100#100#100
16#78#139
16#78#139
100#100#100
364
true
76#77
false
76
*nodeMUXEA1
368
430
16#78#139
16#78#139
100#100#100
100#100#100
100#100#100
100#100#100
692
false
78
false
77
MEMDATAINPUT1B
697
712
100#100#100
100#100#100
100#100#100
16#78#139
16#78#139
100#100#100
364
true
0
false
78
*nodeMUXEA1
692
825
16#78#139
16#78#139
100#100#100
100#100#100
100#100#100
100#100#100
430
true
80
false
79
ZERO_ALU1
670
690
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
340
true
82
false
80
nodeMUXG1B
430
375
16#78#139
16#78#139
100#100#100
100#100#100
100#100#100
100#100#100
825
false
81
false
81
nodeMUXG1C
825
837
16#78#139
16#78#139
100#100#100
100#100#100
100#100#100
100#100#100
375
true
0
false
82
ZERO_ALU1
340
200
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
690
false
83
false
83
ZERO_ALU1
690
725
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
200
true
84
false
84
*AND_MUXC1
742
823
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
192
true
85
false
85
*AND_MUXC2
192
144
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
823
false
88
false
86
*SIG_CTRL_MUXB2
209
146
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
780
false
0
false
87
*MUXCinput2
790
805
238#221#130
255#218#185
255#218#185
255#218#185
255#218#185
255#218#185
134
true
0
false
88
*PCinput1
832
845
205#149#15
205#149#15
255#218#185
205#149#15
205#149#15
255#218#185
120
true
89
false
89
*PCinput2
120
49
205#149#15
205#149#15
255#218#185
205#149#15
205#149#15
255#218#185
845
false
90
false
90
*PCinput3
845
85
205#149#15
205#149#15
255#218#185
205#149#15
205#149#15
255#218#185
49
true
91
false
91
*PCinput4
49
362
205#149#15
205#149#15
255#218#185
205#149#15
205#149#15
255#218#185
85
false
92
false
92
*PCinput5
85
112
205#149#15
205#149#15
255#218#185
205#149#15
205#149#15
255#218#185
362
true
100
false
93
outputDATAMEM1
810
835
100#100#100
100#100#100
100#100#100
30#144#255
100#100#100
100#100#100
354
true
94
false
94
*outputMUXE1
865
895
16#78#139
16#78#139
100#100#100
30#144#255
100#100#100
100#100#100
365
true
95
false
95
outputDATAMEM1
365
522
16#78#139
16#78#139
100#100#100
30#144#255
100#100#100
100#100#100
895
false
96
false
96
outputDATAMEM1
895
400
16#78#139
16#78#139
100#100#100
30#144#255
100#100#100
100#100#100
522
true
97
false
97
outputDATAMEM1
522
414
16#78#139
16#78#139
100#100#100
30#144#255
100#100#100
100#100#100
400
false
4
false
98
READING
420
300
255#0#0
255#0#0
100#100#100
255#0#0
255#0#0
255#0#0
450
false
65#66
true
99
ALUVALUE
400
315
255#0#0
255#0#0
100#100#100
255#0#0
255#0#0
255#0#0
620
false
75#79
true
100
CP+4
400
370
255#0#0
255#0#0
100#100#100
255#0#0
255#0#0
255#0#0
130
false
0
true
101
WRITING
420
300
255#0#0
255#0#0
100#100#100
255#0#0
255#0#0
255#0#0
450
false
101
true
00000
$zero
00001
at
00010
$v0
00011
$v1
00100
$a0
00101
$a1
00110
$a2
00111
$a3
01000
$t0
01001
$t1
01010
$t2
01011
$t3
01100
$t4
01101
$t5
01110
$t6
01111
$t7
10000
$s0
10001
$s1
10010
$s2
10011
$s3
10100
$s4
10101
$s5
11000
$s6
10111
$s7
11000
$t8
11001
$t9
11010
$k0
11011
$k1
11100
$gp
11101
$sp
11110
$fp
11111
$ra
0
init
1
2
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
50
true
1#2#38#39#40#41#42
false
1
registerAdd1
1
700
0#205#0
0#205#0
100#100#100
0#205#0
0#205#0
0#205#0
68
true
58
false
2
registerAdd2
1
700
0#0#255
0#0#255
100#100#100
0#0#255
0#0#255
0#0#255
275
true
59
false
3
registerWrite
1
163
0#0#255
0#255#255
100#100#100
0#0#255
100#100#100
100#100#100
346
true
5
false
4
registerData
1
270
16#78#139
16#78#139
100#100#100
00#255#255
100#100#100
100#100#100
427
true
6
false
5
registerWrite
346
245
0#0#255
0#255#255
100#100#100
0#0#255
100#100#100
100#100#100
163
false
28#29#30#31#32
false
6
registerData
427
252
16#78#139
16#78#139
100#100#100
00#255#255
100#100#100
100#100#100
272
false
7#8
false
7
registerData
252
223
16#78#139
16#78#139
100#100#100
00#255#255
100#100#100
100#100#100
272
false
9#10
false
8
inputReg32
272
375
16#78#139
16#78#139
100#100#100
00#255#255
100#100#100
100#100#100
250
true
38
false
9
registerData
212
195
16#78#139
16#78#139
100#100#100
00#255#255
100#100#100
100#100#100
272
false
11#13
false
10
inputReg31
278
375
16#78#139
16#78#139
100#100#100
00#255#255
100#100#100
100#100#100
220
true
39
false
11
registerData
183
162
16#78#139
16#78#139
100#100#100
00#255#255
100#100#100
100#100#100
272
false
12#14
false
12
inputReg2
278
375
16#78#139
16#78#139
100#100#100
00#255#255
100#100#100
100#100#100
158
true
41
false
13
inputRegIND
278
375
16#78#139
16#78#139
100#100#100
00#255#255
100#100#100
100#100#100
188
true
40
false
14
registerData
152
126
16#78#139
16#78#139
100#100#100
00#255#255
100#100#100
100#100#100
272
false
15
false
15
inputReg1
274
375
16#78#139
16#78#139
100#100#100
00#255#255
100#100#100
100#100#100S
126
true
42
false
16
writeControl
0
52
255#0#0
255#0#0
100#100#100
255#0#0
100#100#100
100#100#100
392
false
17
false
17
writeControl
392
257
255#0#0
255#0#0
100#100#100
255#0#0
100#100#100
100#100#100
52
true
18
false
18
writeControl
52
110
255#0#0
255#0#0
100#100#100
255#0#0
100#100#100
100#100#100
257
false
19#20
false
19
writeControl
121
141
255#0#0
255#0#0
100#100#100
255#0#0
100#100#100
100#100#100
257
false
21#22
false
20
and1
262
313
255#0#0
255#0#0
100#100#100
255#0#0
100#100#100
100#100#100
116
true
0
false
21
and2
262
313
255#0#0
255#0#0
100#100#100
255#0#0
100#100#100
100#100#100
147
true
0
false
22
writeControl
152
175
255#0#0
255#0#0
100#100#100
255#0#0
100#100#100
100#100#100
257
false
23#24
false
23
and3
262
313
255#0#0
255#0#0
100#100#100
255#0#0
100#100#100
100#100#100
180
true
0
false
24
writeControl
185
205
255#0#0
255#0#0
100#100#100
255#0#0
100#100#100
100#100#100
257
false
25#26
false
25
writeControl
216
240
255#0#0
255#0#0
100#100#100
255#0#0
100#100#100
100#100#100
257
false
27
false
26
and4
262
313
255#0#0
255#0#0
100#100#100
255#0#0
100#100#100
100#100#100
211
true
36
false
27
and5
258
313
255#0#0
255#0#0
100#100#100
255#0#0
100#100#100
100#100#100
241
true
37
false
28
and1a
233
313
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
102
true
33
false
29
and2a
233
313
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
137
true
34
false
30
and3a
233
313
0#0#255
255#0#0
100#100#100
255#0#0
100#100#100
100#100#100
169
true
35
false
31
and4a
233
313
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
197
true
0
false
32
and5a
233
313
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
228
true
0
false
33
regData1
340
375
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
110
true
0
false
34
regData2
340
375
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
140
true
0
false
35
regData3
340
375
255#0#0
255#0#0
100#100#100
255#0#0
100#100#100
100#100#100
172
true
0
false
36
regData4
340
375
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
202
true
0
false
37
regData5
340
375
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
234
true
0
false
38
regOutput32
520
543
010#010#150
010#010#150
100#100#100
010#010#150
010#010#150
100#100#100
242
true
43#44
false
39
regOutput31
520
566
254#254#0
254#254#0
100#100#100
254#254#0
254#254#0
254#254#0
210
true
46#47
false
40
regOutputIND
520
588
010#250#150
010#250#150
100#100#100
010#250#150
010#250#150
100#100#100
182
true
49#50
false
41
regOutput2
520
610
0#255#255
0#255#255
100#100#100
0#255#255
0#255#255
0#255#255
151
true
52#53
false
42
regOutput1
520
633
123#123#0
123#123#0
100#100#100
123#123#0
123#123#0
100#100#100
120
true
55#56
false
43
mux1Reg32
552
665
010#010#150
010#010#150
100#100#100
010#010#150
010#010#150
100#100#100
242
true
0
false
44
mux2Reg32
247
435
010#010#150
010#010#150
100#100#100
010#010#150
010#010#150
100#100#100
547
false
45
false
45
mux2Reg32
548
665
010#010#150
010#010#150
100#100#100
010#010#150
010#010#150
100#100#100
434
true
0
false
46
muxReg31
575
663
254#254#0
254#254#0
100#100#100
254#254#0
254#254#0
100#100#100
210
true
0
false
47
mux2Reg31
217
407
254#254#0
254#254#0
100#100#100
254#254#0
254#254#0
100#100#100
570
false
48
false
48
mux2Reg31
570
665
254#254#0
254#254#0
100#100#100
254#254#0
254#254#0
100#100#100
407
true
0
false
49
muxRegInd
597
665
010#250#150
010#250#150
100#100#100
010#250#150
010#250#150
100#100#100
182
true
0
false
50
muxRegInd
186
379
010#250#150
010#250#150
100#100#100
010#250#150
010#250#150
100#100#100
594
false
51
false
51
muxRegInd
594
665
010#250#150
010#250#150
100#100#100
010#250#150
010#250#150
100#100#100
379
true
0
false
52
muxReg2
155
353
0#255#255
0#255#255
100#100#100
0#255#255
0#255#255
100#100#100
616
false
54
false
53
muxReg2
623
665
0#255#255
0#255#255
100#100#100
0#255#255
0#255#255
100#100#100
150
true
0
false
54
muxReg2
615
665
0#255#255
0#255#255
100#100#100
0#255#255
0#255#255
100#100#100
353
true
0
false
55
mux2reg1
642
665
123#123#0
123#123#0
100#100#100
123#123#0
123#123#0
100#100#100
120
true
0
false
56
mux1reg1
125
335
123#123#0
123#123#0
100#100#100
123#123#0
123#123#0
100#100#100
639
false
57
false
57
mux2reg1
639
665
123#123#0
123#123#0
100#100#100
123#123#0
123#123#0
100#100#100
335
true
0
false
58
registerAdd1
68
95
0#205#0
0#205#0
100#100#100
0#205#0
0#205#0
0#205#0
700
false
61
false
59
registerAdd2
275
290
0#0#255
0#0#255
100#100#100
0#0#255
0#0#255
0#0#255
700
false
60
false
60
mux2output
738
800
254#254#0
254#254#0
100#100#100
254#254#0
254#254#0
100#100#100
346
true
0
false
61
mux2output
737
800
010#250#150
010#250#150
100#100#100
010#250#150
010#250#150
100#100#100
145
true
3#4#16
false
00000
$zero
00001
at
00010
$v0
00011
$v1
00100
$a0
00101
$a1
00110
$a2
00111
$a3
01000
$t0
01001
$t1
01010
$t2
01011
$t3
01100
$t4
01101
$t5
01110
$t6
01111
$t7
10000
$s0
10001
$s1
10010
$s2
10011
$s3
10100
$s4
10101
$s5
11000
$s6
10111
$s7
11000
$t8
11001
$t9
11010
$k0
11011
$k1
11100
$gp
11101
$sp
11110
$fp
11111
$ra
0
init
1
2
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
28
true
1#2#3#4#5#6
false
1
bit5_1and1
3
207
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
28
true
7#8
false
2
bit4_1and1
3
217
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
52
true
9#10
false
3
bit3_1and1
3
228
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
76
true
11#12
false
4
bit2_1and1
3
238
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100
true
13#14
false
5
bit1_1and1
3
247
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
124
true
15#16
false
6
bit0_1and1
3
255
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
145
true
17#18
false
7
bit5_2and1
217
312
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
28
true
19#20
false
8
bit5_3and1
37
160
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
211
false
55
false
9
bit4_2and1
228
320
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
52
true
21#22
false
10
bit4_3and1
60
160
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
222
false
0
false
11
bit3_2and1
238
330
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
76
true
23#24
false
12
bit3_3and1
82
160
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
231
false
0
false
13
bit2_2and1
247
342
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100
true
25#26
false
14
bit2_3and1
105
160
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
242
false
0
false
15
bit1_2and1
258
352
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
124
true
27#28
false
16
bit1_3and1
130
160
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
252
false
0
false
17
bit0_2and1
267
360
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
145
true
29#30
false
18
bit0_3and1
150
160
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
262
false
0
false
19
bit5_2and2
320
408
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
28
true
31#32
false
20
bit5_3and2
37
167
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
316
false
56
false
21
bit4_2and2
332
417
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
52
true
33#34
false
22
bit4_3and2
60
160
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
325
false
0
false
23
bit3_2and2
342
427
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
76
true
35#36
false
24
bit3_3and2
82
160
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
336
false
0
false
25
bit2_2and2
352
437
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100
true
37#38
false
26
bit2_3and2
105
160
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
346
false
0
false
27
bit1_2and2
362
446
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
124
true
39#40
false
28
bit1_3and2
130
168
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
357
false
0
false
29
bit0_2and2
372
457
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
145
true
41#42
false
30
bit0_3and2
152
167
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
367
false
0
false
31
bit5_2and3
418
502
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
28
true
43#44
false
32
bit5_3and3
37
167
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
412
false
57
false
33
bit4_2and3
426
511
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
52
true
45#46
false
34
bit4_3and3
60
160
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
422
false
0
false
35
bit3_2and3
436
521
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
76
true
47#48
false
36
bit3_3and3
82
165
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
432
false
0
false
37
bit2_2and3
446
531
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100
true
49#50
false
38
bit2_3and3
105
160
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
442
false
0
false
39
bit1_2and3
456
540
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
124
true
51#52
false
40
bit1_3and3
130
168
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
452
false
0
false
41
bit0_2and3
466
551
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
145
true
53#54
false
42
bit0_3and3
152
167
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
461
false
0
false
43
bit5_2and4
515
660
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
28
true
0
false
44
bit5_3and4
37
160
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
507
false
58
false
45
bit4_2and4
524
660
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
52
true
0
false
46
bit4_3and4
60
160
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
517
false
0
false
47
bit3_2and4
534
660
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
76
true
0
false
48
bit3_3and4
82
160
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
527
false
0
false
49
bit2_2and4
544
660
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100
true
0
false
50
bit2_3and4
105
167
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
537
false
0
false
51
bit1_2and4
554
660
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
124
true
0
false
52
bit1_3and4
130
158
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
547
false
0
false
53
bit0_2and4
564
660
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
145
true
0
false
54
bit0_3and4
152
158
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
557
false
0
false
55
and1_out
225
233
255#0#0
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
236
false
59#60
false
56
and2_out
225
249
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
341
false
63#64
false
57
and3_out
225
277
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
435
false
71#72
false
58
and4_out
225
418
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
532
false
75#76
false
59
and1_out2
245
332
255#0#0
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
236
false
61#62
false
60
regDst
242
795
255#0#0
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
239
true
0
false
61
and1_out3
340
443
255#0#0
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
236
false
69#78
false
62
regDst
244
577
255#0#0
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
336
true
0
false
63
and2_out2
261
302
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
341
false
65#69
false
64
or1_in1
345
574
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
255
true
0
false
65
and2_out3
312
355
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
341
false
66#68
false
66
and2_out4
365
377
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
341
false
67#70
false
67
and2_out5
390
470
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
341
false
0
false
68
or2_in2
345
574
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
360
true
80
false
69
memToReg
345
795
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
308
true
0
false
70
readMem
345
795
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
384
true
0
false
71
and3_out2
287
397
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
435
false
73#74
false
72
or1_in2
440
575
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
283
true
79
false
73
and3_out3
410
480
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
435
false
0
false
74
writeMem
440
795
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
403
true
0
false
75
branch
537
795
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
425
true
0
false
76
and4_out2
430
465
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
532
false
77
false
77
opALU0
537
795
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
470
true
0
false
78
OpAlu1
242
795
255#0#0
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
448
true
0
false
79
or1_out
640
795
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
266
true
0
false
80
writeReg
648
795
255#0#0
255#0#0
100#100#100
255#0#0
100#100#100
100#100#100
345
true
0
false
000000
sll
000010
srl
000011
sra
000100
sllv
000110
srlv
000111
srav
001000
jr
001001
jalr
001010
movz
001011
movn
001100
SYSCALL
001101
BREAK
010000
mfhi
010001
mthi
010010
mflo
010011
mtlo
011000
mult
011001
multu
011010
div
011011
divu
100000
add
100001
addu
100010
sub
100011
subu
100100
and
100101
or
100110
xor
100111
nor
101010
slt
101011
sltu
110000
tge
110001
tgeu
110010
tlt
110011
tltu
110100
teq
110110
tne
0
init
1
2
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
28
true
1#4#7#10#11#17
false
1
bit3_1
5
105
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
110
true
2
false
2
bit3_2
110
335
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
105
false
3
false
3
bit3_3
105
155
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
335
true
19
false
4
bit2_1
5
154
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
183
true
5
false
5
bit2_2
183
262
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
154
false
6
false
6
bit2_2
154
560
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
262
true
23
false
7
bit1_1
5
193
100#100#100
255#0#0
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
285
true
8
false
8
bit1_2
285
187
100#100#100
255#0#0
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
193
false
9
false
9
bit1_3
193
300
100#100#100
255#0#0
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
187
true
21
false
10
bit0_1
5
160
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
370
true
0
false
11
opALU0_1
5
140
255#00#00
255#00#00
255#00#00
255#00#00
255#00#00
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
239
false
12#13
false
12
opALU0_2
155
225
255#00#00
255#00#00
255#00#00
255#00#00
255#00#00
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
239
false
14#15
false,
13
and1_in1
245
295
255#00#00
255#00#00
255#00#00
255#00#00
255#00#00
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
147
true
0
false
14
opALU0_3
237
310
255#00#00
255#00#00
255#00#00
255#00#00
255#00#00
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
239
false
16
false
15
or2_in2
245
560
255#00#00
255#00#00
255#00#00
255#00#00
255#00#00
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
230
true
22
false
16
and2_in1
240
300
255#00#00
255#00#00
255#00#00
255#00#00
255#00#00
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
313
true
0
false
17
opALU0_1
5
118
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
390
false
18
false
18
or1_in1
390
570
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
118
true
0
false
19
or0_out
245
305
100#100#100
100#100#100
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
348
true
20
false
20
op3
382
795
100#100#100
100#100#100
100#100#100
255#0#0
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
324
true
0
false
21
or1_in2
374
570
100#100#100
255#0#0
100#100#100
100#100#100
255#0#0
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
100#100#100
157
true
0
false
22
op1
660
795
100#100#100
255#0#0
100#100#100
100#100#100
255#0#0
255#00#00
255#00#00
100#100#100
100#100#100
100#100#100
100#100#100
133
true
0
false
23
op2
665
795
255#0#0
255#0#0
100#100#100
100#100#100
255#0#0
255#0#0
255#00#00
255#0#0
255#0#0
255#0#0
255#0#0
243
true
0
false
jar cmf mainclass.txt Mars.jar PseudoOps.txt Config.properties Syscall.properties Settings.properties MARSlicense.txt mainclass.txt MipsXRayOpcode.xml registerDatapath.xml controlDatapath.xml ALUcontrolDatapath.xml CreateMarsJar.bat Mars.java Mars.class docs help images mars
Mars.java
Mars.java
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Portal to Mars
*
* @author Pete Sanderson
* @version March 2006
**/
public class Mars {
public static void main(String[] args) {
new mars.MarsLaunch(args);
}
}
Mars
public synchronized class Mars {
public void Mars();
public static void main(String[]);
}
All Classes
All Classes
AbstractDumpFormat
AbstractFontSettingDialog
AbstractMarsToolAndApplication
AbstractSyscall
AccessNotice
AddressErrorException
AsciiTextDumpFormat
Assembler
BackStepper
BasicInstruction
BasicInstructionFormat
BHTableModel
BHTEntry
BHTSimGUI
BHTSimulator
Binary
BinaryDumpFormat
BinaryTextDumpFormat
BitmapDisplay
CacheSimulator
Coprocessor0
Coprocessor0Window
Coprocessor1
Coprocessor1Window
DataSegmentWindow
DataTypes
DefaultInputHandler
DelayedBranch
DigitalLabSim
Directives
DumpFormat
DumpFormatLoader
EditCopyAction
EditCutAction
EditFindReplaceAction
Editor
EditorFont
EditPane
EditPasteAction
EditRedoAction
EditSelectAllAction
EditTabbedPane
EditUndoAction
ErrorList
ErrorMessage
Exceptions
ExecutePane
ExtendedInstruction
FileCloseAction
FileCloseAllAction
FileDumpMemoryAction
FileExitAction
FilenameFinder
FileNewAction
FileOpenAction
FilePrintAction
FileSaveAction
FileSaveAllAction
FileSaveAsAction
FileStatus
FloatRepresentation
GenericTextArea
Globals
GuiAction
HardcopyWriter
HardcopyWriter.PrintCanceledException
HelpAboutAction
HelpHelpAction
HexTextDumpFormat
InputHandler
InputHandler.backspace
InputHandler.backspace_word
InputHandler.clip_copy
InputHandler.clip_cut
InputHandler.clip_paste
InputHandler.delete
InputHandler.delete_word
InputHandler.document_end
InputHandler.document_home
InputHandler.end
InputHandler.home
InputHandler.insert_break
InputHandler.insert_char
InputHandler.insert_tab
InputHandler.MacroRecorder
InputHandler.next_char
InputHandler.next_line
InputHandler.next_page
InputHandler.next_word
InputHandler.NonRecordable
InputHandler.NonRepeatable
InputHandler.overwrite
InputHandler.prev_char
InputHandler.prev_line
InputHandler.prev_page
InputHandler.prev_word
InputHandler.repeat
InputHandler.select_all
InputHandler.toggle_rect
InputHandler.Wrapper
Instruction
InstructionCounter
InstructionSet
InstructionStatistics
IntelHexDumpFormat
IntroToTools
InvalidRegisterAccessException
JEditBasedTextArea
JEditTextArea
KeyboardAndDisplaySimulator
KeywordMap
LabelsWindow
Macro
MacroPool
MainPane
Mars
MarsBot
MarsLaunch
MarsSplashScreen
MARSTextEditingArea
MarsTool
Memory
MemoryAccessNotice
MemoryConfiguration
MemoryConfigurations
MemoryDump
MemoryReferenceVisualization
MessagesPane
MIFDumpFormat
MIPSprogram
MIPSTokenMarker
NumberDisplayBaseChooser
OperandFormat
PopupHelpItem
PopupListener
ProcessingException
ProgramArgumentList
ProgramStatement
PropertiesFile
RandomStreams
Register
RegisterAccessNotice
RegisterFile
RegistersPane
RegistersWindow
RepeatButton
RunAssembleAction
RunBackstepAction
RunClearBreakpointsAction
RunGoAction
RunPauseAction
RunResetAction
RunSpeedPanel
RunStepAction
RunStopAction
RunToggleBreakpointsAction
ScavengerHunt
ScreenMagnifier
SegmentWindowDumpFormat
Settings
SettingsAddressDisplayBaseAction
SettingsAssembleAllAction
SettingsAssembleOnOpenAction
SettingsDelayedBranchingAction
SettingsEditorAction
SettingsExceptionHandlerAction
SettingsExtendedAction
SettingsHighlightingAction
SettingsLabelAction
SettingsMemoryConfigurationAction
SettingsPopupInputAction
SettingsProgramArgumentsAction
SettingsSelfModifyingCodeAction
SettingsStartAtMainAction
SettingsValueDisplayBaseAction
SettingsWarningsAreErrorsAction
SimulationCode
Simulator
Simulator.StopListener
SimulatorNotice
SourceLine
SwingWorker
Symbol
SymbolTable
SyntaxDocument
SyntaxStyle
SyntaxUtilities
Syscall
SyscallClose
SyscallConfirmDialog
SyscallExit
SyscallExit2
SyscallInputDialogDouble
SyscallInputDialogFloat
SyscallInputDialogInt
SyscallInputDialogString
SyscallMessageDialog
SyscallMessageDialogDouble
SyscallMessageDialogFloat
SyscallMessageDialogInt
SyscallMessageDialogString
SyscallMidiOut
SyscallMidiOutSync
SyscallNumberOverride
SyscallOpen
SyscallPrintChar
SyscallPrintDouble
SyscallPrintFloat
SyscallPrintInt
SyscallPrintIntBinary
SyscallPrintIntHex
SyscallPrintIntUnsigned
SyscallPrintString
SyscallRandDouble
SyscallRandFloat
SyscallRandInt
SyscallRandIntRange
SyscallRandSeed
SyscallRead
SyscallReadChar
SyscallReadDouble
SyscallReadFloat
SyscallReadInt
SyscallReadString
SyscallSbrk
SyscallSleep
SyscallTime
SyscallWrite
SystemIO
TextAreaDefaults
TextAreaPainter
TextAreaPainter.Highlight
TextSegmentWindow
TextUtilities
Token
Token
Tokenizer
TokenList
TokenMarker
TokenTypes
ToolAction
ToolLoader
TranslationCode
VenusUI
All Classes
All Classes
AbstractDumpFormat
AbstractFontSettingDialog
AbstractMarsToolAndApplication
AbstractSyscall
AccessNotice
AddressErrorException
AsciiTextDumpFormat
Assembler
BackStepper
BasicInstruction
BasicInstructionFormat
BHTableModel
BHTEntry
BHTSimGUI
BHTSimulator
Binary
BinaryDumpFormat
BinaryTextDumpFormat
BitmapDisplay
CacheSimulator
Coprocessor0
Coprocessor0Window
Coprocessor1
Coprocessor1Window
DataSegmentWindow
DataTypes
DefaultInputHandler
DelayedBranch
DigitalLabSim
Directives
DumpFormat
DumpFormatLoader
EditCopyAction
EditCutAction
EditFindReplaceAction
Editor
EditorFont
EditPane
EditPasteAction
EditRedoAction
EditSelectAllAction
EditTabbedPane
EditUndoAction
ErrorList
ErrorMessage
Exceptions
ExecutePane
ExtendedInstruction
FileCloseAction
FileCloseAllAction
FileDumpMemoryAction
FileExitAction
FilenameFinder
FileNewAction
FileOpenAction
FilePrintAction
FileSaveAction
FileSaveAllAction
FileSaveAsAction
FileStatus
FloatRepresentation
GenericTextArea
Globals
GuiAction
HardcopyWriter
HardcopyWriter.PrintCanceledException
HelpAboutAction
HelpHelpAction
HexTextDumpFormat
InputHandler
InputHandler.backspace
InputHandler.backspace_word
InputHandler.clip_copy
InputHandler.clip_cut
InputHandler.clip_paste
InputHandler.delete
InputHandler.delete_word
InputHandler.document_end
InputHandler.document_home
InputHandler.end
InputHandler.home
InputHandler.insert_break
InputHandler.insert_char
InputHandler.insert_tab
InputHandler.MacroRecorder
InputHandler.next_char
InputHandler.next_line
InputHandler.next_page
InputHandler.next_word
InputHandler.NonRecordable
InputHandler.NonRepeatable
InputHandler.overwrite
InputHandler.prev_char
InputHandler.prev_line
InputHandler.prev_page
InputHandler.prev_word
InputHandler.repeat
InputHandler.select_all
InputHandler.toggle_rect
InputHandler.Wrapper
Instruction
InstructionCounter
InstructionSet
InstructionStatistics
IntelHexDumpFormat
IntroToTools
InvalidRegisterAccessException
JEditBasedTextArea
JEditTextArea
KeyboardAndDisplaySimulator
KeywordMap
LabelsWindow
Macro
MacroPool
MainPane
Mars
MarsBot
MarsLaunch
MarsSplashScreen
MARSTextEditingArea
MarsTool
Memory
MemoryAccessNotice
MemoryConfiguration
MemoryConfigurations
MemoryDump
MemoryReferenceVisualization
MessagesPane
MIFDumpFormat
MIPSprogram
MIPSTokenMarker
NumberDisplayBaseChooser
OperandFormat
PopupHelpItem
PopupListener
ProcessingException
ProgramArgumentList
ProgramStatement
PropertiesFile
RandomStreams
Register
RegisterAccessNotice
RegisterFile
RegistersPane
RegistersWindow
RepeatButton
RunAssembleAction
RunBackstepAction
RunClearBreakpointsAction
RunGoAction
RunPauseAction
RunResetAction
RunSpeedPanel
RunStepAction
RunStopAction
RunToggleBreakpointsAction
ScavengerHunt
ScreenMagnifier
SegmentWindowDumpFormat
Settings
SettingsAddressDisplayBaseAction
SettingsAssembleAllAction
SettingsAssembleOnOpenAction
SettingsDelayedBranchingAction
SettingsEditorAction
SettingsExceptionHandlerAction
SettingsExtendedAction
SettingsHighlightingAction
SettingsLabelAction
SettingsMemoryConfigurationAction
SettingsPopupInputAction
SettingsProgramArgumentsAction
SettingsSelfModifyingCodeAction
SettingsStartAtMainAction
SettingsValueDisplayBaseAction
SettingsWarningsAreErrorsAction
SimulationCode
Simulator
Simulator.StopListener
SimulatorNotice
SourceLine
SwingWorker
Symbol
SymbolTable
SyntaxDocument
SyntaxStyle
SyntaxUtilities
Syscall
SyscallClose
SyscallConfirmDialog
SyscallExit
SyscallExit2
SyscallInputDialogDouble
SyscallInputDialogFloat
SyscallInputDialogInt
SyscallInputDialogString
SyscallMessageDialog
SyscallMessageDialogDouble
SyscallMessageDialogFloat
SyscallMessageDialogInt
SyscallMessageDialogString
SyscallMidiOut
SyscallMidiOutSync
SyscallNumberOverride
SyscallOpen
SyscallPrintChar
SyscallPrintDouble
SyscallPrintFloat
SyscallPrintInt
SyscallPrintIntBinary
SyscallPrintIntHex
SyscallPrintIntUnsigned
SyscallPrintString
SyscallRandDouble
SyscallRandFloat
SyscallRandInt
SyscallRandIntRange
SyscallRandSeed
SyscallRead
SyscallReadChar
SyscallReadDouble
SyscallReadFloat
SyscallReadInt
SyscallReadString
SyscallSbrk
SyscallSleep
SyscallTime
SyscallWrite
SystemIO
TextAreaDefaults
TextAreaPainter
TextAreaPainter.Highlight
TextSegmentWindow
TextUtilities
Token
Token
Tokenizer
TokenList
TokenMarker
TokenTypes
ToolAction
ToolLoader
TranslationCode
VenusUI
Constant Field Values
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Constant Field Values
Contents mars.*
mars.*
mars.ErrorList
public static final String ERROR_MESSAGE_PREFIX “Error”
public static final String FILENAME_PREFIX ” in ”
public static final String LINE_PREFIX ” line ”
public static final String MESSAGE_SEPARATOR “: ”
public static final String POSITION_PREFIX ” column ”
public static final String WARNING_MESSAGE_PREFIX “Warning”
mars.ErrorMessage
public static final boolean ERROR false
public static final boolean WARNING true
mars.Globals
public static final String helpPath “/help/”
public static final String imagesPath “/images/”
public static final String version “4.4”
mars.Settings
public static final int ASSEMBLE_ALL_ENABLED 3
public static final int ASSEMBLE_ON_OPEN_ENABLED 2
public static final int AUTO_INDENT 19
public static final int BARE_MACHINE_ENABLED 1
public static final int CARET_BLINK_RATE 4
public static final int DATA_SEGMENT_HIGHLIGHTING 12
public static final int DATASEGMENT_HIGHLIGHT_BACKGROUND 8
public static final int DATASEGMENT_HIGHLIGHT_FONT 5
public static final int DATASEGMENT_HIGHLIGHT_FOREGROUND 9
public static final int DELAYED_BRANCHING_ENABLED 8
public static final int DISPLAY_ADDRESSES_IN_HEX 5
public static final int DISPLAY_VALUES_IN_HEX 6
public static final int EDITOR_CURRENT_LINE_HIGHLIGHTING 15
public static final int EDITOR_FONT 0
public static final int EDITOR_LINE_NUMBERS_DISPLAYED 9
public static final int EDITOR_POPUP_PREFIX_LENGTH 6
public static final int EDITOR_TAB_SIZE 5
public static final int EVEN_ROW_BACKGROUND 0
public static final int EVEN_ROW_FONT 1
public static final int EVEN_ROW_FOREGROUND 1
public static final int EXCEPTION_HANDLER 0
public static final int EXCEPTION_HANDLER_ENABLED 7
public static final int EXTENDED_ASSEMBLER_ENABLED 0
public static final int GENERIC_TEXT_EDITOR 18
public static final int LABEL_SORT_STATE 2
public static final int LABEL_WINDOW_VISIBILITY 4
public static final int MEMORY_CONFIGURATION 3
public static final int ODD_ROW_BACKGROUND 2
public static final int ODD_ROW_FONT 2
public static final int ODD_ROW_FOREGROUND 3
public static final int POPUP_INSTRUCTION_GUIDANCE 16
public static final int POPUP_SYSCALL_INPUT 17
public static final int PROGRAM_ARGUMENTS 11
public static final int REGISTER_HIGHLIGHT_BACKGROUND 10
public static final int REGISTER_HIGHLIGHT_FONT 6
public static final int REGISTER_HIGHLIGHT_FOREGROUND 11
public static final int REGISTERS_HIGHLIGHTING 13
public static final int SELF_MODIFYING_CODE_ENABLED 20
public static final int START_AT_MAIN 14
public static final int TEXT_COLUMN_ORDER 1
public static final int TEXTSEGMENT_DELAYSLOT_HIGHLIGHT_BACKGROUND 6
public static final int TEXTSEGMENT_DELAYSLOT_HIGHLIGHT_FONT 4
public static final int TEXTSEGMENT_DELAYSLOT_HIGHLIGHT_FOREGROUND 7
public static final int TEXTSEGMENT_HIGHLIGHT_BACKGROUND 4
public static final int TEXTSEGMENT_HIGHLIGHT_FONT 3
public static final int TEXTSEGMENT_HIGHLIGHT_FOREGROUND 5
public static final int WARNINGS_ARE_ERRORS 10
mars.assembler.*
mars.assembler.DataTypes
public static final int BYTE_SIZE 1
public static final int CHAR_SIZE 1
public static final int DOUBLE_SIZE 8
public static final int FLOAT_SIZE 4
public static final int HALF_SIZE 2
public static final double LOW_DOUBLE_VALUE -1.7976931348623157E308
public static final double LOW_FLOAT_VALUE -3.4028234663852886E38
public static final int MAX_BYTE_VALUE 127
public static final double MAX_DOUBLE_VALUE 1.7976931348623157E308
public static final double MAX_FLOAT_VALUE 3.4028234663852886E38
public static final int MAX_HALF_VALUE 32767
public static final int MAX_UHALF_VALUE 65535
public static final int MAX_WORD_VALUE 2147483647
public static final int MIN_BYTE_VALUE -128
public static final int MIN_HALF_VALUE -32768
public static final int MIN_UHALF_VALUE 0
public static final int MIN_WORD_VALUE -2147483648
public static final int WORD_SIZE 4
mars.assembler.Symbol
public static final boolean DATA_SYMBOL true
public static final boolean TEXT_SYMBOL false
mars.assembler.SymbolTable
public static final int NOT_FOUND -1
mars.assembler.TokenTypes
public static final String TOKEN_DELIMITERS “\t ,()”
mars.mips.*
mars.mips.hardware.AccessNotice
public static final int READ 0
public static final int WRITE 1
mars.mips.hardware.Coprocessor0
public static final int CAUSE 13
public static final int DEFAULT_STATUS_VALUE 65297
public static final int EPC 14
public static final int EXCEPTION_LEVEL 1
public static final int STATUS 12
public static final int VADDR 8
mars.mips.hardware.Memory
public static final boolean BIG_ENDIAN false
public static final boolean LITTLE_ENDIAN true
public static final int WORD_LENGTH_BYTES 4
mars.mips.hardware.RegisterFile
public static final int GLOBAL_POINTER_REGISTER 28
public static final int STACK_POINTER_REGISTER 29
mars.mips.instructions.Instruction
public static final int INSTRUCTION_LENGTH 4
public static final int INSTRUCTION_LENGTH_BITS 32
mars.simulator.*
mars.simulator.Exceptions
public static final int ADDRESS_EXCEPTION_LOAD 4
public static final int ADDRESS_EXCEPTION_STORE 5
public static final int ARITHMETIC_OVERFLOW_EXCEPTION 12
public static final int BREAKPOINT_EXCEPTION 9
public static final int DIVIDE_BY_ZERO_EXCEPTION 15
public static final int EXTERNAL_INTERRUPT_DISPLAY 128
public static final int EXTERNAL_INTERRUPT_KEYBOARD 64
public static final int FLOATING_POINT_OVERFLOW 16
public static final int FLOATING_POINT_UNDERFLOW 17
public static final int RESERVED_INSTRUCTION_EXCEPTION 10
public static final int SYSCALL_EXCEPTION 8
public static final int TRAP_EXCEPTION 13
mars.simulator.Simulator
public static final int BREAKPOINT 1
public static final int CLIFF_TERMINATION 5
public static final int EXCEPTION 2
public static final int MAX_STEPS 3
public static final int NO_DEVICE 0
public static final int NORMAL_TERMINATION 4
public static final int PAUSE_OR_STOP 6
mars.simulator.SimulatorNotice
public static final int SIMULATOR_START 0
public static final int SIMULATOR_STOP 1
mars.tools.*
mars.tools.BHTSimGUI
public static final String BHT_DO_NOT_TAKE_BRANCH “NOT TAKE”
public static final String BHT_TAKE_BRANCH “TAKE”
mars.tools.BHTSimulator
public static final int BHT_DEFAULT_HISTORY 1
public static final boolean BHT_DEFAULT_INITVAL false
public static final int BHT_DEFAULT_SIZE 16
public static final String BHT_HEADING “Branch History Table Simulator”
public static final String BHT_NAME “BHT Simulator”
public static final String BHT_VERSION “Version 1.0 (Ingo Kofler)”
mars.tools.DigitalLabSim
public static final int EXTERNAL_INTERRUPT_HEXA_KEYBOARD 512
public static final int EXTERNAL_INTERRUPT_TIMER 256
mars.util.*
mars.util.EditorFont
public static final int DEFAULT_SIZE 12
public static final int MAX_SIZE 72
public static final int MIN_SIZE 6
mars.util.SystemIO
public static final int SYSCALL_BUFSIZE 128
public static final int SYSCALL_MAXFILES 32
mars.venus.*
mars.venus.Editor
public static final int MAX_BLINK_RATE 1000
public static final int MAX_TAB_SIZE 32
public static final int MIN_BLINK_RATE 0
public static final int MIN_TAB_SIZE 1
mars.venus.FileStatus
public static final int EDITED 4
public static final int NEW_EDITED 2
public static final int NEW_NOT_EDITED 1
public static final int NO_FILE 0
public static final int NOT_EDITED 3
public static final int OPENING 8
public static final int RUNNABLE 5
public static final int RUNNING 6
public static final int TERMINATED 7
mars.venus.HelpHelpAction
public static final String descriptionDetailSeparator “:”
mars.venus.NumberDisplayBaseChooser
public static final int ASCII 0
public static final int DECIMAL 10
public static final int HEXADECIMAL 16
mars.venus.RunSpeedPanel
public static final double UNLIMITED_SPEED 40.0
mars.venus.SettingsHighlightingAction
public static final String APPLY_TOOL_TIP_TEXT “Apply current settings now and leave dialog open”
public static final String CANCEL_TOOL_TIP_TEXT “Close dialog without applying current settings”
public static final String CLOSE_TOOL_TIP_TEXT “Apply current settings and close dialog”
public static final String RESET_TOOL_TIP_TEXT “Reset to initial settings without applying”
mars.venus.editors.MARSTextEditingArea
public static final int TEXT_FOUND 1
public static final int TEXT_NOT_FOUND 0
public static final int TEXT_REPLACED_FOUND_NEXT 2
public static final int TEXT_REPLACED_NOT_FOUND_NEXT 3
mars.venus.editors.jeditsyntax.InputHandler
public static final String SMART_HOME_END_PROPERTY “InputHandler.homeEnd”
mars.venus.editors.jeditsyntax.tokenmarker.Token
public static final byte COMMENT1 1
public static final byte COMMENT2 2
public static final byte END 127
public static final byte ID_COUNT 12
public static final byte INTERNAL_FIRST 100
public static final byte INTERNAL_LAST 126
public static final byte INVALID 10
public static final byte KEYWORD1 6
public static final byte KEYWORD2 7
public static final byte KEYWORD3 8
public static final byte LABEL 5
public static final byte LITERAL1 3
public static final byte LITERAL2 4
public static final byte MACRO_ARG 11
public static final byte NULL 0
public static final byte OPERATOR 9
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Deprecated List
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Deprecated API
Contents Deprecated Methods
Deprecated Constructors
Deprecated Methods
mars.Settings.getAssembleAllEnabled()
Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.ASSEMBLE_ALL_ENABLED)
mars.Settings.getAssembleOnOpenEnabled()
Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.ASSEMBLE_ON_OPEN_ENABLED)
mars.Settings.getBareMachineEnabled()
Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.BARE_MACHINE_ENABLED)
mars.Settings.getDataSegmentHighlighting()
Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.DATA_SEGMENT_HIGHLIGHTING)
mars.Settings.getDelayedBranchingEnabled()
Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.DELAYED_BRANCHING_ENABLED)
mars.Settings.getDisplayAddressesInHex()
Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.DISPLAY_ADDRESSES_IN_HEX)
mars.Settings.getDisplayValuesInHex()
Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.DISPLAY_VALUES_IN_HEX)
mars.Settings.getEditorLineNumbersDisplayed()
Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.EDITOR_LINE_NUMBERS_DISPLAYED)
mars.Settings.getExceptionHandlerEnabled()
Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.EXCEPTION_HANDLER_ENABLED)
mars.Settings.getExtendedAssemblerEnabled()
Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.EXTENDED_ASSEMBLER_ENABLED)
mars.Settings.getLabelWindowVisibility()
Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.LABEL_WINDOW_VISIBILITY)
mars.Settings.getProgramArguments()
Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.PROGRAM_ARGUMENTS)
mars.Settings.getRegistersHighlighting()
Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.REGISTERS_HIGHLIGHTING)
mars.Settings.getStartAtMain()
Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.START_AT_MAIN)
mars.Settings.getWarningsAreErrors()
Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.WARNINGS_ARE_ERRORS)
mars.Settings.setAssembleAllEnabled(boolean)
Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.ASSEMBLE_ALL_ENABLED)
mars.Settings.setAssembleOnOpenEnabled(boolean)
Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.ASSEMBLE_ON_OPEN_ENABLED)
mars.Settings.setDataSegmentHighlighting(boolean)
Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DATA_SEGMENT_HIGHLIGHTING)
mars.Settings.setDelayedBranchingEnabled(boolean)
Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DELAYED_BRANCHING_ENABLED)
mars.Settings.setDelayedBranchingEnabledNonPersistent(boolean)
Use setBooleanSettingNonPersistent(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DELAYED_BRANCHING_ENABLED)
mars.Settings.setDisplayAddressesInHex(boolean)
Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DISPLAY_ADDRESSES_IN_HEX)
mars.Settings.setDisplayValuesInHex(boolean)
Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DISPLAY_VALUES_IN_HEX)
mars.Settings.setEditorLineNumbersDisplayed(boolean)
Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.EDITOR_LINE_NUMBERS_DISPLAYED)
mars.Settings.setExceptionHandlerEnabled(boolean)
Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.EXCEPTION_HANDLER_ENABLED)
mars.Settings.setExtendedAssemblerEnabled(boolean)
Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.EXTENDED_ASSEMBLER_ENABLED)
mars.Settings.setLabelWindowVisibility(boolean)
Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.LABEL_WINDOW_VISIBILITY)
mars.Settings.setProgramArguments(boolean)
Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.PROGRAM_ARGUMENTS)
mars.Settings.setRegistersHighlighting(boolean)
Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.REGISTERS_HIGHLIGHTING)
mars.Settings.setStartAtMain(boolean)
Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.START_AT_MAIN)
mars.Settings.setWarningsAreErrors(boolean)
Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.WARNINGS_ARE_ERRORS)
Deprecated Constructors
mars.ErrorMessage(boolean, String, int, int, String, String)
Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.
mars.ErrorMessage(String, int, int, String)
Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.
mars.ErrorMessage(String, int, int, String, String)
Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
API Help
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
How This API Document Is Organized
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
Overview
The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.
Package
Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:
Interfaces (italic)
Classes
Enums
Exceptions
Errors
Annotation Types
Class/Interface
Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
Class inheritance diagram
Direct Subclasses
All Known Subinterfaces
All Known Implementing Classes
Class/interface declaration
Class/interface description
Nested Class Summary
Field Summary
Constructor Summary
Method Summary
Field Detail
Constructor Detail
Method Detail
Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
Annotation Type
Each annotation type has its own separate page with the following sections:
Annotation Type declaration
Annotation Type description
Required Element Summary
Optional Element Summary
Element Detail
Enum
Each enum has its own separate page with the following sections:
Enum declaration
Enum description
Enum Constant Summary
Enum Constant Detail
Tree (Class Hierarchy)
There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object. When viewing the Overview page, clicking on “Tree” displays the hierarchy for all packages.
When viewing a particular package, class or interface page, clicking “Tree” displays the hierarchy for only that package.
Deprecated API
The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
Index
The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
Prev/Next
These links take you to the next or previous class, interface, package, or related page.
Frames/No Frames
These links show and hide the HTML frames. All pages are available with or without frames.
Serialized Form
Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking “Serialized Form” in the “See also” section of the class description.
Constant Field Values
The Constant Field Values page lists the static final fields and their values.
This help file applies to API documentation generated using the standard doclet.
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Index
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
A B C D E F G H I J K L M N O P Q R S T U V W X Y _
A
AbstractDumpFormat – Class in mars.mips.dump
Abstract class for memory dump file formats.
AbstractDumpFormat(String, String, String, String) –
Constructor for class mars.mips.dump.AbstractDumpFormat
Typical constructor.
AbstractFontSettingDialog – Class in mars.venus
Abstract class for a font selection dialog.
AbstractFontSettingDialog(Frame, String, boolean, Font) –
Constructor for class mars.venus.AbstractFontSettingDialog
Create a new font chooser.
AbstractMarsToolAndApplication – Class in mars.tools
An abstract class that provides generic components to facilitate implementation of
a MarsTool and/or stand-alone Mars-based application.
AbstractMarsToolAndApplication(String, String) –
Constructor for class mars.tools.AbstractMarsToolAndApplication
Simple constructor
AbstractMarsToolAndApplication.ConnectButton – Class in mars.tools
AbstractMarsToolAndApplication.ConnectButton() –
Constructor for class mars.tools.AbstractMarsToolAndApplication.ConnectButton
AbstractMarsToolAndApplication.EnterKeyListener – Class in mars.tools
AbstractMarsToolAndApplication.EnterKeyListener(AbstractButton) –
Constructor for class mars.tools.AbstractMarsToolAndApplication.EnterKeyListener
AbstractSyscall – Class in mars.mips.instructions.syscalls
Abstract class that a MIPS syscall system service may extend.
AbstractSyscall(int, String) –
Constructor for class mars.mips.instructions.syscalls.AbstractSyscall
Constructor is provided so subclass may initialize instance variables.
accessIsFromGUI() –
Method in class mars.mips.hardware.AccessNotice
Query whether the access originated from MARS GUI (AWT event queue)
accessIsFromMIPS() –
Method in class mars.mips.hardware.AccessNotice
Query whether the access originated from executing MIPS program
AccessNotice – Class in mars.mips.hardware
Object provided to Observers of runtime access to MIPS memory or registers.
AccessNotice(int) –
Constructor for class mars.mips.hardware.AccessNotice
action() –
Method in class mars.tools.AbstractMarsToolAndApplication
Required MarsTool method to carry out Tool functions.
action() –
Method in class mars.tools.MarsBot
action() –
Method in interface mars.tools.MarsTool
Performs tool functions.
action() –
Method in class mars.tools.ScavengerHunt
action() –
Method in class mars.tools.ScreenMagnifier
actionPerformed(ActionEvent) –
Method in class mars.tools.BHTSimulator
Handles the actions when selecting another value in one of the two combo boxes.
actionPerformed(ActionEvent) –
Method in class mars.venus.Coprocessor1Window
Called when user clicks on a condition flag checkbox.
actionPerformed(ActionEvent) –
Method in class mars.venus.EditCopyAction
actionPerformed(ActionEvent) –
Method in class mars.venus.EditCutAction
actionPerformed(ActionEvent) –
Method in class mars.venus.EditFindReplaceAction
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.backspace
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.backspace_word
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.clip_copy
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.clip_cut
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.clip_paste
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.delete
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.delete_word
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.document_end
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.document_home
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.end
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.home
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.insert_break
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.insert_char
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.insert_tab
actionPerformed(ActionListener, String) –
Method in interface mars.venus.editors.jeditsyntax.InputHandler.MacroRecorder
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.next_char
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.next_line
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.next_page
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.next_word
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.overwrite
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.prev_char
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.prev_line
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.prev_page
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.prev_word
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.repeat
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.select_all
actionPerformed(ActionEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler.toggle_rect
actionPerformed(ActionEvent) –
Method in class mars.venus.EditPasteAction
actionPerformed(ActionEvent) –
Method in class mars.venus.EditRedoAction
Adapted from TextComponentDemo.java in the
Java Tutorial “Text Component Features”
actionPerformed(ActionEvent) –
Method in class mars.venus.EditSelectAllAction
actionPerformed(ActionEvent) –
Method in class mars.venus.EditUndoAction
Adapted from TextComponentDemo.java in the
Java Tutorial “Text Component Features”
actionPerformed(ActionEvent) –
Method in class mars.venus.FileCloseAction
actionPerformed(ActionEvent) –
Method in class mars.venus.FileCloseAllAction
actionPerformed(ActionEvent) –
Method in class mars.venus.FileDumpMemoryAction
actionPerformed(ActionEvent) –
Method in class mars.venus.FileExitAction
Exit MARS, unless one or more files have unsaved edits and user cancels.
actionPerformed(ActionEvent) –
Method in class mars.venus.FileNewAction
Code to create a new document.
actionPerformed(ActionEvent) –
Method in class mars.venus.FileOpenAction
Launch a file chooser for name of file to open
actionPerformed(ActionEvent) –
Method in class mars.venus.FilePrintAction
Uses the HardcopyWriter class developed by David Flanagan for the book
“Java Examples in a Nutshell”.
actionPerformed(ActionEvent) –
Method in class mars.venus.FileSaveAction
saves the file, if not alredy saved it will do a saveAs
actionPerformed(ActionEvent) –
Method in class mars.venus.FileSaveAllAction
actionPerformed(ActionEvent) –
Method in class mars.venus.FileSaveAsAction
actionPerformed(ActionEvent) –
Method in class mars.venus.GuiAction
does nothing by default.
actionPerformed(ActionEvent) –
Method in class mars.venus.HelpAboutAction
actionPerformed(ActionEvent) –
Method in class mars.venus.HelpHelpAction
Displays tabs with categories of information
actionPerformed(ActionEvent) –
Method in class mars.venus.RepeatButton
Handle action events.
actionPerformed(ActionEvent) –
Method in class mars.venus.RunAssembleAction
actionPerformed(ActionEvent) –
Method in class mars.venus.RunBackstepAction
perform next simulated instruction step.
actionPerformed(ActionEvent) –
Method in class mars.venus.RunClearBreakpointsAction
When this option is selected, tell text segment window to clear breakpoints in its table model.
actionPerformed(ActionEvent) –
Method in class mars.venus.RunGoAction
Action to take when GO is selected — run the MIPS program!
actionPerformed(ActionEvent) –
Method in class mars.venus.RunPauseAction
actionPerformed(ActionEvent) –
Method in class mars.venus.RunResetAction
reset GUI components and MIPS resources
actionPerformed(ActionEvent) –
Method in class mars.venus.RunStepAction
perform next simulated instruction step.
actionPerformed(ActionEvent) –
Method in class mars.venus.RunStopAction
actionPerformed(ActionEvent) –
Method in class mars.venus.RunToggleBreakpointsAction
When this option is selected, tell text segment window to clear breakpoints in its table model.
actionPerformed(ActionEvent) –
Method in class mars.venus.SettingsAddressDisplayBaseAction
actionPerformed(ActionEvent) –
Method in class mars.venus.SettingsAssembleAllAction
actionPerformed(ActionEvent) –
Method in class mars.venus.SettingsAssembleOnOpenAction
actionPerformed(ActionEvent) –
Method in class mars.venus.SettingsDelayedBranchingAction
actionPerformed(ActionEvent) –
Method in class mars.venus.SettingsEditorAction
When this action is triggered, launch a dialog to view and modify
editor settings.
actionPerformed(ActionEvent) –
Method in class mars.venus.SettingsExceptionHandlerAction
actionPerformed(ActionEvent) –
Method in class mars.venus.SettingsExtendedAction
actionPerformed(ActionEvent) –
Method in class mars.venus.SettingsHighlightingAction
When this action is triggered, launch a dialog to view and modify
editor settings.
actionPerformed(ActionEvent) –
Method in class mars.venus.SettingsLabelAction
actionPerformed(ActionEvent) –
Method in class mars.venus.SettingsMemoryConfigurationAction
When this action is triggered, launch a dialog to view and modify
editor settings.
actionPerformed(ActionEvent) –
Method in class mars.venus.SettingsPopupInputAction
actionPerformed(ActionEvent) –
Method in class mars.venus.SettingsProgramArgumentsAction
actionPerformed(ActionEvent) –
Method in class mars.venus.SettingsSelfModifyingCodeAction
actionPerformed(ActionEvent) –
Method in class mars.venus.SettingsStartAtMainAction
actionPerformed(ActionEvent) –
Method in class mars.venus.SettingsValueDisplayBaseAction
actionPerformed(ActionEvent) –
Method in class mars.venus.SettingsWarningsAreErrorsAction
actionPerformed(ActionEvent) –
Method in class mars.venus.ToolAction
Response when tool’s item selected from menu.
add(Token) –
Method in class mars.assembler.TokenList
Adds a Token object to the end of the list.
add(ErrorMessage) –
Method in class mars.ErrorList
Add new error message to end of list.
add(ErrorMessage, int) –
Method in class mars.ErrorList
Add new error message at specified index position.
add(String, byte) –
Method in class mars.venus.editors.jeditsyntax.KeywordMap
Adds a key-value mapping.
addArg(String) –
Method in class mars.assembler.Macro
addAsObserver() –
Method in class mars.tools.AbstractMarsToolAndApplication
Add this app/tool as an Observer of desired MIPS Observables (memory and registers).
addAsObserver(int, int) –
Method in class mars.tools.AbstractMarsToolAndApplication
Add this app/tool as an Observer of the specified subrange of MIPS memory.
addAsObserver(Register) –
Method in class mars.tools.AbstractMarsToolAndApplication
Add this app/tool as an Observer of the specified MIPS register.
addAsObserver() –
Method in class mars.tools.BHTSimulator
Adds BHTSimulator as observer of the text segment.
addAsObserver() –
Method in class mars.tools.BitmapDisplay
Override the inherited method, which registers us as an Observer over the static data segment
(starting address 0x10010000) only.
addAsObserver() –
Method in class mars.tools.DigitalLabSim
addAsObserver() –
Method in class mars.tools.FloatRepresentation
Override the inherited method, which registers us as an Observer over the static data segment
(starting address 0x10010000) only.
addAsObserver() –
Method in class mars.tools.InstructionCounter
addAsObserver() –
Method in class mars.tools.InstructionStatistics
registers the tool as observer for the text segment of the MIPS program
addAsObserver() –
Method in class mars.tools.KeyboardAndDisplaySimulator
Override the inherited method, which registers us as an Observer over the static data segment
(starting address 0x10010000) only.
addAsObserver() –
Method in class mars.tools.MemoryReferenceVisualization
Override the inherited method, which registers us as an Observer over the static data segment
(starting address 0x10010000) only.
addCaretListener(CaretListener) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Adds a caret change listener to this text area.
addConditionFlagClear(int) –
Method in class mars.simulator.BackStepper
Add a new “back step” (the undo action) to the stack.
addConditionFlagSet(int) –
Method in class mars.simulator.BackStepper
Add a new “back step” (the undo action) to the stack.
addCoprocessor0Restore(int, int) –
Method in class mars.simulator.BackStepper
Add a new “back step” (the undo action) to the stack.
addCoprocessor1Restore(int, int) –
Method in class mars.simulator.BackStepper
Add a new “back step” (the undo action) to the stack.
addCustomHighlight(TextAreaPainter.Highlight) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Adds a custom highlight painter.
addDefaultKeyBindings() –
Method in class mars.venus.editors.jeditsyntax.DefaultInputHandler
Sets up the default key bindings.
addDefaultKeyBindings() –
Method in class mars.venus.editors.jeditsyntax.InputHandler
Adds the default key bindings to this input handler.
addDoNothing(int) –
Method in class mars.simulator.BackStepper
Add a new “back step” (the undo action) to the stack.
addKeyBinding(String, ActionListener) –
Method in class mars.venus.editors.jeditsyntax.DefaultInputHandler
Adds a key binding to this input handler.
addKeyBinding(String, ActionListener) –
Method in class mars.venus.editors.jeditsyntax.InputHandler
Adds a key binding to this input handler.
addLabel(String) –
Method in class mars.assembler.Macro
addMemoryRestoreByte(int, int) –
Method in class mars.simulator.BackStepper
Add a new “back step” (the undo action) to the stack.
addMemoryRestoreHalf(int, int) –
Method in class mars.simulator.BackStepper
Add a new “back step” (the undo action) to the stack.
addMemoryRestoreRawWord(int, int) –
Method in class mars.simulator.BackStepper
Add a new “back step” (the undo action) to the stack.
addMemoryRestoreWord(int, int) –
Method in class mars.simulator.BackStepper
Add a new “back step” (the undo action) to the stack.
addObserver(Observer) –
Method in class mars.mips.hardware.Memory
Method to accept registration from observer for any memory address.
addObserver(Observer, int) –
Method in class mars.mips.hardware.Memory
Method to accept registration from observer for specific address.
addObserver(Observer, int, int) –
Method in class mars.mips.hardware.Memory
Method to accept registration from observer for specific address range.
addPCRestore(int) –
Method in class mars.simulator.BackStepper
Add a new “back step” (the undo action) to the stack.
addProgramArgumentsPanel() –
Method in class mars.venus.TextSegmentWindow
addRegisterFileRestore(int, int) –
Method in class mars.simulator.BackStepper
Add a new “back step” (the undo action) to the stack.
addRegistersObserver(Observer) –
Static method in class mars.mips.hardware.Coprocessor0
Each individual register is a separate object and Observable.
addRegistersObserver(Observer) –
Static method in class mars.mips.hardware.Coprocessor1
Each individual register is a separate object and Observable.
addRegistersObserver(Observer) –
Static method in class mars.mips.hardware.RegisterFile
Each individual register is a separate object and Observable.
ADDRESS_EXCEPTION_LOAD –
Static variable in class mars.simulator.Exceptions
ADDRESS_EXCEPTION_STORE –
Static variable in class mars.simulator.Exceptions
AddressErrorException – Exception in mars.mips.hardware
Represents MIPS AddressErrorException.
AddressErrorException(String, int, int) –
Constructor for exception mars.mips.hardware.AddressErrorException
Constructor for the AddressErrorException class
addStopListener(Simulator.StopListener) –
Method in class mars.simulator.Simulator
addSymbol(Token, int, boolean, ErrorList) –
Method in class mars.assembler.SymbolTable
Adds a Symbol object into the array of Symbols.
addToken(int, byte) –
Method in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
Adds a token to the token list.
addUndoableEdit(UndoableEdit) –
Method in class mars.venus.editors.jeditsyntax.SyntaxDocument
Adds an undoable edit to this document’s undo list.
aff –
Variable in class mars.tools.DigitalLabSim.SevenSegmentDisplay
ALIGN –
Static variable in class mars.assembler.Directives
alignToWordBoundary(int) –
Static method in class mars.mips.hardware.Memory
Utility method to align given address to next full word boundary, if not already
aligned.
allocateBytesFromHeap(int) –
Method in class mars.mips.hardware.Memory
Returns the next available word-aligned heap address.
apply(Font) –
Method in class mars.venus.AbstractFontSettingDialog
Apply the given font.
APPLY_TOOL_TIP_TEXT –
Static variable in class mars.venus.SettingsHighlightingAction
ARITHMETIC_OVERFLOW_EXCEPTION –
Static variable in class mars.simulator.Exceptions
ASCII –
Static variable in class mars.assembler.Directives
ASCII –
Static variable in class mars.venus.NumberDisplayBaseChooser
ASCII_NON_PRINT –
Static variable in class mars.Globals
Placeholder for non-printable ASCII codes
ASCII_TABLE –
Static variable in class mars.Globals
Array of strings to display for ASCII codes in ASCII display of data segment.
AsciiTextDumpFormat – Class in mars.mips.dump
Class that represents the “ASCII text” memory dump format.
AsciiTextDumpFormat() –
Constructor for class mars.mips.dump.AsciiTextDumpFormat
Constructor.
ASCIIZ –
Static variable in class mars.assembler.Directives
assemble(MIPSprogram, boolean) –
Method in class mars.assembler.Assembler
Parse and generate machine code for the given MIPS program.
assemble(MIPSprogram, boolean, boolean) –
Method in class mars.assembler.Assembler
Parse and generate machine code for the given MIPS program.
assemble(ArrayList, boolean) –
Method in class mars.assembler.Assembler
Parse and generate machine code for the given MIPS program.
assemble(ArrayList, boolean, boolean) –
Method in class mars.assembler.Assembler
Parse and generate machine code for the given MIPS program.
assemble(ArrayList, boolean) –
Method in class mars.MIPSprogram
Assembles the MIPS source program.
assemble(ArrayList, boolean, boolean) –
Method in class mars.MIPSprogram
Assembles the MIPS source program.
ASSEMBLE_ALL_ENABLED –
Static variable in class mars.Settings
Flag to determine whether only the current editor source file (enabled false) or
all files in its directory (enabled true) will be assembled when assembly is selected.
ASSEMBLE_ON_OPEN_ENABLED –
Static variable in class mars.Settings
Flag to determine whether or not a file is immediately and automatically assembled
upon opening.
Assembler – Class in mars.assembler
An Assembler is capable of assembling a MIPS program.
Assembler() –
Constructor for class mars.assembler.Assembler
AUTO_INDENT –
Static variable in class mars.Settings
Flag to control whether or not language-aware editor will use auto-indent feature
B
BACKSPACE –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
BACKSPACE_WORD –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
backStep() –
Method in class mars.simulator.BackStepper
Carry out a “back step”, which will undo the latest execution step.
BackStepper – Class in mars.simulator
Used to “step backward” through execution, undoing each instruction.
BackStepper() –
Constructor for class mars.simulator.BackStepper
Create a fresh BackStepper.
backSteppingEnabled() –
Method in class mars.MIPSprogram
Returns status of BackStepper associated with this program.
BARE_MACHINE_ENABLED –
Static variable in class mars.Settings
Flag to determine whether or not program being assembled is limited to
using register numbers instead of names.
BasicInstruction – Class in mars.mips.instructions
Class to represent a basic instruction in the MIPS instruction set.
BasicInstruction(String, String, BasicInstructionFormat, String, SimulationCode) –
Constructor for class mars.mips.instructions.BasicInstruction
BasicInstruction constructor.
BasicInstruction(String, BasicInstructionFormat, String, SimulationCode) –
Constructor for class mars.mips.instructions.BasicInstruction
BasicInstructionFormat – Class in mars.mips.instructions
These are the MIPS-defined formats of basic machine instructions.
beginCompoundEdit() –
Method in class mars.venus.editors.jeditsyntax.SyntaxDocument
Starts a compound edit that can be undone in one operation.
beginMacro(Token) –
Method in class mars.assembler.MacroPool
This method will be called by parser when reached .macro
directive.
Instantiates a new Macro object and stores it in MacroPool.current
.
BHT_DEFAULT_HISTORY –
Static variable in class mars.tools.BHTSimulator
constant for the default history size
BHT_DEFAULT_INITVAL –
Static variable in class mars.tools.BHTSimulator
constant for the default inital value
BHT_DEFAULT_SIZE –
Static variable in class mars.tools.BHTSimulator
constant for the default size of the BHT
BHT_DO_NOT_TAKE_BRANCH –
Static variable in class mars.tools.BHTSimGUI
constant for the String representing “do not take the branch”
BHT_HEADING –
Static variable in class mars.tools.BHTSimulator
the heading of the tool
BHT_NAME –
Static variable in class mars.tools.BHTSimulator
the name of the tool
BHT_TAKE_BRANCH –
Static variable in class mars.tools.BHTSimGUI
constant for the String representing “take the branch”
BHT_VERSION –
Static variable in class mars.tools.BHTSimulator
the version of the tool
BHTableModel – Class in mars.tools
Simulates the actual functionality of a Branch History Table (BHT).
BHTableModel(int, int, boolean) –
Constructor for class mars.tools.BHTableModel
Constructs a new BHT with given number of entries and history size.
BHTEntry – Class in mars.tools
Represents a single entry of the Branch History Table.
BHTEntry(int, boolean) –
Constructor for class mars.tools.BHTEntry
Constructs a BHT entry with a given history size.
BHTSimGUI – Class in mars.tools
Represents the GUI of the BHT Simulator Tool.
BHTSimGUI() –
Constructor for class mars.tools.BHTSimGUI
Creates the GUI components of the BHT Simulator
The GUI is a subclass of JPanel which is integrated in the GUI of the MARS tool
BHTSimulator – Class in mars.tools
A MARS tool for simulating branch prediction with a Branch History Table (BHT)
BHTSimulator() –
Constructor for class mars.tools.BHTSimulator
Creates a BHT Simulator with given name and heading.
biasLeft –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
BIG_ENDIAN –
Static variable in class mars.mips.hardware.Memory
Constant representing byte order of each memory word.
Binary – Class in mars.util
Some utility methods for working with binary representations.
Binary() –
Constructor for class mars.util.Binary
BinaryDumpFormat – Class in mars.mips.dump
Class that represents the “binary” memory dump format.
BinaryDumpFormat() –
Constructor for class mars.mips.dump.BinaryDumpFormat
Constructor.
binaryStringToHexDigit(String) –
Static method in class mars.util.Binary
Translate String consisting of ‘1’s and ‘0’s into char equivalent of the corresponding
hexadecimal digit.
binaryStringToHexString(String) –
Static method in class mars.util.Binary
Translate String consisting of ‘1’s and ‘0’s into String equivalent of the corresponding
hexadecimal value.
binaryStringToInt(String) –
Static method in class mars.util.Binary
Translate String consisting of ‘1’s and ‘0’s into an int value having that binary representation.
binaryStringToLong(String) –
Static method in class mars.util.Binary
Translate String consisting of ‘1’s and ‘0’s into a long value having that binary representation.
BinaryTextDumpFormat – Class in mars.mips.dump
Class that represents the “binary text” memory dump format.
BinaryTextDumpFormat() –
Constructor for class mars.mips.dump.BinaryTextDumpFormat
Constructor.
BitmapDisplay – Class in mars.tools
Bitmapp display simulator.
BitmapDisplay(String, String) –
Constructor for class mars.tools.BitmapDisplay
Simple constructor, likely used to run a stand-alone bitmap display tool.
BitmapDisplay() –
Constructor for class mars.tools.BitmapDisplay
Simple constructor, likely used by the MARS Tools menu mechanism
bitValue(int, int) –
Static method in class mars.util.Binary
Returns the bit value of the given bit position of the given int value.
bitValue(long, int) –
Static method in class mars.util.Binary
Returns the bit value of the given bit position of the given long value.
blink –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
blinkCaret() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Blinks the caret.
blockCaret –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
blockCaret –
Variable in class mars.venus.editors.jeditsyntax.TextAreaPainter
BOTTOM –
Static variable in class mars.venus.editors.jeditsyntax.JEditTextArea
bracketHighlight –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
bracketHighlight –
Variable in class mars.venus.editors.jeditsyntax.TextAreaPainter
bracketHighlightColor –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
bracketHighlightColor –
Variable in class mars.venus.editors.jeditsyntax.TextAreaPainter
bracketLine –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
bracketPosition –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
BREAKPOINT –
Static variable in class mars.simulator.Simulator
various reasons for simulate to end…
BREAKPOINT_EXCEPTION –
Static variable in class mars.simulator.Exceptions
buildBasicStatementFromBasicInstruction(ErrorList) –
Method in class mars.ProgramStatement
Given specification of BasicInstruction for this operator, build the
corresponding assembly statement in basic assembly format (e.g.
buildButtonAreaMarsTool() –
Method in class mars.tools.AbstractMarsToolAndApplication
The MarsTool default set of controls has one row of 3 buttons.
buildButtonAreaStandAlone() –
Method in class mars.tools.AbstractMarsToolAndApplication
The Mars stand-alone app default set of controls has two rows of controls.
buildConfigurationCollection() –
Static method in class mars.mips.hardware.MemoryConfigurations
buildControlPanel() –
Method in class mars.venus.AbstractFontSettingDialog
buildDialogPanel() –
Method in class mars.venus.AbstractFontSettingDialog
buildDisplayArea() –
Method in class mars.tools.FloatRepresentation
buildHeadingArea() –
Method in class mars.tools.AbstractMarsToolAndApplication
Constructs GUI header as label with default positioning and font.
buildMachineStatementFromBasicStatement(ErrorList) –
Method in class mars.ProgramStatement
Given the current statement in Basic Assembly format (see above), build the
32-bit binary machine code statement.
buildMainDisplayArea() –
Method in class mars.tools.AbstractMarsToolAndApplication
Abstract method that must be instantiated by subclass to build the main display area
of the GUI.
buildMainDisplayArea() –
Method in class mars.tools.BHTSimulator
Creates a GUI and initialize the GUI with the default values.
buildMainDisplayArea() –
Method in class mars.tools.BitmapDisplay
Method that constructs the main display area.
buildMainDisplayArea() –
Method in class mars.tools.CacheSimulator
Method that constructs the main cache simulator display area.
buildMainDisplayArea() –
Method in class mars.tools.DigitalLabSim
buildMainDisplayArea() –
Method in class mars.tools.FloatRepresentation
Method that constructs the main display area.
buildMainDisplayArea() –
Method in class mars.tools.InstructionCounter
buildMainDisplayArea() –
Method in class mars.tools.InstructionStatistics
creates the display area for the tool as required by the API
buildMainDisplayArea() –
Method in class mars.tools.IntroToTools
Implementation of the inherited abstract method to build the main
display area of the GUI.
buildMainDisplayArea() –
Method in class mars.tools.KeyboardAndDisplaySimulator
Method that constructs the main display area.
buildMainDisplayArea() –
Method in class mars.tools.MemoryReferenceVisualization
Method that constructs the main display area.
buildToolsMenu() –
Method in class mars.venus.ToolLoader
Called in VenusUI to build its Tools menu.
button –
Variable in class mars.tools.DigitalLabSim.HexaKeyboard
BYTE –
Static variable in class mars.assembler.Directives
BYTE_SIZE –
Static variable in class mars.assembler.DataTypes
Number of bytes occupied by MIPS byte is 1.
C
CacheSimulator – Class in mars.tools
A data cache simulator.
CacheSimulator(String, String) –
Constructor for class mars.tools.CacheSimulator
Simple constructor, likely used to run a stand-alone cache simulator.
CacheSimulator() –
Constructor for class mars.tools.CacheSimulator
Simple constructor, likely used by the MARS Tools menu mechanism
CANCEL_TOOL_TIP_TEXT –
Static variable in class mars.venus.SettingsHighlightingAction
CARET_BLINK_RATE –
Static variable in class mars.Settings
Caret blink rate in milliseconds, 0 means don’t blink.
caretBlinkRate –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
caretBlinkRate –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
caretBlinks –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
caretBlinks –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
caretColor –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
caretColor –
Variable in class mars.venus.editors.jeditsyntax.TextAreaPainter
caretEvent –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
caretTimer –
Static variable in class mars.venus.editors.jeditsyntax.JEditTextArea
caretUpdate(CaretEvent) –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
Display caret position on the edit pane.
caretVisible –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
caretVisible –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
CAUSE –
Static variable in class mars.mips.hardware.Coprocessor0
CENTER –
Static variable in class mars.venus.editors.jeditsyntax.JEditTextArea
changeResetValue(int) –
Method in class mars.mips.hardware.Register
Change the register’s reset value; the value to which it will be
set when resetValue() is called.
CHAR_SIZE –
Static variable in class mars.assembler.DataTypes
Number of bytes occupied by MIPS character is 1.
charnum –
Variable in class mars.venus.HardcopyWriter
chars_per_line –
Variable in class mars.venus.HardcopyWriter
chars_per_tab –
Variable in class mars.venus.HardcopyWriter
charwidth –
Variable in class mars.venus.HardcopyWriter
clear() –
Method in class mars.assembler.SymbolTable
Creates a fresh arrayList for a new table.
clear() –
Method in class mars.mips.hardware.Memory
Explicitly clear the contents of memory.
clearAllBreakpoints() –
Method in class mars.venus.TextSegmentWindow
Clears all breakpoints that have been set since last assemble, and
updates the display of the breakpoint column.
clearBit(int, int) –
Static method in class mars.util.Binary
Sets the specified bit of the specified value to 0, and returns the result.
clearConditionFlag(int) –
Static method in class mars.mips.hardware.Coprocessor1
Set condition flag to 0 (false).
clearConditionFlags() –
Static method in class mars.mips.hardware.Coprocessor1
Clear all condition flags (0-7).
clearHighlighting() –
Method in class mars.venus.Coprocessor0Window
Clear highlight background color from any row currently highlighted.
clearHighlighting() –
Method in class mars.venus.Coprocessor1Window
Clear highlight background color from any row currently highlighted.
clearHighlighting() –
Method in class mars.venus.DataSegmentWindow
Clear highlight background color from any cell currently highlighted.
clearHighlighting() –
Method in class mars.venus.RegistersWindow
Clear highlight background color from any cell currently highlighted.
clearPane() –
Method in class mars.venus.ExecutePane
Clears out all components of the Execute tab: text segment
display, data segment display, label display and register display.
clearWindow() –
Method in class mars.venus.Coprocessor0Window
Reset and redisplay registers
clearWindow() –
Method in class mars.venus.Coprocessor1Window
Reset and redisplay registers.
clearWindow() –
Method in class mars.venus.DataSegmentWindow
Removes the table from its frame, typically done when a file is closed.
clearWindow() –
Method in class mars.venus.LabelsWindow
Clear the window
clearWindow() –
Method in class mars.venus.RegistersWindow
clear and redisplay registers
clearWindow() –
Method in class mars.venus.TextSegmentWindow
remove all components
CLIFF_TERMINATION –
Static variable in class mars.simulator.Simulator
CLIP_COPY –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
CLIP_CUT –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
CLIP_PASTE –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
clone() –
Method in class mars.assembler.TokenList
Makes clone (shallow copy) of this token list object.
close() –
Method in class mars.venus.Editor
Perform “close” operation on current tab’s file.
close() –
Method in class mars.venus.HardcopyWriter
This is the close( ) method that all Writer subclasses must implement.
CLOSE_TOOL_TIP_TEXT –
Static variable in class mars.venus.SettingsHighlightingAction
closeAll() –
Method in class mars.venus.Editor
Close all currently open files.
closeAllFiles() –
Method in class mars.venus.EditTabbedPane
Carries out all necessary operations to implement
the Close All operation from the File menu.
closeCurrentFile() –
Method in class mars.venus.EditTabbedPane
Carries out all necessary operations to implement
the Close operation from the File menu.
closeDialog() –
Method in class mars.venus.AbstractFontSettingDialog
closeFile(int) –
Static method in class mars.util.SystemIO
Close the file with specified file descriptor
COLON –
Static variable in class mars.assembler.TokenTypes
COLOR_PREDICTION_CORRECT –
Static variable in class mars.tools.BHTSimGUI
constant for the color to signal a correct prediction
COLOR_PREDICTION_INCORRECT –
Static variable in class mars.tools.BHTSimGUI
constant for the color to signal a misprediction
COLOR_PREPREDICTION –
Static variable in class mars.tools.BHTSimGUI
constant for the color that highlights the current BHT entry
cols –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
cols –
Variable in class mars.venus.editors.jeditsyntax.TextAreaPainter
COMMENT –
Static variable in class mars.assembler.TokenTypes
COMMENT1 –
Static variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
Comment 1 token id.
COMMENT2 –
Static variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
Comment 2 token id.
commitMacro(Token) –
Method in class mars.assembler.MacroPool
This method will be called by parser when reached .end_macro
directive.
connect() –
Method in class mars.tools.AbstractMarsToolAndApplication.ConnectButton
connectButton –
Variable in class mars.tools.AbstractMarsToolAndApplication
construct() –
Method in class mars.simulator.SwingWorker
Compute the value to be returned by the get method.
convertLineColumnToStreamPosition(int, int) –
Method in class mars.venus.EditPane
Given line and column (position in the line) numbers, calculate
its byte stream position in text being edited.
convertStreamPositionToLineColumn(int) –
Method in class mars.venus.EditPane
Coprocessor0 – Class in mars.mips.hardware
Represents Coprocessor 0.
Coprocessor0() –
Constructor for class mars.mips.hardware.Coprocessor0
Coprocessor0Window – Class in mars.venus
Sets up a window to display registers in the UI.
Coprocessor0Window() –
Constructor for class mars.venus.Coprocessor0Window
Constructor which sets up a fresh window with a table that contains the register values.
Coprocessor1 – Class in mars.mips.hardware
Represents Coprocessor 1, the Floating Point Unit (FPU)
Coprocessor1() –
Constructor for class mars.mips.hardware.Coprocessor1
Coprocessor1Window – Class in mars.venus
Sets up a window to display Coprocessor 1 registers in the Registers pane of the UI.
Coprocessor1Window() –
Constructor for class mars.venus.Coprocessor1Window
Constructor which sets up a fresh window with a table that contains the register values.
copy() –
Method in class mars.venus.editors.jeditsyntax.DefaultInputHandler
Returns a copy of this input handler that shares the same
key bindings.
copy() –
Method in class mars.venus.editors.jeditsyntax.InputHandler
Returns a copy of this input handler that shares the same
key bindings.
copy() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Places the selected text into the clipboard.
copy() –
Method in interface mars.venus.editors.MARSTextEditingArea
copyrightHolders –
Static variable in class mars.Globals
MARS copyright holders
copyrightYears –
Static variable in class mars.Globals
MARS copyright years
copyText() –
Method in class mars.venus.EditPane
copy currently-selected text into clipboard
counter –
Variable in class mars.tools.InstructionCounter
Number of instructions executed until now.
counterI –
Variable in class mars.tools.InstructionCounter
Number of instructions of type I.
counterJ –
Variable in class mars.tools.InstructionCounter
Number of instructions of type J.
counterR –
Variable in class mars.tools.InstructionCounter
Number of instructions of type R.
countObservers() –
Method in class mars.mips.hardware.Memory
Return number of observers
createExampleTokenList() –
Method in class mars.mips.instructions.Instruction
Used to build a token list from the example instruction
provided as constructor argument.
createFontFromStringValues(String, String, String) –
Static method in class mars.util.EditorFont
Creates a new Font object based on the given String specifications.
createMacroPool() –
Method in class mars.MIPSprogram
Instantiates a new MacroPool and sends reference of this
MIPSprogram to it
createParsedList() –
Method in class mars.MIPSprogram
Produces new empty list to hold parsed source code statements.
currentFont –
Variable in class mars.venus.AbstractFontSettingDialog
cut() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Deletes the selected text from the text area and places it
into the clipboard.
cut() –
Method in interface mars.venus.editors.MARSTextEditingArea
cutText() –
Method in class mars.venus.EditPane
cut currently-selected text into clipboard
D
DATA –
Static variable in class mars.assembler.Directives
DATA_SEGMENT_HIGHLIGHTING –
Static variable in class mars.Settings
Flag to control whether or not highlighting is applied to data segment window
DATA_SYMBOL –
Static variable in class mars.assembler.Symbol
dataBaseAddress –
Static variable in class mars.mips.hardware.Memory
base address for storage of non-global static data in data segment: 0x10010000 (from SPIM)
DATASEGMENT_HIGHLIGHT_BACKGROUND –
Static variable in class mars.Settings
RGB color for text segment highlighted background
DATASEGMENT_HIGHLIGHT_FONT –
Static variable in class mars.Settings
Font for text segment highlighted background
DATASEGMENT_HIGHLIGHT_FOREGROUND –
Static variable in class mars.Settings
RGB color for text segment highlighted foreground
dataSegmentBaseAddress –
Static variable in class mars.mips.hardware.Memory
base address for (user) data segment: 0x10000000
dataSegmentLimitAddress –
Static variable in class mars.mips.hardware.Memory
DataSegmentWindow – Class in mars.venus
Represents the Data Segment window, which is a type of JInternalFrame.
DataSegmentWindow(NumberDisplayBaseChooser[]) –
Constructor for class mars.venus.DataSegmentWindow
Constructor for the Data Segment window.
DataTypes – Class in mars.assembler
Information about MIPS data types.
DataTypes() –
Constructor for class mars.assembler.DataTypes
debug –
Static variable in class mars.Globals
Flag to determine whether or not to produce internal debugging information.
DECIMAL –
Static variable in class mars.venus.NumberDisplayBaseChooser
DEFAULT_SIZE –
Static variable in class mars.util.EditorFont
DEFAULT_STATUS_VALUE –
Static variable in class mars.mips.hardware.Coprocessor0
DEFAULT_STYLE_INT –
Static variable in class mars.util.EditorFont
DEFAULT_STYLE_STRING –
Static variable in class mars.util.EditorFont
defaultBooleanSettingsValues –
Static variable in class mars.Settings
Last resort default values for boolean settings; will use only if neither
the Preferences nor the properties file work.
DefaultInputHandler – Class in mars.venus.editors.jeditsyntax
The default input handler.
DefaultInputHandler() –
Constructor for class mars.venus.editors.jeditsyntax.DefaultInputHandler
Creates a new input handler with no key bindings defined.
defaultMaxSteps –
Static variable in class mars.venus.RunGoAction
DELAYED_BRANCHING_ENABLED –
Static variable in class mars.Settings
Flag to determine whether or not delayed branching is in effect at MIPS execution.
DelayedBranch – Class in mars.simulator
Represents a (potential) delayed branch.
DelayedBranch() –
Constructor for class mars.simulator.DelayedBranch
DELETE –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
DELETE_WORD –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
deleteAsObserver() –
Method in class mars.tools.AbstractMarsToolAndApplication
Delete this app/tool as an Observer of MIPS Observables (memory and registers).
deleteAsObserver(Register) –
Method in class mars.tools.AbstractMarsToolAndApplication
Delete this app/tool as an Observer of the specified MIPS register
deleteAsObserver() –
Method in class mars.tools.FloatRepresentation
Delete this app/tool as an Observer of the attached register.
deleteLines(int, int) –
Method in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
Informs the token marker that line have been deleted from
the document.
deleteObserver(Observer) –
Method in class mars.mips.hardware.Memory
Remove specified memory observers
deleteObservers() –
Method in class mars.mips.hardware.Memory
Remove all memory observers
deleteRegistersObserver(Observer) –
Static method in class mars.mips.hardware.Coprocessor0
Each individual register is a separate object and Observable.
deleteRegistersObserver(Observer) –
Static method in class mars.mips.hardware.Coprocessor1
Each individual register is a separate object and Observable.
deleteRegistersObserver(Observer) –
Static method in class mars.mips.hardware.RegisterFile
Each individual register is a separate object and Observable.
DELIMITER –
Static variable in class mars.assembler.TokenTypes
description –
Variable in class mars.mips.instructions.Instruction
Description of instruction for display to user
descriptionDetailSeparator –
Static variable in class mars.venus.HelpHelpAction
Separates Instruction name descriptor from detailed (operation) description
in help string.
DigitalLabSim – Class in mars.tools
DigitalLabSim(String, String) –
Constructor for class mars.tools.DigitalLabSim
DigitalLabSim() –
Constructor for class mars.tools.DigitalLabSim
DigitalLabSim.HexaKeyboard – Class in mars.tools
DigitalLabSim.HexaKeyboard() –
Constructor for class mars.tools.DigitalLabSim.HexaKeyboard
DigitalLabSim.HexaKeyboard.EcouteurClick – Class in mars.tools
DigitalLabSim.HexaKeyboard.EcouteurClick(int) –
Constructor for class mars.tools.DigitalLabSim.HexaKeyboard.EcouteurClick
DigitalLabSim.OneSecondCounter – Class in mars.tools
DigitalLabSim.OneSecondCounter() –
Constructor for class mars.tools.DigitalLabSim.OneSecondCounter
DigitalLabSim.SevenSegmentDisplay – Class in mars.tools
DigitalLabSim.SevenSegmentDisplay(char) –
Constructor for class mars.tools.DigitalLabSim.SevenSegmentDisplay
DigitalLabSim.SevenSegmentPanel – Class in mars.tools
DigitalLabSim.SevenSegmentPanel() –
Constructor for class mars.tools.DigitalLabSim.SevenSegmentPanel
DIRECTIVE –
Static variable in class mars.assembler.TokenTypes
Directives – Class in mars.assembler
Class representing MIPS assembler directives.
discardAllUndoableEdits() –
Method in class mars.venus.editors.generic.GenericTextArea
Tell UndoManager to discard all its collected undoable edits.
discardAllUndoableEdits() –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
Get rid of any accumulated undoable edits.
discardAllUndoableEdits() –
Method in interface mars.venus.editors.MARSTextEditingArea
discardAllUndoableEdits() –
Method in class mars.venus.EditPane
Get rid of any accumulated undoable edits.
disconnect() –
Method in class mars.tools.AbstractMarsToolAndApplication.ConnectButton
dispatchEventToMenu(KeyEvent) –
Method in class mars.venus.VenusUI
Send keyboard event to menu for possible processing.
display –
Variable in class mars.tools.DigitalLabSim.SevenSegmentPanel
DISPLAY_ADDRESSES_IN_HEX –
Static variable in class mars.Settings
Default setting for displaying addresses and values in hexidecimal in the Execute
pane.
DISPLAY_VALUES_IN_HEX –
Static variable in class mars.Settings
displayCaretPosition(int) –
Method in class mars.venus.EditPane
Update the caret position label on the editor’s border to
display the current line and column.
displayCaretPosition(Point) –
Method in class mars.venus.EditPane
Display cursor coordinates
DIVIDE_BY_ZERO_EXCEPTION –
Static variable in class mars.simulator.Exceptions
document –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
document –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
DOCUMENT_END –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
DOCUMENT_HOME –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
documentChanged(DocumentEvent) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
documentHandler –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
doFindText(String, boolean) –
Method in class mars.venus.editors.generic.GenericTextArea
Finds next occurrence of text in a forward search of a string.
doFindText(String, boolean) –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
Finds next occurrence of text in a forward search of a string.
doFindText(String, boolean) –
Method in interface mars.venus.editors.MARSTextEditingArea
doFindText(String, boolean) –
Method in class mars.venus.EditPane
Finds next occurrence of text in a forward search of a string.
doReplace(String, String, boolean) –
Method in class mars.venus.editors.generic.GenericTextArea
Finds and replaces next occurrence of text in a string in a forward search.
doReplace(String, String, boolean) –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
Finds and replaces next occurrence of text in a string in a forward search.
doReplace(String, String, boolean) –
Method in interface mars.venus.editors.MARSTextEditingArea
doReplace(String, String, boolean) –
Method in class mars.venus.EditPane
Finds and replaces next occurrence of text in a string in a forward search.
doReplaceAll(String, String, boolean) –
Method in class mars.venus.editors.generic.GenericTextArea
Finds and replaces ALL occurrences of text in a string in a forward search.
doReplaceAll(String, String, boolean) –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
Finds and replaces ALL occurrences of text in a string in a forward search.
doReplaceAll(String, String, boolean) –
Method in interface mars.venus.editors.MARSTextEditingArea
doReplaceAll(String, String, boolean) –
Method in class mars.venus.EditPane
Finds and replaces ALL occurrences of text in a string in a forward search.
DOUBLE –
Static variable in class mars.assembler.Directives
DOUBLE_SIZE –
Static variable in class mars.assembler.DataTypes
Number of bytes occupied by MIPS double is 8.
doublewordAligned(int) –
Static method in class mars.mips.hardware.Memory
Utility to determine if given address is doubleword-aligned.
DumpFormat – Interface in mars.mips.dump
Interface for memory dump file formats.
DumpFormatLoader – Class in mars.mips.dump
DumpFormatLoader() –
Constructor for class mars.mips.dump.DumpFormatLoader
dumpMemoryRange(File, int, int) –
Method in class mars.mips.dump.AbstractDumpFormat
Write MIPS memory contents according to the
specification for this format.
dumpMemoryRange(File, int, int) –
Method in class mars.mips.dump.AsciiTextDumpFormat
Interpret MIPS memory contents as ASCII characters.
dumpMemoryRange(File, int, int) –
Method in class mars.mips.dump.BinaryDumpFormat
Write MIPS memory contents in pure binary format.
dumpMemoryRange(File, int, int) –
Method in class mars.mips.dump.BinaryTextDumpFormat
Write MIPS memory contents in binary text format.
dumpMemoryRange(File, int, int) –
Method in interface mars.mips.dump.DumpFormat
Write MIPS memory contents according to the
specification for this format.
dumpMemoryRange(File, int, int) –
Method in class mars.mips.dump.HexTextDumpFormat
Write MIPS memory contents in hexadecimal text format.
dumpMemoryRange(File, int, int) –
Method in class mars.mips.dump.IntelHexDumpFormat
Write MIPS memory contents according to the Memory Initialization File
(MIF) specification.
dumpMemoryRange(File, int, int) –
Method in class mars.mips.dump.MIFDumpFormat
Write MIPS memory contents according to the Memory Initialization File
(MIF) specification.
dumpMemoryRange(File, int, int) –
Method in class mars.mips.dump.SegmentWindowDumpFormat
Write MIPS memory contents in Segment Window format.
dumpTriples –
Static variable in class mars.util.MemoryDump
A list of segmentname/dumpformat/filename triples which should be dumped
E
editable –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
editable –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
EditCopyAction – Class in mars.venus
Action for the Edit -> Copy menu item
EditCopyAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.EditCopyAction
EditCutAction – Class in mars.venus
Action for the Edit -> Cut menu item
EditCutAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.EditCutAction
EDITED –
Static variable in class mars.venus.FileStatus
open/saved edit window with unsaved edits
EditFindReplaceAction – Class in mars.venus
Action for the Edit -> Find/Replace menu item
EditFindReplaceAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.EditFindReplaceAction
Editor – Class in mars.venus
Manage the file being edited.
Editor(VenusUI) –
Constructor for class mars.venus.Editor
Create editor.
EDITOR_CURRENT_LINE_HIGHLIGHTING –
Static variable in class mars.Settings
Flag to control whether or not editor will highlight the line currently being edited
EDITOR_FONT –
Static variable in class mars.Settings
Font for the text editor
EDITOR_LINE_NUMBERS_DISPLAYED –
Static variable in class mars.Settings
Flag to determine whether or not the editor will display line numbers.
EDITOR_POPUP_PREFIX_LENGTH –
Static variable in class mars.Settings
Number of letters to be matched by editor’s instruction guide before popup generated (if popup enabled)
EDITOR_TAB_SIZE –
Static variable in class mars.Settings
Editor tab size in characters.
EditorFont – Class in mars.util
Specialized Font class designed to be used by both the
settings menu methods and the Settings class.
EditorFont() –
Constructor for class mars.util.EditorFont
EditPane – Class in mars.venus
Represents one file opened for editing.
EditPane(VenusUI) –
Constructor for class mars.venus.EditPane
Constructor for the EditPane class.
EditPasteAction – Class in mars.venus
Action for the Edit -> Paste menu item
EditPasteAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.EditPasteAction
EditRedoAction – Class in mars.venus
Action for the Edit -> Redo menu item
EditRedoAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.EditRedoAction
EditSelectAllAction – Class in mars.venus
Action for the Edit -> Copy menu item
EditSelectAllAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.EditSelectAllAction
editsSavedOrAbandoned() –
Method in class mars.venus.Editor
Called by several of the Action objects when there is potential
loss of editing changes.
editsSavedOrAbandoned() –
Method in class mars.venus.EditTabbedPane
Check whether file has unsaved edits and, if so, check with user about saving them.
EditTabbedPane – Class in mars.venus
Tabbed pane for the editor.
EditTabbedPane(VenusUI, Editor, MainPane) –
Constructor for class mars.venus.EditTabbedPane
Constructor for the EditTabbedPane class.
EditUndoAction – Class in mars.venus
Action for the Edit -> Undo menu item
EditUndoAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.EditUndoAction
electricScroll –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
electricScroll –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
empty() –
Method in class mars.simulator.BackStepper
Test whether there are steps that can be undone.
enabled() –
Method in class mars.simulator.BackStepper
Determine whether execution “undo” steps are currently being recorded.
END –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
END –
Static variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
The token type, that along with a length of 0
marks the end of the token list.
END_MACRO –
Static variable in class mars.assembler.Directives
endCompoundEdit() –
Method in class mars.venus.editors.jeditsyntax.SyntaxDocument
Ends a compound edit that can be undone in one operation.
ensureCapacity(int) –
Method in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
Ensures that the lineInfo array can contain the
specified index.
eolMarkerColor –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
eolMarkerColor –
Variable in class mars.venus.editors.jeditsyntax.TextAreaPainter
eolMarkers –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
eolMarkers –
Variable in class mars.venus.editors.jeditsyntax.TextAreaPainter
EPC –
Static variable in class mars.mips.hardware.Coprocessor0
equals(Object) –
Method in class mars.assembler.Macro
EQV –
Static variable in class mars.assembler.Directives
ERROR –
Static variable in class mars.assembler.TokenTypes
ERROR –
Static variable in class mars.ErrorMessage
Constant to indicate this message is error not warning
ERROR_MESSAGE_PREFIX –
Static variable in class mars.ErrorList
errorCount() –
Method in class mars.ErrorList
Count of number of error messages in list.
errorLimitExceeded() –
Method in class mars.ErrorList
Check to see if error limit has been exceeded.
ErrorList – Class in mars
Maintains list of generated error messages, regardless of source (tokenizing, parsing,
assembly, execution).
ErrorList() –
Constructor for class mars.ErrorList
Constructor for ErrorList
ErrorMessage – Class in mars
Represents occurrance of an error detected during tokenizing, assembly or simulation.
ErrorMessage(String, int, int, String) –
Constructor for class mars.ErrorMessage
Deprecated. Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.
ErrorMessage(String, int, int, String, String) –
Constructor for class mars.ErrorMessage
Deprecated. Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.
ErrorMessage(boolean, String, int, int, String, String) –
Constructor for class mars.ErrorMessage
Deprecated. Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.
ErrorMessage(MIPSprogram, int, int, String) –
Constructor for class mars.ErrorMessage
Constructor for ErrorMessage.
ErrorMessage(boolean, MIPSprogram, int, int, String) –
Constructor for class mars.ErrorMessage
Constructor for ErrorMessage.
ErrorMessage(ProgramStatement, String) –
Constructor for class mars.ErrorMessage
Constructor for ErrorMessage, to be used for runtime exceptions.
errors() –
Method in exception mars.ProcessingException
Produce the list of error messages.
errorsOccurred() –
Method in class mars.ErrorList
Determine whether error has occured or not.
EVEN_ROW_BACKGROUND –
Static variable in class mars.Settings
RGB color for table even row background (text, data, register displays)
EVEN_ROW_FONT –
Static variable in class mars.Settings
Font for table even row background (text, data, register displays)
EVEN_ROW_FOREGROUND –
Static variable in class mars.Settings
RGB color for table even row foreground (text, data, register displays)
exampleFormat –
Variable in class mars.mips.instructions.Instruction
Example usage of this instruction.
EXCEPTION –
Static variable in class mars.simulator.Simulator
EXCEPTION_HANDLER –
Static variable in class mars.Settings
Current specified exception handler file (a MIPS assembly source file)
EXCEPTION_HANDLER_ENABLED –
Static variable in class mars.Settings
Flag to determine whether the currently selected exception handler source file will
be included in each assembly operation.
EXCEPTION_LEVEL –
Static variable in class mars.mips.hardware.Coprocessor0
exceptionHandlerAddress –
Static variable in class mars.mips.hardware.Memory
starting address for exception handlers: 0x80000180
Exceptions – Class in mars.simulator
Represents an error/interrupt that occurs during execution (simulation).
Exceptions() –
Constructor for class mars.simulator.Exceptions
executeAction(ActionListener, Object, String) –
Method in class mars.venus.editors.jeditsyntax.InputHandler
Executes the specified action, repeating and recording it as
necessary.
ExecutePane – Class in mars.venus
Container for the execution-related windows.
ExecutePane(VenusUI, RegistersWindow, Coprocessor1Window, Coprocessor0Window) –
Constructor for class mars.venus.ExecutePane
initialize the Execute pane with major components
exitCode –
Static variable in class mars.Globals
MARS exit code — useful with SYSCALL 17 when running from command line (not GUI)
EXTENDED_ASSEMBLER_ENABLED –
Static variable in class mars.Settings
Flag to determine whether or not program being assembled is limited to
basic MIPS instructions and formats.
ExtendedInstruction – Class in mars.mips.instructions
ExtendedInstruction represents a MIPS extended (a.k.a pseudo) instruction.
ExtendedInstruction(String, String, String, String) –
Constructor for class mars.mips.instructions.ExtendedInstruction
Constructor for ExtendedInstruction.
ExtendedInstruction(String, String, String) –
Constructor for class mars.mips.instructions.ExtendedInstruction
Constructor for ExtendedInstruction.
ExtendedInstruction(String, String) –
Constructor for class mars.mips.instructions.ExtendedInstruction
Constructor for ExtendedInstruction, where no instruction description or
compact translation is provided.
EXTERN –
Static variable in class mars.assembler.Directives
EXTERNAL_INTERRUPT_DISPLAY –
Static variable in class mars.simulator.Exceptions
EXTERNAL_INTERRUPT_HEXA_KEYBOARD –
Static variable in class mars.tools.DigitalLabSim
EXTERNAL_INTERRUPT_KEYBOARD –
Static variable in class mars.simulator.Exceptions
The exception number is stored in coprocessor 0 cause register ($13)
Note: the codes for External Interrupts have been modified from MIPS
specs in order to encode two pieces of information.
EXTERNAL_INTERRUPT_TIMER –
Static variable in class mars.tools.DigitalLabSim
externalInterruptingDevice –
Static variable in class mars.simulator.Simulator
externBaseAddress –
Static variable in class mars.mips.hardware.Memory
base address for .extern directive: 0x10000000
extractBranchAddress(ProgramStatement) –
Static method in class mars.tools.BHTSimulator
Extracts the target address of the branch.
extractOperator(String) –
Method in class mars.mips.instructions.Instruction
Used by subclass constructors to extract operator mnemonic from the
instruction example.
F
FileCloseAction – Class in mars.venus
Action for the File -> Close menu item
FileCloseAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.FileCloseAction
FileCloseAllAction – Class in mars.venus
Action for the File -> Close All menu item
FileCloseAllAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.FileCloseAllAction
FileDumpMemoryAction – Class in mars.venus
Action for the File -> Save For Dump Memory menu item
FileDumpMemoryAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.FileDumpMemoryAction
fileErrorString –
Static variable in class mars.util.SystemIO
String used for description of file error
FileExitAction – Class in mars.venus
Action for the File -> Exit menu item
FileExitAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.FileExitAction
fileExtensionMatch(String, String) –
Static method in class mars.util.FilenameFinder
Determine if given filename ends with given extension.
fileExtensions –
Static variable in class mars.Globals
List of accepted file extensions for MIPS assembly source files.
FILENAME_PREFIX –
Static variable in class mars.ErrorList
FilenameFinder – Class in mars.util
Utility class to perform necessary file-related search
operations.
FilenameFinder() –
Constructor for class mars.util.FilenameFinder
FileNewAction – Class in mars.venus
Action for the File -> New menu item
FileNewAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.FileNewAction
FileOpenAction – Class in mars.venus
Action for the File -> Open menu item
FileOpenAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.FileOpenAction
FilePrintAction – Class in mars.venus
Action for the File -> Print menu item
FilePrintAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.FilePrintAction
FileSaveAction – Class in mars.venus
Action for the File -> Save menu item
FileSaveAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.FileSaveAction
FileSaveAllAction – Class in mars.venus
Action for the File -> Close All menu item
FileSaveAllAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.FileSaveAllAction
FileSaveAsAction – Class in mars.venus
Action for the File -> Save As menu item
FileSaveAsAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.FileSaveAsAction
FileStatus – Class in mars.venus
Used to store and return information on the status of the current ASM file that
is being edited in the program.
FileStatus() –
Constructor for class mars.venus.FileStatus
Create a FileStatus object with FileStatis.NO_FILE for status and null for file getters.
FileStatus(int, String) –
Constructor for class mars.venus.FileStatus
Create a FileStatus object with given status and file pathname.
findByBinaryCode(int) –
Method in class mars.mips.instructions.InstructionSet
findDumpFormatGivenCommandDescriptor(ArrayList, String) –
Static method in class mars.mips.dump.DumpFormatLoader
findMatchingBracket(Document, int) –
Static method in class mars.venus.editors.jeditsyntax.TextUtilities
Returns the offset of the bracket matching the one at the
specified offset of the document, or -1 if the bracket is
unmatched (or if the character is not a bracket).
findWordEnd(String, int, String) –
Static method in class mars.venus.editors.jeditsyntax.TextUtilities
Locates the end of the word at the specified position.
findWordStart(String, int, String) –
Static method in class mars.venus.editors.jeditsyntax.TextUtilities
Locates the start of the word at the specified position.
finished() –
Method in class mars.simulator.SwingWorker
Called on the event dispatching thread (not on the worker thread)
after the construct method has returned.
fireCaretEvent() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
fireInsertUpdate(DocumentEvent) –
Method in class mars.venus.editors.jeditsyntax.SyntaxDocument
We overwrite this method to update the token marker
state immediately so that any event listeners get a
consistent token marker.
fireRemoveUpdate(DocumentEvent) –
Method in class mars.venus.editors.jeditsyntax.SyntaxDocument
We overwrite this method to update the token marker
state immediately so that any event listeners get a
consistent token marker.
firstLine –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
firstToken –
Variable in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
The first token in the list.
fixSymbolTableAddress(int, int) –
Method in class mars.assembler.SymbolTable
Fix address in symbol table entry.
FLOAT –
Static variable in class mars.assembler.Directives
FLOAT_SIZE –
Static variable in class mars.assembler.DataTypes
Number of bytes occupied by MIPS float is 4.
FLOATING_POINT_OVERFLOW –
Static variable in class mars.simulator.Exceptions
FLOATING_POINT_UNDERFLOW –
Static variable in class mars.simulator.Exceptions
FloatRepresentation – Class in mars.tools
Tool to help students learn about IEEE 754 representation of 32 bit
floating point values.
FloatRepresentation(String, String) –
Constructor for class mars.tools.FloatRepresentation
Simple constructor, likely used to run a stand-alone memory reference visualizer.
FloatRepresentation() –
Constructor for class mars.tools.FloatRepresentation
Simple constructor, likely used by the MARS Tools menu mechanism
flush() –
Method in class mars.venus.HardcopyWriter
This is the flush( ) method that all Writer subclasses must implement.
fm –
Variable in class mars.venus.editors.jeditsyntax.TextAreaPainter
focusedComponent –
Static variable in class mars.venus.editors.jeditsyntax.JEditTextArea
font –
Variable in class mars.venus.HardcopyWriter
fontsize –
Variable in class mars.venus.HardcopyWriter
formatDoubleNumber(long, int) –
Static method in class mars.venus.NumberDisplayBaseChooser
Produces a string form of a double given a long containing
the 64 bit pattern and the numerical base to use (10 or 16).
formatFloatNumber(int, int) –
Static method in class mars.venus.NumberDisplayBaseChooser
Produces a string form of a float given an integer containing
the 32 bit pattern and the numerical base to use (10 or 16).
formatNumber(int, int) –
Static method in class mars.venus.NumberDisplayBaseChooser
Produces a string form of an integer given the value and the
numerical base to convert it to.
formatNumber(float, int) –
Static method in class mars.venus.NumberDisplayBaseChooser
Produces a string form of a float given the value and the
numerical base to convert it to.
formatNumber(double, int) –
Static method in class mars.venus.NumberDisplayBaseChooser
Produces a string form of a double given the value and the
numerical base to convert it to.
formatNumber(int) –
Method in class mars.venus.NumberDisplayBaseChooser
Produces a string form of a number given the value.
formatUnsignedInteger(int, int) –
Static method in class mars.venus.NumberDisplayBaseChooser
Produces a string form of an unsigned given the value and the
numerical base to convert it to.
formatUnsignedInteger(int) –
Method in class mars.venus.NumberDisplayBaseChooser
Produces a string form of an unsigned integer given the value.
FP_REGISTER_NAME –
Static variable in class mars.assembler.TokenTypes
G
generateErrorAndWarningReport() –
Method in class mars.ErrorList
Produce report containing both warnings and errors, warnings first.
generateErrorReport() –
Method in class mars.ErrorList
Produce error report.
generateWarningReport() –
Method in class mars.ErrorList
Produce warning report.
GENERIC_TEXT_EDITOR –
Static variable in class mars.Settings
Flag to control whether or not to use generic text editor instead of language-aware styled editor
GenericTextArea – Class in mars.venus.editors.generic
GenericTextArea(EditPane, JComponent) –
Constructor for class mars.venus.editors.generic.GenericTextArea
get(int) –
Method in class mars.assembler.TokenList
Returns requested token given position number (starting at 0).
get(int, int) –
Method in class mars.mips.hardware.Memory
Starting at the given word address, read the given number of bytes (max 4).
get() –
Method in class mars.simulator.SwingWorker
Return the value created by the construct method.
get() –
Static method in class mars.venus.FileStatus
Get file status
getAccessType() –
Method in class mars.mips.hardware.AccessNotice
Get the access type: READ or WRITE.
getAction() –
Method in class mars.simulator.SimulatorNotice
Fetch the memory address that was accessed.
getAction(String) –
Static method in class mars.venus.editors.jeditsyntax.InputHandler
Returns a named text area action.
getActionName(ActionListener) –
Static method in class mars.venus.editors.jeditsyntax.InputHandler
Returns the name of the specified text area action.
getActions() –
Static method in class mars.venus.editors.jeditsyntax.InputHandler
Returns an enumeration of all available actions.
getAddress() –
Method in class mars.assembler.Symbol
Returns the address of the the Symbol.
getAddress(String) –
Method in class mars.assembler.SymbolTable
Method to return the address associated with the given label.
getAddress() –
Method in exception mars.mips.hardware.AddressErrorException
Get the erroneous memory address.
getAddress() –
Method in class mars.mips.hardware.MemoryAccessNotice
Fetch the memory address that was accessed.
getAddress() –
Method in class mars.ProgramStatement
Produces Text Segment address where the binary machine statement is stored.
getAddressDisplayBase() –
Method in class mars.venus.ExecutePane
Retrieve the number system base for displaying memory addresses
getAddressDisplayBaseChooser() –
Method in class mars.venus.ExecutePane
Retrieve component used to set numerical base (10 or 16) of address display.
getAddressDisplayBaseMenuItem() –
Method in class mars.venus.VenusUI
Get reference to settings menu item for display base of memory/register values.
getAddressLocalOrGlobal(String) –
Method in class mars.assembler.SymbolTable
Method to return the address associated with the given label.
getAddressOfFirstNull(int, int) –
Method in class mars.mips.hardware.Memory
Look for first “null” memory value in an address range.
getAddressOfFirstNull(int, int) –
Static method in class mars.util.MemoryDump
Look for first “null” memory value in an address range.
getAllFamilies() –
Static method in class mars.util.EditorFont
Obtain an array of all available font family names.
getAllSymbols() –
Method in class mars.assembler.SymbolTable
For obtaining all the Symbols.
getArgs() –
Method in class mars.assembler.Macro
getAsciiNonPrint() –
Static method in class mars.Globals
getAsciiStrings() –
Static method in class mars.Globals
getAssembleAllEnabled() –
Method in class mars.Settings
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.ASSEMBLE_ALL_ENABLED)
getAssembleOnOpenEnabled() –
Method in class mars.Settings
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.ASSEMBLE_ON_OPEN_ENABLED)
getAssembleTextArea() –
Method in class mars.venus.MessagesPane
Returns component used to display assembler messages
getAutoIndent() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Constructs string for auto-indent feature.
getBackStepper() –
Method in class mars.MIPSprogram
Returns BackStepper associated with this program.
getBackSteppingEnabled() –
Method in class mars.Settings
Return whether backstepping is permitted at this time.
getBareMachineEnabled() –
Method in class mars.Settings
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.BARE_MACHINE_ENABLED)
getBase() –
Method in class mars.venus.NumberDisplayBaseChooser
Retrieve the current number base.
getBase(boolean) –
Static method in class mars.venus.NumberDisplayBaseChooser
Return the number base corresponding to the specified setting.
getBaseAddresses(String[]) –
Static method in class mars.util.MemoryDump
Get the MIPS memory base address(es) of the specified segment name(s).
getBasicAssemblyStatement() –
Method in class mars.ProgramStatement
Produces Basic Assembly statement for this MIPS source statement.
getBasicIntructionTemplateList() –
Method in class mars.mips.instructions.ExtendedInstruction
Get ArrayList of Strings that represent list of templates for
basic instructions generated by this extended instruction.
getBinaryStatement() –
Method in class mars.ProgramStatement
Produces 32-bit binary machine statement as int.
getBooleanSetting(int) –
Method in class mars.Settings
Fetch value of a boolean setting given its identifier.
getBracketHighlightColor() –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Returns the bracket highlight color.
getBracketLine() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the line of the highlighted bracket (the bracket
matching the one before the caret)
getBracketPosition() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the position of the highlighted bracket (the bracket
matching the one before the caret)
getBreakpointCount() –
Method in class mars.venus.TextSegmentWindow
Returns number of breakpoints currently set.
getByte(int) –
Method in class mars.mips.hardware.Memory
Reads specified Memory byte into low order 8 bits of int.
getByte(int, int) –
Static method in class mars.util.Binary
Gets the specified byte of the specified value.
getByteOrder() –
Method in class mars.mips.hardware.Memory
Retrieve memory byte order.
getCallStack() –
Method in class mars.assembler.MacroPool
getCaretBlinkRate() –
Method in class mars.Settings
Retrieve the caret blink rate in milliseconds.
getCaretColor() –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Returns the caret color.
getCaretLine() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the caret line.
getCaretPosition() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the caret position.
getCaretPosition() –
Method in interface mars.venus.editors.MARSTextEditingArea
getCbBHTentries() –
Method in class mars.tools.BHTSimGUI
Returns the combo box for selecting the number of BHT entries.
getCbBHThistory() –
Method in class mars.tools.BHTSimGUI
Returns the combo box for selecting the size of the BHT history.
getCbBHTinitVal() –
Method in class mars.tools.BHTSimGUI
Returns the combo box for selecting the initial value of the BHT
getCharactersPerLine() –
Method in class mars.venus.HardcopyWriter
Return the number of columns of characters that fit on the page
getCodeHighlighting() –
Method in class mars.venus.TextSegmentWindow
Get code highlighting status.
getColor() –
Method in class mars.venus.editors.jeditsyntax.SyntaxStyle
Returns the color specified in this style.
getColorAsHexString() –
Method in class mars.venus.editors.jeditsyntax.SyntaxStyle
Returns the color coded as Stringified 32-bit hex with
Red in bits 16-23, Green in bits 8-15, Blue in bits 0-7
e.g.
getColorSettingByKey(String) –
Method in class mars.Settings
Get Color object for specified settings key.
getColorSettingByPosition(int) –
Method in class mars.Settings
Get Color object for specified settings name (a static constant).
getColumnClass(int) –
Method in class mars.tools.BHTableModel
Returns the class/type of the i-th column of the table.
getColumnCount() –
Method in class mars.tools.BHTableModel
Returns the number of columns.
getColumnName(int) –
Method in class mars.tools.BHTableModel
Returns the name of the i-th column of the table.
getCommandDescriptor() –
Method in class mars.mips.dump.AbstractDumpFormat
One-word description of format to be used by MARS command mode parser
and user in conjunction with the “dump” option.
getCommandDescriptor() –
Method in interface mars.mips.dump.DumpFormat
A short one-word descriptor that will be used by the MARS
command line parser (and the MARS command line user) to specify
that this format is to be used.
getCommonFamilies() –
Static method in class mars.util.EditorFont
Obtain an array of common font family names.
getCompactBasicIntructionTemplateList() –
Method in class mars.mips.instructions.ExtendedInstruction
Get ArrayList of Strings that represent list of templates for
basic instructions generated by the “compact” or 16-bit version
of this extended instruction.
getCompactInstructionLength() –
Method in class mars.mips.instructions.ExtendedInstruction
Get length in bytes that this extended instruction requires in its
binary form if it includes an alternative expansion for compact
memory (16 bit addressing) configuration.
getConditionFlag(int) –
Static method in class mars.mips.hardware.Coprocessor1
Get value of specified condition flag (0-7).
getConditionFlagCount() –
Static method in class mars.mips.hardware.Coprocessor1
Get count of condition flags.
getConditionFlags() –
Static method in class mars.mips.hardware.Coprocessor1
Get array of condition flags (0-7).
getConfigurationByName(String) –
Static method in class mars.mips.hardware.MemoryConfigurations
getConfigurationIdentifier() –
Method in class mars.mips.hardware.MemoryConfiguration
getConfigurationItemNames() –
Method in class mars.mips.hardware.MemoryConfiguration
getConfigurationItemValues() –
Method in class mars.mips.hardware.MemoryConfiguration
getConfigurationName() –
Method in class mars.mips.hardware.MemoryConfiguration
getConfigurationsIterator() –
Static method in class mars.mips.hardware.MemoryConfigurations
getCoprocessor0Window() –
Method in class mars.venus.ExecutePane
Access the coprocessor0 values window.
getCoprocessor0Window() –
Method in class mars.venus.RegistersPane
Return component containing coprocessor 0 (exceptions) register set.
getCoprocessor1Window() –
Method in class mars.venus.ExecutePane
Access the coprocessor1 values window.
getCoprocessor1Window() –
Method in class mars.venus.RegistersPane
Return component containing coprocessor 1 (floating point) register set.
getCurrent() –
Method in class mars.assembler.MacroPool
getCurrentConfiguration() –
Static method in class mars.mips.hardware.MemoryConfigurations
getCurrentEditTab() –
Method in class mars.venus.EditTabbedPane
The current EditPane representing a file.
getCurrentEditTabForFile(File) –
Method in class mars.venus.EditTabbedPane
If the given file is open in the tabbed pane, make it the
current tab.
getCurrentOpenDirectory() –
Method in class mars.venus.Editor
Get name of current directory for Open operation.
getCurrentSaveDirectory() –
Method in class mars.venus.Editor
Get name of current directory for Save or Save As operation.
getCurrentSyntaxStyles() –
Static method in class mars.venus.editors.jeditsyntax.SyntaxUtilities
Returns the CURRENT style table.
getDataBaseAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getDataSegmentBaseAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getDataSegmentHighlighting() –
Method in class mars.Settings
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.DATA_SEGMENT_HIGHLIGHTING)
getDataSegmentLimitAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getDataSegmentWindow() –
Method in class mars.venus.ExecutePane
Access the data segment window.
getDataSymbols() –
Method in class mars.assembler.SymbolTable
For obtaining the Data Symbols.
getDefaultColorSettingByKey(String) –
Method in class mars.Settings
Get default Color value for specified settings key.
getDefaultColorSettingByPosition(int) –
Method in class mars.Settings
Get default Color object for specified settings name (a static constant).
getDefaultConfiguration() –
Static method in class mars.mips.hardware.MemoryConfigurations
getDefaultDataBaseAddress() –
Static method in class mars.mips.hardware.MemoryConfigurations
getDefaultDataSegmentBaseAddress() –
Static method in class mars.mips.hardware.MemoryConfigurations
getDefaultDataSegmentLimitAddress() –
Method in class mars.mips.hardware.MemoryConfigurations
getDefaultEditorSyntaxStyleByPosition(int) –
Method in class mars.Settings
getDefaultEditorTabSize() –
Method in class mars.Settings
Get the text editor default tab size in characters
getDefaultExceptionHandlerAddress() –
Static method in class mars.mips.hardware.MemoryConfigurations
getDefaultExternBaseAddress() –
Static method in class mars.mips.hardware.MemoryConfigurations
getDefaultFontByPosition(int) –
Method in class mars.Settings
Retrieve a default Font setting
getDefaultGlobalPointer() –
Static method in class mars.mips.hardware.MemoryConfigurations
getDefaultHeapBaseAddress() –
Static method in class mars.mips.hardware.MemoryConfigurations
getDefaultKernelBaseAddress() –
Static method in class mars.mips.hardware.MemoryConfigurations
getDefaultKernelDataBaseAddress() –
Static method in class mars.mips.hardware.MemoryConfigurations
getDefaultKernelDataSegmentLimitAddress() –
Method in class mars.mips.hardware.MemoryConfigurations
getDefaultKernelHighAddress() –
Static method in class mars.mips.hardware.MemoryConfigurations
getDefaultKernelTextBaseAddress() –
Static method in class mars.mips.hardware.MemoryConfigurations
getDefaultKernelTextLimitAddress() –
Method in class mars.mips.hardware.MemoryConfigurations
getDefaultMemoryMapBaseAddress() –
Static method in class mars.mips.hardware.MemoryConfigurations
getDefaults() –
Static method in class mars.venus.editors.jeditsyntax.TextAreaDefaults
Returns a new TextAreaDefaults object with the default values filled
in.
getDefaultStackBaseAddress() –
Static method in class mars.mips.hardware.MemoryConfigurations
getDefaultStackLimitAddress() –
Method in class mars.mips.hardware.MemoryConfigurations
getDefaultStackPointer() –
Static method in class mars.mips.hardware.MemoryConfigurations
getDefaultSyntaxStyles() –
Static method in class mars.venus.editors.jeditsyntax.SyntaxUtilities
Returns the default style table.
getDefaultTextBaseAddress() –
Static method in class mars.mips.hardware.MemoryConfigurations
getDefaultTextLimitAddress() –
Method in class mars.mips.hardware.MemoryConfigurations
getDefaultUserHighAddress() –
Static method in class mars.mips.hardware.MemoryConfigurations
getDelay() –
Method in class mars.venus.RepeatButton
Gets the delay for the timer of this button.
getDelayedBranchingEnabled() –
Method in class mars.Settings
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.DELAYED_BRANCHING_ENABLED)
getDescription() –
Method in class mars.assembler.Directives
Get description of this Directives object
getDescription() –
Method in class mars.mips.dump.AbstractDumpFormat
Get a short description of the format, suitable for displaying along with
the extension, in the file save dialog, or as a tool tip.
getDescription() –
Method in interface mars.mips.dump.DumpFormat
Get a short description of the format, suitable
for displaying along with the extension, if any, in the file
save dialog and also for displaying as a tool tip.
getDescription() –
Method in class mars.mips.instructions.Instruction
Get string describing the instruction.
getDescription() –
Method in class mars.venus.editors.jeditsyntax.PopupHelpItem
getDirectiveList() –
Static method in class mars.assembler.Directives
Produces List of Directive objects
getDisplayAddressesInHex() –
Method in class mars.Settings
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.DISPLAY_ADDRESSES_IN_HEX)
getDisplayValuesInHex() –
Method in class mars.Settings
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.DISPLAY_VALUES_IN_HEX)
getDocument() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the document this text area is editing.
getDocument() –
Method in interface mars.venus.editors.MARSTextEditingArea
getDocumentLength() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the length of the document.
getDoubleFromRegisterPair(int) –
Static method in class mars.mips.hardware.Coprocessor1
Gets the double value stored in the given FPU register.
getDoubleFromRegisterPair(String) –
Static method in class mars.mips.hardware.Coprocessor1
Gets the double value stored in the given FPU register.
getEditor() –
Method in class mars.venus.VenusUI
Get reference to Editor object associated with this GUI.
getEditorFont() –
Method in class mars.Settings
Current editor font.
getEditorLineNumbersDisplayed() –
Method in class mars.Settings
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.EDITOR_LINE_NUMBERS_DISPLAYED)
getEditorPopupPrefixLength() –
Method in class mars.Settings
Get number of letters to be matched by editor’s instruction guide before popup generated (if popup enabled).
getEditorSyntaxStyleByPosition(int) –
Method in class mars.Settings
getEditorTabSize() –
Method in class mars.Settings
Get the tab size in characters.
getEditPane() –
Method in class mars.venus.MainPane
Returns current edit pane.
getEditPaneForFile(String) –
Method in class mars.venus.EditTabbedPane
If there is an EditPane for the given file pathname, return it else return null.
getEditTabbedPane() –
Method in class mars.venus.MainPane
Returns component containing editor display
getElectricScroll() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the number of lines from the top and button of the
text area that are always visible.
getEOLMarkerColor() –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Returns the EOL marker color.
getEOLMarkersPainted() –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Returns true if EOL markers are drawn, false otherwise.
getErrorLimit() –
Method in class mars.ErrorList
Get limit on number of error messages to be generated
by one assemble operation.
getErrorList() –
Method in class mars.assembler.Assembler
Get list of assembler errors and warnings
getErrorMessages() –
Method in class mars.ErrorList
Get ArrayList of error messages.
getErrors() –
Method in class mars.assembler.Tokenizer
Fetch this Tokenizer’s error list.
getExact() –
Method in class mars.venus.editors.jeditsyntax.PopupHelpItem
Determines whether match occurred in an exact-match or prefix-match search.
getExample() –
Method in class mars.venus.editors.jeditsyntax.PopupHelpItem
getExampleFormat() –
Method in class mars.mips.instructions.Instruction
Get string descriptor of instruction’s format.
getExampleLength() –
Method in class mars.venus.editors.jeditsyntax.PopupHelpItem
getExamplePaddedToLength(int) –
Method in class mars.venus.editors.jeditsyntax.PopupHelpItem
getExceptionHandler() –
Method in class mars.Settings
Name of currently selected exception handler file.
getExceptionHandlerAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getExceptionHandlerEnabled() –
Method in class mars.Settings
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.EXCEPTION_HANDLER_ENABLED)
getExecutePane() –
Method in class mars.venus.MainPane
returns component containing execution-time display
getExecuteTab() –
Method in class mars.venus.MainPane
returns component containing execution-time display.
getExpansionHistory() –
Method in class mars.assembler.MacroPool
getExtendedAssemblerEnabled() –
Method in class mars.Settings
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.EXTENDED_ASSEMBLER_ENABLED)
getExtension(File) –
Static method in class mars.util.FilenameFinder
Get the filename extension of the specified File.
getExternalTools() –
Static method in class mars.Globals
Get list of MarsTools that reside outside the MARS distribution.
getExternBaseAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getFile() –
Static method in class mars.venus.FileStatus
Returns the ASM file.
getFileErrorMessage() –
Static method in class mars.util.SystemIO
Retrieve file operation or error message
getFileExtension() –
Method in class mars.mips.dump.AbstractDumpFormat
Get the file extension associated with this format.
getFileExtension() –
Method in interface mars.mips.dump.DumpFormat
Get the file extension associated with this format.
getFileFilter(ArrayList, String, boolean) –
Static method in class mars.util.FilenameFinder
Get a FileFilter that will filter files based on the given list of filename extensions.
getFileFilter(ArrayList, String) –
Static method in class mars.util.FilenameFinder
Get a FileFilter that will filter files based on the given list of filename extensions.
getFileFilter(String, String, boolean) –
Static method in class mars.util.FilenameFinder
Get a FileFilter that will filter files based on the given filename extension.
getFileFilter(String, String) –
Static method in class mars.util.FilenameFinder
Get a FileFilter that will filter files based on the given filename extension.
getFilename() –
Method in class mars.assembler.SourceLine
Retrieve name of file containing source statement
getFilename() –
Method in class mars.ErrorMessage
Produce name of file containing error.
getFilename() –
Method in class mars.MIPSprogram
Produces name of associated source code file.
getFilename() –
Method in class mars.venus.EditPane
Delegates to corresponding FileStatus method
getFilename() –
Method in class mars.venus.FileStatus
Get file name with no path information.
getFilenameList(ClassLoader, String, String) –
Static method in class mars.util.FilenameFinder
Locate files and return list of file names.
getFilenameList(ClassLoader, String, ArrayList) –
Static method in class mars.util.FilenameFinder
Locate files and return list of file names.
getFilenameList(String, String) –
Static method in class mars.util.FilenameFinder
Locate files and return list of file names.
getFilenameList(String, ArrayList) –
Static method in class mars.util.FilenameFinder
Locate files and return list of file names.
getFilenameList(ArrayList, String) –
Static method in class mars.util.FilenameFinder
Return list of file names.
getFilenameList(ArrayList, ArrayList) –
Static method in class mars.util.FilenameFinder
Return list of file names.
getFileStatus() –
Method in class mars.venus.EditPane
Get the editing status for this EditPane’s associated document.
getFileStatus() –
Method in class mars.venus.FileStatus
Get editing status of this file.
getFirstLine() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the line displayed at the text area’s origin.
getFloatFromRegister(int) –
Static method in class mars.mips.hardware.Coprocessor1
Gets the float value stored in the given FPU register.
getFloatFromRegister(String) –
Static method in class mars.mips.hardware.Coprocessor1
Gets the float value stored in the given FPU register.
getFont() –
Method in class mars.venus.AbstractFontSettingDialog
getFont() –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
getFont() –
Method in interface mars.venus.editors.MARSTextEditingArea
getFontByPosition(int) –
Method in class mars.Settings
Retrieve a Font setting
getFontMetrics(Font) –
Method in class mars.venus.editors.jeditsyntax.SyntaxStyle
Returns the font metrics for the styled font.
getFontMetrics() –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Returns the font metrics used by this component.
getFontMetrics(Font) –
Method in interface mars.venus.editors.MARSTextEditingArea
getFontStyleStrings() –
Static method in class mars.util.EditorFont
Get array containing String values for font style names.
getFromLine() –
Method in class mars.assembler.Macro
getGlobalPointer() –
Method in class mars.mips.hardware.MemoryConfiguration
getGui() –
Static method in class mars.Globals
getHalf(int) –
Method in class mars.mips.hardware.Memory
Starting at the given word address, read a 2 byte word into lower 16 bits of int.
getHeapBaseAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getHelpComponent() –
Method in class mars.tools.AbstractMarsToolAndApplication
Override this method to provide a JComponent (probably a JButton) of your choice
to be placed just left of the Close/Exit button.
getHelpComponent() –
Method in class mars.tools.BitmapDisplay
Overrides default method, to provide a Help button for this tool/app.
getHelpComponent() –
Method in class mars.tools.DigitalLabSim
getHelpComponent() –
Method in class mars.tools.KeyboardAndDisplaySimulator
Overrides default method, to provide a Help button for this tool/app.
getHelpComponent() –
Method in class mars.tools.MemoryReferenceVisualization
Overrides default method, to provide a Help button for this tool/app.
getHistoryAsStr() –
Method in class mars.tools.BHTEntry
Builds a string representation of the BHT entry’s history.
getHorizontalOffset() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the horizontal offset of drawn lines.
getIdxForAddress(int) –
Method in class mars.tools.BHTableModel
Returns the index into the BHT for a given branch instruction address.
getIgnoreCase() –
Method in class mars.venus.editors.jeditsyntax.KeywordMap
Returns true if the keyword map is set to be case insensitive,
false otherwise.
getInitialDelay() –
Method in class mars.venus.RepeatButton
Gets the initial delay for the timer of this button.
getInitialProgramCounter() –
Static method in class mars.mips.hardware.RegisterFile
For returning the program counter’s initial (reset) value.
getInputHandler() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the input handler.
getInputString(String) –
Method in class mars.venus.MessagesPane
Method used by the SystemIO class to get interactive user input
requested by a running MIPS program (e.g.
getInputString(int) –
Method in class mars.venus.MessagesPane
Method used by the SystemIO class to get interactive user input
requested by a running MIPS program (e.g.
getInstance() –
Static method in class mars.mips.hardware.Memory
Returns the unique Memory instance, which becomes in essence global.
getInstance() –
Static method in class mars.simulator.Simulator
Returns the Simulator object
getInstance() –
Static method in class mars.venus.RunSpeedPanel
Retrieve the run speed panel object
getInstruction() –
Method in class mars.ProgramStatement
Produces Instruction object corresponding to this statement’s operator.
getInstructionCategory(ProgramStatement) –
Method in class mars.tools.InstructionStatistics
decodes the instruction and determines the category of the instruction.
getInstructionFormat() –
Method in class mars.mips.instructions.BasicInstruction
Gets the operand format of the instruction.
getInstructionLength() –
Method in class mars.mips.instructions.ExtendedInstruction
Get length in bytes that this extended instruction requires in its
binary form.
getInstructionLength() –
Method in class mars.mips.instructions.Instruction
Get length in bytes that this instruction requires in its binary form.
getInstructionList() –
Method in class mars.mips.instructions.InstructionSet
Retrieve the current instruction set.
getIntFromRegister(int) –
Static method in class mars.mips.hardware.Coprocessor1
Gets the 32-bit int bit pattern stored in the given FPU register.
getIntFromRegister(String) –
Static method in class mars.mips.hardware.Coprocessor1
Gets the 32-bit int bit pattern stored in the given FPU register.
getInvalidLinesPainted() –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Returns true if invalid lines are painted as red tildes (~),
false otherwise.
getKernelBaseAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getKernelDataBaseAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getKernelDataSegmentLimitAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getKernelHighAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getKernelTextBaseAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getKernelTextLimitAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getKeywords() –
Static method in class mars.venus.editors.jeditsyntax.tokenmarker.MIPSTokenMarker
Get KeywordMap containing all MIPS key words.
getLabelSortState() –
Method in class mars.Settings
Get the saved state of the Labels Window sorting (can sort by either
label or address and either ascending or descending order).
getLabelsWindow() –
Method in class mars.venus.ExecutePane
Access the label values window.
getLabelWindowVisibility() –
Method in class mars.Settings
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.LABEL_WINDOW_VISIBILITY)
getLeadingWhiteSpace() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Makes a copy of leading white space (tab or space) from the current line and
returns it.
getLength() –
Method in class mars.mips.hardware.MemoryAccessNotice
Fetch the length in bytes of the access operation (4,2,1).
getLengthInBytes(Directives) –
Static method in class mars.assembler.DataTypes
Get length in bytes for numeric MIPS directives.
getLimitAddresses(String[]) –
Static method in class mars.util.MemoryDump
Get the MIPS memory limit address(es) of the specified segment name(s).
getLine() –
Method in class mars.ErrorMessage
Produce line number of error.
getLineCount() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the number of lines in the document.
getLineCount() –
Method in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
Returns the number of lines in this token marker.
getLineEndOffset(int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the end offset of the specified line.
getLineHighlightColor() –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Returns the line highlight color.
getLineLength(int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the length of the specified line.
getLineNumber() –
Method in class mars.assembler.SourceLine
Retrieve line number of source statement
getLineNumbersList(Document) –
Method in class mars.venus.EditPane
getLineOfOffset(int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the line containing the specified offset.
getLinesPerPage() –
Method in class mars.venus.HardcopyWriter
Return the number of lines that fit on a page
getLineStartOffset(int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the start offset of the specified line.
getLineText(int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the text on the specified line.
getLineText(int, Segment) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Copies the text on the specified line into a segment.
getLocalMacroPool() –
Method in class mars.MIPSprogram
Gets local macro pool MacroPool for this program
getLocalSymbolTable() –
Method in class mars.MIPSprogram
Returns SymbolTable associated with this program.
getLongFromRegisterPair(int) –
Static method in class mars.mips.hardware.Coprocessor1
Gets a long representing the double value stored in the given double
precision FPU register.
getLongFromRegisterPair(String) –
Static method in class mars.mips.hardware.Coprocessor1
Gets the double value stored in the given FPU register.
getMachineList() –
Method in class mars.MIPSprogram
Produces list of machine statements that are assembled from the program.
getMachineStatement() –
Method in class mars.ProgramStatement
Produces binary machine statement as 32 character string, all ‘0’ and ‘1’ chars.
getMacroExpansionHistory() –
Method in class mars.ErrorMessage
Returns string describing macro expansion.
getMacroRecorder() –
Method in class mars.venus.editors.jeditsyntax.InputHandler
Returns the macro recorder.
getMagicCaretPosition() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the `magic’ caret position.
getMainPane() –
Method in class mars.venus.VenusUI
Get reference to messages pane associated with this GUI.
getMarkLine() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the mark line.
getMarkPosition() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the mark position.
getMatchingMacro(TokenList, int) –
Method in class mars.assembler.MacroPool
Will be called by parser when reaches a macro expansion call
getMaxSteps() –
Method in class mars.simulator.SimulatorNotice
Fetch the length in bytes of the access operation (4,2,1).
getMemoryConfiguration() –
Method in class mars.Settings
Returns identifier of current built-in memory configuration.
getMemoryMapBaseAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getMemoryMapLimitAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getMemoryMapLimitAddress() –
Method in class mars.mips.hardware.MemoryConfigurations
getMenuState() –
Static method in class mars.venus.VenusUI
Get current menu state.
getMessage() –
Method in class mars.ErrorMessage
Produce error message.
getMessagesPane() –
Method in class mars.venus.VenusUI
Get reference to messages pane associated with this GUI.
getMinimumSize() –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Returns the painter’s minimum size.
getMIPSprogram() –
Method in class mars.assembler.SourceLine
Retrieve MIPSprogram object containing source statement
getMIPSTokenExamples() –
Static method in class mars.venus.editors.jeditsyntax.tokenmarker.MIPSTokenMarker
getMIPSTokenLabels() –
Static method in class mars.venus.editors.jeditsyntax.tokenmarker.MIPSTokenMarker
getName() –
Method in class mars.assembler.Directives
Get name of this Directives object
getName() –
Method in class mars.assembler.Macro
getName() –
Method in class mars.assembler.Symbol
Returns the label of the the Symbol.
getName() –
Method in class mars.mips.hardware.Register
Returns the name of the Register.
getName() –
Method in class mars.mips.instructions.Instruction
Get operation mnemonic
getName() –
Method in class mars.mips.instructions.syscalls.AbstractSyscall
Return the name you have chosen for this syscall.
getName() –
Method in interface mars.mips.instructions.syscalls.Syscall
Return a name you have chosen for this syscall.
getName() –
Method in class mars.mips.instructions.syscalls.SyscallNumberOverride
Get the service name as a String.
getName() –
Method in class mars.tools.AbstractMarsToolAndApplication
Required MarsTool method to return Tool name.
getName() –
Method in class mars.tools.BHTSimulator
Returns the name of the tool.
getName() –
Method in class mars.tools.BitmapDisplay
Required MarsTool method to return Tool name.
getName() –
Method in class mars.tools.CacheSimulator
Required MarsTool method to return Tool name.
getName() –
Method in class mars.tools.DigitalLabSim
getName() –
Method in class mars.tools.FloatRepresentation
Fetch tool name (for display in MARS Tools menu)
getName() –
Method in class mars.tools.InstructionCounter
getName() –
Method in class mars.tools.InstructionStatistics
returns the name of the tool
getName() –
Method in class mars.tools.IntroToTools
Required method to return Tool name.
getName() –
Method in class mars.tools.KeyboardAndDisplaySimulator
Required MarsTool method to return Tool name.
getName() –
Method in class mars.tools.MarsBot
getName() –
Method in interface mars.tools.MarsTool
Return a name you have chosen for this tool.
getName() –
Method in class mars.tools.MemoryReferenceVisualization
Required MarsTool method to return Tool name.
getName() –
Method in class mars.tools.ScavengerHunt
getName() –
Method in class mars.tools.ScreenMagnifier
getName() –
Static method in class mars.venus.FileStatus
Returns the name of the file.
getNextCounter() –
Method in class mars.assembler.MacroPool
MacroPool.counter will be set to 0 on construction of this class and will
be incremented by each call.
getNextDefaultFilename() –
Method in class mars.venus.Editor
Generates a default file name
getNumber(String) –
Static method in class mars.mips.hardware.Coprocessor0
For getting the number representation of the register.
getNumber() –
Method in class mars.mips.hardware.Register
Returns the number of the Register.
getNumber(String) –
Static method in class mars.mips.hardware.RegisterFile
For getting the number representation of the register.
getNumber() –
Method in class mars.mips.instructions.syscalls.AbstractSyscall
Return the assigned service number.
getNumber() –
Method in interface mars.mips.instructions.syscalls.Syscall
Return the assigned service number.
getNumber() –
Method in class mars.mips.instructions.syscalls.SyscallNumberOverride
Get the new service number as an int.
getOpcodeMask() –
Method in class mars.mips.instructions.BasicInstruction
getOpcodeMatch() –
Method in class mars.mips.instructions.BasicInstruction
getOperand(int) –
Method in class mars.ProgramStatement
Produces operand value from given array position (first operand is position 0).
getOperands() –
Method in class mars.ProgramStatement
Produces int array of operand values for this statement.
getOperationMask() –
Method in class mars.mips.instructions.BasicInstruction
Gets the 32-character operation mask.
getOriginalFromLine() –
Method in class mars.assembler.Macro
getOriginalProgram() –
Method in class mars.assembler.Token
Produces original program containing this token.
getOriginalSourceLine() –
Method in class mars.assembler.Token
Produces original line number of this token.
getOriginalTokenList() –
Method in class mars.ProgramStatement
Produces token list generated from original source statement.
getOriginalToLine() –
Method in class mars.assembler.Macro
getOuterComponent() –
Method in class mars.venus.editors.generic.GenericTextArea
getOuterComponent() –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
getOuterComponent() –
Method in interface mars.venus.editors.MARSTextEditingArea
getPainter() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the object responsible for painting this text area.
getParent() –
Method in class mars.venus.FileStatus
Get file parent pathname.
getParsedList() –
Method in class mars.MIPSprogram
Produces existing list of parsed source code statements.
getPathname() –
Method in class mars.venus.EditPane
Delegates to corresponding FileStatus method
getPathname() –
Method in class mars.venus.FileStatus
Get full file pathname.
getPosition() –
Method in class mars.ErrorMessage
Produce position within erroneous line.
getPrediction() –
Method in class mars.tools.BHTEntry
Returns the branch prediction based on the history.
getPredictionAsStr() –
Method in class mars.tools.BHTEntry
Returns a string representation of the BHT entry’s current prediction.
getPredictionAtIdx(int) –
Method in class mars.tools.BHTableModel
Retrieve the prediction for the i-th BHT entry.
getPreferredSize() –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Returns the painter’s preferred size.
getPrintableBasicAssemblyStatement() –
Method in class mars.ProgramStatement
Produces printable Basic Assembly statement for this MIPS source
statement.
getProcessedLine() –
Method in class mars.assembler.TokenList
Retrieve the source line String associated with this
token list.
getProgram() –
Method in class mars.assembler.Macro
getProgramArguments() –
Method in class mars.Settings
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.PROGRAM_ARGUMENTS)
getProgramArguments() –
Method in class mars.venus.TextSegmentWindow
Get program arguments from text field in south border of text segment window.
getProgramCounter() –
Static method in class mars.mips.hardware.RegisterFile
For returning the program counters value.
getProgramCounter() –
Method in class mars.simulator.SimulatorNotice
Fetch the value of the access operation (the value read or written).
getProgramCounterRegister() –
Static method in class mars.mips.hardware.RegisterFile
Returns Register object for program counter.
getPropertyEntry(String, String) –
Static method in class mars.Globals
Read and return property file value (if any) for requested property.
getRawWord(int) –
Method in class mars.mips.hardware.Memory
Starting at the given word address, read a 4 byte word as an int.
getRawWordOrNull(int) –
Method in class mars.mips.hardware.Memory
Starting at the given word address, read a 4 byte word as an int and return Integer.
getRegister(String) –
Static method in class mars.mips.hardware.Coprocessor0
Get register object corresponding to given name.
getRegister(String) –
Static method in class mars.mips.hardware.Coprocessor1
Get register object corresponding to given name.
getRegisterName() –
Method in class mars.mips.hardware.RegisterAccessNotice
Fetch the register number of register accessed.
getRegisterNumber(String) –
Static method in class mars.mips.hardware.Coprocessor1
For getting the number representation of the FPU register.
getRegisterPosition(Register) –
Static method in class mars.mips.hardware.Coprocessor0
Coprocessor0 implements only selected registers, so the register number
(8, 12, 13, 14) does not correspond to its position in the list of registers
(0, 1, 2, 3).
getRegisters() –
Static method in class mars.mips.hardware.Coprocessor0
For returning the set of registers.
getRegisters() –
Static method in class mars.mips.hardware.Coprocessor1
For returning the set of registers.
getRegisters() –
Static method in class mars.mips.hardware.RegisterFile
For returning the set of registers.
getRegistersHighlighting() –
Method in class mars.Settings
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.REGISTERS_HIGHLIGHTING)
getRegistersPane() –
Method in class mars.venus.VenusUI
Get reference to registers pane associated with this GUI.
getRegistersWindow() –
Method in class mars.venus.ExecutePane
Access the register values window.
getRegistersWindow() –
Method in class mars.venus.RegistersPane
Return component containing integer register set.
getRepeatCount() –
Method in class mars.venus.editors.jeditsyntax.InputHandler
Returns the number of times the next action will be repeated.
getReset() –
Static method in class mars.venus.VenusUI
To find out whether the register values are reset.
getResetValue() –
Method in class mars.mips.hardware.Register
Returns the reset value of the Register.
getRightClickPopup() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the right click popup menu.
getRowCount() –
Method in class mars.tools.BHTableModel
Returns the number of entries of the BHT.
getRunAssembleAction() –
Method in class mars.venus.VenusUI
Return reference tothe Run->Assemble item’s action.
getRunSpeed() –
Method in class mars.simulator.SimulatorNotice
Fetch the value of the access operation (the value read or written).
getRunSpeed() –
Method in class mars.venus.RunSpeedPanel
returns current run speed setting, in instructions/second.
getRunTextArea() –
Method in class mars.venus.MessagesPane
Returns component used to display runtime messages
getSegmentBounds(String) –
Static method in class mars.util.MemoryDump
Return array with segment address bounds for specified segment.
getSegmentMapKey(Segment, int, int) –
Method in class mars.venus.editors.jeditsyntax.KeywordMap
getSegmentNames() –
Static method in class mars.util.MemoryDump
Get the names of segments available for memory dump.
getSelectedText() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the selected text, or null if no selection is active.
getSelectedText() –
Method in interface mars.venus.editors.MARSTextEditingArea
getSelectionColor() –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Returns the selection color.
getSelectionEnd() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the selection end offset.
getSelectionEnd(int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the offset where the selection ends on the specified
line.
getSelectionEnd() –
Method in interface mars.venus.editors.MARSTextEditingArea
getSelectionEndLine() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the selection end line.
getSelectionStart() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the selection start offset.
getSelectionStart(int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the offset where the selection starts on the specified
line.
getSelectionStart() –
Method in interface mars.venus.editors.MARSTextEditingArea
getSelectionStartLine() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the selection start line.
getSettings() –
Static method in class mars.Globals
getSimulationCode() –
Method in class mars.mips.instructions.BasicInstruction
Gets the SimulationCode object.
getSize() –
Method in class mars.assembler.SymbolTable
Get the count of entries currently in the table.
getSortedBreakPointsArray() –
Method in class mars.venus.TextSegmentWindow
Returns array of current breakpoints, each represented by a MIPS program counter address.
getSource() –
Method in class mars.assembler.SourceLine
Retrieve source statement itself
getSource() –
Method in class mars.ProgramStatement
Produces MIPS source statement.
getSource() –
Method in class mars.venus.EditPane
Get source code text
getSourceFile() –
Method in class mars.ProgramStatement
Produces String name of the source file containing this statement.
getSourceLine() –
Method in class mars.assembler.Token
Produces line number of MIPS program of this token.
getSourceLine(int) –
Method in class mars.MIPSprogram
Produces specified line of MIPS source program.
getSourceLine() –
Method in class mars.ProgramStatement
Produces line number of MIPS source statement.
getSourceLineCount() –
Method in class mars.venus.EditPane
Calculate and return number of lines in source code text.
getSourceLineList() –
Method in class mars.MIPSprogram
Retrieve list of source statements that comprise the program.
getSourceList() –
Method in class mars.MIPSprogram
Produces list of source statements that comprise the program.
getSourceMIPSprogram() –
Method in class mars.assembler.Token
Produces MIPSprogram object associated with this token.
getSourceMIPSprogram() –
Method in class mars.ProgramStatement
Produces MIPSprogram object representing the source file containing this statement.
getStackBaseAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getStackLimitAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getStackPointer() –
Method in class mars.mips.hardware.MemoryConfiguration
getStartAtMain() –
Method in class mars.Settings
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.START_AT_MAIN)
getStarted() –
Static method in class mars.venus.VenusUI
To find out whether MIPS program is currently executing.
getStartLabel() –
Static method in class mars.assembler.SymbolTable
Fetches the text segment label (symbol) which, if declared global, indicates
the starting address for execution.
getStartPos() –
Method in class mars.assembler.Token
Produces position within source line of this token.
getStatement(int) –
Method in class mars.mips.hardware.Memory
Gets ProgramStatement from Text Segment.
getStatementNoNotify(int) –
Method in class mars.mips.hardware.Memory
Gets ProgramStatement from Text Segment without notifying observers.
getStatsPredCorrect() –
Method in class mars.tools.BHTEntry
Get the absolute number of correct predictions.
getStatsPredIncorrect() –
Method in class mars.tools.BHTEntry
Get the absolute number of mispredictions.
getStatsPredPrecision() –
Method in class mars.tools.BHTEntry
Get the percentage of correct predictions.
getStringMapKey(String) –
Method in class mars.venus.editors.jeditsyntax.KeywordMap
getStrippedTokenList() –
Method in class mars.ProgramStatement
Produces token list stripped of all but operator and operand tokens.
getStyledFont(Font) –
Method in class mars.venus.editors.jeditsyntax.SyntaxStyle
Returns the specified font, but with the style’s bold and
italic flags applied.
getStyles() –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Returns the syntax styles used to paint colorized text.
getSubstitutedLine(int, TokenList, long, ErrorList) –
Method in class mars.assembler.Macro
Substitutes macro arguments in a line of source code inside macro
definition to be parsed after macro expansion.
getSymbol(String) –
Method in class mars.assembler.SymbolTable
Produce Symbol object from symbol table that corresponds to given String.
getSymbolGivenAddress(String) –
Method in class mars.assembler.SymbolTable
Produce Symbol object from symbol table that has the given address.
getSymbolGivenAddressLocalOrGlobal(String) –
Method in class mars.assembler.SymbolTable
Produce Symbol object from either local or global symbol table that has the
given address.
getSyntaxSensitiveToolTipText(int, int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Return any relevant tool tip text for token at specified position.
getSyscallOverrides() –
Method in class mars.Globals
Read any syscall number assignment overrides from config file.
getTabBHT() –
Method in class mars.tools.BHTSimGUI
Returns the table representing the BHT.
getTabSize() –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Fetch the tab size in characters.
getTaLog() –
Method in class mars.tools.BHTSimGUI
Returns the text area for log purposes.
getText() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the entire text of this text area.
getText(int, int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the specified substring of the document.
getText(int, int, Segment) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Copies the specified substring of the document into a segment.
getText() –
Method in interface mars.venus.editors.MARSTextEditingArea
getTextArea(EventObject) –
Static method in class mars.venus.editors.jeditsyntax.InputHandler
Returns the text area that fired the specified event.
getTextBaseAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getTextColumnOrder() –
Method in class mars.Settings
Order of text segment display columns (there are 5, numbered 0 to 4).
getTextLimitAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getTextSegmentWindow() –
Method in class mars.venus.ExecutePane
Access the text segment window.
getTextSymbols() –
Method in class mars.assembler.SymbolTable
For obtaining the Text Symbols.
getTfAddress() –
Method in class mars.tools.BHTSimGUI
Returns the text field for displaying the address of the most recent branch instruction
getTfIndex() –
Method in class mars.tools.BHTSimGUI
Returns the text field for displaying the corresponding index into the BHT
getTfInstruction() –
Method in class mars.tools.BHTSimGUI
Returns the text field for displaying the most recent branch instruction
getThread() –
Method in class mars.mips.hardware.AccessNotice
Get reference to thread that created this notice
getTokenExactMatchHelp(Token, String) –
Method in class mars.venus.editors.jeditsyntax.tokenmarker.MIPSTokenMarker
Construct and return any appropriate help information for
the given token.
getTokenExactMatchHelp(Token, String) –
Method in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
Construct and return any appropriate help information for
the given token.
getTokenizer() –
Method in class mars.MIPSprogram
Retrieves Tokenizer for this program
getTokenList() –
Method in class mars.mips.instructions.Instruction
Get TokenList corresponding to correct instruction syntax.
getTokenList() –
Method in class mars.MIPSprogram
Produces list of tokens that comprise the program.
getTokenMarker() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the document’s token marker.
getTokenMarker() –
Method in class mars.venus.editors.jeditsyntax.SyntaxDocument
Returns the token marker that is to be used to split lines
of this document up into tokens.
getTokenPrefixMatchHelp(String, Token, Token, String) –
Method in class mars.venus.editors.jeditsyntax.tokenmarker.MIPSTokenMarker
Construct and return any appropriate help information for
prefix match based on current line’s token list.
getTokenPrefixMatchHelp(String, Token, Token, String) –
Method in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
Construct and return any appropriate help information for
the given token or “token prefix”.
getTokenText() –
Method in class mars.venus.editors.jeditsyntax.PopupHelpItem
The document text that mached this item
getToLine() –
Method in class mars.assembler.Macro
getToolTipText(MouseEvent) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Returns the tool tip to display at the specified location.
getToolTipText(MouseEvent) –
Method in interface mars.venus.editors.jeditsyntax.TextAreaPainter.Highlight
Returns the tool tip to display at the specified
location.
getType() –
Method in class mars.assembler.Symbol
Finds the type of symbol, text or data.
getType() –
Method in class mars.assembler.Token
Produces token type of this token.
getType() –
Method in exception mars.mips.hardware.AddressErrorException
Get the exception type (load or store).
getUndoManager() –
Method in class mars.venus.editors.generic.GenericTextArea
Returns the undo manager for this editing area
getUndoManager() –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
Returns the undo manager for this editing area
getUndoManager() –
Method in interface mars.venus.editors.MARSTextEditingArea
getUndoManager() –
Method in class mars.venus.EditPane
get the manager in charge of Undo and Redo operations
getUserHighAddress() –
Method in class mars.mips.hardware.MemoryConfiguration
getUserRegister(String) –
Static method in class mars.mips.hardware.RegisterFile
Get register object corresponding to given name.
getValue() –
Method in class mars.assembler.Token
Produces source code of this token.
getValue(int) –
Static method in class mars.mips.hardware.Coprocessor0
Returns the value of the register who’s number is num.
getValue(int) –
Static method in class mars.mips.hardware.Coprocessor1
Returns the value of the FPU register who’s number is num.
getValue() –
Method in class mars.mips.hardware.MemoryAccessNotice
Fetch the value of the access operation (the value read or written).
getValue() –
Method in class mars.mips.hardware.Register
Returns the value of the Register.
getValue(int) –
Static method in class mars.mips.hardware.RegisterFile
Returns the value of the register who’s number is num.
getValue() –
Method in class mars.simulator.SwingWorker
Get the value produced by the worker thread, or null if it
hasn’t been constructed yet.
getValueAt(int, int) –
Method in class mars.tools.BHTableModel
Returns the value of the cell at the given row and column
Required by the TableModel interface.
getValueDisplayBase() –
Method in class mars.venus.ExecutePane
Retrieve the number system base for displaying values (mem/register contents)
getValueDisplayBaseChooser() –
Method in class mars.venus.ExecutePane
Retrieve component used to set numerical base (10 or 16) of data value display.
getValueDisplayBaseMenuItem() –
Method in class mars.venus.VenusUI
Get reference to settings menu item for display base of memory/register values.
getValueNoNotify() –
Method in class mars.mips.hardware.Register
Returns the value of the Register.
getVisibleLines() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns the number of lines visible in this text area.
getWarningsAreErrors() –
Method in class mars.Settings
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.WARNINGS_ARE_ERRORS)
getWord(int) –
Method in class mars.mips.hardware.Memory
Starting at the given word address, read a 4 byte word as an int.
getWordNoNotify(int) –
Method in class mars.mips.hardware.Memory
Starting at the given word address, read a 4 byte word as an int.
GLOBAL_POINTER_REGISTER –
Static variable in class mars.mips.hardware.RegisterFile
globalPointer –
Static variable in class mars.mips.hardware.Memory
base address for storing globals
Globals – Class in mars
Collection of globally-available data structures.
Globals() –
Constructor for class mars.Globals
GLOBL –
Static variable in class mars.assembler.Directives
go() –
Method in class mars.tools.AbstractMarsToolAndApplication
Run the simulator as stand-alone application.
grabAction –
Variable in class mars.venus.editors.jeditsyntax.InputHandler
grabFocus() –
Method in interface mars.venus.editors.MARSTextEditingArea
grabNextKeyStroke(ActionListener) –
Method in class mars.venus.editors.jeditsyntax.InputHandler
Grabs the next key typed event and invokes the specified
action with the key as a the action command.
GuiAction – Class in mars.venus
parent class for Action subclasses to be defined for every menu/toolbar
option.
GuiAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.GuiAction
H
HALF –
Static variable in class mars.assembler.Directives
HALF_SIZE –
Static variable in class mars.assembler.DataTypes
Number of bytes occupied by MIPS halfword is 2.
handleExecBranchInst(int, boolean) –
Method in class mars.tools.BHTSimulator
Handles the execution of the branch instruction.
handleGrabAction(KeyEvent) –
Method in class mars.venus.editors.jeditsyntax.InputHandler
If a key is being grabbed, this method should be called with
the appropriate key event.
handlePreBranchInst(ProgramStatement) –
Method in class mars.tools.BHTSimulator
Handles the execution branch instruction.
HardcopyWriter – Class in mars.venus
HardcopyWriter(Frame, String, int, double, double, double, double) –
Constructor for class mars.venus.HardcopyWriter
The constructor for this class has a bunch of arguments:
The frame argument is required for all printing in Java.
HardcopyWriter.PrintCanceledException – Exception in mars.venus
This is the exception class that the HardcopyWriter constructor
throws when the user clicks “Cancel” in the print dialog box.
HardcopyWriter.PrintCanceledException(String) –
Constructor for exception mars.venus.HardcopyWriter.PrintCanceledException
hasCompactTranslation() –
Method in class mars.mips.instructions.ExtendedInstruction
Determine whether or not this pseudo-instruction has a second
translation optimized for 16 bit address space: a compact version.
hasUnsavedEdits() –
Method in class mars.venus.EditPane
Delegates to corresponding FileStatus method
hasUnsavedEdits() –
Method in class mars.venus.FileStatus
Determine if file has been modified since last save or, if not yet saved, since
being created using New or Open.
haveMenuRequestFocus() –
Method in class mars.venus.VenusUI
Have the menu request keyboard focus.
headerfont –
Variable in class mars.venus.HardcopyWriter
headermetrics –
Variable in class mars.venus.HardcopyWriter
headery –
Variable in class mars.venus.HardcopyWriter
heapAddress –
Static variable in class mars.mips.hardware.Memory
heapBaseAddress –
Static variable in class mars.mips.hardware.Memory
base address for heap: 0x10040000 (I think from SPIM not MIPS)
height –
Variable in class mars.venus.HardcopyWriter
HelpAboutAction – Class in mars.venus
Action for the Help -> About menu item
HelpAboutAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.HelpAboutAction
HelpHelpAction – Class in mars.venus
Action for the Help -> Help menu item
HelpHelpAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.HelpHelpAction
helpPath –
Static variable in class mars.Globals
Path to folder that contains help text
HEXADECIMAL –
Static variable in class mars.venus.NumberDisplayBaseChooser
hexStringToBinaryString(String) –
Static method in class mars.util.Binary
Translate String consisting of hexadecimal digits into String consisting of
corresponding binary digits (‘1’s and ‘0’s).
HexTextDumpFormat – Class in mars.mips.dump
Class that represents the “hexadecimal text” memory dump format.
HexTextDumpFormat() –
Constructor for class mars.mips.dump.HexTextDumpFormat
Constructor.
highlights –
Variable in class mars.venus.editors.jeditsyntax.TextAreaPainter
highlightStepAtAddress(int) –
Method in class mars.venus.TextSegmentWindow
Highlights the source code line whose address matches the given
text segment address.
highlightStepAtAddress(int, boolean) –
Method in class mars.venus.TextSegmentWindow
Highlights the source code line whose address matches the given
text segment address.
highlightStepAtPC() –
Method in class mars.venus.TextSegmentWindow
Highlights the source code line whose address matches the current
program counter value.
highlightStepAtPC(boolean) –
Method in class mars.venus.TextSegmentWindow
Highlights the source code line whose address matches the current
program counter value.
highOrderLongToInt(long) –
Static method in class mars.util.Binary
Returns int representing the bit values of the high order 32 bits of given
64 bit long value.
HOME –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
horizontal –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
horizontalOffset –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
I
I_BRANCH_FORMAT –
Static variable in class mars.mips.instructions.BasicInstructionFormat
I_FORMAT –
Static variable in class mars.mips.instructions.BasicInstructionFormat
id –
Variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
The id of this token.
ID_COUNT –
Static variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
The total number of defined token ids.
IDENTIFIER –
Static variable in class mars.assembler.TokenTypes
imagesPath –
Static variable in class mars.Globals
Path to folder that contains images
INCLUDE –
Static variable in class mars.assembler.Directives
incrementPC() –
Static method in class mars.mips.hardware.RegisterFile
Method to increment the Program counter in the general case (not a jump or branch).
inDataSegment(int) –
Static method in class mars.mips.hardware.Memory
Handy little utility to find out if given address is in MARS data
segment (starts at Memory.dataSegmentBaseAddress).
inDelaySlot() –
Method in class mars.simulator.BackStepper
Determine whether the next back-step action occurred as the result of
an instruction that executed in the “delay slot” of a delayed branch.
inDelaySlot() –
Static method in class mars.simulator.Simulator
Determine whether or not the next instruction to be executed is in a
“delay slot”.
init(JEditTextArea, TextAreaPainter.Highlight) –
Method in interface mars.venus.editors.jeditsyntax.TextAreaPainter.Highlight
Called after the highlight painter has been added.
initBHT(int, int, boolean) –
Method in class mars.tools.BHTableModel
Initializes the BHT with the given size and history.
initialize(boolean) –
Static method in class mars.Globals
Method called once upon system initialization to create the global data structures.
initializePostGUI() –
Method in class mars.tools.AbstractMarsToolAndApplication
Method that will be called once just after the GUI is constructed in the go() and action()
methods.
initializePostGUI() –
Method in class mars.tools.BitmapDisplay
The only post-GUI initialization is to create the initial Grid object based on the default settings
of the various combo boxes.
initializePostGUI() –
Method in class mars.tools.CacheSimulator
The only post-GUI initialization is to create the initial cache object based on the default settings
of the various combo boxes.
initializePostGUI() –
Method in class mars.tools.KeyboardAndDisplaySimulator
Initialization code to be executed after the GUI is configured.
initializePostGUI() –
Method in class mars.tools.MemoryReferenceVisualization
The only post-GUI initialization is to create the initial Grid object based on the default settings
of the various combo boxes.
initializePreGUI() –
Method in class mars.tools.AbstractMarsToolAndApplication
Method that will be called once just before the GUI is constructed in the go() and action()
methods.
initializePreGUI() –
Method in class mars.tools.BitmapDisplay
Initialize all JComboBox choice structures not already initialized at declaration.
initializePreGUI() –
Method in class mars.tools.CacheSimulator
Initialize all JComboBox choice structures not already initialized at declaration.
initializePreGUI() –
Method in class mars.tools.InstructionCounter
initializePreGUI() –
Method in class mars.tools.InstructionStatistics
performs initialization tasks of the counters before the GUI is created.
initializePreGUI() –
Method in class mars.tools.KeyboardAndDisplaySimulator
initializePreGUI() –
Method in class mars.tools.MemoryReferenceVisualization
Initialize all JComboBox choice structures not already initialized at declaration.
initializeProgramCounter(int) –
Static method in class mars.mips.hardware.RegisterFile
For initializing the Program Counter.
initializeProgramCounter(boolean) –
Static method in class mars.mips.hardware.RegisterFile
Will initialize the Program Counter to either the default reset value, or the address
associated with source program global label “main”, if it exists as a text segment label
and the global setting is set.
inKernelDataSegment(int) –
Static method in class mars.mips.hardware.Memory
Handy little utility to find out if given address is in MARS kernel data
segment (starts at Memory.kernelDataSegmentBaseAddress).
inKernelTextSegment(int) –
Static method in class mars.mips.hardware.Memory
Handy little utility to find out if given address is in MARS kernel
text segment (starts at Memory.kernelTextBaseAddress).
inMemoryMapSegment(int) –
Static method in class mars.mips.hardware.Memory
Handy little utility to find out if given address is in the Memory Map area
starts at Memory.memoryMapBaseAddress, range 0xffff0000 to 0xffffffff.
InputHandler – Class in mars.venus.editors.jeditsyntax
An input handler converts the user’s key strokes into concrete actions.
InputHandler() –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler
inputHandler –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
inputHandler –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
InputHandler.backspace – Class in mars.venus.editors.jeditsyntax
InputHandler.backspace() –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.backspace
InputHandler.backspace_word – Class in mars.venus.editors.jeditsyntax
InputHandler.backspace_word() –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.backspace_word
InputHandler.clip_copy – Class in mars.venus.editors.jeditsyntax
InputHandler.clip_copy() –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.clip_copy
InputHandler.clip_cut – Class in mars.venus.editors.jeditsyntax
InputHandler.clip_cut() –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.clip_cut
InputHandler.clip_paste – Class in mars.venus.editors.jeditsyntax
InputHandler.clip_paste() –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.clip_paste
InputHandler.delete – Class in mars.venus.editors.jeditsyntax
InputHandler.delete() –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.delete
InputHandler.delete_word – Class in mars.venus.editors.jeditsyntax
InputHandler.delete_word() –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.delete_word
InputHandler.document_end – Class in mars.venus.editors.jeditsyntax
InputHandler.document_end(boolean) –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.document_end
InputHandler.document_home – Class in mars.venus.editors.jeditsyntax
InputHandler.document_home(boolean) –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.document_home
InputHandler.end – Class in mars.venus.editors.jeditsyntax
InputHandler.end(boolean) –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.end
InputHandler.home – Class in mars.venus.editors.jeditsyntax
InputHandler.home(boolean) –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.home
InputHandler.insert_break – Class in mars.venus.editors.jeditsyntax
InputHandler.insert_break() –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.insert_break
InputHandler.insert_char – Class in mars.venus.editors.jeditsyntax
InputHandler.insert_char() –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.insert_char
InputHandler.insert_tab – Class in mars.venus.editors.jeditsyntax
InputHandler.insert_tab() –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.insert_tab
InputHandler.MacroRecorder – Interface in mars.venus.editors.jeditsyntax
Macro recorder.
InputHandler.next_char – Class in mars.venus.editors.jeditsyntax
InputHandler.next_char(boolean) –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.next_char
InputHandler.next_line – Class in mars.venus.editors.jeditsyntax
InputHandler.next_line(boolean) –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.next_line
InputHandler.next_page – Class in mars.venus.editors.jeditsyntax
InputHandler.next_page(boolean) –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.next_page
InputHandler.next_word – Class in mars.venus.editors.jeditsyntax
InputHandler.next_word(boolean) –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.next_word
InputHandler.NonRecordable – Interface in mars.venus.editors.jeditsyntax
If an action implements this interface, it should not be recorded
by the macro recorder.
InputHandler.NonRepeatable – Interface in mars.venus.editors.jeditsyntax
If an action implements this interface, it should not be repeated.
InputHandler.overwrite – Class in mars.venus.editors.jeditsyntax
InputHandler.overwrite() –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.overwrite
InputHandler.prev_char – Class in mars.venus.editors.jeditsyntax
InputHandler.prev_char(boolean) –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.prev_char
InputHandler.prev_line – Class in mars.venus.editors.jeditsyntax
InputHandler.prev_line(boolean) –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.prev_line
InputHandler.prev_page – Class in mars.venus.editors.jeditsyntax
InputHandler.prev_page(boolean) –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.prev_page
InputHandler.prev_word – Class in mars.venus.editors.jeditsyntax
InputHandler.prev_word(boolean) –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.prev_word
InputHandler.repeat – Class in mars.venus.editors.jeditsyntax
InputHandler.repeat() –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.repeat
InputHandler.select_all – Class in mars.venus.editors.jeditsyntax
InputHandler.select_all() –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.select_all
InputHandler.toggle_rect – Class in mars.venus.editors.jeditsyntax
InputHandler.toggle_rect() –
Constructor for class mars.venus.editors.jeditsyntax.InputHandler.toggle_rect
InputHandler.Wrapper – Interface in mars.venus.editors.jeditsyntax
For use by EditAction.Wrapper only.
INSERT_BREAK –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
INSERT_CHAR –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
INSERT_TAB –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
insertLines(int, int) –
Method in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
Informs the token marker that lines have been inserted into
the document.
inSteppedExecution() –
Method in class mars.MIPSprogram
Will be true only while in process of simulating a program statement
in step mode (e.g.
Instruction – Class in mars.mips.instructions
Base class to represent member of MIPS instruction set.
Instruction() –
Constructor for class mars.mips.instructions.Instruction
INSTRUCTION_LENGTH –
Static variable in class mars.mips.instructions.Instruction
Length in bytes of a machine instruction.
INSTRUCTION_LENGTH_BITS –
Static variable in class mars.mips.instructions.Instruction
InstructionCounter – Class in mars.tools
Instruction counter tool.
InstructionCounter(String, String) –
Constructor for class mars.tools.InstructionCounter
Simple constructor, likely used to run a stand-alone memory reference visualizer.
InstructionCounter() –
Constructor for class mars.tools.InstructionCounter
Simple construction, likely used by the MARS Tools menu mechanism.
instructionSet –
Static variable in class mars.Globals
The set of implemented MIPS instructions.
InstructionSet – Class in mars.mips.instructions
The list of Instruction objects, each of which represents a MIPS instruction.
InstructionSet() –
Constructor for class mars.mips.instructions.InstructionSet
Creates a new InstructionSet object.
InstructionStatistics – Class in mars.tools
A MARS tool for obtaining instruction statistics by instruction category.
InstructionStatistics(String, String) –
Constructor for class mars.tools.InstructionStatistics
Simple constructor, likely used to run a stand-alone enhanced instruction counter.
InstructionStatistics() –
Constructor for class mars.tools.InstructionStatistics
Simple construction, likely used by the MARS Tools menu mechanism.
INTEGER_16 –
Static variable in class mars.assembler.TokenTypes
INTEGER_16U –
Static variable in class mars.assembler.TokenTypes
INTEGER_32 –
Static variable in class mars.assembler.TokenTypes
INTEGER_5 –
Static variable in class mars.assembler.TokenTypes
IntelHexDumpFormat – Class in mars.mips.dump
Intel’s Hex memory initialization format
IntelHexDumpFormat() –
Constructor for class mars.mips.dump.IntelHexDumpFormat
Constructor.
INTERNAL_FIRST –
Static variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
The first id that can be used for internal state
in a token marker.
INTERNAL_LAST –
Static variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
The last id that can be used for internal state
in a token marker.
interrupt() –
Method in class mars.simulator.SwingWorker
A new method that interrupts the worker thread.
inTextSegment(int) –
Static method in class mars.mips.hardware.Memory
Handy little utility to find out if given address is in MARS text
segment (starts at Memory.textBaseAddress).
IntroToTools – Class in mars.tools
The “hello world” of MarsTools!
IntroToTools(String, String) –
Constructor for class mars.tools.IntroToTools
Simple constructor, likely used to run a stand-alone memory reference visualizer.
IntroToTools() –
Constructor for class mars.tools.IntroToTools
Simple constructor, likely used by the MARS Tools menu mechanism
intToAscii(int) –
Static method in class mars.util.Binary
Produce ASCII string equivalent of integer value, interpreting it as 4 one-byte
characters.
intToBinaryString(int, int) –
Static method in class mars.util.Binary
Translate int value into a String consisting of ‘1’s and ‘0’s.
intToBinaryString(int) –
Static method in class mars.util.Binary
Translate int value into a String consisting of ‘1’s and ‘0’s.
intToHalfHexString(int) –
Static method in class mars.util.Binary
Returns a 6 character string representing the 16-bit hexadecimal equivalent of the
given integer value.
intToHexString(int) –
Static method in class mars.util.Binary
Prefix a hexadecimal-indicating string “0x” to the string which is
returned by the method “Integer.toHexString”.
INVALID –
Static variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
Invalid token id.
invalidateLine(int) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Marks a line as needing a repaint.
invalidateLineRange(int, int) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Marks a range of lines as needing a repaint.
invalidateSelectedLines() –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Repaints the lines containing the selection.
InvalidRegisterAccessException – Exception in mars.mips.hardware
Represents attempt to access double precision register using an odd
(e.g.
InvalidRegisterAccessException() –
Constructor for exception mars.mips.hardware.InvalidRegisterAccessException
Constructor for IllegalRegisterException.
isAssembled() –
Static method in class mars.venus.FileStatus
Tells whether the file has been assembled.
isBeingUsedAsAMarsTool –
Variable in class mars.tools.AbstractMarsToolAndApplication
isBlockCaretEnabled() –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Returns true if the caret should be drawn as a block, false otherwise.
isBold() –
Method in class mars.venus.editors.jeditsyntax.SyntaxStyle
Returns true if boldface is enabled for this style.
isBracketHighlightEnabled() –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Returns true if bracket highlighting is enabled, false otherwise.
isBranchInstruction(ProgramStatement) –
Static method in class mars.tools.BHTSimulator
Determines if the instruction is a branch instruction or not.
isCaretBlinkEnabled() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns true if the caret is blinking, false otherwise.
isCaretVisible() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns true if the caret is visible, false otherwise.
isConnected() –
Method in class mars.tools.AbstractMarsToolAndApplication.ConnectButton
isEditable() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns true if this text area is editable, false otherwise.
isEdited() –
Static method in class mars.venus.FileStatus
Tells whether the file has been edited since it has been saved.
isEmpty() –
Method in class mars.assembler.TokenList
Returns empty/non-empty status of list.
isFloatingDirective(Directives) –
Static method in class mars.assembler.Directives
Lets you know whether given directive is for floating number (FLOAT,DOUBLE).
isFloatingTokenType(TokenTypes) –
Static method in class mars.assembler.TokenTypes
Lets you know if given tokentype is for floating point numbers (REAL_NUMBER).
isHex(String) –
Static method in class mars.util.Binary
Parsing method to see if a string represents a hex number.
isIntegerDirective(Directives) –
Static method in class mars.assembler.Directives
Lets you know whether given directive is for integer (WORD,HALF,BYTE).
isIntegerTokenType(TokenTypes) –
Static method in class mars.assembler.TokenTypes
Lets you know if given tokentype is for integers (INTGER_5, INTEGER_16, INTEGER_32).
isItalic() –
Method in class mars.venus.editors.jeditsyntax.SyntaxStyle
Returns true if italics is enabled for this style.
isLineHighlightEnabled() –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Returns true if line highlight is enabled, false otherwise.
isManagingFocus() –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Returns if this component can be traversed by pressing the
Tab key.
isNew() –
Method in class mars.venus.EditPane
Delegates to corresponding FileStatus method
isNew() –
Method in class mars.venus.FileStatus
Determine if file is “new”, which means created using New but not yet saved.
isNextLineRequested() –
Method in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
Returns true if the next line should be repainted.
isObserving() –
Method in class mars.tools.AbstractMarsToolAndApplication
Query method to let you know if the tool/app is (or could be) currently
“observing” any MIPS resources.
isOctal(String) –
Static method in class mars.util.Binary
Parsing method to see if a string represents an octal number.
isOverwriteEnabled() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns true if overwrite mode is enabled, false otherwise.
isPlain() –
Method in class mars.venus.editors.jeditsyntax.SyntaxStyle
Returns true if no font styles are enabled.
isRepeatEnabled() –
Method in class mars.venus.editors.jeditsyntax.InputHandler
Returns if repeating is enabled.
isRepeatEnabled() –
Method in class mars.venus.RepeatButton
Checks if the button should fire events when held.
isSaved() –
Static method in class mars.venus.FileStatus
Tells whether the file has been saved.
isSelectionRectangular() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Returns true if the selection is rectangular, false otherwise.
isValidIdentifier(String) –
Static method in class mars.assembler.TokenTypes
isWarning() –
Method in class mars.ErrorMessage
Determine whether this message represents error or warning.
J
J_FORMAT –
Static variable in class mars.mips.instructions.BasicInstructionFormat
JEditBasedTextArea – Class in mars.venus.editors.jeditsyntax
Adaptor subclass for JEditTextArea
Provides those methods required by the MARSTextEditingArea interface
that are not defined by JEditTextArea.
JEditBasedTextArea(EditPane, JComponent) –
Constructor for class mars.venus.editors.jeditsyntax.JEditBasedTextArea
JEditTextArea – Class in mars.venus.editors.jeditsyntax
jEdit’s text area component.
JEditTextArea(JComponent) –
Constructor for class mars.venus.editors.jeditsyntax.JEditTextArea
Creates a new JEditTextArea with the default settings.
JEditTextArea(TextAreaDefaults, JComponent) –
Constructor for class mars.venus.editors.jeditsyntax.JEditTextArea
job –
Variable in class mars.venus.HardcopyWriter
jobname –
Variable in class mars.venus.HardcopyWriter
K
KDATA –
Static variable in class mars.assembler.Directives
kernelBaseAddress –
Static variable in class mars.mips.hardware.Memory
kernel boundary.
kernelDataBaseAddress –
Static variable in class mars.mips.hardware.Memory
base address for kernel data segment: 0x90000000
kernelDataSegmentLimitAddress –
Static variable in class mars.mips.hardware.Memory
kernelHighAddress –
Static variable in class mars.mips.hardware.Memory
highest address acessible in kernel mode.
kernelTextBaseAddress –
Static variable in class mars.mips.hardware.Memory
base address for kernel text segment: 0x80000000
kernelTextLimitAddress –
Static variable in class mars.mips.hardware.Memory
KeyboardAndDisplaySimulator – Class in mars.tools
Keyboard and Display Simulator.
KeyboardAndDisplaySimulator(String, String) –
Constructor for class mars.tools.KeyboardAndDisplaySimulator
Simple constructor, likely used to run a stand-alone keyboard/display simulator.
KeyboardAndDisplaySimulator() –
Constructor for class mars.tools.KeyboardAndDisplaySimulator
Simple constructor, likely used by the MARS Tools menu mechanism
keyPressed(KeyEvent) –
Method in class mars.tools.AbstractMarsToolAndApplication.EnterKeyListener
keyPressed(KeyEvent) –
Method in class mars.venus.editors.jeditsyntax.DefaultInputHandler
Handle a key pressed event.
keyTyped(KeyEvent) –
Method in class mars.venus.editors.jeditsyntax.DefaultInputHandler
Handle a key typed event.
KEYWORD1 –
Static variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
Keyword 1 token id.
KEYWORD2 –
Static variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
Keyword 2 token id.
KEYWORD3 –
Static variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
Keyword 3 token id.
KeywordMap – Class in mars.venus.editors.jeditsyntax
A KeywordMap is similar to a hashtable in that it maps keys
to values.
KeywordMap(boolean) –
Constructor for class mars.venus.editors.jeditsyntax.KeywordMap
Creates a new KeywordMap.
KeywordMap(boolean, int) –
Constructor for class mars.venus.editors.jeditsyntax.KeywordMap
Creates a new KeywordMap.
KTEXT –
Static variable in class mars.assembler.Directives
L
LABEL –
Static variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
Label token id.
LABEL_SORT_STATE –
Static variable in class mars.Settings
State for sorting label window display
LABEL_WINDOW_VISIBILITY –
Static variable in class mars.Settings
Default visibilty of label window (symbol table).
LabelsWindow – Class in mars.venus
Represents the Labels window, which is a type of JInternalFrame.
LabelsWindow() –
Constructor for class mars.venus.LabelsWindow
Constructor for the Labels (symbol table) window.
lastAddress –
Variable in class mars.tools.InstructionCounter
The last address we saw.
lastAddress –
Variable in class mars.tools.InstructionStatistics
The last address we saw.
lastLine –
Variable in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
The last tokenized line.
lastToken –
Variable in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
The last token in the list.
LEFT_OF_SCROLLBAR –
Static variable in class mars.venus.editors.jeditsyntax.JEditTextArea
Adding components with this name to the text area will place
them left of the horizontal scroll bar.
LEFT_PAREN –
Static variable in class mars.assembler.TokenTypes
length –
Variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
The length of this token.
length –
Variable in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
The number of lines in the model being tokenized.
LINE_PREFIX –
Static variable in class mars.ErrorList
lineascent –
Variable in class mars.venus.HardcopyWriter
lineheight –
Variable in class mars.venus.HardcopyWriter
lineHighlight –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
lineHighlight –
Variable in class mars.venus.editors.jeditsyntax.TextAreaPainter
lineHighlightColor –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
lineHighlightColor –
Variable in class mars.venus.editors.jeditsyntax.TextAreaPainter
lineInfo –
Variable in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
An array for storing information about lines.
linenum –
Variable in class mars.venus.HardcopyWriter
lines_per_page –
Variable in class mars.venus.HardcopyWriter
lineSegment –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
lineToY(int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Converts a line index to a y co-ordinate.
listenerList –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
LITERAL1 –
Static variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
Literal 1 token id.
LITERAL2 –
Static variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
Literal 2 token id.
LITTLE_ENDIAN –
Static variable in class mars.mips.hardware.Memory
Constant representing byte order of each memory word.
loadDumpFormats() –
Method in class mars.mips.dump.DumpFormatLoader
Dynamically loads dump formats into an ArrayList.
loadPropertiesFromFile(String) –
Static method in class mars.util.PropertiesFile
Produce Properties (a Hashtable) object containing key-value pairs
from specified properties file.
longToBinaryString(long, int) –
Static method in class mars.util.Binary
Translate long value into a String consisting of ‘1’s and ‘0’s.
longToBinaryString(long) –
Static method in class mars.util.Binary
Translate long value into a String consisting of ‘1’s and ‘0’s.
longToHexString(long) –
Static method in class mars.util.Binary
Prefix a hexadecimal-indicating string “0x” to the string equivalent to the
hexadecimal value in the long parameter.
lookup(Segment, int, int) –
Method in class mars.venus.editors.jeditsyntax.KeywordMap
Looks up a key.
LOW_DOUBLE_VALUE –
Static variable in class mars.assembler.DataTypes
Largest magnitude negative value that can be stored in a MIPS double(negative of the max)
LOW_FLOAT_VALUE –
Static variable in class mars.assembler.DataTypes
Largest magnitude negative value that can be stored in a MIPS float (negative of the max)
lowOrderLongToInt(long) –
Static method in class mars.util.Binary
Returns int representing the bit values of the low order 32 bits of given
64 bit long value.
M
MACRO –
Static variable in class mars.assembler.Directives
Macro – Class in mars.assembler
Stores information of a macro definition.
Macro() –
Constructor for class mars.assembler.Macro
MACRO_ARG –
Static variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
Macro parameter token.
MACRO_PARAMETER –
Static variable in class mars.assembler.TokenTypes
MacroPool – Class in mars.assembler
Stores information of macros defined by now.
MacroPool(MIPSprogram) –
Constructor for class mars.assembler.MacroPool
Create an empty MacroPool for given program
magicCaret –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
main(String[]) –
Static method in class Mars
main(String[]) –
Static method in class mars.tools.BitmapDisplay
Main provided for pure stand-alone use.
main(String[]) –
Static method in class mars.tools.CacheSimulator
Main provided for pure stand-alone use.
main(String[]) –
Static method in class mars.tools.DigitalLabSim
main(String[]) –
Static method in class mars.tools.FloatRepresentation
Main provided for pure stand-alone use.
main(String[]) –
Static method in class mars.tools.IntroToTools
Main provided for pure stand-alone use.
main(String[]) –
Static method in class mars.tools.KeyboardAndDisplaySimulator
Main provided for pure stand-alone use.
main(String[]) –
Static method in class mars.tools.MemoryReferenceVisualization
Main provided for pure stand-alone use.
main(String[]) –
Static method in class mars.tools.ScreenMagnifier
main(String[]) –
Static method in class mars.venus.HardcopyWriter
A program that prints the specified file using HardcopyWriter
main(String[]) –
Static method in class mars.venus.RepeatButton
Main method, for testing.
MainPane – Class in mars.venus
Creates the tabbed areas in the UI and also created the internal windows that
exist in them.
MainPane(VenusUI, Editor, RegistersWindow, Coprocessor1Window, Coprocessor0Window) –
Constructor for class mars.venus.MainPane
Constructor for the MainPane class.
mainUI –
Variable in class mars.venus.GuiAction
makeTemplateSubstitutions(MIPSprogram, String, TokenList) –
Static method in class mars.mips.instructions.ExtendedInstruction
Given a basic instruction template and the list of tokens from an extended
instruction statement, substitute operands from the token list appropriately into the
template to generate the basic statement.
mapLength –
Variable in class mars.venus.editors.jeditsyntax.KeywordMap
markTokens(Segment, int) –
Method in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
A wrapper for the lower-level markTokensImpl method
that is called to split a line up into tokens.
markTokensImpl(byte, Segment, int) –
Method in class mars.venus.editors.jeditsyntax.tokenmarker.MIPSTokenMarker
markTokensImpl(byte, Segment, int) –
Method in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
An abstract method that splits a line up into tokens.
mars – package mars
Mars – Class in
Portal to Mars
Mars() –
Constructor for class Mars
mars.assembler – package mars.assembler
mars.mips.dump – package mars.mips.dump
mars.mips.hardware – package mars.mips.hardware
mars.mips.instructions – package mars.mips.instructions
mars.mips.instructions.syscalls – package mars.mips.instructions.syscalls
mars.simulator – package mars.simulator
mars.tools – package mars.tools
mars.util – package mars.util
mars.venus – package mars.venus
mars.venus.editors – package mars.venus.editors
mars.venus.editors.generic – package mars.venus.editors.generic
mars.venus.editors.jeditsyntax – package mars.venus.editors.jeditsyntax
mars.venus.editors.jeditsyntax.tokenmarker – package mars.venus.editors.jeditsyntax.tokenmarker
MarsBot – Class in mars.tools
Simple Demo of Mars tool capability
MarsBot() –
Constructor for class mars.tools.MarsBot
MarsLaunch – Class in mars
Launch the Mars application
MarsLaunch(String[]) –
Constructor for class mars.MarsLaunch
MarsSplashScreen – Class in mars
Produces MARS splash screen.
Adapted from http://www.java-tips.org/content/view/1267/2/
MarsSplashScreen(int) –
Constructor for class mars.MarsSplashScreen
MARSTextEditingArea – Interface in mars.venus.editors
Specifies capabilities that any test editor used in MARS must have.
MarsTool – Interface in mars.tools
Interface for any tool that interacts with an executing MIPS program.
MATCH_ALL_EXTENSIONS –
Static variable in class mars.util.FilenameFinder
matchDirective(String) –
Static method in class mars.assembler.Directives
Find Directive object, if any, which matches the given String.
matchesAnyMacroName(String) –
Method in class mars.assembler.MacroPool
matchOperator(String) –
Method in class mars.mips.instructions.InstructionSet
Given an operator mnemonic, will return the corresponding Instruction object(s)
from the instruction set.
matchTokenType(String) –
Static method in class mars.assembler.TokenTypes
Classifies the given token into one of the MIPS types.
MAX_BLINK_RATE –
Static variable in class mars.venus.Editor
MAX_BYTE_VALUE –
Static variable in class mars.assembler.DataTypes
Maximum value that can be stored in a MIPS byte is 27-1
MAX_DOUBLE_VALUE –
Static variable in class mars.assembler.DataTypes
Maximum positive finite value that can be stored in a MIPS double is same as Java Double
MAX_FLOAT_VALUE –
Static variable in class mars.assembler.DataTypes
Maximum positive finite value that can be stored in a MIPS float is same as Java Float
MAX_HALF_VALUE –
Static variable in class mars.assembler.DataTypes
Maximum value that can be stored in a MIPS halfword is 215-1
MAX_SIZE –
Static variable in class mars.util.EditorFont
MAX_STEPS –
Static variable in class mars.simulator.Simulator
MAX_TAB_SIZE –
Static variable in class mars.venus.Editor
MAX_UHALF_VALUE –
Static variable in class mars.assembler.DataTypes
Maximum value that can be stored in an unsigned MIPS halfword is 216-1
MAX_WORD_VALUE –
Static variable in class mars.assembler.DataTypes
Maximum value that can be stored in a MIPS word is 231-1
maxExampleLength(ArrayList) –
Static method in class mars.venus.editors.jeditsyntax.PopupHelpItem
MAXIMUM_SCROLLED_CHARACTERS –
Static variable in class mars.venus.MessagesPane
maximumBacksteps –
Static variable in class mars.Globals
Maximum number of back-step operations to buffer
maximumErrorMessages –
Static variable in class mars.Globals
Maximum number of assembler errors produced by one assemble operation
maximumMessageCharacters –
Static variable in class mars.Globals
Maximum length of scrolled message window (MARS Messages and Run I/O)
maxSteps –
Static variable in class mars.venus.RunGoAction
memory –
Static variable in class mars.Globals
Simulated MIPS memory component.
Memory – Class in mars.mips.hardware
Represents MIPS memory.
MEMORY_CONFIGURATION –
Static variable in class mars.Settings
Identifier of current memory configuration
MemoryAccessNotice – Class in mars.mips.hardware
Object provided to Observers of runtime access to MIPS memory.
MemoryAccessNotice(int, int, int) –
Constructor for class mars.mips.hardware.MemoryAccessNotice
Constructor will be called only within this package, so assume
address is in valid range.
memoryAndRegistersLock –
Static variable in class mars.Globals
Lock variable used at head of synchronized block to guard MIPS memory and registers
MemoryConfiguration – Class in mars.mips.hardware
Models the memory configuration for the simulated MIPS machine.
MemoryConfiguration(String, String, String[], int[]) –
Constructor for class mars.mips.hardware.MemoryConfiguration
MemoryConfigurations – Class in mars.mips.hardware
Models the collection of MIPS memory configurations.
MemoryConfigurations() –
Constructor for class mars.mips.hardware.MemoryConfigurations
MemoryDump – Class in mars.util
MemoryDump() –
Constructor for class mars.util.MemoryDump
memoryMapBaseAddress –
Static variable in class mars.mips.hardware.Memory
starting address for memory mapped I/O: 0xffff0000 (-65536)
memoryMapLimitAddress –
Static variable in class mars.mips.hardware.Memory
MemoryReferenceVisualization – Class in mars.tools
Memory reference visualization.
MemoryReferenceVisualization(String, String) –
Constructor for class mars.tools.MemoryReferenceVisualization
Simple constructor, likely used to run a stand-alone memory reference visualizer.
MemoryReferenceVisualization() –
Constructor for class mars.tools.MemoryReferenceVisualization
Simple constructor, likely used by the MARS Tools menu mechanism
menu –
Variable in class mars.venus.VenusUI
MESSAGE_SEPARATOR –
Static variable in class mars.ErrorList
MessagesPane – Class in mars.venus
Creates the message window at the bottom of the UI.
MessagesPane() –
Constructor for class mars.venus.MessagesPane
Constructor for the class, sets up two fresh tabbed text areas for program feedback.
metrics –
Variable in class mars.venus.HardcopyWriter
MIFDumpFormat – Class in mars.mips.dump
The Memory Initialization File (.mif) VHDL-supported file format
This is documented for the Altera platform at
www.altera.com/support/software/nativelink/quartus2/glossary/def_mif.html.
MIFDumpFormat() –
Constructor for class mars.mips.dump.MIFDumpFormat
Constructor.
MIN_BLINK_RATE –
Static variable in class mars.venus.Editor
MIN_BYTE_VALUE –
Static variable in class mars.assembler.DataTypes
Lowest value that can be stored in a MIPS byte is -27
MIN_HALF_VALUE –
Static variable in class mars.assembler.DataTypes
Lowest value that can be stored in a MIPS halfword is -215
MIN_SIZE –
Static variable in class mars.util.EditorFont
MIN_TAB_SIZE –
Static variable in class mars.venus.Editor
MIN_UHALF_VALUE –
Static variable in class mars.assembler.DataTypes
Lowest value that can be stored in na unsigned MIPS halfword is 0
MIN_WORD_VALUE –
Static variable in class mars.assembler.DataTypes
Lowest value that can be stored in a MIPS word is -231
MINUS –
Static variable in class mars.assembler.TokenTypes
MIPSprogram – Class in mars
Internal representations of MIPS program.
MIPSprogram() –
Constructor for class mars.MIPSprogram
MIPSTokenMarker – Class in mars.venus.editors.jeditsyntax.tokenmarker
MIPS token marker.
MIPSTokenMarker() –
Constructor for class mars.venus.editors.jeditsyntax.tokenmarker.MIPSTokenMarker
MIPSTokenMarker(KeywordMap) –
Constructor for class mars.venus.editors.jeditsyntax.tokenmarker.MIPSTokenMarker
mnemonic –
Variable in class mars.mips.instructions.Instruction
The instruction name.
modifyDisplay(char) –
Method in class mars.tools.DigitalLabSim.SevenSegmentDisplay
modifyDisplay(int, char) –
Method in class mars.tools.DigitalLabSim.SevenSegmentPanel
mouseClicked(MouseEvent) –
Method in class mars.tools.DigitalLabSim.HexaKeyboard.EcouteurClick
mouseClicked(MouseEvent) –
Method in class mars.venus.RepeatButton
Handle mouse clicked events.
mouseEntered(MouseEvent) –
Method in class mars.tools.DigitalLabSim.HexaKeyboard.EcouteurClick
mouseEntered(MouseEvent) –
Method in class mars.venus.RepeatButton
Handle mouse entered events.
mouseExited(MouseEvent) –
Method in class mars.tools.DigitalLabSim.HexaKeyboard.EcouteurClick
mouseExited(MouseEvent) –
Method in class mars.venus.RepeatButton
Handle mouse exited events.
mousePressed(MouseEvent) –
Method in class mars.tools.DigitalLabSim.HexaKeyboard.EcouteurClick
mousePressed(MouseEvent) –
Method in class mars.venus.PopupListener
mousePressed(MouseEvent) –
Method in class mars.venus.RepeatButton
Handle mouse pressed events.
mouseReleased(MouseEvent) –
Method in class mars.tools.DigitalLabSim.HexaKeyboard.EcouteurClick
mouseReleased(MouseEvent) –
Method in class mars.venus.PopupListener
mouseReleased(MouseEvent) –
Method in class mars.venus.RepeatButton
Handle mouse released events.
N
NEW_EDITED –
Static variable in class mars.venus.FileStatus
New edit window with unsaved edits
NEW_NOT_EDITED –
Static variable in class mars.venus.FileStatus
New edit window with no edits
newFile() –
Method in class mars.venus.Editor
Perform “new” operation to create an empty tab.
newFile() –
Method in class mars.venus.EditTabbedPane
Carries out all necessary operations to implement
the New operation from the File menu.
newline() –
Method in class mars.venus.HardcopyWriter
This internal method begins a new line
newpage() –
Method in class mars.venus.HardcopyWriter
This internal method begins a new page and prints the header.
next –
Variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
The next token in the linked list.
NEXT_CHAR –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
NEXT_LINE –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
NEXT_PAGE –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
NEXT_WORD –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
nextIndex(String, String, int, boolean) –
Method in class mars.venus.editors.generic.GenericTextArea
Returns next posn of word in text – forward search.
nextIndex(String, String, int, boolean) –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
Returns next posn of word in text – forward search.
nextLineRequested –
Variable in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
True if the next line should be painted.
nextTabStop(float, int) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Implementation of TabExpander interface.
NO_DEVICE –
Static variable in class mars.simulator.Simulator
NO_FILE –
Static variable in class mars.venus.FileStatus
initial state or after close
NORMAL_TERMINATION –
Static variable in class mars.simulator.Simulator
NOT_EDITED –
Static variable in class mars.venus.FileStatus
open/saved edit window with no edits
NOT_FOUND –
Static variable in class mars.assembler.SymbolTable
notifyObservers() –
Method in class mars.mips.hardware.Memory
Overridden to be unavailable.
notifyObservers(Object) –
Method in class mars.mips.hardware.Memory
Overridden to be unavailable.
NULL –
Static variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
Normal text token id.
NUMBER_OF_CHARACTERS_TO_CUT –
Static variable in class mars.venus.MessagesPane
numberDisplayBaseChanged(NumberDisplayBaseChooser) –
Method in class mars.venus.ExecutePane
Update display of columns based on state of given chooser.
NumberDisplayBaseChooser – Class in mars.venus
Use to select base for displaying numbers.
NumberDisplayBaseChooser(String, boolean) –
Constructor for class mars.venus.NumberDisplayBaseChooser
constructor.
O
obj –
Variable in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker.LineInfo
This is for use by the token marker implementations
themselves.
ODD_ROW_BACKGROUND –
Static variable in class mars.Settings
RGB color for table odd row background (text, data, register displays)
ODD_ROW_FONT –
Static variable in class mars.Settings
Font for table odd row background (text, data, register displays)
ODD_ROW_FOREGROUND –
Static variable in class mars.Settings
RGB color for table odd row foreground (text, data, register displays)
offsetToX(int, int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Converts an offset in a line into an x co-ordinate.
open() –
Method in class mars.venus.Editor
Open file in a new tab.
openFile(String, int) –
Static method in class mars.util.SystemIO
Open a file for either reading or writing.
openFile() –
Method in class mars.venus.EditTabbedPane
Carries out all necessary operations to implement
the Open operation from the File menu.
openFile(File) –
Method in class mars.venus.EditTabbedPane
Carries out all necessary operations to open the
specified file in the editor.
OPENING –
Static variable in class mars.venus.FileStatus
file is being opened.
OperandFormat – Class in mars.assembler
Provides utility method related to MIPS operand formats.
operandMask –
Static variable in class mars.mips.instructions.Instruction
Characters used in instruction mask to indicate bit positions
for ‘f’irst, ‘s’econd, and ‘t’hird operands.
OPERATOR –
Static variable in class mars.assembler.TokenTypes
OPERATOR –
Static variable in class mars.venus.editors.jeditsyntax.tokenmarker.Token
Operator token id.
outOfRange(Directives, int) –
Static method in class mars.assembler.DataTypes
Determines whether given integer value falls within value range for given directive.
outOfRange(Directives, double) –
Static method in class mars.assembler.DataTypes
Determines whether given floating point value falls within value range for given directive.
OVERWRITE –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
overwrite –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
overwriteSetSelectedText(String) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Similar to setSelectedText(), but overstrikes the
appropriate number of characters if overwrite mode is enabled.
P
page –
Variable in class mars.venus.HardcopyWriter
pageBreak() –
Method in class mars.venus.HardcopyWriter
End the current page.
pagedpi –
Variable in class mars.venus.HardcopyWriter
pagenum –
Variable in class mars.venus.HardcopyWriter
pagesize –
Variable in class mars.venus.HardcopyWriter
paint(Graphics) –
Method in class mars.tools.DigitalLabSim.SevenSegmentDisplay
paint(Graphics) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Repaints the text.
paintBracketHighlight(Graphics, int, int) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
paintCaret(Graphics, int, int) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
painter –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
paintHighlight(Graphics, int, int) –
Method in interface mars.venus.editors.jeditsyntax.TextAreaPainter.Highlight
This should paint the highlight and delgate to the
next highlight painter.
paintHighlight(Graphics, int, int) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
paintInvalid –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
paintInvalid –
Variable in class mars.venus.editors.jeditsyntax.TextAreaPainter
paintLine(Graphics, TokenMarker, int, int) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
paintLineHighlight(Graphics, int, int) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
paintPlainLine(Graphics, int, Font, Color, int, int) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
paintSyntaxLine(Segment, Token, SyntaxStyle[], TabExpander, Graphics, int, int) –
Static method in class mars.venus.editors.jeditsyntax.SyntaxUtilities
paintSyntaxLine(Graphics, TokenMarker, int, Font, Color, int, int) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
parseKeyStroke(String) –
Static method in class mars.venus.editors.jeditsyntax.DefaultInputHandler
Converts a string to a keystroke.
paste() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Inserts the clipboard contents into the text.
paste() –
Method in interface mars.venus.editors.MARSTextEditingArea
pasteText() –
Method in class mars.venus.EditPane
paste clipboard contents at cursor position
PAUSE_OR_STOP –
Static variable in class mars.simulator.Simulator
paused(boolean, int, ProcessingException) –
Method in class mars.venus.RunGoAction
Method to be called when Pause is selected through menu/toolbar/shortcut.
performApply() –
Method in class mars.venus.AbstractFontSettingDialog
performSpecialClosingDuties() –
Method in class mars.tools.AbstractMarsToolAndApplication
This method is called when tool/app is exited either through the close/exit button or the window’s X box.
PLUS –
Static variable in class mars.assembler.TokenTypes
popFromCallStack() –
Method in class mars.assembler.MacroPool
populate() –
Method in class mars.mips.instructions.InstructionSet
Adds all instructions to the set.
popup –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
popup –
Static variable in class mars.venus.editors.jeditsyntax.SyntaxUtilities
popup –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
POPUP_INSTRUCTION_GUIDANCE –
Static variable in class mars.Settings
Flag to control whether or not editor will provide popup instruction guidance while typing
POPUP_SYSCALL_INPUT –
Static variable in class mars.Settings
Flag to control whether or not simulator will use popup dialog for input syscalls
PopupHelpItem – Class in mars.venus.editors.jeditsyntax
Handly little class to contain help information for a popupMenu or
tool tip item.
PopupHelpItem(String, String, String, boolean) –
Constructor for class mars.venus.editors.jeditsyntax.PopupHelpItem
Create popup help item.
PopupHelpItem(String, String, String) –
Constructor for class mars.venus.editors.jeditsyntax.PopupHelpItem
Create popup help item, where match is result of an exact-match search.
PopupListener – Class in mars.venus
PopupListener(JPopupMenu) –
Constructor for class mars.venus.PopupListener
popupShowing –
Static variable in class mars.venus.editors.jeditsyntax.SyntaxUtilities
Paints the specified line onto the graphics context.
POSITION_PREFIX –
Static variable in class mars.ErrorList
postMarsMessage(String) –
Method in class mars.venus.MessagesPane
Post a message to the assembler display
postRunMessage(String) –
Method in class mars.venus.MessagesPane
Post a message to the runtime display
preferredTextAreaDimension –
Static variable in class mars.tools.KeyboardAndDisplaySimulator
prefixMatchDirectives(String) –
Static method in class mars.assembler.Directives
Find Directive object, if any, which contains the given string as a prefix.
prefixMatchOperator(String) –
Method in class mars.mips.instructions.InstructionSet
Given a string, will return the Instruction object(s) from the instruction
set whose operator mnemonic prefix matches it.
prepareFilesForAssembly(ArrayList, String, String) –
Method in class mars.MIPSprogram
Prepares the given list of files for assembly.
PREV_CHAR –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
PREV_LINE –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
PREV_PAGE –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
PREV_WORD –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
printprops –
Static variable in class mars.venus.HardcopyWriter
printString(String) –
Static method in class mars.util.SystemIO
Implements syscall having 4 in $v0, to print a string.
ProcessingException – Exception in mars
Class to represent error that occurs while assembling or running a MIPS program.
ProcessingException(ErrorList) –
Constructor for exception mars.ProcessingException
Constructor for ProcessingException.
ProcessingException(ErrorList, AddressErrorException) –
Constructor for exception mars.ProcessingException
Constructor for ProcessingException.
ProcessingException(ProgramStatement, String) –
Constructor for exception mars.ProcessingException
Constructor for ProcessingException to handle runtime exceptions
ProcessingException(ProgramStatement, String, int) –
Constructor for exception mars.ProcessingException
Constructor for ProcessingException to handle runtime exceptions
ProcessingException(ProgramStatement, AddressErrorException) –
Constructor for exception mars.ProcessingException
Constructor for ProcessingException to handle address runtime exceptions
ProcessingException() –
Constructor for exception mars.ProcessingException
Constructor for ProcessingException.
processKeyEvent(KeyEvent) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Forwards key events directly to the input handler.
processMIPSUpdate(Observable, AccessNotice) –
Method in class mars.tools.AbstractMarsToolAndApplication
Override this method to process a received notice from MIPS Observable (memory or register)
It will only be called if the notice was generated as the result of MIPS instruction execution.
processMIPSUpdate(Observable, AccessNotice) –
Method in class mars.tools.BHTSimulator
Callback for text segment access by the MIPS simulator.
processMIPSUpdate(Observable, AccessNotice) –
Method in class mars.tools.BitmapDisplay
Update display when connected MIPS program accesses (data) memory.
processMIPSUpdate(Observable, AccessNotice) –
Method in class mars.tools.CacheSimulator
Apply caching policies and update display when connected MIPS program accesses (data) memory.
processMIPSUpdate(Observable, AccessNotice) –
Method in class mars.tools.InstructionCounter
processMIPSUpdate(Observable, AccessNotice) –
Method in class mars.tools.InstructionStatistics
method that is called each time the MIPS simulator accesses the text segment.
processMIPSUpdate(Observable, AccessNotice) –
Method in class mars.tools.KeyboardAndDisplaySimulator
Update display when connected MIPS program accesses (data) memory.
processMIPSUpdate(Observable, AccessNotice) –
Method in class mars.tools.MemoryReferenceVisualization
Update display when connected MIPS program accesses (data) memory.
program –
Static variable in class mars.Globals
the program currently being worked with.
PROGRAM_ARGUMENTS –
Static variable in class mars.Settings
Flag to determine whether or not to display and use program arguments
ProgramArgumentList – Class in mars.simulator
Models Program Arguments, one or more strings provided to the MIPS
program at runtime.
ProgramArgumentList(String) –
Constructor for class mars.simulator.ProgramArgumentList
Constructor that parses string to produce list.
ProgramArgumentList(String[]) –
Constructor for class mars.simulator.ProgramArgumentList
Constructor that gets list from String array, one argument per element.
ProgramArgumentList(String[], int) –
Constructor for class mars.simulator.ProgramArgumentList
Constructor that gets list from section of String array, one
argument per element.
ProgramArgumentList(ArrayList) –
Constructor for class mars.simulator.ProgramArgumentList
Constructor that gets list from ArrayList of String, one argument per element.
ProgramArgumentList(ArrayList, int) –
Constructor for class mars.simulator.ProgramArgumentList
Constructor that gets list from section of String ArrayList, one
argument per element.
ProgramStatement – Class in mars
Represents one assembly/machine statement.
ProgramStatement(MIPSprogram, String, TokenList, TokenList, Instruction, int, int) –
Constructor for class mars.ProgramStatement
Constructor for ProgramStatement when there are links back to all source and token
information.
ProgramStatement(int, int) –
Constructor for class mars.ProgramStatement
Constructor for ProgramStatement used only for writing a binary machine
instruction with no source code to refer back to.
PropertiesFile – Class in mars.util
Provides means to work with “.properties” files which are used to store
various MARS settings.
PropertiesFile() –
Constructor for class mars.util.PropertiesFile
pushOnCallStack(Token) –
Method in class mars.assembler.MacroPool
Q
QUOTED_STRING –
Static variable in class mars.assembler.TokenTypes
R
R_FORMAT –
Static variable in class mars.mips.instructions.BasicInstructionFormat
RandomStreams – Class in mars.mips.instructions.syscalls
This small class serves only to hold a static HashMap for storing
random number generators for use by all the random number generator
syscalls.
RandomStreams() –
Constructor for class mars.mips.instructions.syscalls.RandomStreams
READ –
Static variable in class mars.mips.hardware.AccessNotice
Indicates the purpose of access was to read.
readChar(int) –
Static method in class mars.util.SystemIO
Implements syscall having 12 in $v0, to read a char value.
readDouble(int) –
Static method in class mars.util.SystemIO
Implements syscall to read a double value.
readFloat(int) –
Static method in class mars.util.SystemIO
Implements syscall to read a float value.
readFromFile(int, byte[], int) –
Static method in class mars.util.SystemIO
Read bytes from file.
readInteger(int) –
Static method in class mars.util.SystemIO
Implements syscall to read an integer value.
readSource(String) –
Method in class mars.MIPSprogram
Reads MIPS source code from file into structure.
readString(int, int) –
Static method in class mars.util.SystemIO
Implements syscall to read a string.
readyForCommit() –
Method in class mars.assembler.Macro
Operations to be done on this macro before it is committed in macro pool.
REAL_NUMBER –
Static variable in class mars.assembler.TokenTypes
recalculateVisibleLines() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Recalculates the number of visible lines.
RECEIVER_CONTROL –
Static variable in class mars.tools.KeyboardAndDisplaySimulator
RECEIVER_DATA –
Static variable in class mars.tools.KeyboardAndDisplaySimulator
recorder –
Variable in class mars.venus.editors.jeditsyntax.InputHandler
rectSelect –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
redo() –
Method in class mars.venus.editors.generic.GenericTextArea
Redo previous edit
redo() –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
Redo previous edit
redo() –
Method in interface mars.venus.editors.MARSTextEditingArea
redo() –
Method in class mars.venus.EditPane
Redo previous edit
refresh() –
Method in class mars.venus.Coprocessor0Window
Refresh the table, triggering re-rendering.
refresh() –
Method in class mars.venus.Coprocessor1Window
Refresh the table, triggering re-rendering.
refresh() –
Method in class mars.venus.RegistersWindow
Refresh the table, triggering re-rendering.
regionMatches(boolean, Segment, int, String) –
Static method in class mars.venus.editors.jeditsyntax.SyntaxUtilities
Checks if a subregion of a Segment is equal to a
string.
regionMatches(boolean, Segment, int, char[]) –
Static method in class mars.venus.editors.jeditsyntax.SyntaxUtilities
Checks if a subregion of a Segment is equal to a
character array.
Register – Class in mars.mips.hardware
Abstraction to represent a register of a MIPS Assembler.
Register(String, int, int) –
Constructor for class mars.mips.hardware.Register
Creates a new register with specified name, number, and value.
register(int) –
Static method in class mars.simulator.DelayedBranch
Register the fact that a successful branch is to occur.
REGISTER_HIGHLIGHT_BACKGROUND –
Static variable in class mars.Settings
RGB color for register highlighted background
REGISTER_HIGHLIGHT_FONT –
Static variable in class mars.Settings
Font for register highlighted background
REGISTER_HIGHLIGHT_FOREGROUND –
Static variable in class mars.Settings
RGB color for register highlighted foreground
REGISTER_NAME –
Static variable in class mars.assembler.TokenTypes
note: REGISTER_NAME is token of form $zero whereas REGISTER_NUMBER is token
of form $0.
REGISTER_NUMBER –
Static variable in class mars.assembler.TokenTypes
RegisterAccessNotice – Class in mars.mips.hardware
Object provided to Observers of runtime access to MIPS register.
RegisterFile – Class in mars.mips.hardware
Represents the collection of MIPS registers.
RegisterFile() –
Constructor for class mars.mips.hardware.RegisterFile
REGISTERS_HIGHLIGHTING –
Static variable in class mars.Settings
Flag to control whether or not highlighting is applied to register windows
RegistersPane – Class in mars.venus
Contains tabbed areas in the UI to display register contents
RegistersPane(VenusUI, RegistersWindow, Coprocessor1Window, Coprocessor0Window) –
Constructor for class mars.venus.RegistersPane
Constructor for the RegistersPane class.
RegistersWindow – Class in mars.venus
Sets up a window to display registers in the UI.
RegistersWindow() –
Constructor for class mars.venus.RegistersWindow
Constructor which sets up a fresh window with a table that contains the register values.
registerTableModelListener(TableModelListener) –
Method in class mars.venus.TextSegmentWindow
Assign listener to Table model.
remove(int) –
Method in class mars.assembler.TokenList
Removes Token object at specified list position.
remove(EditPane) –
Method in class mars.venus.EditTabbedPane
Remove the pane and update menu status
removeAllKeyBindings() –
Method in class mars.venus.editors.jeditsyntax.DefaultInputHandler
Removes all key bindings from this input handler.
removeAllKeyBindings() –
Method in class mars.venus.editors.jeditsyntax.InputHandler
Removes all key bindings from this input handler.
removeCaretListener(CaretListener) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Removes a caret change listener from this text area.
removeKeyBinding(String) –
Method in class mars.venus.editors.jeditsyntax.DefaultInputHandler
Removes a key binding from this input handler.
removeKeyBinding(String) –
Method in class mars.venus.editors.jeditsyntax.InputHandler
Removes a key binding from this input handler.
removeNotify() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Called by the AWT when this component is removed from it’s parent.
removeProgramArgumentsPanel() –
Method in class mars.venus.TextSegmentWindow
removeStopListener(Simulator.StopListener) –
Method in class mars.simulator.Simulator
removeSymbol(Token) –
Method in class mars.assembler.SymbolTable
Removes a symbol from the Symbol table.
REPEAT –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
repeat –
Variable in class mars.venus.editors.jeditsyntax.InputHandler
RepeatButton – Class in mars.venus
RepeatButton is a JButton which contains a timer
for firing events while the button is held down.
RepeatButton() –
Constructor for class mars.venus.RepeatButton
Creates a button with no set text or icon.
RepeatButton(Action) –
Constructor for class mars.venus.RepeatButton
Creates a button where properties are taken from the Action supplied.
RepeatButton(Icon) –
Constructor for class mars.venus.RepeatButton
Creates a button with an icon.
RepeatButton(String) –
Constructor for class mars.venus.RepeatButton
Creates a button with text.
RepeatButton(String, Icon) –
Constructor for class mars.venus.RepeatButton
Creates a button with initial text and an icon.
repeatCount –
Variable in class mars.venus.editors.jeditsyntax.InputHandler
replaceSelection(String) –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
Same as setSelectedText but named for compatibility with
JTextComponent method replaceSelection.
replaceSelection(String) –
Method in interface mars.venus.editors.MARSTextEditingArea
requestFocusInWindow() –
Method in interface mars.venus.editors.MARSTextEditingArea
RESERVED_INSTRUCTION_EXCEPTION –
Static variable in class mars.simulator.Exceptions
reset(boolean) –
Method in class mars.Settings
Reset settings to default values, as described in the constructor comments.
reset() –
Method in class mars.tools.AbstractMarsToolAndApplication
Method that will be called each time the default Reset button is clicked.
reset() –
Method in class mars.tools.BHTSimulator
Performs a reset of the simulator.
reset() –
Method in class mars.tools.BitmapDisplay
Method to reset counters and display when the Reset button selected.
reset() –
Method in class mars.tools.CacheSimulator
Method to reset cache, counters and display when the Reset button selected.
reset() –
Method in class mars.tools.DigitalLabSim
reset() –
Method in class mars.tools.FloatRepresentation
Method to reset display values to 0 when the Reset button selected.
reset() –
Method in class mars.tools.InstructionCounter
reset() –
Method in class mars.tools.InstructionStatistics
resets the counter values of the tool and updates the display.
reset() –
Method in class mars.tools.KeyboardAndDisplaySimulator
Method to reset counters and display when the Reset button selected.
reset() –
Method in class mars.tools.MemoryReferenceVisualization
Method to reset counters and display when the Reset button selected.
reset() –
Method in class mars.venus.AbstractFontSettingDialog
reset() –
Static method in class mars.venus.FileStatus
Resets all the values in FileStatus
RESET_TOOL_TIP_TEXT –
Static variable in class mars.venus.SettingsHighlightingAction
resetFiles() –
Static method in class mars.util.SystemIO
Reset all files — clears out the file descriptor table.
resetHexaKeyboard() –
Method in class mars.tools.DigitalLabSim.HexaKeyboard
resetMaxSteps() –
Static method in class mars.venus.RunGoAction
Reset max steps limit to default value at termination of a simulated execution.
resetMemoryRange() –
Method in class mars.venus.DataSegmentWindow
Reset range of memory addresses to base address of currently selected segment and update display.
resetOneSecondCounter() –
Method in class mars.tools.DigitalLabSim.OneSecondCounter
resetRegisters() –
Static method in class mars.mips.hardware.Coprocessor0
Method to reinitialize the values of the registers.
resetRegisters() –
Static method in class mars.mips.hardware.Coprocessor1
Method to reinitialize the values of the registers.
resetRegisters() –
Static method in class mars.mips.hardware.RegisterFile
Method to reinitialize the values of the registers.
resetSevenSegment() –
Method in class mars.tools.DigitalLabSim.SevenSegmentPanel
resetSimulator() –
Method in class mars.tools.BHTSimulator
Resets the simulator by clearing the GUI elements and resetting the BHT.
resetValue() –
Method in class mars.mips.hardware.Register
Resets the value of the register to the value it was constructed with.
resetValues() –
Method in class mars.venus.DataSegmentWindow
Reset all data display values to 0
revalidate() –
Method in interface mars.venus.editors.MARSTextEditingArea
RIGHT –
Static variable in class mars.venus.editors.jeditsyntax.JEditTextArea
RIGHT_PAREN –
Static variable in class mars.assembler.TokenTypes
rows –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
rows –
Variable in class mars.venus.editors.jeditsyntax.TextAreaPainter
RunAssembleAction – Class in mars.venus
Action class for the Run -> Assemble menu item (and toolbar icon)
RunAssembleAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.RunAssembleAction
RunBackstepAction – Class in mars.venus
Action for the Run -> Backstep menu item
RunBackstepAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.RunBackstepAction
RunClearBreakpointsAction – Class in mars.venus
Action class for the Run menu item to clear execution breakpoints that have been set.
RunClearBreakpointsAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.RunClearBreakpointsAction
Create the object and register with text segment window as a listener on its table model.
RunGoAction – Class in mars.venus
Action class for the Run -> Go menu item (and toolbar icon)
RunGoAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.RunGoAction
RUNNABLE –
Static variable in class mars.venus.FileStatus
successful assembly
RUNNING –
Static variable in class mars.venus.FileStatus
execution is under way
RunPauseAction – Class in mars.venus
Action class for the Run -> Pause menu item (and toolbar icon)
RunPauseAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.RunPauseAction
RunResetAction – Class in mars.venus
Action for the Run -> Reset menu item
RunResetAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.RunResetAction
RunSpeedPanel – Class in mars.venus
Class for the Run speed slider control.
runSpeedPanelExists –
Static variable in class mars.Globals
RunStepAction – Class in mars.venus
Action for the Run -> Step menu item
RunStepAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.RunStepAction
RunStopAction – Class in mars.venus
Action class for the Run -> Stop menu item (and toolbar icon)
RunStopAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.RunStopAction
RunToggleBreakpointsAction – Class in mars.venus
Action class for the Run menu item to clear execution breakpoints that have been set.
RunToggleBreakpointsAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.RunToggleBreakpointsAction
Create the object and register with text segment window as a listener on its table model.
S
save() –
Method in class mars.venus.Editor
Perform “save” operation on current tab’s file.
saveAll() –
Method in class mars.venus.Editor
Perform save operation on all open files (tabs).
saveAllFiles() –
Method in class mars.venus.EditTabbedPane
Saves all files currently open in the editor.
saveAs() –
Method in class mars.venus.Editor
Perform “save as” operation on current tab’s file.
saveAsCurrentFile() –
Method in class mars.venus.EditTabbedPane
Pops up a dialog box to do “Save As” operation.
saveCurrentFile() –
Method in class mars.venus.EditTabbedPane
Saves file under existing name.
ScavengerHunt – Class in mars.tools
Demo of Mars tool capability.
ScavengerHunt() –
Constructor for class mars.tools.ScavengerHunt
ScreenMagnifier – Class in mars.tools
Handy little tool to magnify a selected section of the screen
by a given scale and display it.
ScreenMagnifier() –
Constructor for class mars.tools.ScreenMagnifier
scrollBarsInitialized –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
scrollTo(int, int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Ensures that the specified line and offset is visible by scrolling
the text area if necessary.
scrollToCaret() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Ensures that the caret is visible by scrolling the text area if
necessary.
SegmentWindowDumpFormat – Class in mars.mips.dump
Dump MIPS memory contents in Segment Window format.
SegmentWindowDumpFormat() –
Constructor for class mars.mips.dump.SegmentWindowDumpFormat
Constructor.
select(int, int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Selects from the start offset to the end offset.
select(int, int) –
Method in interface mars.venus.editors.MARSTextEditingArea
SELECT_ALL –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
SELECT_DOC_END –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
SELECT_DOC_HOME –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
SELECT_END –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
SELECT_HOME –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
SELECT_NEXT_CHAR –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
SELECT_NEXT_LINE –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
SELECT_NEXT_PAGE –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
SELECT_NEXT_WORD –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
SELECT_PREV_CHAR –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
SELECT_PREV_LINE –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
SELECT_PREV_PAGE –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
SELECT_PREV_WORD –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
selectAll() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Selects all text in the document.
selectAll() –
Method in interface mars.venus.editors.MARSTextEditingArea
selectAllText() –
Method in class mars.venus.EditPane
select all text
selectEditorTextLine(String, int, int) –
Method in class mars.venus.MessagesPane
Will select the specified line in an editor tab.
selectErrorMessage(String, int, int) –
Method in class mars.venus.MessagesPane
Will select the Mars Messages tab error message that matches the given
specifications, if it is found.
selectionColor –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
selectionColor –
Variable in class mars.venus.editors.jeditsyntax.TextAreaPainter
selectionEnd –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
selectionEndLine –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
selectionStart –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
selectionStartLine –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
selectLine(int) –
Method in class mars.venus.EditPane
Select the specified editor text line.
selectLine(int, int) –
Method in class mars.venus.EditPane
Select the specified editor text line.
selectMarsMessageTab() –
Method in class mars.venus.MessagesPane
Make the assembler message tab current (up front)
selectNone() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Moves the mark to the caret position.
selectRunMessageTab() –
Method in class mars.venus.MessagesPane
Make the runtime message tab current (up front)
SELF_MODIFYING_CODE_ENABLED –
Static variable in class mars.Settings
Flag to determine whether a program can write binary code to the text or data segment and
execute that code.
SET –
Static variable in class mars.assembler.Directives
set(int, Token) –
Method in class mars.assembler.TokenList
Replaces token at position with different one.
set(int, int, int) –
Method in class mars.mips.hardware.Memory
Starting at the given address, write the given value over the given number of bytes.
set(int) –
Static method in class mars.venus.FileStatus
Set file status.
setAddress(int) –
Method in class mars.assembler.Symbol
Sets (replaces) the address of the the Symbol.
setArgs(ArrayList
Method in class mars.assembler.Macro
setAssembleAllEnabled(boolean) –
Method in class mars.Settings
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.ASSEMBLE_ALL_ENABLED)
setAssembled(boolean) –
Static method in class mars.venus.FileStatus
Changes the value of assenbked to the parameter given.
setAssembleOnOpenEnabled(boolean) –
Method in class mars.Settings
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.ASSEMBLE_ON_OPEN_ENABLED)
setBackground(Color) –
Method in interface mars.venus.editors.MARSTextEditingArea
setBase(int) –
Method in class mars.venus.NumberDisplayBaseChooser
Set the current number base.
setBasicAssemblyStatement(String) –
Method in class mars.ProgramStatement
Assigns given String to be Basic Assembly statement equivalent to this source line.
setBinaryStatement(int) –
Method in class mars.ProgramStatement
Assigns given int to be binary machine code equivalent to this source line.
setBit(int, int) –
Static method in class mars.util.Binary
Sets the specified bit of the specified value to 1, and returns the result.
setBlockCaretEnabled(boolean) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Sets if the caret should be drawn as a block, false otherwise.
setBooleanSetting(int, boolean) –
Method in class mars.Settings
Set value of a boolean setting given its id and the value.
setBooleanSettingNonPersistent(int, boolean) –
Method in class mars.Settings
Temporarily establish boolean setting.
setBracketHighlightColor(Color) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Sets the bracket highlight color.
setBracketHighlightEnabled(boolean) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Enables or disables bracket highlighting.
setByte(int, int) –
Method in class mars.mips.hardware.Memory
Writes low order 8 bits of given value into specified Memory byte.
setByte(int, int, int) –
Static method in class mars.util.Binary
Sets the specified byte of the specified value to the low order 8 bits of
specified replacement value, and returns the result.
setByteOrder(boolean) –
Method in class mars.mips.hardware.Memory
Set byte order to either LITTLE_ENDIAN or BIG_ENDIAN.
setCaretBlinkEnabled(boolean) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Toggles caret blinking.
setCaretBlinkRate(int) –
Method in class mars.Settings
Set the caret blinking rate in milliseconds.
setCaretBlinkRate(int) –
Method in class mars.venus.editors.generic.GenericTextArea
Set the caret blinking rate in milliseconds.
setCaretBlinkRate(int) –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
Set the caret blinking rate in milliseconds.
setCaretBlinkRate(int) –
Method in interface mars.venus.editors.MARSTextEditingArea
setCaretColor(Color) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Sets the caret color.
setCaretPosition(int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Sets the caret position.
setCaretPosition(int) –
Method in interface mars.venus.editors.MARSTextEditingArea
setCaretVisible(boolean) –
Method in class mars.venus.editors.generic.GenericTextArea
Control caret visibility
setCaretVisible(boolean) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Sets if the caret should be visible.
setCaretVisible(boolean) –
Method in interface mars.venus.editors.MARSTextEditingArea
setCodeHighlighting(boolean) –
Method in class mars.venus.TextSegmentWindow
Used to enable or disable source code highlighting.
setColorSettingByKey(String, Color) –
Method in class mars.Settings
Set Color object for specified settings key.
setColorSettingByPosition(int, Color) –
Method in class mars.Settings
Set Color object for specified settings name (a static constant).
setConditionFlag(int) –
Static method in class mars.mips.hardware.Coprocessor1
Set condition flag to 1 (true).
setConditionFlags() –
Static method in class mars.mips.hardware.Coprocessor1
Set all condition flags (0-7).
setConfiguration() –
Static method in class mars.mips.hardware.Memory
Sets current memory configuration for simulated MIPS.
setCurrent(Macro) –
Method in class mars.assembler.MacroPool
setCurrentConfiguration(MemoryConfiguration) –
Static method in class mars.mips.hardware.MemoryConfigurations
setCurrentEditTab(EditPane) –
Method in class mars.venus.EditTabbedPane
Select the specified EditPane to be the current tab.
setDataSegmentHighlighting(boolean) –
Method in class mars.Settings
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DATA_SEGMENT_HIGHLIGHTING)
setDelay(int) –
Method in class mars.venus.RepeatButton
Set the delay for the timer of this button.
setDelayedBranchingEnabled(boolean) –
Method in class mars.Settings
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DELAYED_BRANCHING_ENABLED)
setDelayedBranchingEnabledNonPersistent(boolean) –
Method in class mars.Settings
Deprecated. Use setBooleanSettingNonPersistent(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DELAYED_BRANCHING_ENABLED)
setDescription(String) –
Method in class mars.venus.editors.jeditsyntax.PopupHelpItem
setDisplayAddressesInHex(boolean) –
Method in class mars.Settings
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DISPLAY_ADDRESSES_IN_HEX)
setDisplayValuesInHex(boolean) –
Method in class mars.Settings
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DISPLAY_VALUES_IN_HEX)
setDocument(SyntaxDocument) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Sets the document this text area is editing.
setDouble(int, double) –
Method in class mars.mips.hardware.Memory
Writes 64 bit double value starting at specified Memory address.
setEditable(boolean) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Sets if this component is editable.
setEditable(boolean) –
Method in interface mars.venus.editors.MARSTextEditingArea
setEdited(boolean) –
Static method in class mars.venus.FileStatus
Changes the value of edited to the parameter given.
setEditorFont(Font) –
Method in class mars.Settings
Set editor font to the specified Font object and write it to persistent storage.
setEditorLineNumbersDisplayed(boolean) –
Method in class mars.Settings
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.EDITOR_LINE_NUMBERS_DISPLAYED)
setEditorPopupPrefixLength(int) –
Method in class mars.Settings
Set number of letters to be matched by editor’s instruction guide before popup generated (if popup enabled).
setEditorSyntaxStyleByPosition(int, SyntaxStyle) –
Method in class mars.Settings
setEditorTabSize(int) –
Method in class mars.Settings
Set the tab size in characters.
setEditTabbedPane(EditTabbedPane) –
Method in class mars.venus.Editor
Set associated EditTabbedPane.
setElectricScroll(int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Sets the number of lines from the top and bottom of the text
area that are always visible
setEnabled(boolean) –
Method in class mars.simulator.BackStepper
Set enable status.
setEnabled(boolean) –
Method in interface mars.venus.editors.MARSTextEditingArea
setEnabled(boolean) –
Method in class mars.venus.RepeatButton
Sets the enabled state of this button.
setEOLMarkerColor(Color) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Sets the EOL marker color.
setEOLMarkersPainted(boolean) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Sets if EOL markers are to be drawn.
setExample(String) –
Method in class mars.venus.editors.jeditsyntax.PopupHelpItem
setExceptionHandler(String) –
Method in class mars.Settings
Set name of exception handler file and write it to persistent storage.
setExceptionHandlerEnabled(boolean) –
Method in class mars.Settings
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.EXCEPTION_HANDLER_ENABLED)
setExtendedAssemblerEnabled(boolean) –
Method in class mars.Settings
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.EXTENDED_ASSEMBLER_ENABLED)
setFile(File) –
Static method in class mars.venus.FileStatus
Sets the file to the ASM file passed.
setFileStatus(int) –
Method in class mars.venus.EditPane
Set the editing status for this EditPane’s associated document.
setFileStatus(int) –
Method in class mars.venus.FileStatus
Set editing status of this file.
setFirstLine(int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Sets the line displayed at the text area’s origin and
updates the scroll bars.
setFont(Font) –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
setFont(Font) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Sets the font for this component.
setFont(Font) –
Method in interface mars.venus.editors.MARSTextEditingArea
setFontByPosition(int, Font) –
Method in class mars.Settings
Store a Font setting
setFontStyle(int) –
Method in class mars.venus.HardcopyWriter
Set the font style.
setFromLine(int) –
Method in class mars.assembler.Macro
setGraphicsFlags(Graphics, Font) –
Method in class mars.venus.editors.jeditsyntax.SyntaxStyle
Sets the foreground color and font of the specified graphics
context to that specified in this style.
setGui(VenusUI) –
Static method in class mars.Globals
setHalf(int, int) –
Method in class mars.mips.hardware.Memory
Starting at the given halfword address, write the lower 16 bits of given value
into 2 bytes (a halfword).
setHorizontalOffset(int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Sets the horizontal offset of drawn lines.
setIgnoreCase(boolean) –
Method in class mars.venus.editors.jeditsyntax.KeywordMap
Sets if the keyword map should be case insensitive.
setInitialDelay(int) –
Method in class mars.venus.RepeatButton
Sets the initial delay for the timer of this button.
setInputHandler(InputHandler) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Sets the input handler.
setInvalidLinesPainted(boolean) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Sets if invalid lines are to be painted as red tildes.
setLabelSortState(String) –
Method in class mars.Settings
Store the current state of the Labels Window sorter.
setLabelWindowVisibility(boolean) –
Method in class mars.Settings
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.LABEL_WINDOW_VISIBILITY)
setLabelWindowVisibility(boolean) –
Method in class mars.venus.ExecutePane
Show or hide the label window (symbol table).
setLineHighlightColor(Color) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Sets the line highlight color.
setLineHighlightEnabled(boolean) –
Method in class mars.venus.editors.generic.GenericTextArea
Does nothing, but required by the interface.
setLineHighlightEnabled(boolean) –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
Use for highlighting the line currently being edited.
setLineHighlightEnabled(boolean) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Enables or disables current line highlighting.
setLineHighlightEnabled(boolean) –
Method in interface mars.venus.editors.MARSTextEditingArea
setLocalMacroPool(MacroPool) –
Method in class mars.MIPSprogram
Sets local macro pool MacroPool for this program
setMachineStatement(String) –
Method in class mars.ProgramStatement
Assigns given String to be binary machine code (32 characters, all of them 0 or 1)
equivalent to this source line.
setMacroRecorder(InputHandler.MacroRecorder) –
Method in class mars.venus.editors.jeditsyntax.InputHandler
Sets the macro recorder.
setMagicCaretPosition(int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Sets the `magic’ caret position.
setMemoryConfiguration(String) –
Method in class mars.Settings
Store the identifier of the memory configuration.
setName(String) –
Method in class mars.assembler.Macro
setName(String) –
Static method in class mars.venus.FileStatus
Changes the value of name to the parameter given.
setNumber(int) –
Method in class mars.mips.instructions.syscalls.AbstractSyscall
Set the service number.
setNumber(int) –
Method in interface mars.mips.instructions.syscalls.Syscall
Set the service number.
setOrigin(int, int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
A fast way of changing both the first line and horizontal
offset.
setOriginal(MIPSprogram, int) –
Method in class mars.assembler.Token
Set original program and line number for this token.
setOriginalFromLine(int) –
Method in class mars.assembler.Macro
setOriginalToLine(int) –
Method in class mars.assembler.Macro
setOverwriteEnabled(boolean) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Sets if overwrite mode should be enabled.
setPathname(String) –
Method in class mars.venus.EditPane
Delegates to corresponding FileStatus method
setPathname(String) –
Method in class mars.venus.FileStatus
Set full file pathname.
setPathname(String, String) –
Method in class mars.venus.FileStatus
Set full file pathname.
setProcessedLine(String) –
Method in class mars.assembler.TokenList
Use this to record the source line String for this token list
after possible modification (textual substitution) during
assembly preprocessing.
setProgram(MIPSprogram) –
Method in class mars.assembler.Macro
setProgramArguments(boolean) –
Method in class mars.Settings
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.PROGRAM_ARGUMENTS)
setProgramCounter(int) –
Static method in class mars.mips.hardware.RegisterFile
For setting the Program Counter.
setRawWord(int, int) –
Method in class mars.mips.hardware.Memory
Starting at the given word address, write the given value over 4 bytes (a word).
setRegisterPairToDouble(int, double) –
Static method in class mars.mips.hardware.Coprocessor1
Sets the value of the FPU register given to the double value given.
setRegisterPairToDouble(String, double) –
Static method in class mars.mips.hardware.Coprocessor1
Sets the value of the FPU register given to the double value given.
setRegisterPairToLong(int, long) –
Static method in class mars.mips.hardware.Coprocessor1
Sets the value of the FPU register pair given to the long value containing 64 bit pattern
given.
setRegisterPairToLong(String, long) –
Static method in class mars.mips.hardware.Coprocessor1
Sets the value of the FPU register pair given to the long value containing 64 bit pattern
given.
setRegisters(int) –
Static method in class mars.simulator.Exceptions
Given MIPS exception cause code, will place that code into
coprocessor 0 CAUSE register ($13), set the EPC register to
“current” program counter, and set Exception Level bit in STATUS register.
setRegisters(int, int) –
Static method in class mars.simulator.Exceptions
Given MIPS exception cause code and bad address, place the bad address into VADDR
register ($8) then call overloaded setRegisters with the cause code to do the rest.
setRegistersHighlighting(boolean) –
Method in class mars.Settings
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.REGISTERS_HIGHLIGHTING)
setRegisterToFloat(String, float) –
Static method in class mars.mips.hardware.Coprocessor1
Sets the value of the FPU register given to the value given.
setRegisterToFloat(int, float) –
Static method in class mars.mips.hardware.Coprocessor1
Sets the value of the FPU register given to the value given.
setRegisterToInt(String, int) –
Static method in class mars.mips.hardware.Coprocessor1
Sets the value of the FPU register given to the 32-bit
pattern given by the int parameter.
setRegisterToInt(int, int) –
Static method in class mars.mips.hardware.Coprocessor1
Sets the value of the FPU register given to the 32-bit
pattern given by the int parameter.
setRepeatCount(int) –
Method in class mars.venus.editors.jeditsyntax.InputHandler
Sets the number of times the next action will be repeated.
setRepeatEnabled(boolean) –
Method in class mars.venus.editors.jeditsyntax.InputHandler
Enables repeating.
setRepeatEnabled(boolean) –
Method in class mars.venus.RepeatButton
Sets if the button should fire events when held.
setReset(boolean) –
Static method in class mars.venus.VenusUI
To set whether the register values are reset.
setRightClickPopup(JPopupMenu) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Sets the right click popup menu.
setSaved(boolean) –
Static method in class mars.venus.FileStatus
Changes the value of saved to the parameter given.
setSelectedText(String) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Replaces the selection with the specified text.
setSelectionColor(Color) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Sets the selection color.
setSelectionEnd(int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Sets the selection end.
setSelectionEnd(int) –
Method in interface mars.venus.editors.MARSTextEditingArea
setSelectionRectangular(boolean) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Sets if the selection should be rectangular.
setSelectionStart(int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Sets the selection start.
setSelectionStart(int) –
Method in interface mars.venus.editors.MARSTextEditingArea
setSelectionVisible(boolean) –
Method in class mars.venus.editors.generic.GenericTextArea
Control selection visibility
setSelectionVisible(boolean) –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
setSelectionVisible(boolean) –
Method in interface mars.venus.editors.MARSTextEditingArea
setSettingsMenuItem(JCheckBoxMenuItem) –
Method in class mars.venus.NumberDisplayBaseChooser
Set the menu item from Settings menu that corresponds to this chooser.
setShowLineNumbersEnabled(boolean) –
Method in class mars.venus.EditPane
enable or disable checkbox that controls display of line numbers
setSource(String) –
Method in class mars.ProgramStatement
associates MIPS source statement.
setSourceCode(String, boolean) –
Method in class mars.venus.editors.generic.GenericTextArea
For initalizing the source code when opening an ASM file
setSourceCode(String, boolean) –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
setSourceCode(String, boolean) –
Method in interface mars.venus.editors.MARSTextEditingArea
setSourceCode(String, boolean) –
Method in class mars.venus.EditPane
For initalizing the source code when opening an ASM file
setSourceLineList(ArrayList
Method in class mars.MIPSprogram
Set list of source statements that comprise the program.
setStartAtMain(boolean) –
Method in class mars.Settings
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.START_AT_MAIN)
setStarted(boolean) –
Static method in class mars.venus.VenusUI
To set whether MIPS program execution has started.
setStatement(int, ProgramStatement) –
Method in class mars.mips.hardware.Memory
Stores ProgramStatement in Text Segment.
setStyles(SyntaxStyle[]) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Sets the syntax styles used to paint colorized text.
setTabSize(int) –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
Set the number of characters a tab will expand to.
setTabSize(int) –
Method in class mars.venus.editors.jeditsyntax.TextAreaPainter
Set the tab size in characters.
setTabSize(int) –
Method in interface mars.venus.editors.MARSTextEditingArea
setText(String) –
Method in class mars.venus.editors.generic.GenericTextArea
Override inherited setText to temporarily remove UndoableEditListener because this
operation is not undoable.
setText(String) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Sets the entire text of this text area.
setText(String) –
Method in interface mars.venus.editors.MARSTextEditingArea
setTextColumnOrder(int[]) –
Method in class mars.Settings
Store the current order of Text Segment window table columns, so the ordering
can be preserved and restored.
Settings – Class in mars
Contains various IDE settings.
Settings() –
Constructor for class mars.Settings
Create Settings object and set to saved values.
Settings(boolean) –
Constructor for class mars.Settings
Create Settings object and set to saved values.
SettingsAddressDisplayBaseAction – Class in mars.venus
Action class for the Settings menu item to control number base (10 or 16) of memory addresses.
SettingsAddressDisplayBaseAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.SettingsAddressDisplayBaseAction
SettingsAssembleAllAction – Class in mars.venus
Action class for the Settings menu item to determine whether assemble operation applies
only to current file or to all files in its directory.
SettingsAssembleAllAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.SettingsAssembleAllAction
SettingsAssembleOnOpenAction – Class in mars.venus
Action class for the Settings menu item to control automatic assemble of file upon opening.
SettingsAssembleOnOpenAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.SettingsAssembleOnOpenAction
SettingsDelayedBranchingAction – Class in mars.venus
Action class for the Settings menu item to control delayed branching.
SettingsDelayedBranchingAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.SettingsDelayedBranchingAction
SettingsEditorAction – Class in mars.venus
Action class for the Settings menu item for text editor settings.
SettingsEditorAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.SettingsEditorAction
Create a new SettingsEditorAction.
SettingsExceptionHandlerAction – Class in mars.venus
Action class for the Settings menu item for optionally loading a MIPS exception handler.
SettingsExceptionHandlerAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.SettingsExceptionHandlerAction
SettingsExtendedAction – Class in mars.venus
Action class for the Settings menu item to control use of extended (pseudo) instructions or formats.
SettingsExtendedAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.SettingsExtendedAction
SettingsHighlightingAction – Class in mars.venus
Action class for the Settings menu item for text editor settings.
SettingsHighlightingAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.SettingsHighlightingAction
Create a new SettingsEditorAction.
SettingsLabelAction – Class in mars.venus
Action class for the Settings menu item to control display of Labels window (symbol table).
SettingsLabelAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.SettingsLabelAction
SettingsMemoryConfigurationAction – Class in mars.venus
Action class for the Settings menu item for text editor settings.
SettingsMemoryConfigurationAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.SettingsMemoryConfigurationAction
Create a new SettingsEditorAction.
SettingsPopupInputAction – Class in mars.venus
Action class for the Settings menu item to control use of popup dialog for input syscalls.
SettingsPopupInputAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.SettingsPopupInputAction
SettingsProgramArgumentsAction – Class in mars.venus
Action class for the Settings menu item to control whether or not
program arguments can be entered and used.
SettingsProgramArgumentsAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.SettingsProgramArgumentsAction
SettingsSelfModifyingCodeAction – Class in mars.venus
Action class for the Settings menu item to control whether
the running MIPS program can write to the text segment or
branch to the data segment.
SettingsSelfModifyingCodeAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.SettingsSelfModifyingCodeAction
SettingsStartAtMainAction – Class in mars.venus
Action class for the Settings menu item to control whether or not
assembler warnings are considered errors.
SettingsStartAtMainAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.SettingsStartAtMainAction
SettingsValueDisplayBaseAction – Class in mars.venus
Action class for the Settings menu item to control number base (10 or 16) of memory/register contents.
SettingsValueDisplayBaseAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.SettingsValueDisplayBaseAction
SettingsWarningsAreErrorsAction – Class in mars.venus
Action class for the Settings menu item to control whether or not
assembler warnings are considered errors.
SettingsWarningsAreErrorsAction(String, Icon, String, Integer, KeyStroke, VenusUI) –
Constructor for class mars.venus.SettingsWarningsAreErrorsAction
setTitle(String, String, int) –
Method in class mars.venus.Editor
Places name of file currently being edited into its edit tab and
the application’s title bar.
setTokenMarker(TokenMarker) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Sets the document’s token marker.
setTokenMarker(TokenMarker) –
Method in class mars.venus.editors.jeditsyntax.SyntaxDocument
Sets the token marker that is to be used to split lines of
this document up into tokens.
setToLine(int) –
Method in class mars.assembler.Macro
setType(TokenTypes) –
Method in class mars.assembler.Token
Set or modify token type.
setupTable() –
Method in class mars.venus.DataSegmentWindow
Generates and displays fresh table, typically done upon successful assembly.
setupTable() –
Method in class mars.venus.LabelsWindow
Initialize table of labels (symbol table)
setupTable() –
Method in class mars.venus.TextSegmentWindow
Method to be called once the user compiles the program.
setupWindow() –
Method in class mars.venus.Coprocessor0Window
Sets up the data for the window.
setupWindow() –
Method in class mars.venus.Coprocessor1Window
Sets up the data for the window.
setupWindow() –
Method in class mars.venus.RegistersWindow
Sets up the data for the window.
setValue(int) –
Method in class mars.mips.hardware.Register
Sets the value of the register to the val passed to it.
setWarningsAreErrors(boolean) –
Method in class mars.Settings
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.WARNINGS_ARE_ERRORS)
setWindowBounds() –
Method in class mars.venus.ExecutePane
This method will set the bounds of this JDesktopPane’s internal windows
relative to the current size of this JDesktopPane.
setWord(int, int) –
Method in class mars.mips.hardware.Memory
Starting at the given word address, write the given value over 4 bytes (a word).
showingLineNumbers() –
Method in class mars.venus.EditPane
get editor’s line number display status
showRegisters() –
Static method in class mars.mips.hardware.Coprocessor0
Method for displaying the register values for debugging.
showRegisters() –
Static method in class mars.mips.hardware.Coprocessor1
Method for displaying the register values for debugging.
showRegisters() –
Static method in class mars.mips.hardware.RegisterFile
Method for displaying the register values for debugging.
showSplash() –
Method in class mars.MarsSplashScreen
A simple little method to show a title screen in the center
of the screen for the amount of time given in the constructor
simulate(ProgramStatement) –
Method in interface mars.mips.instructions.SimulationCode
Method to simulate the execution of a specific MIPS basic instruction.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.AbstractSyscall
Performs syscall function.
simulate(ProgramStatement) –
Method in interface mars.mips.instructions.syscalls.Syscall
Performs syscall function.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallClose
Performs syscall function to close file descriptor given in $a0.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallConfirmDialog
System call to display a message to user.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallExit
Performs syscall function to exit the MIPS program.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallExit2
Performs syscall function to exit the MIPS program with return value given in $a0.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallInputDialogDouble
System call to input data.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallInputDialogFloat
System call to input data.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallInputDialogInt
System call to input data.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallInputDialogString
System call to input data.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallMessageDialog
System call to display a message to user.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallMessageDialogDouble
System call to display a message to user.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallMessageDialogFloat
System call to display a message to user.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallMessageDialogInt
System call to display a message to user.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallMessageDialogString
System call to display a message to user.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallMidiOut
Performs syscall function to send MIDI output to sound card.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallMidiOutSync
Performs syscall function to send MIDI output to sound card.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallOpen
Performs syscall function to open file name specified by $a0.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallPrintChar
Performs syscall function to print on the console the character stored in $a0.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallPrintDouble
Performs syscall function to print double whose bits are stored in $f12 & $f13.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallPrintFloat
Performs syscall function to display float whose bits are stored in $f12
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallPrintInt
Performs syscall function to print on the console the integer stored in $a0.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallPrintIntBinary
Performs syscall function to print on the console the integer stored in $a0, in hexadecimal format.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallPrintIntHex
Performs syscall function to print on the console the integer stored in $a0, in hexadecimal format.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallPrintIntUnsigned
Performs syscall function to print on the console the integer stored in $a0.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallPrintString
Performs syscall function to print string stored starting at address in $a0.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallRandDouble
System call to the random number generator.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallRandFloat
System call to the random number generator.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallRandInt
System call to the random number generator.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallRandIntRange
System call to the random number generator, with an upper range specified.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallRandSeed
Set the seed of the underlying Java pseudorandom number generator.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallRead
Performs syscall function to read from file descriptor given in $a0.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallReadChar
Performs syscall function to read a character from input console into $a0
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallReadDouble
Performs syscall function to read the bits of input double into $f0 and $f1.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallReadFloat
Performs syscall function to read the bits of input float into $f0
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallReadInt
Performs syscall function to read an integer from input console into $v0
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallReadString
Performs syscall function to read console input string into buffer starting at address in $a0.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallSbrk
Performs syscall function to allocate amount of heap memory specified in $a0, putting address into $v0.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallSleep
System call to cause the MARS Java thread to sleep for (at least) the specified number of milliseconds.
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallTime
Performs syscall function to place current system time into $a0 (low order 32 bits)
and $a1 (high order 32 bits).
simulate(ProgramStatement) –
Method in class mars.mips.instructions.syscalls.SyscallWrite
Performs syscall function to write to file descriptor given in $a0.
simulate(int[]) –
Method in class mars.MIPSprogram
Simulates execution of the MIPS program.
simulate(int) –
Method in class mars.MIPSprogram
Simulates execution of the MIPS program.
simulate(MIPSprogram, int, int, int[], AbstractAction) –
Method in class mars.simulator.Simulator
Simulate execution of given MIPS program.
simulateFromPC(int[], int, AbstractAction) –
Method in class mars.MIPSprogram
Simulates execution of the MIPS program.
simulateStepAtPC(AbstractAction) –
Method in class mars.MIPSprogram
Simulates execution of the MIPS program.
SimulationCode – Interface in mars.mips.instructions
Interface to represent the method for simulating the execution of a specific MIPS basic
instruction.
Simulator – Class in mars.simulator
Used to simulate the execution of an assembled MIPS program.
Simulator.StopListener – Interface in mars.simulator
SIMULATOR_START –
Static variable in class mars.simulator.SimulatorNotice
SIMULATOR_STOP –
Static variable in class mars.simulator.SimulatorNotice
SimulatorNotice – Class in mars.simulator
Object provided to Observers of the Simulator.
SimulatorNotice(int, int, double, int) –
Constructor for class mars.simulator.SimulatorNotice
Constructor will be called only within this package, so assume
address and length are in valid ranges.
size() –
Method in class mars.assembler.TokenList
Returns number of tokens in list.
sizeIntToSizeString(int) –
Static method in class mars.util.EditorFont
Given an int representing font size, returns corresponding string.
sizeStringToSizeInt(String) –
Static method in class mars.util.EditorFont
Given a String representing font size, returns corresponding int.
SMART_HOME_END_PROPERTY –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
If this client property is set to Boolean.TRUE on the text area,
the home/end keys will support ‘smart’ BRIEF-like behaviour
(one press = start/end of line, two presses = start/end of
viewscreen, three presses = start/end of document).
SourceLine – Class in mars.assembler
Handy class to represent, for a given line of source code, the code
itself, the program containing it, and its line number within that program.
SourceLine(String, MIPSprogram, int) –
Constructor for class mars.assembler.SourceLine
SourceLine constructor
SPACE –
Static variable in class mars.assembler.Directives
STACK_POINTER_REGISTER –
Static variable in class mars.mips.hardware.RegisterFile
stackBaseAddress –
Static variable in class mars.mips.hardware.Memory
base address for stack: 0x7ffffffc (this is mine – start of highest word below kernel space)
stackLimitAddress –
Static variable in class mars.mips.hardware.Memory
stackPointer –
Static variable in class mars.mips.hardware.Memory
starting address for stack: 0x7fffeffc (this is from SPIM not MIPS)
start() –
Method in class mars.simulator.SwingWorker
Start the worker thread.
START_AT_MAIN –
Static variable in class mars.Settings
Flag to control whether or not assembler automatically initializes program counter to ‘main’s address
STATUS –
Static variable in class mars.mips.hardware.Coprocessor0
stepped(boolean, int, ProcessingException) –
Method in class mars.venus.RunStepAction
stopExecution(AbstractAction) –
Method in class mars.simulator.Simulator
Set the volatile stop boolean variable checked by the execution
thread at the end of each MIPS instruction execution.
stopped(Simulator) –
Method in interface mars.simulator.Simulator.StopListener
stopped(ProcessingException, int) –
Method in class mars.venus.RunGoAction
Method to be called when Stop is selected through menu/toolbar/shortcut.
storeProgramArguments() –
Method in class mars.simulator.ProgramArgumentList
stringToInt(String) –
Static method in class mars.util.Binary
Attempt to validate given string whose characters represent a 32 bit integer.
stringToLong(String) –
Static method in class mars.util.Binary
Attempt to validate given string whose characters represent a 64 bit long.
styleIntToStyleString(int) –
Static method in class mars.util.EditorFont
Given an int that represents a font style from the Font class,
returns the corresponding String.
styles –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
styles –
Variable in class mars.venus.editors.jeditsyntax.TextAreaPainter
styleStringToStyleInt(String) –
Static method in class mars.util.EditorFont
Given a string that represents a font style, returns the
corresponding final int defined in Font: PLAIN, BOLD, ITALIC.
substituteSpacesForTabs(String) –
Static method in class mars.util.EditorFont
substituteSpacesForTabs(String, int) –
Static method in class mars.util.EditorFont
Handy utility to produce a string that substitutes spaces for all tab characters
in the given string.
supportsMultilineTokens() –
Method in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
Returns if the token marker supports tokens that span multiple
lines.
SwingWorker – Class in mars.simulator
This is the 3rd version of SwingWorker (also known as
SwingWorker 3), an abstract class that you subclass to
perform GUI-related work in a dedicated thread.
SwingWorker(boolean) –
Constructor for class mars.simulator.SwingWorker
Start a thread that will call the construct method
and then exit.
SwitchSegment(Graphics, char) –
Method in class mars.tools.DigitalLabSim.SevenSegmentDisplay
Symbol – Class in mars.assembler
Represents a MIPS program identifier to be stored in the symbol table.
Symbol(String, int, boolean) –
Constructor for class mars.assembler.Symbol
Basic constructor, creates a symbol object.
SymbolTable – Class in mars.assembler
Creats a table of Symbol objects.
SymbolTable(String) –
Constructor for class mars.assembler.SymbolTable
Create a new empty symbol table for given file
symbolTable –
Static variable in class mars.Globals
Symbol table for file currently being assembled.
SyntaxDocument – Class in mars.venus.editors.jeditsyntax
A document implementation that can be tokenized by the syntax highlighting
system.
SyntaxDocument() –
Constructor for class mars.venus.editors.jeditsyntax.SyntaxDocument
SyntaxStyle – Class in mars.venus.editors.jeditsyntax
A simple text style class.
SyntaxStyle(Color, boolean, boolean) –
Constructor for class mars.venus.editors.jeditsyntax.SyntaxStyle
Creates a new SyntaxStyle.
SyntaxUtilities – Class in mars.venus.editors.jeditsyntax
Class with several utility functions used by jEdit’s syntax colorizing
subsystem.
Syscall – Interface in mars.mips.instructions.syscalls
Interface for any MIPS syscall system service.
SYSCALL_BUFSIZE –
Static variable in class mars.util.SystemIO
Buffer size for syscalls for file I/O
SYSCALL_EXCEPTION –
Static variable in class mars.simulator.Exceptions
SYSCALL_MAXFILES –
Static variable in class mars.util.SystemIO
Maximum number of files that can be open
SyscallClose – Class in mars.mips.instructions.syscalls
Service to close file descriptor given in $a0.
SyscallClose() –
Constructor for class mars.mips.instructions.syscalls.SyscallClose
Build an instance of the Close syscall.
SyscallConfirmDialog – Class in mars.mips.instructions.syscalls
Service to display a message to user.
SyscallConfirmDialog() –
Constructor for class mars.mips.instructions.syscalls.SyscallConfirmDialog
Build an instance of the syscall with its default service number and name.
SyscallExit – Class in mars.mips.instructions.syscalls
Service to exit the MIPS program.
SyscallExit() –
Constructor for class mars.mips.instructions.syscalls.SyscallExit
Build an instance of the Exit syscall.
SyscallExit2 – Class in mars.mips.instructions.syscalls
Service to exit the MIPS program with return value given in $a0.
SyscallExit2() –
Constructor for class mars.mips.instructions.syscalls.SyscallExit2
Build an instance of the Exit2 syscall.
SyscallInputDialogDouble – Class in mars.mips.instructions.syscalls
Service to input data.
SyscallInputDialogDouble() –
Constructor for class mars.mips.instructions.syscalls.SyscallInputDialogDouble
Build an instance of the syscall with its default service number and name.
SyscallInputDialogFloat – Class in mars.mips.instructions.syscalls
Service to input data.
SyscallInputDialogFloat() –
Constructor for class mars.mips.instructions.syscalls.SyscallInputDialogFloat
Build an instance of the syscall with its default service number and name.
SyscallInputDialogInt – Class in mars.mips.instructions.syscalls
Service to input data.
SyscallInputDialogInt() –
Constructor for class mars.mips.instructions.syscalls.SyscallInputDialogInt
Build an instance of the syscall with its default service number and name.
SyscallInputDialogString – Class in mars.mips.instructions.syscalls
Service to input data.
SyscallInputDialogString() –
Constructor for class mars.mips.instructions.syscalls.SyscallInputDialogString
Build an instance of the syscall with its default service number and name.
SyscallMessageDialog – Class in mars.mips.instructions.syscalls
Service to display a message to user.
SyscallMessageDialog() –
Constructor for class mars.mips.instructions.syscalls.SyscallMessageDialog
Build an instance of the syscall with its default service number and name.
SyscallMessageDialogDouble – Class in mars.mips.instructions.syscalls
Service to display a message to user.
SyscallMessageDialogDouble() –
Constructor for class mars.mips.instructions.syscalls.SyscallMessageDialogDouble
Build an instance of the syscall with its default service number and name.
SyscallMessageDialogFloat – Class in mars.mips.instructions.syscalls
Service to display a message to user.
SyscallMessageDialogFloat() –
Constructor for class mars.mips.instructions.syscalls.SyscallMessageDialogFloat
Build an instance of the syscall with its default service number and name.
SyscallMessageDialogInt – Class in mars.mips.instructions.syscalls
Service to display a message to user.
SyscallMessageDialogInt() –
Constructor for class mars.mips.instructions.syscalls.SyscallMessageDialogInt
Build an instance of the syscall with its default service number and name.
SyscallMessageDialogString – Class in mars.mips.instructions.syscalls
Service to display a message to user.
SyscallMessageDialogString() –
Constructor for class mars.mips.instructions.syscalls.SyscallMessageDialogString
Build an instance of the syscall with its default service number and name.
SyscallMidiOut – Class in mars.mips.instructions.syscalls
Service to output simulated MIDI tone to sound card.
SyscallMidiOut() –
Constructor for class mars.mips.instructions.syscalls.SyscallMidiOut
Build an instance of the MIDI (simulated) out syscall.
SyscallMidiOutSync – Class in mars.mips.instructions.syscalls
Service to output simulated MIDI tone to sound card.
SyscallMidiOutSync() –
Constructor for class mars.mips.instructions.syscalls.SyscallMidiOutSync
Build an instance of the MIDI (simulated) out syscall.
SyscallNumberOverride – Class in mars.mips.instructions.syscalls
Represents User override of default syscall number assignment.
SyscallNumberOverride(String, String) –
Constructor for class mars.mips.instructions.syscalls.SyscallNumberOverride
Constructor is called with two strings: service name and desired
number.
SyscallOpen – Class in mars.mips.instructions.syscalls
Service to open file name specified by $a0.
SyscallOpen() –
Constructor for class mars.mips.instructions.syscalls.SyscallOpen
Build an instance of the Open file syscall.
SyscallPrintChar – Class in mars.mips.instructions.syscalls
Service to display character stored in $a0 on the console.
SyscallPrintChar() –
Constructor for class mars.mips.instructions.syscalls.SyscallPrintChar
Build an instance of the Print Char syscall.
SyscallPrintDouble – Class in mars.mips.instructions.syscalls
Service to display double whose bits are stored in $f12 & $f13 onto the console.
SyscallPrintDouble() –
Constructor for class mars.mips.instructions.syscalls.SyscallPrintDouble
Build an instance of the Print Double syscall.
SyscallPrintFloat – Class in mars.mips.instructions.syscalls
Service to display on the console float whose bits are stored in $f12
SyscallPrintFloat() –
Constructor for class mars.mips.instructions.syscalls.SyscallPrintFloat
Build an instance of the Print Float syscall.
SyscallPrintInt – Class in mars.mips.instructions.syscalls
Service to display integer stored in $a0 on the console.
SyscallPrintInt() –
Constructor for class mars.mips.instructions.syscalls.SyscallPrintInt
Build an instance of the Print Integer syscall.
SyscallPrintIntBinary – Class in mars.mips.instructions.syscalls
Service to display integer stored in $a0 on the console.
SyscallPrintIntBinary() –
Constructor for class mars.mips.instructions.syscalls.SyscallPrintIntBinary
Build an instance of the Print Integer syscall.
SyscallPrintIntHex – Class in mars.mips.instructions.syscalls
Service to display integer stored in $a0 on the console.
SyscallPrintIntHex() –
Constructor for class mars.mips.instructions.syscalls.SyscallPrintIntHex
Build an instance of the Print Integer syscall.
SyscallPrintIntUnsigned – Class in mars.mips.instructions.syscalls
Service to display integer stored in $a0 on the console as unsigned decimal.
SyscallPrintIntUnsigned() –
Constructor for class mars.mips.instructions.syscalls.SyscallPrintIntUnsigned
Build an instance of the Print Integer Unsigned syscall.
SyscallPrintString – Class in mars.mips.instructions.syscalls
Service to display string stored starting at address in $a0 onto the console.
SyscallPrintString() –
Constructor for class mars.mips.instructions.syscalls.SyscallPrintString
Build an instance of the Print String syscall.
SyscallRandDouble – Class in mars.mips.instructions.syscalls
Service to return a random floating point value.
SyscallRandDouble() –
Constructor for class mars.mips.instructions.syscalls.SyscallRandDouble
Build an instance of the syscall with its default service number and name.
SyscallRandFloat – Class in mars.mips.instructions.syscalls
Service to return a random floating point value.
SyscallRandFloat() –
Constructor for class mars.mips.instructions.syscalls.SyscallRandFloat
Build an instance of the syscall with its default service number and name.
SyscallRandInt – Class in mars.mips.instructions.syscalls
Service to return a random integer.
SyscallRandInt() –
Constructor for class mars.mips.instructions.syscalls.SyscallRandInt
Build an instance of the syscall with its default service number and name.
SyscallRandIntRange – Class in mars.mips.instructions.syscalls
Service to return a random integer in a specified range.
SyscallRandIntRange() –
Constructor for class mars.mips.instructions.syscalls.SyscallRandIntRange
Build an instance of the syscall with its default service number and name.
SyscallRandSeed – Class in mars.mips.instructions.syscalls
Service to set seed for the underlying Java pseudorandom number generator.
SyscallRandSeed() –
Constructor for class mars.mips.instructions.syscalls.SyscallRandSeed
Build an instance of the syscall with its default service number and name.
SyscallRead – Class in mars.mips.instructions.syscalls
Service to read from file descriptor given in $a0.
SyscallRead() –
Constructor for class mars.mips.instructions.syscalls.SyscallRead
Build an instance of the Read file syscall.
SyscallReadChar – Class in mars.mips.instructions.syscalls
Service to read a character from input console into $a0.
SyscallReadChar() –
Constructor for class mars.mips.instructions.syscalls.SyscallReadChar
Build an instance of the Read Char syscall.
SyscallReadDouble – Class in mars.mips.instructions.syscalls
Service to read the bits of console input double into $f0 and $f1.
SyscallReadDouble() –
Constructor for class mars.mips.instructions.syscalls.SyscallReadDouble
Build an instance of the Read Double syscall.
SyscallReadFloat – Class in mars.mips.instructions.syscalls
Service to read the bits of input float into $f0
SyscallReadFloat() –
Constructor for class mars.mips.instructions.syscalls.SyscallReadFloat
Build an instance of the Read Float syscall.
SyscallReadInt – Class in mars.mips.instructions.syscalls
Service to read an integer from input console into $v0.
SyscallReadInt() –
Constructor for class mars.mips.instructions.syscalls.SyscallReadInt
Build an instance of the Read Integer syscall.
SyscallReadString – Class in mars.mips.instructions.syscalls
Service to read console input string into buffer starting at address in $a0.
SyscallReadString() –
Constructor for class mars.mips.instructions.syscalls.SyscallReadString
Build an instance of the Read String syscall.
SyscallSbrk – Class in mars.mips.instructions.syscalls
Service to allocate amount of heap memory specified in $a0, putting address into $v0.
SyscallSbrk() –
Constructor for class mars.mips.instructions.syscalls.SyscallSbrk
Build an instance of the Sbrk syscall.
SyscallSleep – Class in mars.mips.instructions.syscalls
Service to cause the MARS Java thread to sleep for (at least) the specified number of milliseconds.
SyscallSleep() –
Constructor for class mars.mips.instructions.syscalls.SyscallSleep
Build an instance of the syscall with its default service number and name.
SyscallTime – Class in mars.mips.instructions.syscalls
Service to read a character from input console into $a0.
SyscallTime() –
Constructor for class mars.mips.instructions.syscalls.SyscallTime
Build an instance of the Read Char syscall.
SyscallWrite – Class in mars.mips.instructions.syscalls
Service to write to file descriptor given in $a0.
SyscallWrite() –
Constructor for class mars.mips.instructions.syscalls.SyscallWrite
Build an instance of the Write file syscall.
SystemIO – Class in mars.util
Provides standard i/o services needed to simulate the MIPS syscall
routines.
SystemIO() –
Constructor for class mars.util.SystemIO
T
tableChanged(TableModelEvent) –
Method in class mars.venus.RunClearBreakpointsAction
Required TableModelListener method.
tabSize –
Variable in class mars.venus.editors.jeditsyntax.TextAreaDefaults
tabSize –
Variable in class mars.venus.editors.jeditsyntax.TextAreaPainter
tabSizeChars –
Variable in class mars.venus.editors.jeditsyntax.TextAreaPainter
tellEditingComponentToRequestFocusInWindow() –
Method in class mars.venus.EditPane
Delegates to text area’s requestFocusInWindow method.
TERMINATED –
Static variable in class mars.venus.FileStatus
execution terminated
TEXT –
Static variable in class mars.assembler.Directives
TEXT_COLUMN_ORDER –
Static variable in class mars.Settings
Order of text segment table columns
TEXT_FOUND –
Static variable in interface mars.venus.editors.MARSTextEditingArea
TEXT_NOT_FOUND –
Static variable in interface mars.venus.editors.MARSTextEditingArea
TEXT_REPLACED_FOUND_NEXT –
Static variable in interface mars.venus.editors.MARSTextEditingArea
TEXT_REPLACED_NOT_FOUND_NEXT –
Static variable in interface mars.venus.editors.MARSTextEditingArea
TEXT_SYMBOL –
Static variable in class mars.assembler.Symbol
textArea –
Variable in class mars.venus.editors.jeditsyntax.TextAreaPainter
TextAreaDefaults – Class in mars.venus.editors.jeditsyntax
Encapsulates default settings for a text area.
TextAreaDefaults() –
Constructor for class mars.venus.editors.jeditsyntax.TextAreaDefaults
TextAreaPainter – Class in mars.venus.editors.jeditsyntax
The text area repaint manager.
TextAreaPainter(JEditTextArea, TextAreaDefaults) –
Constructor for class mars.venus.editors.jeditsyntax.TextAreaPainter
Creates a new repaint manager.
TextAreaPainter.Highlight – Interface in mars.venus.editors.jeditsyntax
Highlight interface.
textBaseAddress –
Static variable in class mars.mips.hardware.Memory
base address for (user) text segment: 0x00400000
textLimitAddress –
Static variable in class mars.mips.hardware.Memory
TEXTSEGMENT_DELAYSLOT_HIGHLIGHT_BACKGROUND –
Static variable in class mars.Settings
RGB color for text segment delay slot highlighted background
TEXTSEGMENT_DELAYSLOT_HIGHLIGHT_FONT –
Static variable in class mars.Settings
Font for text segment delay slot highlighted background
TEXTSEGMENT_DELAYSLOT_HIGHLIGHT_FOREGROUND –
Static variable in class mars.Settings
RGB color for text segment delay slot highlighted foreground
TEXTSEGMENT_HIGHLIGHT_BACKGROUND –
Static variable in class mars.Settings
RGB color for text segment highlighted background
TEXTSEGMENT_HIGHLIGHT_FONT –
Static variable in class mars.Settings
Font for table odd row foreground (text, data, register displays)
TEXTSEGMENT_HIGHLIGHT_FOREGROUND –
Static variable in class mars.Settings
RGB color for text segment highlighted foreground
TextSegmentWindow – Class in mars.venus
Creates the Text Segment window in the Execute tab of the UI
TextSegmentWindow() –
Constructor for class mars.venus.TextSegmentWindow
Constructor, sets up a new JInternalFrame.
TextUtilities – Class in mars.venus.editors.jeditsyntax
Class with several utility functions used by the text area component.
TextUtilities() –
Constructor for class mars.venus.editors.jeditsyntax.TextUtilities
theWindow –
Variable in class mars.tools.AbstractMarsToolAndApplication
thisMarsApp –
Variable in class mars.tools.AbstractMarsToolAndApplication
time –
Variable in class mars.venus.HardcopyWriter
TOGGLE_RECT –
Static variable in class mars.venus.editors.jeditsyntax.InputHandler
toggleBreakpoints() –
Method in class mars.venus.TextSegmentWindow
Enable or disable all items in the Breakpoints column.
Token – Class in mars.assembler
Represents one token in the input MIPS program.
Token(TokenTypes, String, MIPSprogram, int, int) –
Constructor for class mars.assembler.Token
Constructor for Token class.
Token – Class in mars.venus.editors.jeditsyntax.tokenmarker
A linked list of tokens.
Token(int, byte) –
Constructor for class mars.venus.editors.jeditsyntax.tokenmarker.Token
Creates a new token.
token –
Variable in class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker.LineInfo
The id of the last token of the line.
TOKEN_DELIMITERS –
Static variable in class mars.assembler.TokenTypes
tokenIsMacroParameter(String, boolean) –
Static method in class mars.assembler.Macro
returns whether tokenValue is macro parameter or not
tokenize(MIPSprogram) –
Method in class mars.assembler.Tokenizer
Will tokenize a complete MIPS program.
tokenize() –
Method in class mars.MIPSprogram
Tokenizes the MIPS source program.
tokenizeExampleInstruction(String) –
Method in class mars.assembler.Tokenizer
Used only to create a token list for the example provided with each instruction
specification.
tokenizeLine(int, String) –
Method in class mars.assembler.Tokenizer
Will tokenize one line of source code.
tokenizeLine(int, String, ErrorList) –
Method in class mars.assembler.Tokenizer
Will tokenize one line of source code.
tokenizeLine(int, String, ErrorList, boolean) –
Method in class mars.assembler.Tokenizer
Will tokenize one line of source code.
tokenizeLine(MIPSprogram, int, String, boolean) –
Method in class mars.assembler.Tokenizer
Will tokenize one line of source code.
tokenizeLines() –
Method in class mars.venus.editors.jeditsyntax.SyntaxDocument
Reparses the document, by passing all lines to the token
marker.
tokenizeLines(int, int) –
Method in class mars.venus.editors.jeditsyntax.SyntaxDocument
Reparses the document, by passing the specified lines to the
token marker.
Tokenizer – Class in mars.assembler
A tokenizer is capable of tokenizing a complete MIPS program, or a given line from
a MIPS program.
Tokenizer() –
Constructor for class mars.assembler.Tokenizer
Simple constructor.
Tokenizer(MIPSprogram) –
Constructor for class mars.assembler.Tokenizer
Constructor for use with existing MIPSprogram.
TokenList – Class in mars.assembler
Represents the list of tokens in a single line of MIPS code.
TokenList() –
Constructor for class mars.assembler.TokenList
Constructor for objects of class TokenList
tokenList –
Variable in class mars.mips.instructions.Instruction
List of tokens generated by tokenizing example usage (see exampleFormat).
tokenMarker –
Variable in class mars.venus.editors.jeditsyntax.SyntaxDocument
TokenMarker – Class in mars.venus.editors.jeditsyntax.tokenmarker
A token marker that splits lines of text into tokens.
TokenMarker() –
Constructor for class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
Creates a new TokenMarker.
TokenMarker.LineInfo – Class in mars.venus.editors.jeditsyntax.tokenmarker
Inner class for storing information about tokenized lines.
TokenMarker.LineInfo() –
Constructor for class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker.LineInfo
Creates a new LineInfo object with token = Token.NULL
and obj = null.
TokenMarker.LineInfo(byte, Object) –
Constructor for class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker.LineInfo
Creates a new LineInfo object with the specified
parameters.
TokenTypes – Class in mars.assembler
Constants to identify the types of tokens found in MIPS programs.
ToolAction – Class in mars.venus
Connects a MarsTool class (class that implements MarsTool interface) to
the Mars menu system by supplying the response to that tool’s menu item
selection.
ToolAction(Class, String) –
Constructor for class mars.venus.ToolAction
Simple constructor.
ToolLoader – Class in mars.venus
This class provides functionality to bring external Mars tools into the Mars
system by adding them to its Tools menu.
ToolLoader() –
Constructor for class mars.venus.ToolLoader
toString() –
Method in class mars.assembler.Directives
Produces String-ified version of Directive object
toString() –
Method in class mars.assembler.Token
Get a String representing the token.
toString() –
Method in class mars.assembler.TokenList
Get a String representing the token list.
toString() –
Method in class mars.assembler.TokenTypes
Produces String equivalent of this token type, which is its name.
toString() –
Method in class mars.mips.dump.AbstractDumpFormat
String representing this object.
toString() –
Method in interface mars.mips.dump.DumpFormat
Descriptive name for the format.
toString() –
Method in class mars.mips.hardware.MemoryAccessNotice
String representation indicates access type, address and length in bytes
toString() –
Method in class mars.mips.hardware.RegisterAccessNotice
String representation indicates access type and which register
toString() –
Method in class mars.ProgramStatement
Crude attempt at building String representation of this complex structure.
toString() –
Method in class mars.simulator.SimulatorNotice
String representation indicates access type, address and length in bytes
toString() –
Method in class mars.venus.editors.jeditsyntax.SyntaxStyle
Returns a string representation of this object.
toString() –
Method in class mars.venus.editors.jeditsyntax.tokenmarker.Token
Returns a string representation of this token.
toTypeString() –
Method in class mars.assembler.TokenList
Get a String representing the sequence of token types for this list.
translate() –
Method in interface mars.assembler.TranslationCode
This is a callback method defined in anonymous class specified as
argument to ExtendedInstruction constructor.
TranslationCode – Interface in mars.assembler
This interface is intended for use by ExtendedInstruction objects to define, using
the translate() method, how to translate the extended (pseudo) instruction into
a sequence of one or more basic instructions, which can then be translated into
binary machine code.
TRANSMITTER_CONTROL –
Static variable in class mars.tools.KeyboardAndDisplaySimulator
TRANSMITTER_DATA –
Static variable in class mars.tools.KeyboardAndDisplaySimulator
TRAP_EXCEPTION –
Static variable in class mars.simulator.Exceptions
twoIntsToLong(int, int) –
Static method in class mars.util.Binary
Returns long (64 bit integer) combining the bit values of two given 32 bit
integer values.
U
undo() –
Method in class mars.venus.editors.generic.GenericTextArea
Undo previous edit
undo() –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
Undo previous edit
undo() –
Method in interface mars.venus.editors.MARSTextEditingArea
undo() –
Method in class mars.venus.EditPane
Undo previous edit
unhighlightAllSteps() –
Method in class mars.venus.TextSegmentWindow
If any steps are highlighted, this erases the highlighting.
UNLIMITED_SPEED –
Static variable in class mars.venus.RunSpeedPanel
Constant that represents unlimited run speed.
unredoing –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
unsignedIntToIntString(int) –
Static method in class mars.util.Binary
Produce String equivalent of integer value interpreting it as an unsigned integer.
update(Observable, Object) –
Method in class mars.tools.AbstractMarsToolAndApplication
Called when receiving notice of access to MIPS memory or registers.
update(Observable, Object) –
Method in class mars.tools.DigitalLabSim
update(Observable, Object) –
Method in class mars.tools.FloatRepresentation
Override inherited update() to update display when “attached” register is modified
either by MIPS program or by user editing it on the MARS user interface.
update(Observable, Object) –
Method in class mars.tools.MarsBot
update(Observable, Object) –
Method in class mars.tools.ScavengerHunt
update(Observable, Object) –
Method in class mars.venus.Coprocessor0Window
Required by Observer interface.
update(Observable, Object) –
Method in class mars.venus.Coprocessor1Window
Required by Observer interface.
update(Observable, Object) –
Method in class mars.venus.DataSegmentWindow
Required by Observer interface.
update(Observable, Object) –
Method in class mars.venus.EditPane
Update, if source code is visible, when Font setting changes.
update(Observable, Object) –
Method in class mars.venus.RegistersWindow
Required by Observer interface.
update(Observable, Object) –
Method in class mars.venus.TextSegmentWindow
Required by Observer interface.
updateBaseAddressComboBox() –
Method in class mars.venus.DataSegmentWindow
updateBasicStatements() –
Method in class mars.venus.TextSegmentWindow
Redisplay the basic statements.
updateBracketHighlight(int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
updateCell(int, int) –
Method in class mars.venus.DataSegmentWindow
Update data display to show this value (I’m not sure it is being called).
updateCodeAddresses() –
Method in class mars.venus.TextSegmentWindow
Redisplay the addresses.
updateDataAddresses() –
Method in class mars.venus.DataSegmentWindow
Redisplay the addresses.
updateDisplay() –
Method in class mars.tools.AbstractMarsToolAndApplication
Override this method to implement updating of GUI after each MIPS instruction is executed,
while running in “timed” mode (user specifies execution speed on the slider control).
updateDisplay() –
Method in class mars.tools.BitmapDisplay
Updates display immediately after each update (AccessNotice) is processed, after
display configuration changes as needed, and after each execution step when Mars
is running in timed mode.
updateDisplay() –
Method in class mars.tools.CacheSimulator
Updates display immediately after each update (AccessNotice) is processed, after
cache configuration changes as needed, and after each execution step when Mars
is running in timed mode.
updateDisplay() –
Method in class mars.tools.InstructionCounter
updateDisplay() –
Method in class mars.tools.InstructionStatistics
updates the text fields and progress bars according to the current counter values.
updateDisplay() –
Method in class mars.tools.MemoryReferenceVisualization
Updates display immediately after each update (AccessNotice) is processed, after
display configuration changes as needed, and after each execution step when Mars
is running in timed mode.
updateDoubleRegisterValue(int, int) –
Method in class mars.venus.Coprocessor1Window
This method handles the updating of the GUI.
updateFloatRegisterValue(int, int, int) –
Method in class mars.venus.Coprocessor1Window
This method handles the updating of the GUI.
updateHexaKeyboard(char) –
Method in class mars.tools.DigitalLabSim
updateLabelAddresses() –
Method in class mars.venus.LabelsWindow
Method to update display of label addresses.
updateModelForMemoryRange(int) –
Method in class mars.venus.DataSegmentWindow
Update table model with contents of new memory “chunk”.
updateOneSecondCounter(char) –
Method in class mars.tools.DigitalLabSim
updatePrediction(boolean) –
Method in class mars.tools.BHTEntry
Updates the entry’s history and prediction.
updatePredictionAtIdx(int, boolean) –
Method in class mars.tools.BHTableModel
Updates the BHT entry with the outcome of the branch instruction.
updateRedoState() –
Method in class mars.venus.EditPane
Update state of Edit menu’s Redo menu item.
updateRegister(String, int) –
Static method in class mars.mips.hardware.Coprocessor0
Sets the value of the register given to the value given.
updateRegister(int, int) –
Static method in class mars.mips.hardware.Coprocessor0
This method updates the register value who’s number is num.
updateRegister(int, int) –
Static method in class mars.mips.hardware.Coprocessor1
This method updates the FPU register value who’s number is num.
updateRegister(int, int) –
Static method in class mars.mips.hardware.RegisterFile
This method updates the register value who’s number is num.
updateRegister(String, int) –
Static method in class mars.mips.hardware.RegisterFile
Sets the value of the register given to the value given.
updateRegisters() –
Method in class mars.venus.Coprocessor0Window
Update register display using current display base (10 or 16)
updateRegisters(int) –
Method in class mars.venus.Coprocessor0Window
Update register display using specified display base
updateRegisters() –
Method in class mars.venus.Coprocessor1Window
Redisplay registers using current display number base (10 or 16)
updateRegisters(int) –
Method in class mars.venus.Coprocessor1Window
Redisplay registers using specified display number base (10 or 16)
updateRegisters() –
Method in class mars.venus.RegistersWindow
update register display using current number base (10 or 16)
updateRegisters(int) –
Method in class mars.venus.RegistersWindow
update register display using specified number base (10 or 16)
updateRegisterValue(int, int, int) –
Method in class mars.venus.Coprocessor0Window
This method handles the updating of the GUI.
updateRegisterValue(int, int, int) –
Method in class mars.venus.RegistersWindow
This method handles the updating of the GUI.
updateScrollBars() –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Updates the state of the scroll bars.
updateSevenSegment(int, char) –
Method in class mars.tools.DigitalLabSim
updateStaticFileStatus() –
Method in class mars.venus.EditPane
Delegates to corresponding FileStatus method
updateStaticFileStatus() –
Method in class mars.venus.FileStatus
Update static FileStatus fields with values from this FileStatus object
To support legacy code that depends on the static.
updateSyntaxStyles() –
Method in class mars.venus.editors.generic.GenericTextArea
Does nothing, but required by the interface.
updateSyntaxStyles() –
Method in class mars.venus.editors.jeditsyntax.JEditBasedTextArea
Update the syntax style table, which is obtained from
SyntaxUtilities.
updateSyntaxStyles() –
Method in interface mars.venus.editors.MARSTextEditingArea
updateUndoState() –
Method in class mars.venus.EditPane
Update state of Edit menu’s Undo menu item.
updateValues() –
Method in class mars.venus.DataSegmentWindow
Update data display to show all values
userHighAddress –
Static variable in class mars.mips.hardware.Memory
highest address accessible in user (not kernel) mode.
userInputAlert –
Static variable in class mars.Globals
String to GUI’s RunI/O text area when echoing user input from pop-up dialog.
usingCompactMemoryConfiguration() –
Method in class mars.mips.hardware.Memory
Determine whether the current memory configuration has a maximum address that can be stored
in 16 bits.
V
VADDR –
Static variable in class mars.mips.hardware.Coprocessor0
Coprocessor register names
VenusUI – Class in mars.venus
Top level container for Venus GUI.
VenusUI(String) –
Constructor for class mars.venus.VenusUI
Constructor for the Class.
version –
Static variable in class mars.Globals
The current MARS version number.
vertical –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
visibleLines –
Variable in class mars.venus.editors.jeditsyntax.JEditTextArea
W
WARNING –
Static variable in class mars.ErrorMessage
Constant to indicate this message is warning not error
WARNING_MESSAGE_PREFIX –
Static variable in class mars.ErrorList
warningCount() –
Method in class mars.ErrorList
Count of number of warning messages in list.
WARNINGS_ARE_ERRORS –
Static variable in class mars.Settings
Flag to determine whether or not assembler warnings are considered errors.
warningsOccurred() –
Method in class mars.ErrorList
Determine whether warning has occured or not.
width –
Variable in class mars.venus.HardcopyWriter
willBranch(ProgramStatement) –
Static method in class mars.tools.BHTSimulator
Checks if the branch instruction delivered as parameter will branch or not.
WORD –
Static variable in class mars.assembler.Directives
WORD_LENGTH_BYTES –
Static variable in class mars.mips.hardware.Memory
MIPS word length in bytes.
WORD_SIZE –
Static variable in class mars.assembler.DataTypes
Number of bytes occupied by MIPS word is 4.
wordAligned(int) –
Static method in class mars.mips.hardware.Memory
Utility to determine if given address is word-aligned.
WRITE –
Static variable in class mars.mips.hardware.AccessNotice
Indicates the purpose of access was to write.
write(char[], int, int) –
Method in class mars.venus.HardcopyWriter
This is the write( ) method of the stream.
writeToFile(int, byte[], int) –
Static method in class mars.util.SystemIO
Write bytes to file.
X
x0 –
Variable in class mars.venus.HardcopyWriter
xToOffset(int, int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Converts an x co-ordinate to an offset within a line.
xyToOffset(int, int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Converts a point to an offset, from the start of the text.
Y
y0 –
Variable in class mars.venus.HardcopyWriter
yToLine(int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Converts a y co-ordinate to a line index.
_
_offsetToX(int, int) –
Method in class mars.venus.editors.jeditsyntax.JEditTextArea
Converts an offset in a line into an x co-ordinate.
A B C D E F G H I J K L M N O P Q R S T U V W X Y _
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Generated Documentation (Untitled)
Frame Alert
This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
Link toNon-frame version.
Assembler
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.assembler
Class Assembler
java.lang.Object
mars.assembler.Assembler
public class Assembler
extends Object
An Assembler is capable of assembling a MIPS program. It has only one public
method, assemble(), which implements a two-pass assembler. It
translates MIPS source code into binary machine code.
Author:
Pete Sanderson
Constructor Summary
Assembler()
Method Summary
ArrayList assemble(ArrayList tokenizedProgramFiles,
boolean extendedAssemblerEnabled)
Parse and generate machine code for the given MIPS program.
ArrayList assemble(ArrayList tokenizedProgramFiles,
boolean extendedAssemblerEnabled,
boolean warningsAreErrors)
Parse and generate machine code for the given MIPS program.
ArrayList assemble(MIPSprogram p,
boolean extendedAssemblerEnabled)
Parse and generate machine code for the given MIPS program.
ArrayList assemble(MIPSprogram p,
boolean extendedAssemblerEnabled,
boolean warningsAreErrors)
Parse and generate machine code for the given MIPS program.
ErrorList getErrorList()
Get list of assembler errors and warnings
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
Assembler
public Assembler()
Method Detail
assemble
public ArrayList assemble(MIPSprogram p,
boolean extendedAssemblerEnabled)
throws ProcessingException
Parse and generate machine code for the given MIPS program. It must have
already been tokenized. Warnings are not considered errors.
Parameters:
p – A MIPSprogram object representing the program source.
extendedAssemblerEnabled – A boolean value that if true permits use of extended (pseudo)
instructions in the source code. If false, these are flagged
as errors.
Returns:
An ArrayList representing the assembled program. Each member of
the list is a ProgramStatement object containing the source,
intermediate, and machine binary representations of a program
statement.
Throws:
ProcessingException
See Also:
ProgramStatement
assemble
public ArrayList assemble(MIPSprogram p,
boolean extendedAssemblerEnabled,
boolean warningsAreErrors)
throws ProcessingException
Parse and generate machine code for the given MIPS program. It must have
already been tokenized.
Parameters:
p – A MIPSprogram object representing the program source.
extendedAssemblerEnabled – A boolean value that if true permits use of extended (pseudo)
instructions in the source code. If false, these are flagged
as errors.
warningsAreErrors – A boolean value – true means assembler warnings will be
considered errors and terminate the assemble; false means the
assembler will produce warning message but otherwise ignore
warnings.
Returns:
An ArrayList representing the assembled program. Each member of
the list is a ProgramStatement object containing the source,
intermediate, and machine binary representations of a program
statement.
Throws:
ProcessingException
See Also:
ProgramStatement
getErrorList
public ErrorList getErrorList()
Get list of assembler errors and warnings
Returns:
ErrorList of any assembler errors and warnings.
assemble
public ArrayList assemble(ArrayList tokenizedProgramFiles,
boolean extendedAssemblerEnabled)
throws ProcessingException
Parse and generate machine code for the given MIPS program. All source
files must have already been tokenized. Warnings will not be considered
errors.
Parameters:
tokenizedProgramFiles – An ArrayList of MIPSprogram objects, each produced from a
different source code file, representing the program source.
extendedAssemblerEnabled – A boolean value that if true permits use of extended (pseudo)
instructions in the source code. If false, these are flagged
as errors.
Returns:
An ArrayList representing the assembled program. Each member of
the list is a ProgramStatement object containing the source,
intermediate, and machine binary representations of a program
statement. Returns null if incoming array list is null or empty.
Throws:
ProcessingException
See Also:
ProgramStatement
assemble
public ArrayList assemble(ArrayList tokenizedProgramFiles,
boolean extendedAssemblerEnabled,
boolean warningsAreErrors)
throws ProcessingException
Parse and generate machine code for the given MIPS program. All source
files must have already been tokenized.
Parameters:
tokenizedProgramFiles – An ArrayList of MIPSprogram objects, each produced from a
different source code file, representing the program source.
extendedAssemblerEnabled – A boolean value that if true permits use of extended (pseudo)
instructions in the source code. If false, these are flagged
as errors.
warningsAreErrors – A boolean value – true means assembler warnings will be
considered errors and terminate the assemble; false means the
assembler will produce warning message but otherwise ignore
warnings.
Returns:
An ArrayList representing the assembled program. Each member of
the list is a ProgramStatement object containing the source,
intermediate, and machine binary representations of a program
statement. Returns null if incoming array list is null or empty.
Throws:
ProcessingException
See Also:
ProgramStatement
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
DataTypes
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.assembler
Class DataTypes
java.lang.Object
mars.assembler.DataTypes
public final class DataTypes
extends Object
Information about MIPS data types.
Author:
Pete Sanderson
Field Summary
static int BYTE_SIZE
Number of bytes occupied by MIPS byte is 1.
static int CHAR_SIZE
Number of bytes occupied by MIPS character is 1.
static int DOUBLE_SIZE
Number of bytes occupied by MIPS double is 8.
static int FLOAT_SIZE
Number of bytes occupied by MIPS float is 4.
static int HALF_SIZE
Number of bytes occupied by MIPS halfword is 2.
static double LOW_DOUBLE_VALUE
Largest magnitude negative value that can be stored in a MIPS double(negative of the max)
static double LOW_FLOAT_VALUE
Largest magnitude negative value that can be stored in a MIPS float (negative of the max)
static int MAX_BYTE_VALUE
Maximum value that can be stored in a MIPS byte is 27-1
static double MAX_DOUBLE_VALUE
Maximum positive finite value that can be stored in a MIPS double is same as Java Double
static double MAX_FLOAT_VALUE
Maximum positive finite value that can be stored in a MIPS float is same as Java Float
static int MAX_HALF_VALUE
Maximum value that can be stored in a MIPS halfword is 215-1
static int MAX_UHALF_VALUE
Maximum value that can be stored in an unsigned MIPS halfword is 216-1
static int MAX_WORD_VALUE
Maximum value that can be stored in a MIPS word is 231-1
static int MIN_BYTE_VALUE
Lowest value that can be stored in a MIPS byte is -27
static int MIN_HALF_VALUE
Lowest value that can be stored in a MIPS halfword is -215
static int MIN_UHALF_VALUE
Lowest value that can be stored in na unsigned MIPS halfword is 0
static int MIN_WORD_VALUE
Lowest value that can be stored in a MIPS word is -231
static int WORD_SIZE
Number of bytes occupied by MIPS word is 4.
Constructor Summary
DataTypes()
Method Summary
static int getLengthInBytes(Directives direct)
Get length in bytes for numeric MIPS directives.
static boolean outOfRange(Directives direct,
double value)
Determines whether given floating point value falls within value range for given directive.
static boolean outOfRange(Directives direct,
int value)
Determines whether given integer value falls within value range for given directive.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
DOUBLE_SIZE
public static final int DOUBLE_SIZE
Number of bytes occupied by MIPS double is 8.
See Also:
Constant Field Values
FLOAT_SIZE
public static final int FLOAT_SIZE
Number of bytes occupied by MIPS float is 4.
See Also:
Constant Field Values
WORD_SIZE
public static final int WORD_SIZE
Number of bytes occupied by MIPS word is 4.
See Also:
Constant Field Values
HALF_SIZE
public static final int HALF_SIZE
Number of bytes occupied by MIPS halfword is 2.
See Also:
Constant Field Values
BYTE_SIZE
public static final int BYTE_SIZE
Number of bytes occupied by MIPS byte is 1.
See Also:
Constant Field Values
CHAR_SIZE
public static final int CHAR_SIZE
Number of bytes occupied by MIPS character is 1.
See Also:
Constant Field Values
MAX_WORD_VALUE
public static final int MAX_WORD_VALUE
Maximum value that can be stored in a MIPS word is 231-1
See Also:
Constant Field Values
MIN_WORD_VALUE
public static final int MIN_WORD_VALUE
Lowest value that can be stored in a MIPS word is -231
See Also:
Constant Field Values
MAX_HALF_VALUE
public static final int MAX_HALF_VALUE
Maximum value that can be stored in a MIPS halfword is 215-1
See Also:
Constant Field Values
MIN_HALF_VALUE
public static final int MIN_HALF_VALUE
Lowest value that can be stored in a MIPS halfword is -215
See Also:
Constant Field Values
MAX_UHALF_VALUE
public static final int MAX_UHALF_VALUE
Maximum value that can be stored in an unsigned MIPS halfword is 216-1
See Also:
Constant Field Values
MIN_UHALF_VALUE
public static final int MIN_UHALF_VALUE
Lowest value that can be stored in na unsigned MIPS halfword is 0
See Also:
Constant Field Values
MAX_BYTE_VALUE
public static final int MAX_BYTE_VALUE
Maximum value that can be stored in a MIPS byte is 27-1
See Also:
Constant Field Values
MIN_BYTE_VALUE
public static final int MIN_BYTE_VALUE
Lowest value that can be stored in a MIPS byte is -27
See Also:
Constant Field Values
MAX_FLOAT_VALUE
public static final double MAX_FLOAT_VALUE
Maximum positive finite value that can be stored in a MIPS float is same as Java Float
See Also:
Constant Field Values
LOW_FLOAT_VALUE
public static final double LOW_FLOAT_VALUE
Largest magnitude negative value that can be stored in a MIPS float (negative of the max)
See Also:
Constant Field Values
MAX_DOUBLE_VALUE
public static final double MAX_DOUBLE_VALUE
Maximum positive finite value that can be stored in a MIPS double is same as Java Double
See Also:
Constant Field Values
LOW_DOUBLE_VALUE
public static final double LOW_DOUBLE_VALUE
Largest magnitude negative value that can be stored in a MIPS double(negative of the max)
See Also:
Constant Field Values
Constructor Detail
DataTypes
public DataTypes()
Method Detail
getLengthInBytes
public static int getLengthInBytes(Directives direct)
Get length in bytes for numeric MIPS directives.
Parameters:
direct – Directive to be measured.
Returns:
Returns length in bytes for values of that type. If type is not numeric
(or not implemented yet), returns 0.
outOfRange
public static boolean outOfRange(Directives direct,
int value)
Determines whether given integer value falls within value range for given directive.
Parameters:
direct – Directive that controls storage allocation for value.
value – The value to be stored.
Returns:
Returns true if value can be stored in the number of bytes allowed
by the given directive (.word, .half, .byte), false otherwise.
outOfRange
public static boolean outOfRange(Directives direct,
double value)
Determines whether given floating point value falls within value range for given directive.
For float, this refers to range of the data type, not precision. Example: 1.23456789012345
be stored in a float with loss of precision. It’s within the range. But 1.23e500 cannot be
stored in a float because the exponent 500 is too large (float allows 8 bits for exponent).
Parameters:
direct – Directive that controls storage allocation for value.
value – The value to be stored.
Returns:
Returns true if value is within range of
the given directive (.float, .double), false otherwise.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Directives
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.assembler
Class Directives
java.lang.Object
mars.assembler.Directives
public final class Directives
extends Object
Class representing MIPS assembler directives. If Java had enumerated types, these
would probably be implemented that way. Each directive is represented by a unique object.
The directive name is indicative of the directive it represents. For example, DATA
represents the MIPS .data directive.
Author:
Pete Sanderson
Field Summary
static Directives ALIGN
static Directives ASCII
static Directives ASCIIZ
static Directives BYTE
static Directives DATA
static Directives DOUBLE
static Directives END_MACRO
static Directives EQV
static Directives EXTERN
static Directives FLOAT
static Directives GLOBL
static Directives HALF
static Directives INCLUDE
static Directives KDATA
static Directives KTEXT
static Directives MACRO
static Directives SET
static Directives SPACE
static Directives TEXT
static Directives WORD
Method Summary
String getDescription()
Get description of this Directives object
static ArrayList getDirectiveList()
Produces List of Directive objects
String getName()
Get name of this Directives object
static boolean isFloatingDirective(Directives direct)
Lets you know whether given directive is for floating number (FLOAT,DOUBLE).
static boolean isIntegerDirective(Directives direct)
Lets you know whether given directive is for integer (WORD,HALF,BYTE).
static Directives matchDirective(String str)
Find Directive object, if any, which matches the given String.
static ArrayList prefixMatchDirectives(String str)
Find Directive object, if any, which contains the given string as a prefix.
String toString()
Produces String-ified version of Directive object
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
DATA
public static final Directives DATA
TEXT
public static final Directives TEXT
WORD
public static final Directives WORD
ASCII
public static final Directives ASCII
ASCIIZ
public static final Directives ASCIIZ
BYTE
public static final Directives BYTE
ALIGN
public static final Directives ALIGN
HALF
public static final Directives HALF
SPACE
public static final Directives SPACE
DOUBLE
public static final Directives DOUBLE
FLOAT
public static final Directives FLOAT
EXTERN
public static final Directives EXTERN
KDATA
public static final Directives KDATA
KTEXT
public static final Directives KTEXT
GLOBL
public static final Directives GLOBL
SET
public static final Directives SET
EQV
public static final Directives EQV
MACRO
public static final Directives MACRO
END_MACRO
public static final Directives END_MACRO
INCLUDE
public static final Directives INCLUDE
Method Detail
matchDirective
public static Directives matchDirective(String str)
Find Directive object, if any, which matches the given String.
Parameters:
str – A String containing candidate directive name (e.g. “.ascii”)
Returns:
If match is found, returns matching Directives object, else returns null.
prefixMatchDirectives
public static ArrayList prefixMatchDirectives(String str)
Find Directive object, if any, which contains the given string as a prefix. For example,
“.a” will match “.ascii”, “.asciiz” and “.align”
Parameters:
str – A String
Returns:
If match is found, returns ArrayList of matching Directives objects, else returns null.
toString
public String toString()
Produces String-ified version of Directive object
Overrides:
toString in class Object
Returns:
String representing Directive: its MIPS name
getName
public String getName()
Get name of this Directives object
Returns:
name of this MIPS directive as a String
getDescription
public String getDescription()
Get description of this Directives object
Returns:
description of this MIPS directive (for help purposes)
getDirectiveList
public static ArrayList getDirectiveList()
Produces List of Directive objects
Returns:
MIPS Directive
isIntegerDirective
public static boolean isIntegerDirective(Directives direct)
Lets you know whether given directive is for integer (WORD,HALF,BYTE).
Parameters:
direct – a MIPS directive
Returns:
true if given directive is FLOAT or DOUBLE, false otherwise
isFloatingDirective
public static boolean isFloatingDirective(Directives direct)
Lets you know whether given directive is for floating number (FLOAT,DOUBLE).
Parameters:
direct – a MIPS directive
Returns:
true if given directive is FLOAT or DOUBLE, false otherwise.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Macro
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.assembler
Class Macro
java.lang.Object
mars.assembler.Macro
public class Macro
extends Object
Stores information of a macro definition.
Author:
M.H.Sekhavat
Constructor Summary
Macro()
Method Summary
void addArg(String value)
void addLabel(String value)
boolean equals(Object obj)
ArrayList
int getFromLine()
String getName()
int getOriginalFromLine()
int getOriginalToLine()
MIPSprogram getProgram()
String getSubstitutedLine(int line,
TokenList args,
long counter,
ErrorList errors)
Substitutes macro arguments in a line of source code inside macro
definition to be parsed after macro expansion.
int getToLine()
void readyForCommit()
Operations to be done on this macro before it is committed in macro pool.
void setArgs(ArrayList
void setFromLine(int fromLine)
void setName(String name)
void setOriginalFromLine(int origFromLine)
void setOriginalToLine(int origToLine)
void setProgram(MIPSprogram program)
void setToLine(int toLine)
static boolean tokenIsMacroParameter(String tokenValue,
boolean acceptSpimStyleParameters)
returns whether tokenValue is macro parameter or not
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
Macro
public Macro()
Method Detail
getName
public String getName()
setName
public void setName(String name)
getProgram
public MIPSprogram getProgram()
setProgram
public void setProgram(MIPSprogram program)
getFromLine
public int getFromLine()
getOriginalFromLine
public int getOriginalFromLine()
setFromLine
public void setFromLine(int fromLine)
setOriginalFromLine
public void setOriginalFromLine(int origFromLine)
getToLine
public int getToLine()
getOriginalToLine
public int getOriginalToLine()
setToLine
public void setToLine(int toLine)
setOriginalToLine
public void setOriginalToLine(int origToLine)
getArgs
public ArrayList
setArgs
public void setArgs(ArrayList
equals
public boolean equals(Object obj)
Overrides:
equals in class Object
Parameters:
obj – Macro object to check if their name and count of
arguments are same
addArg
public void addArg(String value)
getSubstitutedLine
public String getSubstitutedLine(int line,
TokenList args,
long counter,
ErrorList errors)
Substitutes macro arguments in a line of source code inside macro
definition to be parsed after macro expansion.
Also appends “_M#” to all labels defined inside macro body where # is value of counter
Parameters:
line – source line number in macro definition to be substituted
args –
counter – unique macro expansion id
errors –
Returns:
line-th line of source code, with substituted
arguments
tokenIsMacroParameter
public static boolean tokenIsMacroParameter(String tokenValue,
boolean acceptSpimStyleParameters)
returns whether tokenValue is macro parameter or not
Parameters:
tokenValue –
acceptSpimStyleParameters – accepts SPIM-style parameters which begin with ‘$’ if true
Returns:
addLabel
public void addLabel(String value)
readyForCommit
public void readyForCommit()
Operations to be done on this macro before it is committed in macro pool.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
MacroPool
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.assembler
Class MacroPool
java.lang.Object
mars.assembler.MacroPool
public class MacroPool
extends Object
Stores information of macros defined by now.
Will be used in first pass of assembling MIPS source code. When reached
.macro directive, parser calls
MacroPool#BeginMacro(String, int) and skips source code lines until
reaches .end_macro directive. then calls
MacroPool#CommitMacro(int) and the macro information stored in a
Macro instance will be added to macroList.
Each MIPSprogram will have one MacroPool
NOTE: Forward referencing macros (macro expansion before its definition in
source code) and Nested macro definition (defining a macro inside other macro
definition) are not supported.
Author:
M.H.Sekhavat
Constructor Summary
MacroPool(MIPSprogram mipsProgram)
Create an empty MacroPool for given program
Method Summary
void beginMacro(Token nameToken)
This method will be called by parser when reached .macro
directive.
Instantiates a new Macro object and stores it in current
.
void commitMacro(Token endToken)
This method will be called by parser when reached .end_macro
directive.
ArrayList
Macro getCurrent()
String getExpansionHistory()
Macro getMatchingMacro(TokenList tokens,
int callerLine)
Will be called by parser when reaches a macro expansion call
int getNextCounter()
counter will be set to 0 on construction of this class and will
be incremented by each call.
boolean matchesAnyMacroName(String value)
void popFromCallStack()
boolean pushOnCallStack(Token token)
void setCurrent(Macro current)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
MacroPool
public MacroPool(MIPSprogram mipsProgram)
Create an empty MacroPool for given program
Parameters:
mipsProgram – associated MIPS program
Method Detail
beginMacro
public void beginMacro(Token nameToken)
This method will be called by parser when reached .macro
directive.
Instantiates a new Macro object and stores it in current
. current will be added to macroList by
#CommitMacro(int)
Parameters:
nameToken – Token containing name of macro after .macro directive
commitMacro
public void commitMacro(Token endToken)
This method will be called by parser when reached .end_macro
directive.
Adds/Replaces current macro into the macroList.
Parameters:
endToken – Token containing .end_macro directive in source code
getMatchingMacro
public Macro getMatchingMacro(TokenList tokens,
int callerLine)
Will be called by parser when reaches a macro expansion call
Parameters:
tokens – tokens passed to macro expansion call
Returns:
Macro object matching the name and argument count of
tokens passed
matchesAnyMacroName
public boolean matchesAnyMacroName(String value)
Parameters:
value –
Returns:
true if any macros have been defined with name value
by now, not concerning arguments count.
getCurrent
public Macro getCurrent()
setCurrent
public void setCurrent(Macro current)
getNextCounter
public int getNextCounter()
counter will be set to 0 on construction of this class and will
be incremented by each call. parser calls this method once for every
expansions. it will be a unique id for each expansion of macro in a file
Returns:
counter value
getCallStack
public ArrayList
pushOnCallStack
public boolean pushOnCallStack(Token token)
popFromCallStack
public void popFromCallStack()
getExpansionHistory
public String getExpansionHistory()
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
OperandFormat
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.assembler
Class OperandFormat
java.lang.Object
mars.assembler.OperandFormat
public class OperandFormat
extends Object
Provides utility method related to MIPS operand formats.
Author:
Pete Sanderson
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.assembler
mars.assembler
Interfaces
TranslationCode
Classes
Assembler
DataTypes
Directives
Macro
MacroPool
OperandFormat
SourceLine
Symbol
SymbolTable
Token
Tokenizer
TokenList
TokenTypes
mars.assembler
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
Package mars.assembler
Interface Summary
TranslationCode This interface is intended for use by ExtendedInstruction objects to define, using
the translate() method, how to translate the extended (pseudo) instruction into
a sequence of one or more basic instructions, which can then be translated into
binary machine code.
Class Summary
Assembler An Assembler is capable of assembling a MIPS program.
DataTypes Information about MIPS data types.
Directives Class representing MIPS assembler directives.
Macro Stores information of a macro definition.
MacroPool Stores information of macros defined by now.
OperandFormat Provides utility method related to MIPS operand formats.
SourceLine Handy class to represent, for a given line of source code, the code
itself, the program containing it, and its line number within that program.
Symbol Represents a MIPS program identifier to be stored in the symbol table.
SymbolTable Creats a table of Symbol objects.
Token Represents one token in the input MIPS program.
Tokenizer A tokenizer is capable of tokenizing a complete MIPS program, or a given line from
a MIPS program.
TokenList Represents the list of tokens in a single line of MIPS code.
TokenTypes Constants to identify the types of tokens found in MIPS programs.
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
mars.assembler Class Hierarchy
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Hierarchy For Package mars.assembler
Package Hierarchies:
All Packages
Class Hierarchy
java.lang.Object mars.assembler.Assembler
mars.assembler.DataTypes
mars.assembler.Directives
mars.assembler.Macro
mars.assembler.MacroPool
mars.assembler.OperandFormat
mars.assembler.SourceLine
mars.assembler.Symbol
mars.assembler.SymbolTable
mars.assembler.Token
mars.assembler.Tokenizer
mars.assembler.TokenList (implements java.lang.Cloneable)
mars.assembler.TokenTypes
Interface Hierarchy
mars.assembler.TranslationCode
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
SourceLine
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.assembler
Class SourceLine
java.lang.Object
mars.assembler.SourceLine
public class SourceLine
extends Object
Handy class to represent, for a given line of source code, the code
itself, the program containing it, and its line number within that program.
This is used to separately keep track of the original file/position of
a given line of code. When .include is used, it will migrate to a different
line and possibly different program but the migration should not be visible
to the user.
Constructor Summary
SourceLine(String source,
MIPSprogram mipsProgram,
int lineNumber)
SourceLine constructor
Method Summary
String getFilename()
Retrieve name of file containing source statement
int getLineNumber()
Retrieve line number of source statement
MIPSprogram getMIPSprogram()
Retrieve MIPSprogram object containing source statement
String getSource()
Retrieve source statement itself
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SourceLine
public SourceLine(String source,
MIPSprogram mipsProgram,
int lineNumber)
SourceLine constructor
Parameters:
source – The source code itself
mipsProgram – The program (object representing source file) containing that line
lineNumber – The line number within that program where source appears.
Method Detail
getSource
public String getSource()
Retrieve source statement itself
Returns:
Source statement as String
getFilename
public String getFilename()
Retrieve name of file containing source statement
Returns:
File name as String
getLineNumber
public int getLineNumber()
Retrieve line number of source statement
Returns:
Line number of source statement
getMIPSprogram
public MIPSprogram getMIPSprogram()
Retrieve MIPSprogram object containing source statement
Returns:
program as MIPSprogram object
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Symbol
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.assembler
Class Symbol
java.lang.Object
mars.assembler.Symbol
public class Symbol
extends Object
Represents a MIPS program identifier to be stored in the symbol table.
Author:
Jason Bumgarner, Jason Shrewsbury
Field Summary
static boolean DATA_SYMBOL
static boolean TEXT_SYMBOL
Constructor Summary
Symbol(String name,
int address,
boolean data)
Basic constructor, creates a symbol object.
Method Summary
int getAddress()
Returns the address of the the Symbol.
String getName()
Returns the label of the the Symbol.
boolean getType()
Finds the type of symbol, text or data.
void setAddress(int newAddress)
Sets (replaces) the address of the the Symbol.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
TEXT_SYMBOL
public static final boolean TEXT_SYMBOL
See Also:
Constant Field Values
DATA_SYMBOL
public static final boolean DATA_SYMBOL
See Also:
Constant Field Values
Constructor Detail
Symbol
public Symbol(String name,
int address,
boolean data)
Basic constructor, creates a symbol object.
Parameters:
name – The name of the Symbol.
address – The memroy address that the Symbol refers to.
data – The type of Symbol that it is.
Method Detail
getAddress
public int getAddress()
Returns the address of the the Symbol.
Returns:
The address of the Symbol.
getName
public String getName()
Returns the label of the the Symbol.
Returns:
The label of the Symbol.
getType
public boolean getType()
Finds the type of symbol, text or data.
Returns:
The type of the data.
setAddress
public void setAddress(int newAddress)
Sets (replaces) the address of the the Symbol.
Parameters:
newAddress – The revised address of the Symbol.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SymbolTable
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.assembler
Class SymbolTable
java.lang.Object
mars.assembler.SymbolTable
public class SymbolTable
extends Object
Creats a table of Symbol objects.
Author:
Jason Bumgarner, Jason Shrewsbury
Field Summary
static int NOT_FOUND
Constructor Summary
SymbolTable(String filename)
Create a new empty symbol table for given file
Method Summary
void addSymbol(Token token,
int address,
boolean b,
ErrorList errors)
Adds a Symbol object into the array of Symbols.
void clear()
Creates a fresh arrayList for a new table.
void fixSymbolTableAddress(int originalAddress,
int replacementAddress)
Fix address in symbol table entry.
int getAddress(String s)
Method to return the address associated with the given label.
int getAddressLocalOrGlobal(String s)
Method to return the address associated with the given label.
ArrayList getAllSymbols()
For obtaining all the Symbols.
ArrayList getDataSymbols()
For obtaining the Data Symbols.
int getSize()
Get the count of entries currently in the table.
static String getStartLabel()
Fetches the text segment label (symbol) which, if declared global, indicates
the starting address for execution.
Symbol getSymbol(String s)
Produce Symbol object from symbol table that corresponds to given String.
Symbol getSymbolGivenAddress(String s)
Produce Symbol object from symbol table that has the given address.
Symbol getSymbolGivenAddressLocalOrGlobal(String s)
Produce Symbol object from either local or global symbol table that has the
given address.
ArrayList getTextSymbols()
For obtaining the Text Symbols.
void removeSymbol(Token token)
Removes a symbol from the Symbol table.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
NOT_FOUND
public static final int NOT_FOUND
See Also:
Constant Field Values
Constructor Detail
SymbolTable
public SymbolTable(String filename)
Create a new empty symbol table for given file
Parameters:
filename – name of file this symbol table is associated with. Will be
used only for output/display so it can be any descriptive string.
Method Detail
addSymbol
public void addSymbol(Token token,
int address,
boolean b,
ErrorList errors)
Adds a Symbol object into the array of Symbols.
Parameters:
token – The token representing the Symbol.
address – The address of the Symbol.
b – The type of Symbol, true for data, false for text.
errors – List to which to add any processing errors that occur.
removeSymbol
public void removeSymbol(Token token)
Removes a symbol from the Symbol table. If not found, it does nothing.
This will rarely happen (only when variable is declared .globl after already
being defined in the local symbol table).
Parameters:
token – The token representing the Symbol.
getAddress
public int getAddress(String s)
Method to return the address associated with the given label.
Parameters:
s – The label.
Returns:
The memory address of the label given, or NOT_FOUND if not found in symbol table.
getAddressLocalOrGlobal
public int getAddressLocalOrGlobal(String s)
Method to return the address associated with the given label. Look first
in this (local) symbol table then in symbol table of labels declared
global (.globl directive).
Parameters:
s – The label.
Returns:
The memory address of the label given, or NOT_FOUND if not found in symbol table.
getSymbol
public Symbol getSymbol(String s)
Produce Symbol object from symbol table that corresponds to given String.
Parameters:
s – target String
Returns:
Symbol object for requested target, null if not found in symbol table.
getSymbolGivenAddress
public Symbol getSymbolGivenAddress(String s)
Produce Symbol object from symbol table that has the given address.
Parameters:
s – String representing address
Returns:
Symbol object having requested address, null if address not found in symbol table.
getSymbolGivenAddressLocalOrGlobal
public Symbol getSymbolGivenAddressLocalOrGlobal(String s)
Produce Symbol object from either local or global symbol table that has the
given address.
Parameters:
s – String representing address
Returns:
Symbol object having requested address, null if address not found in symbol table.
getDataSymbols
public ArrayList getDataSymbols()
For obtaining the Data Symbols.
Returns:
An ArrayList of Symbol objects.
getTextSymbols
public ArrayList getTextSymbols()
For obtaining the Text Symbols.
Returns:
An ArrayList of Symbol objects.
getAllSymbols
public ArrayList getAllSymbols()
For obtaining all the Symbols.
Returns:
An ArrayList of Symbol objects.
getSize
public int getSize()
Get the count of entries currently in the table.
Returns:
Number of symbol table entries.
clear
public void clear()
Creates a fresh arrayList for a new table.
fixSymbolTableAddress
public void fixSymbolTableAddress(int originalAddress,
int replacementAddress)
Fix address in symbol table entry. Any and all entries that match the original
address will be modified to contain the replacement address. There is no effect,
if none of the addresses matches.
Parameters:
originalAddress – Address associated with 0 or more symtab entries.
replacementAddress – Any entry that has originalAddress will have its
address updated to this value. Does nothing if none do.
getStartLabel
public static String getStartLabel()
Fetches the text segment label (symbol) which, if declared global, indicates
the starting address for execution.
Returns:
String containing global label whose text segment address is starting address for program execution.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Token
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.assembler
Class Token
java.lang.Object
mars.assembler.Token
public class Token
extends Object
Represents one token in the input MIPS program. Each Token carries, along with its
type and value, the position (line, column) in which its source appears in the MIPS program.
Author:
Pete Sanderson
Constructor Summary
Token(TokenTypes type,
String value,
MIPSprogram sourceMIPSprogram,
int line,
int start)
Constructor for Token class.
Method Summary
MIPSprogram getOriginalProgram()
Produces original program containing this token.
int getOriginalSourceLine()
Produces original line number of this token.
int getSourceLine()
Produces line number of MIPS program of this token.
MIPSprogram getSourceMIPSprogram()
Produces MIPSprogram object associated with this token.
int getStartPos()
Produces position within source line of this token.
TokenTypes getType()
Produces token type of this token.
String getValue()
Produces source code of this token.
void setOriginal(MIPSprogram origProgram,
int origSourceLine)
Set original program and line number for this token.
void setType(TokenTypes type)
Set or modify token type.
String toString()
Get a String representing the token.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
Token
public Token(TokenTypes type,
String value,
MIPSprogram sourceMIPSprogram,
int line,
int start)
Constructor for Token class.
Parameters:
type – The token type that this token has. (e.g. REGISTER_NAME)
value – The source value for this token (e.g. $t3)
sourceMIPSprogram – The MIPSprogram object containing this token
line – The line number in source program in which this token appears.
start – The starting position in that line number of this token’s source value.
See Also:
TokenTypes
Method Detail
setOriginal
public void setOriginal(MIPSprogram origProgram,
int origSourceLine)
Set original program and line number for this token.
Line number or both may change during pre-assembly as a result
of the “.include” directive, and we need to keep the original
for later reference (error messages, text segment display).
Parameters:
origProgram – MIPS program containing this token.
origSourceLine – Line within that program of this token.
getOriginalProgram
public MIPSprogram getOriginalProgram()
Produces original program containing this token.
Returns:
MIPSprogram of origin for this token.
getOriginalSourceLine
public int getOriginalSourceLine()
Produces original line number of this token. It could change as result
of “.include”
Returns:
original line number of this token.
getType
public TokenTypes getType()
Produces token type of this token.
Returns:
TokenType of this token.
setType
public void setType(TokenTypes type)
Set or modify token type. Generally used to note that
an identifier that matches an instruction name is
actually being used as a label.
Parameters:
type – new TokenTypes for this token.
getValue
public String getValue()
Produces source code of this token.
Returns:
String containing source code of this token.
toString
public String toString()
Get a String representing the token. This method is
equivalent to getValue().
Overrides:
toString in class Object
Returns:
String version of the token.
getSourceMIPSprogram
public MIPSprogram getSourceMIPSprogram()
Produces MIPSprogram object associated with this token.
Returns:
MIPSprogram object associated with this token.
getSourceLine
public int getSourceLine()
Produces line number of MIPS program of this token.
Returns:
line number in source program of this token.
getStartPos
public int getStartPos()
Produces position within source line of this token.
Returns:
first character position within source program line of this token.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Tokenizer
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.assembler
Class Tokenizer
java.lang.Object
mars.assembler.Tokenizer
public class Tokenizer
extends Object
A tokenizer is capable of tokenizing a complete MIPS program, or a given line from
a MIPS program. Since MIPS is line-oriented, each line defines a complete statement.
Tokenizing is the process of analyzing the input MIPS program for the purpose of
recognizing each MIPS language element. The types of language elements are known as “tokens”.
MIPS tokens are defined in the TokenTypes class.
Example:
The MIPS statement here: lw $t3, 8($t4) #load third member of array
generates the following token list
IDENTIFIER, COLON, OPERATOR, REGISTER_NAME, COMMA, INTEGER_5, LEFT_PAREN,
REGISTER_NAME, RIGHT_PAREN, COMMENT
Author:
Pete Sanderson
Constructor Summary
Tokenizer()
Simple constructor.
Tokenizer(MIPSprogram program)
Constructor for use with existing MIPSprogram.
Method Summary
ErrorList getErrors()
Fetch this Tokenizer’s error list.
ArrayList tokenize(MIPSprogram p)
Will tokenize a complete MIPS program.
TokenList tokenizeExampleInstruction(String example)
Used only to create a token list for the example provided with each instruction
specification.
TokenList tokenizeLine(int lineNum,
String theLine)
Will tokenize one line of source code.
TokenList tokenizeLine(int lineNum,
String theLine,
ErrorList callerErrorList)
Will tokenize one line of source code.
TokenList tokenizeLine(int lineNum,
String theLine,
ErrorList callerErrorList,
boolean doEqvSubstitutes)
Will tokenize one line of source code.
TokenList tokenizeLine(MIPSprogram program,
int lineNum,
String theLine,
boolean doEqvSubstitutes)
Will tokenize one line of source code.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
Tokenizer
public Tokenizer()
Simple constructor. Initializes empty error list.
Tokenizer
public Tokenizer(MIPSprogram program)
Constructor for use with existing MIPSprogram. Designed to be used with Macro feature.
Parameters:
program – A previously-existing MIPSprogram object or null if none.
Method Detail
tokenize
public ArrayList tokenize(MIPSprogram p)
throws ProcessingException
Will tokenize a complete MIPS program. MIPS is line oriented (not free format),
so we will be line-oriented too.
Parameters:
p – The MIPSprogram to be tokenized.
Returns:
An ArrayList representing the tokenized program. Each list member is a TokenList
that represents a tokenized source statement from the MIPS program.
Throws:
ProcessingException
tokenizeExampleInstruction
public TokenList tokenizeExampleInstruction(String example)
throws ProcessingException
Used only to create a token list for the example provided with each instruction
specification.
Parameters:
example – The example MIPS instruction to be tokenized.
Returns:
An TokenList representing the tokenized instruction. Each list member is a Token
that represents one language element.
Throws:
ProcessingException – This occurs only if the instruction specification itself
contains one or more lexical (i.e. token) errors.
tokenizeLine
public TokenList tokenizeLine(int lineNum,
String theLine)
Will tokenize one line of source code. If lexical errors are discovered,
they are noted in an ErrorMessage object which is added to the ErrorList.
Will NOT throw an exception yet because we want to persevere beyond first error.
Parameters:
lineNum – line number from source code (used in error message)
theLine – String containing source code
Returns:
the generated token list for that line
tokenizeLine
public TokenList tokenizeLine(int lineNum,
String theLine,
ErrorList callerErrorList)
Will tokenize one line of source code. If lexical errors are discovered,
they are noted in an ErrorMessage object which is added to the provided ErrorList
instead of the Tokenizer’s error list. Will NOT throw an exception.
Parameters:
lineNum – line number from source code (used in error message)
theLine – String containing source code
callerErrorList – errors will go into this list instead of tokenizer’s list.
Returns:
the generated token list for that line
tokenizeLine
public TokenList tokenizeLine(int lineNum,
String theLine,
ErrorList callerErrorList,
boolean doEqvSubstitutes)
Will tokenize one line of source code. If lexical errors are discovered,
they are noted in an ErrorMessage object which is added to the provided ErrorList
instead of the Tokenizer’s error list. Will NOT throw an exception.
Parameters:
lineNum – line number from source code (used in error message)
theLine – String containing source code
callerErrorList – errors will go into this list instead of tokenizer’s list.
doEqvSubstitutse – boolean param set true to perform .eqv substitutions, else false
Returns:
the generated token list for that line
tokenizeLine
public TokenList tokenizeLine(MIPSprogram program,
int lineNum,
String theLine,
boolean doEqvSubstitutes)
Will tokenize one line of source code. If lexical errors are discovered,
they are noted in an ErrorMessage object which is added to the provided ErrorList
instead of the Tokenizer’s error list. Will NOT throw an exception.
Parameters:
program – MIPSprogram containing this line of source
lineNum – line number from source code (used in error message)
theLine – String containing source code
doEqvSubstitutes – boolean param set true to perform .eqv substitutions, else false
Returns:
the generated token list for that line
getErrors
public ErrorList getErrors()
Fetch this Tokenizer’s error list.
Returns:
the error list
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
TokenList
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.assembler
Class TokenList
java.lang.Object
mars.assembler.TokenList
All Implemented Interfaces:
Cloneable
public class TokenList
extends Object
implements Cloneable
Represents the list of tokens in a single line of MIPS code. It uses, but is not
a subclass of, ArrayList.
Author:
Pete Sanderson
Constructor Summary
TokenList()
Constructor for objects of class TokenList
Method Summary
void add(Token token)
Adds a Token object to the end of the list.
Object clone()
Makes clone (shallow copy) of this token list object.
Token get(int pos)
Returns requested token given position number (starting at 0).
String getProcessedLine()
Retrieve the source line String associated with this
token list.
boolean isEmpty()
Returns empty/non-empty status of list.
void remove(int pos)
Removes Token object at specified list position.
void set(int pos,
Token replacement)
Replaces token at position with different one.
void setProcessedLine(String line)
Use this to record the source line String for this token list
after possible modification (textual substitution) during
assembly preprocessing.
int size()
Returns number of tokens in list.
String toString()
Get a String representing the token list.
String toTypeString()
Get a String representing the sequence of token types for this list.
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
TokenList
public TokenList()
Constructor for objects of class TokenList
Method Detail
setProcessedLine
public void setProcessedLine(String line)
Use this to record the source line String for this token list
after possible modification (textual substitution) during
assembly preprocessing. The modified source will be displayed in
the Text Segment Display.
Parameters:
line – The source line, possibly modified (possibly not)
getProcessedLine
public String getProcessedLine()
Retrieve the source line String associated with this
token list. It may or may not have been modified during
assembly preprocessing.
Returns:
The source line for this token list.
get
public Token get(int pos)
Returns requested token given position number (starting at 0).
Parameters:
pos – Position in token list.
Returns:
the requested token, or ArrayIndexOutOfBounds exception
set
public void set(int pos,
Token replacement)
Replaces token at position with different one. Will throw
ArrayIndexOutOfBounds exception if position does not exist.
Parameters:
pos – Position in token list.
replacement – Replacement token
size
public int size()
Returns number of tokens in list.
Returns:
token count.
add
public void add(Token token)
Adds a Token object to the end of the list.
Parameters:
token – Token object to be added.
remove
public void remove(int pos)
Removes Token object at specified list position. Uses ArrayList remove method.
Parameters:
pos – Position in token list. Subsequent Tokens are shifted one position left.
Throws:
IndexOutOfBoundsException – if pos is < 0 or >= size()
isEmpty
public boolean isEmpty()
Returns empty/non-empty status of list.
Returns:
true if list has no tokens, else false.
toString
public String toString()
Get a String representing the token list.
Overrides:
toString in class Object
Returns:
String version of the token list
(a blank is inserted after each token).
toTypeString
public String toTypeString()
Get a String representing the sequence of token types for this list.
Returns:
String version of the token types for this list
(a blank is inserted after each token type).
clone
public Object clone()
Makes clone (shallow copy) of this token list object.
Overrides:
clone in class Object
Returns:
the cloned list.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
TokenTypes
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.assembler
Class TokenTypes
java.lang.Object
mars.assembler.TokenTypes
public final class TokenTypes
extends Object
Constants to identify the types of tokens found in MIPS programs. If Java had
enumerated types, that’s how these would probably be implemented.
Author:
Pete Sanderson
Field Summary
static TokenTypes COLON
static TokenTypes COMMENT
static TokenTypes DELIMITER
static TokenTypes DIRECTIVE
static TokenTypes ERROR
static TokenTypes FP_REGISTER_NAME
static TokenTypes IDENTIFIER
static TokenTypes INTEGER_16
static TokenTypes INTEGER_16U
static TokenTypes INTEGER_32
static TokenTypes INTEGER_5
static TokenTypes LEFT_PAREN
static TokenTypes MACRO_PARAMETER
static TokenTypes MINUS
static TokenTypes OPERATOR
static TokenTypes PLUS
static TokenTypes QUOTED_STRING
static TokenTypes REAL_NUMBER
static TokenTypes REGISTER_NAME
note: REGISTER_NAME is token of form $zero whereas REGISTER_NUMBER is token
of form $0.
static TokenTypes REGISTER_NUMBER
static TokenTypes RIGHT_PAREN
static String TOKEN_DELIMITERS
Method Summary
static boolean isFloatingTokenType(TokenTypes type)
Lets you know if given tokentype is for floating point numbers (REAL_NUMBER).
static boolean isIntegerTokenType(TokenTypes type)
Lets you know if given tokentype is for integers (INTGER_5, INTEGER_16, INTEGER_32).
static boolean isValidIdentifier(String value)
static TokenTypes matchTokenType(String value)
Classifies the given token into one of the MIPS types.
String toString()
Produces String equivalent of this token type, which is its name.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
TOKEN_DELIMITERS
public static final String TOKEN_DELIMITERS
See Also:
Constant Field Values
COMMENT
public static final TokenTypes COMMENT
DIRECTIVE
public static final TokenTypes DIRECTIVE
OPERATOR
public static final TokenTypes OPERATOR
DELIMITER
public static final TokenTypes DELIMITER
REGISTER_NAME
public static final TokenTypes REGISTER_NAME
note: REGISTER_NAME is token of form $zero whereas REGISTER_NUMBER is token
of form $0. The former is part of extended assembler, and latter is part
of basic assembler.
REGISTER_NUMBER
public static final TokenTypes REGISTER_NUMBER
FP_REGISTER_NAME
public static final TokenTypes FP_REGISTER_NAME
IDENTIFIER
public static final TokenTypes IDENTIFIER
LEFT_PAREN
public static final TokenTypes LEFT_PAREN
RIGHT_PAREN
public static final TokenTypes RIGHT_PAREN
INTEGER_5
public static final TokenTypes INTEGER_5
INTEGER_16
public static final TokenTypes INTEGER_16
INTEGER_16U
public static final TokenTypes INTEGER_16U
INTEGER_32
public static final TokenTypes INTEGER_32
REAL_NUMBER
public static final TokenTypes REAL_NUMBER
QUOTED_STRING
public static final TokenTypes QUOTED_STRING
PLUS
public static final TokenTypes PLUS
MINUS
public static final TokenTypes MINUS
COLON
public static final TokenTypes COLON
ERROR
public static final TokenTypes ERROR
MACRO_PARAMETER
public static final TokenTypes MACRO_PARAMETER
Method Detail
toString
public String toString()
Produces String equivalent of this token type, which is its name.
Overrides:
toString in class Object
Returns:
String containing descriptive name for token type.
matchTokenType
public static TokenTypes matchTokenType(String value)
Classifies the given token into one of the MIPS types.
Parameters:
value – String containing candidate language element, extracted from MIPS program.
Returns:
Returns the corresponding TokenTypes object if the parameter matches a
defined MIPS token type, else returns null.
isIntegerTokenType
public static boolean isIntegerTokenType(TokenTypes type)
Lets you know if given tokentype is for integers (INTGER_5, INTEGER_16, INTEGER_32).
Parameters:
type – the TokenType of interest
Returns:
true if type is an integer type, false otherwise.
isFloatingTokenType
public static boolean isFloatingTokenType(TokenTypes type)
Lets you know if given tokentype is for floating point numbers (REAL_NUMBER).
Parameters:
type – the TokenType of interest
Returns:
true if type is an floating point type, false otherwise.
isValidIdentifier
public static boolean isValidIdentifier(String value)
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
TranslationCode
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.assembler
Interface TranslationCode
public interface TranslationCode
This interface is intended for use by ExtendedInstruction objects to define, using
the translate() method, how to translate the extended (pseudo) instruction into
a sequence of one or more basic instructions, which can then be translated into
binary machine code.
Author:
Pete Sanderson
Method Summary
void translate()
This is a callback method defined in anonymous class specified as
argument to ExtendedInstruction constructor.
Method Detail
translate
void translate()
This is a callback method defined in anonymous class specified as
argument to ExtendedInstruction constructor. It is called when
assembler finds a program statement matching that ExtendedInstruction,
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
ErrorList
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars
Class ErrorList
java.lang.Object
mars.ErrorList
public class ErrorList
extends Object
Maintains list of generated error messages, regardless of source (tokenizing, parsing,
assembly, execution).
Author:
Pete Sanderson
Field Summary
static String ERROR_MESSAGE_PREFIX
static String FILENAME_PREFIX
static String LINE_PREFIX
static String MESSAGE_SEPARATOR
static String POSITION_PREFIX
static String WARNING_MESSAGE_PREFIX
Constructor Summary
ErrorList()
Constructor for ErrorList
Method Summary
void add(ErrorMessage mess)
Add new error message to end of list.
void add(ErrorMessage mess,
int index)
Add new error message at specified index position.
int errorCount()
Count of number of error messages in list.
boolean errorLimitExceeded()
Check to see if error limit has been exceeded.
boolean errorsOccurred()
Determine whether error has occured or not.
String generateErrorAndWarningReport()
Produce report containing both warnings and errors, warnings first.
String generateErrorReport()
Produce error report.
String generateWarningReport()
Produce warning report.
int getErrorLimit()
Get limit on number of error messages to be generated
by one assemble operation.
ArrayList getErrorMessages()
Get ArrayList of error messages.
int warningCount()
Count of number of warning messages in list.
boolean warningsOccurred()
Determine whether warning has occured or not.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
ERROR_MESSAGE_PREFIX
public static final String ERROR_MESSAGE_PREFIX
See Also:
Constant Field Values
WARNING_MESSAGE_PREFIX
public static final String WARNING_MESSAGE_PREFIX
See Also:
Constant Field Values
FILENAME_PREFIX
public static final String FILENAME_PREFIX
See Also:
Constant Field Values
LINE_PREFIX
public static final String LINE_PREFIX
See Also:
Constant Field Values
POSITION_PREFIX
public static final String POSITION_PREFIX
See Also:
Constant Field Values
MESSAGE_SEPARATOR
public static final String MESSAGE_SEPARATOR
See Also:
Constant Field Values
Constructor Detail
ErrorList
public ErrorList()
Constructor for ErrorList
Method Detail
getErrorMessages
public ArrayList getErrorMessages()
Get ArrayList of error messages.
Returns:
ArrayList of ErrorMessage objects
errorsOccurred
public boolean errorsOccurred()
Determine whether error has occured or not.
Returns:
true if an error has occurred (does not include warnings), false otherwise.
warningsOccurred
public boolean warningsOccurred()
Determine whether warning has occured or not.
Returns:
true if an warning has occurred, false otherwise.
add
public void add(ErrorMessage mess)
Add new error message to end of list.
Parameters:
mess – ErrorMessage object to be added to end of error list.
add
public void add(ErrorMessage mess,
int index)
Add new error message at specified index position.
Parameters:
mess – ErrorMessage object to be added to end of error list.
index – position in error list
errorCount
public int errorCount()
Count of number of error messages in list.
Returns:
Number of error messages in list.
warningCount
public int warningCount()
Count of number of warning messages in list.
Returns:
Number of warning messages in list.
errorLimitExceeded
public boolean errorLimitExceeded()
Check to see if error limit has been exceeded.
Returns:
True if error limit exceeded, false otherwise.
getErrorLimit
public int getErrorLimit()
Get limit on number of error messages to be generated
by one assemble operation.
Returns:
error limit.
generateErrorReport
public String generateErrorReport()
Produce error report.
Returns:
String containing report.
generateWarningReport
public String generateWarningReport()
Produce warning report.
Returns:
String containing report.
generateErrorAndWarningReport
public String generateErrorAndWarningReport()
Produce report containing both warnings and errors, warnings first.
Returns:
String containing report.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
ErrorMessage
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars
Class ErrorMessage
java.lang.Object
mars.ErrorMessage
public class ErrorMessage
extends Object
Represents occurrance of an error detected during tokenizing, assembly or simulation.
Author:
Pete Sanderson
Field Summary
static boolean ERROR
Constant to indicate this message is error not warning
static boolean WARNING
Constant to indicate this message is warning not error
Constructor Summary
ErrorMessage(boolean isWarning,
MIPSprogram sourceMIPSprogram,
int line,
int position,
String message)
Constructor for ErrorMessage.
ErrorMessage(boolean isWarning,
String filename,
int line,
int position,
String message,
String macroExpansionHistory)
Deprecated. Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.
ErrorMessage(MIPSprogram sourceMIPSprogram,
int line,
int position,
String message)
Constructor for ErrorMessage.
ErrorMessage(ProgramStatement statement,
String message)
Constructor for ErrorMessage, to be used for runtime exceptions.
ErrorMessage(String filename,
int line,
int position,
String message)
Deprecated. Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.
ErrorMessage(String filename,
int line,
int position,
String message,
String macroExpansionHistory)
Deprecated. Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.
Method Summary
String getFilename()
Produce name of file containing error.
int getLine()
Produce line number of error.
String getMacroExpansionHistory()
Returns string describing macro expansion.
String getMessage()
Produce error message.
int getPosition()
Produce position within erroneous line.
boolean isWarning()
Determine whether this message represents error or warning.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
WARNING
public static final boolean WARNING
Constant to indicate this message is warning not error
See Also:
Constant Field Values
ERROR
public static final boolean ERROR
Constant to indicate this message is error not warning
See Also:
Constant Field Values
Constructor Detail
ErrorMessage
@Deprecated
public ErrorMessage(String filename,
int line,
int position,
String message)
Deprecated. Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.
Constructor for ErrorMessage.
Parameters:
filename – String containing name of source file in which this error appears.
line – Line number in source program being processed when error occurred.
position – Position within line being processed when error occurred. Normally is starting
position of source token.
message – String containing appropriate error message.
ErrorMessage
@Deprecated
public ErrorMessage(String filename,
int line,
int position,
String message,
String macroExpansionHistory)
Deprecated. Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.
Constructor for ErrorMessage.
Parameters:
filename – String containing name of source file in which this error appears.
line – Line number in source program being processed when error occurred.
position – Position within line being processed when error occurred. Normally is starting
position of source token.
message – String containing appropriate error message.
macroExpansionHistory –
ErrorMessage
@Deprecated
public ErrorMessage(boolean isWarning,
String filename,
int line,
int position,
String message,
String macroExpansionHistory)
Deprecated. Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.
Constructor for ErrorMessage.
Parameters:
isWarning – set to WARNING if message is a warning not error, else set to ERROR or omit.
filename – String containing name of source file in which this error appears.
line – Line number in source program being processed when error occurred.
position – Position within line being processed when error occurred. Normally is starting
position of source token.
message – String containing appropriate error message.
macroExpansionHistory – provided so message for macro can include both definition and usage line numbers
ErrorMessage
public ErrorMessage(MIPSprogram sourceMIPSprogram,
int line,
int position,
String message)
Constructor for ErrorMessage. Assumes line number is calculated after any .include files expanded, and
if there were, it will adjust filename and line number so message reflects original file and line number.
Parameters:
sourceMIPSprogram – MIPSprogram object of source file in which this error appears.
line – Line number in source program being processed when error occurred.
position – Position within line being processed when error occurred. Normally is starting
position of source token.
message – String containing appropriate error message.
ErrorMessage
public ErrorMessage(boolean isWarning,
MIPSprogram sourceMIPSprogram,
int line,
int position,
String message)
Constructor for ErrorMessage. Assumes line number is calculated after any .include files expanded, and
if there were, it will adjust filename and line number so message reflects original file and line number.
Parameters:
isWarning – set to WARNING if message is a warning not error, else set to ERROR or omit.
sourceMIPSprogram – MIPSprogram object of source file in which this error appears.
line – Line number in source program being processed when error occurred.
position – Position within line being processed when error occurred. Normally is starting
position of source token.
message – String containing appropriate error message.
ErrorMessage
public ErrorMessage(ProgramStatement statement,
String message)
Constructor for ErrorMessage, to be used for runtime exceptions.
Parameters:
statement – The ProgramStatement object for the instruction causing the runtime error
message – String containing appropriate error message.
Method Detail
getFilename
public String getFilename()
Produce name of file containing error.
Returns:
Returns String containing name of source file containing the error.
getLine
public int getLine()
Produce line number of error.
Returns:
Returns line number in source program where error occurred.
getPosition
public int getPosition()
Produce position within erroneous line.
Returns:
Returns position within line of source program where error occurred.
getMessage
public String getMessage()
Produce error message.
Returns:
Returns String containing textual error message.
isWarning
public boolean isWarning()
Determine whether this message represents error or warning.
Returns:
Returns true if this message reflects warning, false if error.
getMacroExpansionHistory
public String getMacroExpansionHistory()
Returns string describing macro expansion. Empty string if none.
Returns:
string describing macro expansion
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Globals
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars
Class Globals
java.lang.Object
mars.Globals
public class Globals
extends Object
Collection of globally-available data structures.
Author:
Pete Sanderson
Field Summary
static String ASCII_NON_PRINT
Placeholder for non-printable ASCII codes
static String[] ASCII_TABLE
Array of strings to display for ASCII codes in ASCII display of data segment.
static String copyrightHolders
MARS copyright holders
static String copyrightYears
MARS copyright years
static boolean debug
Flag to determine whether or not to produce internal debugging information.
static int exitCode
MARS exit code — useful with SYSCALL 17 when running from command line (not GUI)
static ArrayList fileExtensions
List of accepted file extensions for MIPS assembly source files.
static String helpPath
Path to folder that contains help text
static String imagesPath
Path to folder that contains images
static InstructionSet instructionSet
The set of implemented MIPS instructions.
static int maximumBacksteps
Maximum number of back-step operations to buffer
static int maximumErrorMessages
Maximum number of assembler errors produced by one assemble operation
static int maximumMessageCharacters
Maximum length of scrolled message window (MARS Messages and Run I/O)
static Memory memory
Simulated MIPS memory component.
static Object memoryAndRegistersLock
Lock variable used at head of synchronized block to guard MIPS memory and registers
static MIPSprogram program
the program currently being worked with.
static boolean runSpeedPanelExists
static SymbolTable symbolTable
Symbol table for file currently being assembled.
static String userInputAlert
String to GUI’s RunI/O text area when echoing user input from pop-up dialog.
static String version
The current MARS version number.
Constructor Summary
Globals()
Method Summary
static String getAsciiNonPrint()
static String[] getAsciiStrings()
static ArrayList getExternalTools()
Get list of MarsTools that reside outside the MARS distribution.
static VenusUI getGui()
static String getPropertyEntry(String propertiesFile,
String propertyName)
Read and return property file value (if any) for requested property.
static Settings getSettings()
ArrayList getSyscallOverrides()
Read any syscall number assignment overrides from config file.
static void initialize(boolean gui)
Method called once upon system initialization to create the global data structures.
static void setGui(VenusUI g)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
instructionSet
public static InstructionSet instructionSet
The set of implemented MIPS instructions.
program
public static MIPSprogram program
the program currently being worked with. Used by GUI only, not command line.
symbolTable
public static SymbolTable symbolTable
Symbol table for file currently being assembled.
memory
public static Memory memory
Simulated MIPS memory component.
memoryAndRegistersLock
public static Object memoryAndRegistersLock
Lock variable used at head of synchronized block to guard MIPS memory and registers
debug
public static boolean debug
Flag to determine whether or not to produce internal debugging information.
userInputAlert
public static String userInputAlert
String to GUI’s RunI/O text area when echoing user input from pop-up dialog.
imagesPath
public static final String imagesPath
Path to folder that contains images
See Also:
Constant Field Values
helpPath
public static final String helpPath
Path to folder that contains help text
See Also:
Constant Field Values
version
public static final String version
The current MARS version number. Can’t wait for “initialize()” call to get it.
See Also:
Constant Field Values
fileExtensions
public static final ArrayList fileExtensions
List of accepted file extensions for MIPS assembly source files.
maximumMessageCharacters
public static final int maximumMessageCharacters
Maximum length of scrolled message window (MARS Messages and Run I/O)
maximumErrorMessages
public static final int maximumErrorMessages
Maximum number of assembler errors produced by one assemble operation
maximumBacksteps
public static final int maximumBacksteps
Maximum number of back-step operations to buffer
copyrightYears
public static final String copyrightYears
MARS copyright years
copyrightHolders
public static final String copyrightHolders
MARS copyright holders
ASCII_NON_PRINT
public static final String ASCII_NON_PRINT
Placeholder for non-printable ASCII codes
ASCII_TABLE
public static final String[] ASCII_TABLE
Array of strings to display for ASCII codes in ASCII display of data segment. ASCII code 0-255 is array index.
exitCode
public static int exitCode
MARS exit code — useful with SYSCALL 17 when running from command line (not GUI)
runSpeedPanelExists
public static boolean runSpeedPanelExists
Constructor Detail
Globals
public Globals()
Method Detail
setGui
public static void setGui(VenusUI g)
getGui
public static VenusUI getGui()
getSettings
public static Settings getSettings()
initialize
public static void initialize(boolean gui)
Method called once upon system initialization to create the global data structures.
getAsciiNonPrint
public static String getAsciiNonPrint()
getAsciiStrings
public static String[] getAsciiStrings()
getExternalTools
public static ArrayList getExternalTools()
Get list of MarsTools that reside outside the MARS distribution.
Currently this is done by adding the tool’s path name to the list
of values for the external_tools property. Use “;” as delimiter!
Returns:
ArrayList. Each item is file path to .class file
of a class that implements MarsTool. If none, returns empty list.
getPropertyEntry
public static String getPropertyEntry(String propertiesFile,
String propertyName)
Read and return property file value (if any) for requested property.
Parameters:
propertiesFile – name of properties file (do NOT include filename extension,
which is assumed to be “.properties”)
propertyName – String containing desired property name
Returns:
String containing associated value; null if property not found
getSyscallOverrides
public ArrayList getSyscallOverrides()
Read any syscall number assignment overrides from config file.
Returns:
ArrayList of SyscallNumberOverride objects
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
MarsLaunch
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars
Class MarsLaunch
java.lang.Object
mars.MarsLaunch
public class MarsLaunch
extends Object
Launch the Mars application
Author:
Pete Sanderson
Constructor Summary
MarsLaunch(String[] args)
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
MarsLaunch
public MarsLaunch(String[] args)
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
MarsSplashScreen
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars
Class MarsSplashScreen
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
javax.swing.JWindow
mars.MarsSplashScreen
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer
public class MarsSplashScreen
extends JWindow
Produces MARS splash screen.
Adapted from http://www.java-tips.org/content/view/1267/2/
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JWindow
JWindow.AccessibleJWindow
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class javax.swing.JWindow
accessibleContext, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
MarsSplashScreen(int d)
Method Summary
void showSplash()
A simple little method to show a title screen in the center
of the screen for the amount of time given in the constructor
Methods inherited from class javax.swing.JWindow
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getGraphics, getLayeredPane, getRootPane, getTransferHandler, isRootPaneCheckingEnabled, paramString, remove, repaint, setContentPane, setGlassPane, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update, windowInit
Methods inherited from class java.awt.Window
addNotify, addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
MarsSplashScreen
public MarsSplashScreen(int d)
Method Detail
showSplash
public void showSplash()
A simple little method to show a title screen in the center
of the screen for the amount of time given in the constructor
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
AbstractDumpFormat
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.dump
Class AbstractDumpFormat
java.lang.Object
mars.mips.dump.AbstractDumpFormat
All Implemented Interfaces:
DumpFormat
Direct Known Subclasses:
AsciiTextDumpFormat, BinaryDumpFormat, BinaryTextDumpFormat, HexTextDumpFormat, IntelHexDumpFormat, SegmentWindowDumpFormat
public abstract class AbstractDumpFormat
extends Object
implements DumpFormat
Abstract class for memory dump file formats. Provides constructors and
defaults for everything except the dumpMemoryRange method itself.
Author:
Pete Sanderson
Constructor Summary
AbstractDumpFormat(String name,
String commandDescriptor,
String description,
String extension)
Typical constructor.
Method Summary
abstract void dumpMemoryRange(File file,
int firstAddress,
int lastAddress)
Write MIPS memory contents according to the
specification for this format.
String getCommandDescriptor()
One-word description of format to be used by MARS command mode parser
and user in conjunction with the “dump” option.
String getDescription()
Get a short description of the format, suitable for displaying along with
the extension, in the file save dialog, or as a tool tip.
String getFileExtension()
Get the file extension associated with this format.
String toString()
String representing this object.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
AbstractDumpFormat
public AbstractDumpFormat(String name,
String commandDescriptor,
String description,
String extension)
Typical constructor. Note you cannot creates objects from this
class but subclass constructor can call this one.
Parameters:
name – Brief descriptive name to be displayed in selection list.
commandDescriptor – One-word descriptive name to be used by MARS command mode parser and user.
Any spaces in this string will be removed.
description – Description to go with standard file extension for
display in file save dialog or to be used as tool tip.
extension – Standard file extension for this format. Null if none.
Method Detail
getFileExtension
public String getFileExtension()
Get the file extension associated with this format.
Specified by:
getFileExtension in interface DumpFormat
Returns:
String containing file extension — without the leading “.” — or
null if there is no standard extension.
getDescription
public String getDescription()
Get a short description of the format, suitable for displaying along with
the extension, in the file save dialog, or as a tool tip.
Specified by:
getDescription in interface DumpFormat
Returns:
String containing short description to go with the extension
or for use as tool tip. Possibly null.
toString
public String toString()
String representing this object.
Specified by:
toString in interface DumpFormat
Overrides:
toString in class Object
Returns:
Name given for this object.
getCommandDescriptor
public String getCommandDescriptor()
One-word description of format to be used by MARS command mode parser
and user in conjunction with the “dump” option.
Specified by:
getCommandDescriptor in interface DumpFormat
Returns:
One-word String describing the format.
dumpMemoryRange
public abstract void dumpMemoryRange(File file,
int firstAddress,
int lastAddress)
throws AddressErrorException,
IOException
Write MIPS memory contents according to the
specification for this format.
Specified by:
dumpMemoryRange in interface DumpFormat
Parameters:
file – File in which to store MIPS memory contents.
firstAddress – first (lowest) memory address to dump. In bytes but
must be on word boundary.
lastAddress – last (highest) memory address to dump. In bytes but
must be on word boundary. Will dump the word that starts at this address.
Throws:
AddressErrorException – if firstAddress is invalid or not on a word boundary.
IOException – if error occurs during file output.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
AsciiTextDumpFormat
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.dump
Class AsciiTextDumpFormat
java.lang.Object
mars.mips.dump.AbstractDumpFormat
mars.mips.dump.AsciiTextDumpFormat
All Implemented Interfaces:
DumpFormat
public class AsciiTextDumpFormat
extends AbstractDumpFormat
Class that represents the “ASCII text” memory dump format. Memory contents
are interpreted as ASCII codes. The output
is a text file with one word of MIPS memory per line. The word is formatted
to leave three spaces for each character. Non-printing characters
rendered as period (.) as placeholder. Common escaped characters
rendered using backslash and single-character descriptor, e.g. \t for tab.
Author:
Pete Sanderson
Constructor Summary
AsciiTextDumpFormat()
Constructor.
Method Summary
void dumpMemoryRange(File file,
int firstAddress,
int lastAddress)
Interpret MIPS memory contents as ASCII characters.
Methods inherited from class mars.mips.dump.AbstractDumpFormat
getCommandDescriptor, getDescription, getFileExtension, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
AsciiTextDumpFormat
public AsciiTextDumpFormat()
Constructor. There is no standard file extension for this format.
Method Detail
dumpMemoryRange
public void dumpMemoryRange(File file,
int firstAddress,
int lastAddress)
throws AddressErrorException,
IOException
Interpret MIPS memory contents as ASCII characters. Each line of
text contains one memory word written in ASCII characters. Those
corresponding to tab, newline, null, etc are rendered as backslash
followed by single-character code, e.g. \t for tab, \0 for null.
Non-printing character (control code,
values above 127) is rendered as a period (.). Written
using PrintStream’s println() method.
Adapted by Pete Sanderson from code written by Greg Gibeling.
Specified by:
dumpMemoryRange in interface DumpFormat
Specified by:
dumpMemoryRange in class AbstractDumpFormat
Parameters:
file – File in which to store MIPS memory contents.
firstAddress – first (lowest) memory address to dump. In bytes but
must be on word boundary.
lastAddress – last (highest) memory address to dump. In bytes but
must be on word boundary. Will dump the word that starts at this address.
Throws:
AddressErrorException – if firstAddress is invalid or not on a word boundary.
IOException – if error occurs during file output.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
BinaryDumpFormat
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.dump
Class BinaryDumpFormat
java.lang.Object
mars.mips.dump.AbstractDumpFormat
mars.mips.dump.BinaryDumpFormat
All Implemented Interfaces:
DumpFormat
public class BinaryDumpFormat
extends AbstractDumpFormat
Class that represents the “binary” memory dump format. The output
is a binary file containing the memory words as a byte stream. Output
is produced using PrintStream’s write() method.
Author:
Pete Sanderson
Constructor Summary
BinaryDumpFormat()
Constructor.
Method Summary
void dumpMemoryRange(File file,
int firstAddress,
int lastAddress)
Write MIPS memory contents in pure binary format.
Methods inherited from class mars.mips.dump.AbstractDumpFormat
getCommandDescriptor, getDescription, getFileExtension, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
BinaryDumpFormat
public BinaryDumpFormat()
Constructor. There is no standard file extension for this format.
Method Detail
dumpMemoryRange
public void dumpMemoryRange(File file,
int firstAddress,
int lastAddress)
throws AddressErrorException,
IOException
Write MIPS memory contents in pure binary format. One byte at a time
using PrintStream’s write() method. Adapted by Pete Sanderson from
code written by Greg Gibeling.
Specified by:
dumpMemoryRange in interface DumpFormat
Specified by:
dumpMemoryRange in class AbstractDumpFormat
Parameters:
file – File in which to store MIPS memory contents.
firstAddress – first (lowest) memory address to dump. In bytes but
must be on word boundary.
lastAddress – last (highest) memory address to dump. In bytes but
must be on word boundary. Will dump the word that starts at this address.
Throws:
AddressErrorException – if firstAddress is invalid or not on a word boundary.
IOException – if error occurs during file output.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
BinaryTextDumpFormat
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.dump
Class BinaryTextDumpFormat
java.lang.Object
mars.mips.dump.AbstractDumpFormat
mars.mips.dump.BinaryTextDumpFormat
All Implemented Interfaces:
DumpFormat
public class BinaryTextDumpFormat
extends AbstractDumpFormat
Class that represents the “binary text” memory dump format. The output
is a text file with one word of MIPS memory per line. The word is formatted
using ‘0’ and ‘1’ characters, e.g. 01110101110000011111110101010011.
Author:
Pete Sanderson
Constructor Summary
BinaryTextDumpFormat()
Constructor.
Method Summary
void dumpMemoryRange(File file,
int firstAddress,
int lastAddress)
Write MIPS memory contents in binary text format.
Methods inherited from class mars.mips.dump.AbstractDumpFormat
getCommandDescriptor, getDescription, getFileExtension, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
BinaryTextDumpFormat
public BinaryTextDumpFormat()
Constructor. There is no standard file extension for this format.
Method Detail
dumpMemoryRange
public void dumpMemoryRange(File file,
int firstAddress,
int lastAddress)
throws AddressErrorException,
IOException
Write MIPS memory contents in binary text format. Each line of
text contains one memory word written as 32 ‘0’ and ‘1’ characters. Written
using PrintStream’s println() method.
Adapted by Pete Sanderson from code written by Greg Gibeling.
Specified by:
dumpMemoryRange in interface DumpFormat
Specified by:
dumpMemoryRange in class AbstractDumpFormat
Parameters:
file – File in which to store MIPS memory contents.
firstAddress – first (lowest) memory address to dump. In bytes but
must be on word boundary.
lastAddress – last (highest) memory address to dump. In bytes but
must be on word boundary. Will dump the word that starts at this address.
Throws:
AddressErrorException – if firstAddress is invalid or not on a word boundary.
IOException – if error occurs during file output.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
DumpFormat
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.dump
Interface DumpFormat
All Known Implementing Classes:
AbstractDumpFormat, AsciiTextDumpFormat, BinaryDumpFormat, BinaryTextDumpFormat, HexTextDumpFormat, IntelHexDumpFormat, SegmentWindowDumpFormat
public interface DumpFormat
Interface for memory dump file formats. All MARS needs to be able
to do is save an assembled program or data in the specified manner for
a given format. Formats are specified through classes
that implement this interface.
Author:
Pete Sanderson
Method Summary
void dumpMemoryRange(File file,
int firstAddress,
int lastAddress)
Write MIPS memory contents according to the
specification for this format.
String getCommandDescriptor()
A short one-word descriptor that will be used by the MARS
command line parser (and the MARS command line user) to specify
that this format is to be used.
String getDescription()
Get a short description of the format, suitable
for displaying along with the extension, if any, in the file
save dialog and also for displaying as a tool tip.
String getFileExtension()
Get the file extension associated with this format.
String toString()
Descriptive name for the format.
Method Detail
getFileExtension
String getFileExtension()
Get the file extension associated with this format.
Returns:
String containing file extension — without the leading “.” — or
null if there is no standard extension.
getDescription
String getDescription()
Get a short description of the format, suitable
for displaying along with the extension, if any, in the file
save dialog and also for displaying as a tool tip.
Returns:
String containing short description to go with the extension
or as tool tip when mouse hovers over GUI component representing
this format.
getCommandDescriptor
String getCommandDescriptor()
A short one-word descriptor that will be used by the MARS
command line parser (and the MARS command line user) to specify
that this format is to be used.
toString
String toString()
Descriptive name for the format.
Overrides:
toString in class Object
Returns:
Format name.
dumpMemoryRange
void dumpMemoryRange(File file,
int firstAddress,
int lastAddress)
throws AddressErrorException,
IOException
Write MIPS memory contents according to the
specification for this format.
Parameters:
file – File in which to store MIPS memory contents.
firstAddress – first (lowest) memory address to dump. In bytes but
must be on word boundary.
lastAddress – last (highest) memory address to dump. In bytes but
must be on word boundary. Will dump the word that starts at this address.
Throws:
AddressErrorException – if firstAddress is invalid or not on a word boundary.
IOException – if error occurs during file output.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
DumpFormatLoader
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.dump
Class DumpFormatLoader
java.lang.Object
mars.mips.dump.DumpFormatLoader
public class DumpFormatLoader
extends Object
Constructor Summary
DumpFormatLoader()
Method Summary
static DumpFormat findDumpFormatGivenCommandDescriptor(ArrayList formatList,
String formatCommandDescriptor)
ArrayList loadDumpFormats()
Dynamically loads dump formats into an ArrayList.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
DumpFormatLoader
public DumpFormatLoader()
Method Detail
loadDumpFormats
public ArrayList loadDumpFormats()
Dynamically loads dump formats into an ArrayList. This method is adapted from
the loadGameControllers() method in Bret Barker’s GameServer class.
Barker (bret@hypefiend.com) is co-author of the book “Developing Games
in Java”. Also see the ToolLoader and SyscallLoader classes elsewhere in MARS.
findDumpFormatGivenCommandDescriptor
public static DumpFormat findDumpFormatGivenCommandDescriptor(ArrayList formatList,
String formatCommandDescriptor)
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
HexTextDumpFormat
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.dump
Class HexTextDumpFormat
java.lang.Object
mars.mips.dump.AbstractDumpFormat
mars.mips.dump.HexTextDumpFormat
All Implemented Interfaces:
DumpFormat
public class HexTextDumpFormat
extends AbstractDumpFormat
Class that represents the “hexadecimal text” memory dump format. The output
is a text file with one word of MIPS memory per line. The word is formatted
using hexadecimal characters, e.g. 3F205A39.
Author:
Pete Sanderson
Constructor Summary
HexTextDumpFormat()
Constructor.
Method Summary
void dumpMemoryRange(File file,
int firstAddress,
int lastAddress)
Write MIPS memory contents in hexadecimal text format.
Methods inherited from class mars.mips.dump.AbstractDumpFormat
getCommandDescriptor, getDescription, getFileExtension, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
HexTextDumpFormat
public HexTextDumpFormat()
Constructor. There is no standard file extension for this format.
Method Detail
dumpMemoryRange
public void dumpMemoryRange(File file,
int firstAddress,
int lastAddress)
throws AddressErrorException,
IOException
Write MIPS memory contents in hexadecimal text format. Each line of
text contains one memory word written in hexadecimal characters. Written
using PrintStream’s println() method.
Adapted by Pete Sanderson from code written by Greg Gibeling.
Specified by:
dumpMemoryRange in interface DumpFormat
Specified by:
dumpMemoryRange in class AbstractDumpFormat
Parameters:
file – File in which to store MIPS memory contents.
firstAddress – first (lowest) memory address to dump. In bytes but
must be on word boundary.
lastAddress – last (highest) memory address to dump. In bytes but
must be on word boundary. Will dump the word that starts at this address.
Throws:
AddressErrorException – if firstAddress is invalid or not on a word boundary.
IOException – if error occurs during file output.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
IntelHexDumpFormat
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.dump
Class IntelHexDumpFormat
java.lang.Object
mars.mips.dump.AbstractDumpFormat
mars.mips.dump.IntelHexDumpFormat
All Implemented Interfaces:
DumpFormat
public class IntelHexDumpFormat
extends AbstractDumpFormat
Intel’s Hex memory initialization format
Author:
Leo Alterman
Constructor Summary
IntelHexDumpFormat()
Constructor.
Method Summary
void dumpMemoryRange(File file,
int firstAddress,
int lastAddress)
Write MIPS memory contents according to the Memory Initialization File
(MIF) specification.
Methods inherited from class mars.mips.dump.AbstractDumpFormat
getCommandDescriptor, getDescription, getFileExtension, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
IntelHexDumpFormat
public IntelHexDumpFormat()
Constructor. File extention is “hex”.
Method Detail
dumpMemoryRange
public void dumpMemoryRange(File file,
int firstAddress,
int lastAddress)
throws AddressErrorException,
IOException
Write MIPS memory contents according to the Memory Initialization File
(MIF) specification.
Specified by:
dumpMemoryRange in interface DumpFormat
Specified by:
dumpMemoryRange in class AbstractDumpFormat
Parameters:
file – File in which to store MIPS memory contents.
firstAddress – first (lowest) memory address to dump. In bytes but
must be on word boundary.
lastAddress – last (highest) memory address to dump. In bytes but
must be on word boundary. Will dump the word that starts at this address.
Throws:
AddressErrorException – if firstAddress is invalid or not on a word boundary.
IOException – if error occurs during file output.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
MIFDumpFormat
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.dump
Class MIFDumpFormat
java.lang.Object
mars.mips.dump.MIFDumpFormat
public class MIFDumpFormat
extends Object
The Memory Initialization File (.mif) VHDL-supported file format
This is documented for the Altera platform at
www.altera.com/support/software/nativelink/quartus2/glossary/def_mif.html.
Author:
Pete Sanderson
Constructor Summary
MIFDumpFormat()
Constructor.
Method Summary
void dumpMemoryRange(File file,
int firstAddress,
int lastAddress)
Write MIPS memory contents according to the Memory Initialization File
(MIF) specification.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
MIFDumpFormat
public MIFDumpFormat()
Constructor. File extention is “mif”.
Method Detail
dumpMemoryRange
public void dumpMemoryRange(File file,
int firstAddress,
int lastAddress)
throws AddressErrorException,
IOException
Write MIPS memory contents according to the Memory Initialization File
(MIF) specification.
Parameters:
file – File in which to store MIPS memory contents.
firstAddress – first (lowest) memory address to dump. In bytes but
must be on word boundary.
lastAddress – last (highest) memory address to dump. In bytes but
must be on word boundary. Will dump the word that starts at this address.
Throws:
AddressErrorException – if firstAddress is invalid or not on a word boundary.
IOException – if error occurs during file output.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.dump
mars.mips.dump
Interfaces
DumpFormat
Classes
AbstractDumpFormat
AsciiTextDumpFormat
BinaryDumpFormat
BinaryTextDumpFormat
DumpFormatLoader
HexTextDumpFormat
IntelHexDumpFormat
MIFDumpFormat
SegmentWindowDumpFormat
mars.mips.dump
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
Package mars.mips.dump
Interface Summary
DumpFormat Interface for memory dump file formats.
Class Summary
AbstractDumpFormat Abstract class for memory dump file formats.
AsciiTextDumpFormat Class that represents the “ASCII text” memory dump format.
BinaryDumpFormat Class that represents the “binary” memory dump format.
BinaryTextDumpFormat Class that represents the “binary text” memory dump format.
DumpFormatLoader
HexTextDumpFormat Class that represents the “hexadecimal text” memory dump format.
IntelHexDumpFormat Intel’s Hex memory initialization format
MIFDumpFormat The Memory Initialization File (.mif) VHDL-supported file format
This is documented for the Altera platform at
www.altera.com/support/software/nativelink/quartus2/glossary/def_mif.html.
SegmentWindowDumpFormat Dump MIPS memory contents in Segment Window format.
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
mars.mips.dump Class Hierarchy
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Hierarchy For Package mars.mips.dump
Package Hierarchies:
All Packages
Class Hierarchy
java.lang.Object mars.mips.dump.AbstractDumpFormat (implements mars.mips.dump.DumpFormat)
mars.mips.dump.AsciiTextDumpFormat
mars.mips.dump.BinaryDumpFormat
mars.mips.dump.BinaryTextDumpFormat
mars.mips.dump.HexTextDumpFormat
mars.mips.dump.IntelHexDumpFormat
mars.mips.dump.SegmentWindowDumpFormat
mars.mips.dump.DumpFormatLoader
mars.mips.dump.MIFDumpFormat
Interface Hierarchy
mars.mips.dump.DumpFormat
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
SegmentWindowDumpFormat
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.dump
Class SegmentWindowDumpFormat
java.lang.Object
mars.mips.dump.AbstractDumpFormat
mars.mips.dump.SegmentWindowDumpFormat
All Implemented Interfaces:
DumpFormat
public class SegmentWindowDumpFormat
extends AbstractDumpFormat
Dump MIPS memory contents in Segment Window format. Each line of
text output resembles the Text Segment Window or Data Segment Window
depending on which segment is selected for the dump. Written
using PrintStream’s println() method. Each line of Text Segment
Window represents one word of text segment memory. The line
includes (1) address, (2) machine code in hex, (3) basic instruction,
(4) source line. Each line of Data Segment Window represents 8
words of data segment memory. The line includes address of first
word for that line followed by 8 32-bit values.
In either case, addresses and values are displayed in decimal or
hexadecimal representation according to the corresponding settings.
Author:
Pete Sanderson
Constructor Summary
SegmentWindowDumpFormat()
Constructor.
Method Summary
void dumpMemoryRange(File file,
int firstAddress,
int lastAddress)
Write MIPS memory contents in Segment Window format.
Methods inherited from class mars.mips.dump.AbstractDumpFormat
getCommandDescriptor, getDescription, getFileExtension, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
SegmentWindowDumpFormat
public SegmentWindowDumpFormat()
Constructor. There is no standard file extension for this format.
Method Detail
dumpMemoryRange
public void dumpMemoryRange(File file,
int firstAddress,
int lastAddress)
throws AddressErrorException,
IOException
Write MIPS memory contents in Segment Window format. Each line of
text output resembles the Text Segment Window or Data Segment Window
depending on which segment is selected for the dump. Written
using PrintStream’s println() method.
Specified by:
dumpMemoryRange in interface DumpFormat
Specified by:
dumpMemoryRange in class AbstractDumpFormat
Parameters:
file – File in which to store MIPS memory contents.
firstAddress – first (lowest) memory address to dump. In bytes but
must be on word boundary.
lastAddress – last (highest) memory address to dump. In bytes but
must be on word boundary. Will dump the word that starts at this address.
Throws:
AddressErrorException – if firstAddress is invalid or not on a word boundary.
IOException – if error occurs during file output.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
AccessNotice
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.hardware
Class AccessNotice
java.lang.Object
mars.mips.hardware.AccessNotice
Direct Known Subclasses:
MemoryAccessNotice, RegisterAccessNotice
public abstract class AccessNotice
extends Object
Object provided to Observers of runtime access to MIPS memory or registers.
The access types READ and WRITE defined here; use subclasses defined for
MemoryAccessNotice and RegisterAccessNotice. This is abstract class.
Author:
Pete Sanderson
Field Summary
static int READ
Indicates the purpose of access was to read.
static int WRITE
Indicates the purpose of access was to write.
Constructor Summary
protected AccessNotice(int type)
Method Summary
boolean accessIsFromGUI()
Query whether the access originated from MARS GUI (AWT event queue)
boolean accessIsFromMIPS()
Query whether the access originated from executing MIPS program
int getAccessType()
Get the access type: READ or WRITE.
Thread getThread()
Get reference to thread that created this notice
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
READ
public static final int READ
Indicates the purpose of access was to read.
See Also:
Constant Field Values
WRITE
public static final int WRITE
Indicates the purpose of access was to write.
See Also:
Constant Field Values
Constructor Detail
AccessNotice
protected AccessNotice(int type)
Method Detail
getAccessType
public int getAccessType()
Get the access type: READ or WRITE.
Returns:
Access type, either AccessNotice.READ or AccessNotice.WRITE
getThread
public Thread getThread()
Get reference to thread that created this notice
Returns:
Return reference to the thread that created this notice.
accessIsFromGUI
public boolean accessIsFromGUI()
Query whether the access originated from MARS GUI (AWT event queue)
Returns:
true if this access originated from MARS GUI, false otherwise
accessIsFromMIPS
public boolean accessIsFromMIPS()
Query whether the access originated from executing MIPS program
Returns:
true if this access originated from executing MIPS program, false otherwise
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
AddressErrorException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.hardware
Class AddressErrorException
java.lang.Object
java.lang.Throwable
java.lang.Exception
mars.mips.hardware.AddressErrorException
All Implemented Interfaces:
Serializable
public class AddressErrorException
extends Exception
Represents MIPS AddressErrorException. This is generated by the assembler when the
source code references a memory address not valid for the context.
Author:
Pete Sanderson
See Also:
Serialized Form
Constructor Summary
AddressErrorException(String message,
int exceptType,
int addr)
Constructor for the AddressErrorException class
Method Summary
int getAddress()
Get the erroneous memory address.
int getType()
Get the exception type (load or store).
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
AddressErrorException
public AddressErrorException(String message,
int exceptType,
int addr)
Constructor for the AddressErrorException class
Parameters:
addr – The erroneous memory address.
Method Detail
getAddress
public int getAddress()
Get the erroneous memory address.
Returns:
The erroneous memory address.
getType
public int getType()
Get the exception type (load or store).
Returns:
Exception type: Exceptions.ADDRESS_EXCEPTION_LOAD, Exceptions.ADDRESS_EXCEPTION_STORE
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Coprocessor0
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.hardware
Class Coprocessor0
java.lang.Object
mars.mips.hardware.Coprocessor0
public class Coprocessor0
extends Object
Represents Coprocessor 0. We will use only its interrupt/exception registers.
Author:
Pete Sanderson
Field Summary
static int CAUSE
static int DEFAULT_STATUS_VALUE
static int EPC
static int EXCEPTION_LEVEL
static int STATUS
static int VADDR
Coprocessor register names
Constructor Summary
Coprocessor0()
Method Summary
static void addRegistersObserver(Observer observer)
Each individual register is a separate object and Observable.
static void deleteRegistersObserver(Observer observer)
Each individual register is a separate object and Observable.
static int getNumber(String n)
For getting the number representation of the register.
static Register getRegister(String rname)
Get register object corresponding to given name.
static int getRegisterPosition(Register r)
Coprocessor0 implements only selected registers, so the register number
(8, 12, 13, 14) does not correspond to its position in the list of registers
(0, 1, 2, 3).
static Register[] getRegisters()
For returning the set of registers.
static int getValue(int num)
Returns the value of the register who’s number is num.
static void resetRegisters()
Method to reinitialize the values of the registers.
static void showRegisters()
Method for displaying the register values for debugging.
static int updateRegister(int num,
int val)
This method updates the register value who’s number is num.
static int updateRegister(String n,
int val)
Sets the value of the register given to the value given.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
VADDR
public static final int VADDR
Coprocessor register names
See Also:
Constant Field Values
STATUS
public static final int STATUS
See Also:
Constant Field Values
CAUSE
public static final int CAUSE
See Also:
Constant Field Values
EPC
public static final int EPC
See Also:
Constant Field Values
EXCEPTION_LEVEL
public static final int EXCEPTION_LEVEL
See Also:
Constant Field Values
DEFAULT_STATUS_VALUE
public static final int DEFAULT_STATUS_VALUE
See Also:
Constant Field Values
Constructor Detail
Coprocessor0
public Coprocessor0()
Method Detail
showRegisters
public static void showRegisters()
Method for displaying the register values for debugging.
updateRegister
public static int updateRegister(String n,
int val)
Sets the value of the register given to the value given.
Parameters:
n – name of register to set the value of ($n, where n is reg number).
val – The desired value for the register.
Returns:
old value in register prior to update
updateRegister
public static int updateRegister(int num,
int val)
This method updates the register value who’s number is num.
Parameters:
num – Number of register to set the value of.
val – The desired value for the register.
Returns:
old value in register prior to update
getValue
public static int getValue(int num)
Returns the value of the register who’s number is num.
Parameters:
num – The register number.
Returns:
The value of the given register. 0 for non-implemented registers
getNumber
public static int getNumber(String n)
For getting the number representation of the register.
Parameters:
n – The string formatted register name to look for.
Returns:
The number of the register represented by the string. -1 if no match.
getRegisters
public static Register[] getRegisters()
For returning the set of registers.
Returns:
The set of registers.
getRegisterPosition
public static int getRegisterPosition(Register r)
Coprocessor0 implements only selected registers, so the register number
(8, 12, 13, 14) does not correspond to its position in the list of registers
(0, 1, 2, 3).
Parameters:
r – A coprocessor0 Register
Returns:
the list position of given register, -1 if not found.
getRegister
public static Register getRegister(String rname)
Get register object corresponding to given name. If no match, return null.
Parameters:
rname – The register name, in $0 format.
Returns:
The register object,or null if not found.
resetRegisters
public static void resetRegisters()
Method to reinitialize the values of the registers.
addRegistersObserver
public static void addRegistersObserver(Observer observer)
Each individual register is a separate object and Observable. This handy method
will add the given Observer to each one.
deleteRegistersObserver
public static void deleteRegistersObserver(Observer observer)
Each individual register is a separate object and Observable. This handy method
will delete the given Observer from each one.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Coprocessor1
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.hardware
Class Coprocessor1
java.lang.Object
mars.mips.hardware.Coprocessor1
public class Coprocessor1
extends Object
Represents Coprocessor 1, the Floating Point Unit (FPU)
Author:
Pete Sanderson
Constructor Summary
Coprocessor1()
Method Summary
static void addRegistersObserver(Observer observer)
Each individual register is a separate object and Observable.
static int clearConditionFlag(int flag)
Set condition flag to 0 (false).
static void clearConditionFlags()
Clear all condition flags (0-7).
static void deleteRegistersObserver(Observer observer)
Each individual register is a separate object and Observable.
static int getConditionFlag(int flag)
Get value of specified condition flag (0-7).
static int getConditionFlagCount()
Get count of condition flags.
static int getConditionFlags()
Get array of condition flags (0-7).
static double getDoubleFromRegisterPair(int reg)
Gets the double value stored in the given FPU register.
static double getDoubleFromRegisterPair(String reg)
Gets the double value stored in the given FPU register.
static float getFloatFromRegister(int reg)
Gets the float value stored in the given FPU register.
static float getFloatFromRegister(String reg)
Gets the float value stored in the given FPU register.
static int getIntFromRegister(int reg)
Gets the 32-bit int bit pattern stored in the given FPU register.
static int getIntFromRegister(String reg)
Gets the 32-bit int bit pattern stored in the given FPU register.
static long getLongFromRegisterPair(int reg)
Gets a long representing the double value stored in the given double
precision FPU register.
static long getLongFromRegisterPair(String reg)
Gets the double value stored in the given FPU register.
static Register getRegister(String rName)
Get register object corresponding to given name.
static int getRegisterNumber(String n)
For getting the number representation of the FPU register.
static Register[] getRegisters()
For returning the set of registers.
static int getValue(int num)
Returns the value of the FPU register who’s number is num.
static void resetRegisters()
Method to reinitialize the values of the registers.
static int setConditionFlag(int flag)
Set condition flag to 1 (true).
static void setConditionFlags()
Set all condition flags (0-7).
static void setRegisterPairToDouble(int reg,
double val)
Sets the value of the FPU register given to the double value given.
static void setRegisterPairToDouble(String reg,
double val)
Sets the value of the FPU register given to the double value given.
static void setRegisterPairToLong(int reg,
long val)
Sets the value of the FPU register pair given to the long value containing 64 bit pattern
given.
static void setRegisterPairToLong(String reg,
long val)
Sets the value of the FPU register pair given to the long value containing 64 bit pattern
given.
static void setRegisterToFloat(int reg,
float val)
Sets the value of the FPU register given to the value given.
static void setRegisterToFloat(String reg,
float val)
Sets the value of the FPU register given to the value given.
static void setRegisterToInt(int reg,
int val)
Sets the value of the FPU register given to the 32-bit
pattern given by the int parameter.
static void setRegisterToInt(String reg,
int val)
Sets the value of the FPU register given to the 32-bit
pattern given by the int parameter.
static void showRegisters()
Method for displaying the register values for debugging.
static int updateRegister(int num,
int val)
This method updates the FPU register value who’s number is num.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
Coprocessor1
public Coprocessor1()
Method Detail
showRegisters
public static void showRegisters()
Method for displaying the register values for debugging.
setRegisterToFloat
public static void setRegisterToFloat(String reg,
float val)
Sets the value of the FPU register given to the value given.
Parameters:
reg – Register to set the value of.
val – The desired float value for the register.
setRegisterToFloat
public static void setRegisterToFloat(int reg,
float val)
Sets the value of the FPU register given to the value given.
Parameters:
reg – Register to set the value of.
val – The desired float value for the register.
setRegisterToInt
public static void setRegisterToInt(String reg,
int val)
Sets the value of the FPU register given to the 32-bit
pattern given by the int parameter.
Parameters:
reg – Register to set the value of.
val – The desired int bit pattern for the register.
setRegisterToInt
public static void setRegisterToInt(int reg,
int val)
Sets the value of the FPU register given to the 32-bit
pattern given by the int parameter.
Parameters:
reg – Register to set the value of.
val – The desired int bit pattern for the register.
setRegisterPairToDouble
public static void setRegisterPairToDouble(int reg,
double val)
throws InvalidRegisterAccessException
Sets the value of the FPU register given to the double value given. The register
must be even-numbered, and the low order 32 bits are placed in it. The high order
32 bits are placed in the (odd numbered) register that follows it.
Parameters:
reg – Register to set the value of.
val – The desired double value for the register.
Throws:
InvalidRegisterAccessException – if register ID is invalid or odd-numbered.
setRegisterPairToDouble
public static void setRegisterPairToDouble(String reg,
double val)
throws InvalidRegisterAccessException
Sets the value of the FPU register given to the double value given. The register
must be even-numbered, and the low order 32 bits are placed in it. The high order
32 bits are placed in the (odd numbered) register that follows it.
Parameters:
reg – Register to set the value of.
val – The desired double value for the register.
Throws:
InvalidRegisterAccessException – if register ID is invalid or odd-numbered.
setRegisterPairToLong
public static void setRegisterPairToLong(int reg,
long val)
throws InvalidRegisterAccessException
Sets the value of the FPU register pair given to the long value containing 64 bit pattern
given. The register
must be even-numbered, and the low order 32 bits from the long are placed in it. The high order
32 bits from the long are placed in the (odd numbered) register that follows it.
Parameters:
reg – Register to set the value of. Must be even register of even/odd pair.
val – The desired double value for the register.
Throws:
InvalidRegisterAccessException – if register ID is invalid or odd-numbered.
setRegisterPairToLong
public static void setRegisterPairToLong(String reg,
long val)
throws InvalidRegisterAccessException
Sets the value of the FPU register pair given to the long value containing 64 bit pattern
given. The register
must be even-numbered, and the low order 32 bits from the long are placed in it. The high order
32 bits from the long are placed in the (odd numbered) register that follows it.
Parameters:
reg – Register to set the value of. Must be even register of even/odd pair.
val – The desired long value containing the 64 bits for the register pair.
Throws:
InvalidRegisterAccessException – if register ID is invalid or odd-numbered.
getFloatFromRegister
public static float getFloatFromRegister(int reg)
Gets the float value stored in the given FPU register.
Parameters:
reg – Register to get the value of.
Returns:
The float value stored by that register.
getFloatFromRegister
public static float getFloatFromRegister(String reg)
Gets the float value stored in the given FPU register.
Parameters:
reg – Register to get the value of.
Returns:
The float value stored by that register.
getIntFromRegister
public static int getIntFromRegister(int reg)
Gets the 32-bit int bit pattern stored in the given FPU register.
Parameters:
reg – Register to get the value of.
Returns:
The int bit pattern stored by that register.
getIntFromRegister
public static int getIntFromRegister(String reg)
Gets the 32-bit int bit pattern stored in the given FPU register.
Parameters:
reg – Register to get the value of.
Returns:
The int bit pattern stored by that register.
getDoubleFromRegisterPair
public static double getDoubleFromRegisterPair(int reg)
throws InvalidRegisterAccessException
Gets the double value stored in the given FPU register. The register
must be even-numbered.
Parameters:
reg – Register to get the value of. Must be even number of even/odd pair.
Throws:
InvalidRegisterAccessException – if register ID is invalid or odd-numbered.
getDoubleFromRegisterPair
public static double getDoubleFromRegisterPair(String reg)
throws InvalidRegisterAccessException
Gets the double value stored in the given FPU register. The register
must be even-numbered.
Parameters:
reg – Register to get the value of. Must be even number of even/odd pair.
Throws:
InvalidRegisterAccessException – if register ID is invalid or odd-numbered.
getLongFromRegisterPair
public static long getLongFromRegisterPair(int reg)
throws InvalidRegisterAccessException
Gets a long representing the double value stored in the given double
precision FPU register.
The register must be even-numbered.
Parameters:
reg – Register to get the value of. Must be even number of even/odd pair.
Throws:
InvalidRegisterAccessException – if register ID is invalid or odd-numbered.
getLongFromRegisterPair
public static long getLongFromRegisterPair(String reg)
throws InvalidRegisterAccessException
Gets the double value stored in the given FPU register. The register
must be even-numbered.
Parameters:
reg – Register to get the value of. Must be even number of even/odd pair.
Throws:
InvalidRegisterAccessException – if register ID is invalid or odd-numbered.
updateRegister
public static int updateRegister(int num,
int val)
This method updates the FPU register value who’s number is num. Note the
registers themselves hold an int value. There are helper methods available
to which you can give a float or double to store.
Parameters:
num – FPU register to set the value of.
val – The desired int value for the register.
getValue
public static int getValue(int num)
Returns the value of the FPU register who’s number is num. Returns the
raw int value actually stored there. If you need a float, use
Float.intBitsToFloat() to get the equivent float.
Parameters:
num – The FPU register number.
Returns:
The int value of the given register.
getRegisterNumber
public static int getRegisterNumber(String n)
For getting the number representation of the FPU register.
Parameters:
n – The string formatted register name to look for.
Returns:
The number of the register represented by the string.
getRegisters
public static Register[] getRegisters()
For returning the set of registers.
Returns:
The set of registers.
getRegister
public static Register getRegister(String rName)
Get register object corresponding to given name. If no match, return null.
Parameters:
rName – The FPU register name, must be “$f0” through “$f31”.
Returns:
The register object,or null if not found.
resetRegisters
public static void resetRegisters()
Method to reinitialize the values of the registers.
addRegistersObserver
public static void addRegistersObserver(Observer observer)
Each individual register is a separate object and Observable. This handy method
will add the given Observer to each one.
deleteRegistersObserver
public static void deleteRegistersObserver(Observer observer)
Each individual register is a separate object and Observable. This handy method
will delete the given Observer from each one.
setConditionFlag
public static int setConditionFlag(int flag)
Set condition flag to 1 (true).
Parameters:
flag – condition flag number (0-7)
Returns:
previous flag setting (0 or 1)
clearConditionFlag
public static int clearConditionFlag(int flag)
Set condition flag to 0 (false).
Parameters:
flag – condition flag number (0-7)
Returns:
previous flag setting (0 or 1)
getConditionFlag
public static int getConditionFlag(int flag)
Get value of specified condition flag (0-7).
Parameters:
flag – condition flag number (0-7)
Returns:
0 if condition is false, 1 if condition is true
getConditionFlags
public static int getConditionFlags()
Get array of condition flags (0-7).
Returns:
array of int condition flags
clearConditionFlags
public static void clearConditionFlags()
Clear all condition flags (0-7).
setConditionFlags
public static void setConditionFlags()
Set all condition flags (0-7).
getConditionFlagCount
public static int getConditionFlagCount()
Get count of condition flags.
Returns:
number of condition flags
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InvalidRegisterAccessException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.hardware
Class InvalidRegisterAccessException
java.lang.Object
java.lang.Throwable
java.lang.Exception
mars.mips.hardware.InvalidRegisterAccessException
All Implemented Interfaces:
Serializable
public class InvalidRegisterAccessException
extends Exception
Represents attempt to access double precision register using an odd
(e.g. $f1, $f23) register name.
Author:
Pete Sanderson
See Also:
Serialized Form
Constructor Summary
InvalidRegisterAccessException()
Constructor for IllegalRegisterException.
Method Summary
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
InvalidRegisterAccessException
public InvalidRegisterAccessException()
Constructor for IllegalRegisterException.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Memory
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.hardware
Class Memory
java.lang.Object
java.util.Observable
mars.mips.hardware.Memory
public class Memory
extends Observable
Represents MIPS memory. Different segments are represented by different data structs.
Author:
Pete Sanderson
Field Summary
static boolean BIG_ENDIAN
Constant representing byte order of each memory word.
static int dataBaseAddress
base address for storage of non-global static data in data segment: 0x10010000 (from SPIM)
static int dataSegmentBaseAddress
base address for (user) data segment: 0x10000000
static int dataSegmentLimitAddress
static int exceptionHandlerAddress
starting address for exception handlers: 0x80000180
static int externBaseAddress
base address for .extern directive: 0x10000000
static int globalPointer
base address for storing globals
static int heapAddress
static int heapBaseAddress
base address for heap: 0x10040000 (I think from SPIM not MIPS)
static int kernelBaseAddress
kernel boundary.
static int kernelDataBaseAddress
base address for kernel data segment: 0x90000000
static int kernelDataSegmentLimitAddress
static int kernelHighAddress
highest address acessible in kernel mode.
static int kernelTextBaseAddress
base address for kernel text segment: 0x80000000
static int kernelTextLimitAddress
static boolean LITTLE_ENDIAN
Constant representing byte order of each memory word.
static int memoryMapBaseAddress
starting address for memory mapped I/O: 0xffff0000 (-65536)
static int memoryMapLimitAddress
static int stackBaseAddress
base address for stack: 0x7ffffffc (this is mine – start of highest word below kernel space)
static int stackLimitAddress
static int stackPointer
starting address for stack: 0x7fffeffc (this is from SPIM not MIPS)
static int textBaseAddress
base address for (user) text segment: 0x00400000
static int textLimitAddress
static int userHighAddress
highest address accessible in user (not kernel) mode.
static int WORD_LENGTH_BYTES
MIPS word length in bytes.
Method Summary
void addObserver(Observer obs)
Method to accept registration from observer for any memory address.
void addObserver(Observer obs,
int addr)
Method to accept registration from observer for specific address.
void addObserver(Observer obs,
int startAddr,
int endAddr)
Method to accept registration from observer for specific address range.
static int alignToWordBoundary(int address)
Utility method to align given address to next full word boundary, if not already
aligned.
int allocateBytesFromHeap(int numBytes)
Returns the next available word-aligned heap address.
void clear()
Explicitly clear the contents of memory.
int countObservers()
Return number of observers
void deleteObserver(Observer obs)
Remove specified memory observers
void deleteObservers()
Remove all memory observers
static boolean doublewordAligned(int address)
Utility to determine if given address is doubleword-aligned.
int get(int address,
int length)
Starting at the given word address, read the given number of bytes (max 4).
int getAddressOfFirstNull(int baseAddress,
int limitAddress)
Look for first “null” memory value in an address range.
int getByte(int address)
Reads specified Memory byte into low order 8 bits of int.
boolean getByteOrder()
Retrieve memory byte order.
int getHalf(int address)
Starting at the given word address, read a 2 byte word into lower 16 bits of int.
static Memory getInstance()
Returns the unique Memory instance, which becomes in essence global.
int getRawWord(int address)
Starting at the given word address, read a 4 byte word as an int.
Integer getRawWordOrNull(int address)
Starting at the given word address, read a 4 byte word as an int and return Integer.
ProgramStatement getStatement(int address)
Gets ProgramStatement from Text Segment.
ProgramStatement getStatementNoNotify(int address)
Gets ProgramStatement from Text Segment without notifying observers.
int getWord(int address)
Starting at the given word address, read a 4 byte word as an int.
int getWordNoNotify(int address)
Starting at the given word address, read a 4 byte word as an int.
static boolean inDataSegment(int address)
Handy little utility to find out if given address is in MARS data
segment (starts at Memory.dataSegmentBaseAddress).
static boolean inKernelDataSegment(int address)
Handy little utility to find out if given address is in MARS kernel data
segment (starts at Memory.kernelDataSegmentBaseAddress).
static boolean inKernelTextSegment(int address)
Handy little utility to find out if given address is in MARS kernel
text segment (starts at Memory.kernelTextBaseAddress).
static boolean inMemoryMapSegment(int address)
Handy little utility to find out if given address is in the Memory Map area
starts at Memory.memoryMapBaseAddress, range 0xffff0000 to 0xffffffff.
static boolean inTextSegment(int address)
Handy little utility to find out if given address is in MARS text
segment (starts at Memory.textBaseAddress).
void notifyObservers()
Overridden to be unavailable.
void notifyObservers(Object obj)
Overridden to be unavailable.
int set(int address,
int value,
int length)
Starting at the given address, write the given value over the given number of bytes.
int setByte(int address,
int value)
Writes low order 8 bits of given value into specified Memory byte.
void setByteOrder(boolean order)
Set byte order to either LITTLE_ENDIAN or BIG_ENDIAN.
static void setConfiguration()
Sets current memory configuration for simulated MIPS.
double setDouble(int address,
double value)
Writes 64 bit double value starting at specified Memory address.
int setHalf(int address,
int value)
Starting at the given halfword address, write the lower 16 bits of given value
into 2 bytes (a halfword).
int setRawWord(int address,
int value)
Starting at the given word address, write the given value over 4 bytes (a word).
void setStatement(int address,
ProgramStatement statement)
Stores ProgramStatement in Text Segment.
int setWord(int address,
int value)
Starting at the given word address, write the given value over 4 bytes (a word).
boolean usingCompactMemoryConfiguration()
Determine whether the current memory configuration has a maximum address that can be stored
in 16 bits.
static boolean wordAligned(int address)
Utility to determine if given address is word-aligned.
Methods inherited from class java.util.Observable
clearChanged, hasChanged, setChanged
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
textBaseAddress
public static int textBaseAddress
base address for (user) text segment: 0x00400000
dataSegmentBaseAddress
public static int dataSegmentBaseAddress
base address for (user) data segment: 0x10000000
externBaseAddress
public static int externBaseAddress
base address for .extern directive: 0x10000000
globalPointer
public static int globalPointer
base address for storing globals
dataBaseAddress
public static int dataBaseAddress
base address for storage of non-global static data in data segment: 0x10010000 (from SPIM)
heapBaseAddress
public static int heapBaseAddress
base address for heap: 0x10040000 (I think from SPIM not MIPS)
stackPointer
public static int stackPointer
starting address for stack: 0x7fffeffc (this is from SPIM not MIPS)
stackBaseAddress
public static int stackBaseAddress
base address for stack: 0x7ffffffc (this is mine – start of highest word below kernel space)
userHighAddress
public static int userHighAddress
highest address accessible in user (not kernel) mode.
kernelBaseAddress
public static int kernelBaseAddress
kernel boundary. Only OS can access this or higher address
kernelTextBaseAddress
public static int kernelTextBaseAddress
base address for kernel text segment: 0x80000000
exceptionHandlerAddress
public static int exceptionHandlerAddress
starting address for exception handlers: 0x80000180
kernelDataBaseAddress
public static int kernelDataBaseAddress
base address for kernel data segment: 0x90000000
memoryMapBaseAddress
public static int memoryMapBaseAddress
starting address for memory mapped I/O: 0xffff0000 (-65536)
kernelHighAddress
public static int kernelHighAddress
highest address acessible in kernel mode.
WORD_LENGTH_BYTES
public static final int WORD_LENGTH_BYTES
MIPS word length in bytes.
See Also:
Constant Field Values
LITTLE_ENDIAN
public static final boolean LITTLE_ENDIAN
Constant representing byte order of each memory word. Little-endian means lowest
numbered byte is right most [3][2][1][0].
See Also:
Constant Field Values
BIG_ENDIAN
public static final boolean BIG_ENDIAN
Constant representing byte order of each memory word. Big-endian means lowest
numbered byte is left most [0][1][2][3].
See Also:
Constant Field Values
heapAddress
public static int heapAddress
dataSegmentLimitAddress
public static int dataSegmentLimitAddress
textLimitAddress
public static int textLimitAddress
kernelDataSegmentLimitAddress
public static int kernelDataSegmentLimitAddress
kernelTextLimitAddress
public static int kernelTextLimitAddress
stackLimitAddress
public static int stackLimitAddress
memoryMapLimitAddress
public static int memoryMapLimitAddress
Method Detail
getInstance
public static Memory getInstance()
Returns the unique Memory instance, which becomes in essence global.
clear
public void clear()
Explicitly clear the contents of memory. Typically done at start of assembly.
setConfiguration
public static void setConfiguration()
Sets current memory configuration for simulated MIPS. Configuration is
collection of memory segment addresses. e.g. text segment starting at
address 0x00400000. Configuration can be modified starting with MARS 3.7.
usingCompactMemoryConfiguration
public boolean usingCompactMemoryConfiguration()
Determine whether the current memory configuration has a maximum address that can be stored
in 16 bits.
Returns:
true if maximum address can be stored in 16 bits or less, false otherwise
allocateBytesFromHeap
public int allocateBytesFromHeap(int numBytes)
throws IllegalArgumentException
Returns the next available word-aligned heap address. There is no recycling and
no heap management! There is however nearly 4MB of heap space available in Mars.
Parameters:
numBytes – Number of bytes requested. Should be multiple of 4, otherwise next higher multiple of 4 allocated.
Returns:
address of allocated heap storage.
Throws:
IllegalArgumentException – if number of requested bytes is negative or exceeds available heap storage
setByteOrder
public void setByteOrder(boolean order)
Set byte order to either LITTLE_ENDIAN or BIG_ENDIAN. Default is LITTLE_ENDIAN.
Parameters:
order – either LITTLE_ENDIAN or BIG_ENDIAN
getByteOrder
public boolean getByteOrder()
Retrieve memory byte order. Default is LITTLE_ENDIAN (like PCs).
Returns:
either LITTLE_ENDIAN or BIG_ENDIAN
set
public int set(int address,
int value,
int length)
throws AddressErrorException
Starting at the given address, write the given value over the given number of bytes.
This one does not check for word boundaries, and copies one byte at a time.
If length == 1, takes value from low order byte. If 2, takes from low order half-word.
Parameters:
address – Starting address of Memory address to be set.
value – Value to be stored starting at that address.
length – Number of bytes to be written.
Returns:
old value that was replaced by the set operation
Throws:
AddressErrorException
setRawWord
public int setRawWord(int address,
int value)
throws AddressErrorException
Starting at the given word address, write the given value over 4 bytes (a word).
It must be written as is, without adjusting for byte order (little vs big endian).
Address must be word-aligned.
Parameters:
address – Starting address of Memory address to be set.
value – Value to be stored starting at that address.
Returns:
old value that was replaced by the set operation.
Throws:
AddressErrorException – If address is not on word boundary.
setWord
public int setWord(int address,
int value)
throws AddressErrorException
Starting at the given word address, write the given value over 4 bytes (a word).
The address must be word-aligned.
Parameters:
address – Starting address of Memory address to be set.
value – Value to be stored starting at that address.
Returns:
old value that was replaced by setWord operation.
Throws:
AddressErrorException – If address is not on word boundary.
setHalf
public int setHalf(int address,
int value)
throws AddressErrorException
Starting at the given halfword address, write the lower 16 bits of given value
into 2 bytes (a halfword).
Parameters:
address – Starting address of Memory address to be set.
value – Value to be stored starting at that address. Only low order 16 bits used.
Returns:
old value that was replaced by setHalf operation.
Throws:
AddressErrorException – If address is not on halfword boundary.
setByte
public int setByte(int address,
int value)
throws AddressErrorException
Writes low order 8 bits of given value into specified Memory byte.
Parameters:
address – Address of Memory byte to be set.
value – Value to be stored at that address. Only low order 8 bits used.
Returns:
old value that was replaced by setByte operation.
Throws:
AddressErrorException
setDouble
public double setDouble(int address,
double value)
throws AddressErrorException
Writes 64 bit double value starting at specified Memory address. Note that
high-order 32 bits are stored in higher (second) memory word regardless
of “endianness”.
Parameters:
address – Starting address of Memory address to be set.
value – Value to be stored at that address.
Returns:
old value that was replaced by setDouble operation.
Throws:
AddressErrorException
setStatement
public void setStatement(int address,
ProgramStatement statement)
throws AddressErrorException
Stores ProgramStatement in Text Segment.
Parameters:
address – Starting address of Memory address to be set. Must be word boundary.
statement – Machine code to be stored starting at that address — for simulation
purposes, actually stores reference to ProgramStatement instead of 32-bit machine code.
Throws:
AddressErrorException – If address is not on word boundary or is outside Text Segment.
See Also:
ProgramStatement
get
public int get(int address,
int length)
throws AddressErrorException
Starting at the given word address, read the given number of bytes (max 4).
This one does not check for word boundaries, and copies one byte at a time.
If length == 1, puts value in low order byte. If 2, puts into low order half-word.
Parameters:
address – Starting address of Memory address to be read.
length – Number of bytes to be read.
Returns:
Value stored starting at that address.
Throws:
AddressErrorException
getRawWord
public int getRawWord(int address)
throws AddressErrorException
Starting at the given word address, read a 4 byte word as an int.
It transfers the 32 bit value “raw” as stored in memory, and does not adjust
for byte order (big or little endian). Address must be word-aligned.
Parameters:
address – Starting address of word to be read.
Returns:
Word (4-byte value) stored starting at that address.
Throws:
AddressErrorException – If address is not on word boundary.
getRawWordOrNull
public Integer getRawWordOrNull(int address)
throws AddressErrorException
Starting at the given word address, read a 4 byte word as an int and return Integer.
It transfers the 32 bit value “raw” as stored in memory, and does not adjust
for byte order (big or little endian). Address must be word-aligned.
Returns null if reading from text segment and there is no instruction at the
requested address. Returns null if reading from data segment and this is the
first reference to the MARS 4K memory allocation block (i.e., an array to
hold the memory has not been allocated).
This method was developed by Greg Giberling of UC Berkeley to support the memory
dump feature that he implemented in Fall 2007.
Parameters:
address – Starting address of word to be read.
Returns:
Word (4-byte value) stored starting at that address as an Integer. Conditions
that cause return value null are described above.
Throws:
AddressErrorException – If address is not on word boundary.
getAddressOfFirstNull
public int getAddressOfFirstNull(int baseAddress,
int limitAddress)
throws AddressErrorException
Look for first “null” memory value in an address range. For text segment (binary code), this
represents a word that does not contain an instruction. Normally use this to find the end of
the program. For data segment, this represents the first block of simulated memory (block length
currently 4K words) that has not been referenced by an assembled/executing program.
Parameters:
baseAddress – lowest MIPS address to be searched; the starting point
limitAddress – highest MIPS address to be searched
Returns:
lowest address within specified range that contains “null” value as described above.
Throws:
AddressErrorException – if the base address is not on a word boundary
getWord
public int getWord(int address)
throws AddressErrorException
Starting at the given word address, read a 4 byte word as an int.
Does not use “get()”; we can do it faster here knowing we’re working only
with full words.
Parameters:
address – Starting address of word to be read.
Returns:
Word (4-byte value) stored starting at that address.
Throws:
AddressErrorException – If address is not on word boundary.
getWordNoNotify
public int getWordNoNotify(int address)
throws AddressErrorException
Starting at the given word address, read a 4 byte word as an int.
Does not use “get()”; we can do it faster here knowing we’re working only
with full words. Observers are NOT notified.
Parameters:
address – Starting address of word to be read.
Returns:
Word (4-byte value) stored starting at that address.
Throws:
AddressErrorException – If address is not on word boundary.
getHalf
public int getHalf(int address)
throws AddressErrorException
Starting at the given word address, read a 2 byte word into lower 16 bits of int.
Parameters:
address – Starting address of word to be read.
Returns:
Halfword (2-byte value) stored starting at that address, stored in lower 16 bits.
Throws:
AddressErrorException – If address is not on halfword boundary.
getByte
public int getByte(int address)
throws AddressErrorException
Reads specified Memory byte into low order 8 bits of int.
Parameters:
address – Address of Memory byte to be read.
Returns:
Value stored at that address. Only low order 8 bits used.
Throws:
AddressErrorException
getStatement
public ProgramStatement getStatement(int address)
throws AddressErrorException
Gets ProgramStatement from Text Segment.
Parameters:
address – Starting address of Memory address to be read. Must be word boundary.
Returns:
reference to ProgramStatement object associated with that address, or null if none.
Throws:
AddressErrorException – If address is not on word boundary or is outside Text Segment.
See Also:
ProgramStatement
getStatementNoNotify
public ProgramStatement getStatementNoNotify(int address)
throws AddressErrorException
Gets ProgramStatement from Text Segment without notifying observers.
Parameters:
address – Starting address of Memory address to be read. Must be word boundary.
Returns:
reference to ProgramStatement object associated with that address, or null if none.
Throws:
AddressErrorException – If address is not on word boundary or is outside Text Segment.
See Also:
ProgramStatement
wordAligned
public static boolean wordAligned(int address)
Utility to determine if given address is word-aligned.
Parameters:
address – the address to check
Returns:
true if address is word-aligned, false otherwise
doublewordAligned
public static boolean doublewordAligned(int address)
Utility to determine if given address is doubleword-aligned.
Parameters:
address – the address to check
Returns:
true if address is doubleword-aligned, false otherwise
alignToWordBoundary
public static int alignToWordBoundary(int address)
Utility method to align given address to next full word boundary, if not already
aligned.
Parameters:
address – a memory address (any int value is potentially valid)
Returns:
address aligned to next word boundary (divisible by 4)
inTextSegment
public static boolean inTextSegment(int address)
Handy little utility to find out if given address is in MARS text
segment (starts at Memory.textBaseAddress).
Note that MARS does not implement the entire MIPS text segment space,
but it does implement enough for hundreds of thousands of lines
of code.
Parameters:
address – integer memory address
Returns:
true if that address is within MARS-defined text segment,
false otherwise.
inKernelTextSegment
public static boolean inKernelTextSegment(int address)
Handy little utility to find out if given address is in MARS kernel
text segment (starts at Memory.kernelTextBaseAddress).
Parameters:
address – integer memory address
Returns:
true if that address is within MARS-defined kernel text segment,
false otherwise.
inDataSegment
public static boolean inDataSegment(int address)
Handy little utility to find out if given address is in MARS data
segment (starts at Memory.dataSegmentBaseAddress).
Note that MARS does not implement the entire MIPS data segment space,
but it does support at least 4MB.
Parameters:
address – integer memory address
Returns:
true if that address is within MARS-defined data segment,
false otherwise.
inKernelDataSegment
public static boolean inKernelDataSegment(int address)
Handy little utility to find out if given address is in MARS kernel data
segment (starts at Memory.kernelDataSegmentBaseAddress).
Parameters:
address – integer memory address
Returns:
true if that address is within MARS-defined kernel data segment,
false otherwise.
inMemoryMapSegment
public static boolean inMemoryMapSegment(int address)
Handy little utility to find out if given address is in the Memory Map area
starts at Memory.memoryMapBaseAddress, range 0xffff0000 to 0xffffffff.
Parameters:
address – integer memory address
Returns:
true if that address is within MARS-defined memory map (MMIO) area,
false otherwise.
addObserver
public void addObserver(Observer obs)
Method to accept registration from observer for any memory address. Overrides
inherited method. Note to observers: this class delegates Observable operations
so notices will come from the delegate, not the memory object.
Overrides:
addObserver in class Observable
Parameters:
obs – the observer
addObserver
public void addObserver(Observer obs,
int addr)
throws AddressErrorException
Method to accept registration from observer for specific address. This includes
the memory word starting at the given address. Note to observers: this class delegates Observable operations
so notices will come from the delegate, not the memory object.
Parameters:
obs – the observer
addr – the memory address which must be on word boundary
Throws:
AddressErrorException
addObserver
public void addObserver(Observer obs,
int startAddr,
int endAddr)
throws AddressErrorException
Method to accept registration from observer for specific address range. The
last byte included in the address range is the last byte of the word specified
by the ending address. Note to observers: this class delegates Observable operations
so notices will come from the delegate, not the memory object.
Parameters:
obs – the observer
startAddr – the low end of memory address range, must be on word boundary
endAddr – the high end of memory address range, must be on word boundary
Throws:
AddressErrorException
countObservers
public int countObservers()
Return number of observers
Overrides:
countObservers in class Observable
deleteObserver
public void deleteObserver(Observer obs)
Remove specified memory observers
Overrides:
deleteObserver in class Observable
Parameters:
obs – Observer to be removed
deleteObservers
public void deleteObservers()
Remove all memory observers
Overrides:
deleteObservers in class Observable
notifyObservers
public void notifyObservers()
Overridden to be unavailable. The notice that an Observer
receives does not come from the memory object itself, but
instead from a delegate.
Overrides:
notifyObservers in class Observable
Throws:
UnsupportedOperationException
notifyObservers
public void notifyObservers(Object obj)
Overridden to be unavailable. The notice that an Observer
receives does not come from the memory object itself, but
instead from a delegate.
Overrides:
notifyObservers in class Observable
Throws:
UnsupportedOperationException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
MemoryAccessNotice
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.hardware
Class MemoryAccessNotice
java.lang.Object
mars.mips.hardware.AccessNotice
mars.mips.hardware.MemoryAccessNotice
public class MemoryAccessNotice
extends AccessNotice
Object provided to Observers of runtime access to MIPS memory.
Observer can get the access type (R/W), address and length in bytes (4,2,1).
Author:
Pete Sanderson
Field Summary
Fields inherited from class mars.mips.hardware.AccessNotice
READ, WRITE
Constructor Summary
MemoryAccessNotice(int type,
int address,
int value)
Constructor will be called only within this package, so assume
address is in valid range.
Method Summary
int getAddress()
Fetch the memory address that was accessed.
int getLength()
Fetch the length in bytes of the access operation (4,2,1).
int getValue()
Fetch the value of the access operation (the value read or written).
String toString()
String representation indicates access type, address and length in bytes
Methods inherited from class mars.mips.hardware.AccessNotice
accessIsFromGUI, accessIsFromMIPS, getAccessType, getThread
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
MemoryAccessNotice
public MemoryAccessNotice(int type,
int address,
int value)
Constructor will be called only within this package, so assume
address is in valid range.
Method Detail
getAddress
public int getAddress()
Fetch the memory address that was accessed.
getLength
public int getLength()
Fetch the length in bytes of the access operation (4,2,1).
getValue
public int getValue()
Fetch the value of the access operation (the value read or written).
toString
public String toString()
String representation indicates access type, address and length in bytes
Overrides:
toString in class Object
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
MemoryConfiguration
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.hardware
Class MemoryConfiguration
java.lang.Object
mars.mips.hardware.MemoryConfiguration
public class MemoryConfiguration
extends Object
Models the memory configuration for the simulated MIPS machine.
“configuration” refers to the starting memory addresses for
the various memory segments.
The default configuration is based on SPIM. Starting with MARS 3.7,
the configuration can be changed.
Author:
Pete Sanderson
Constructor Summary
MemoryConfiguration(String ident,
String name,
String[] items,
int[] values)
Method Summary
String getConfigurationIdentifier()
String[] getConfigurationItemNames()
int[] getConfigurationItemValues()
String getConfigurationName()
int getDataBaseAddress()
int getDataSegmentBaseAddress()
int getDataSegmentLimitAddress()
int getExceptionHandlerAddress()
int getExternBaseAddress()
int getGlobalPointer()
int getHeapBaseAddress()
int getKernelBaseAddress()
int getKernelDataBaseAddress()
int getKernelDataSegmentLimitAddress()
int getKernelHighAddress()
int getKernelTextBaseAddress()
int getKernelTextLimitAddress()
int getMemoryMapBaseAddress()
int getMemoryMapLimitAddress()
int getStackBaseAddress()
int getStackLimitAddress()
int getStackPointer()
int getTextBaseAddress()
int getTextLimitAddress()
int getUserHighAddress()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
MemoryConfiguration
public MemoryConfiguration(String ident,
String name,
String[] items,
int[] values)
Method Detail
getConfigurationIdentifier
public String getConfigurationIdentifier()
getConfigurationName
public String getConfigurationName()
getConfigurationItemValues
public int[] getConfigurationItemValues()
getConfigurationItemNames
public String[] getConfigurationItemNames()
getTextBaseAddress
public int getTextBaseAddress()
getDataSegmentBaseAddress
public int getDataSegmentBaseAddress()
getExternBaseAddress
public int getExternBaseAddress()
getGlobalPointer
public int getGlobalPointer()
getDataBaseAddress
public int getDataBaseAddress()
getHeapBaseAddress
public int getHeapBaseAddress()
getStackPointer
public int getStackPointer()
getStackBaseAddress
public int getStackBaseAddress()
getUserHighAddress
public int getUserHighAddress()
getKernelBaseAddress
public int getKernelBaseAddress()
getKernelTextBaseAddress
public int getKernelTextBaseAddress()
getExceptionHandlerAddress
public int getExceptionHandlerAddress()
getKernelDataBaseAddress
public int getKernelDataBaseAddress()
getMemoryMapBaseAddress
public int getMemoryMapBaseAddress()
getKernelHighAddress
public int getKernelHighAddress()
getDataSegmentLimitAddress
public int getDataSegmentLimitAddress()
getTextLimitAddress
public int getTextLimitAddress()
getKernelDataSegmentLimitAddress
public int getKernelDataSegmentLimitAddress()
getKernelTextLimitAddress
public int getKernelTextLimitAddress()
getStackLimitAddress
public int getStackLimitAddress()
getMemoryMapLimitAddress
public int getMemoryMapLimitAddress()
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
MemoryConfigurations
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.hardware
Class MemoryConfigurations
java.lang.Object
mars.mips.hardware.MemoryConfigurations
public class MemoryConfigurations
extends Object
Models the collection of MIPS memory configurations.
The default configuration is based on SPIM. Starting with MARS 3.7,
the configuration can be changed.
Author:
Pete Sanderson
Constructor Summary
MemoryConfigurations()
Method Summary
static void buildConfigurationCollection()
static MemoryConfiguration getConfigurationByName(String name)
static Iterator getConfigurationsIterator()
static MemoryConfiguration getCurrentConfiguration()
static MemoryConfiguration getDefaultConfiguration()
static int getDefaultDataBaseAddress()
static int getDefaultDataSegmentBaseAddress()
int getDefaultDataSegmentLimitAddress()
static int getDefaultExceptionHandlerAddress()
static int getDefaultExternBaseAddress()
static int getDefaultGlobalPointer()
static int getDefaultHeapBaseAddress()
static int getDefaultKernelBaseAddress()
static int getDefaultKernelDataBaseAddress()
int getDefaultKernelDataSegmentLimitAddress()
static int getDefaultKernelHighAddress()
static int getDefaultKernelTextBaseAddress()
int getDefaultKernelTextLimitAddress()
static int getDefaultMemoryMapBaseAddress()
static int getDefaultStackBaseAddress()
int getDefaultStackLimitAddress()
static int getDefaultStackPointer()
static int getDefaultTextBaseAddress()
int getDefaultTextLimitAddress()
static int getDefaultUserHighAddress()
int getMemoryMapLimitAddress()
static boolean setCurrentConfiguration(MemoryConfiguration config)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
MemoryConfigurations
public MemoryConfigurations()
Method Detail
buildConfigurationCollection
public static void buildConfigurationCollection()
getConfigurationsIterator
public static Iterator getConfigurationsIterator()
getConfigurationByName
public static MemoryConfiguration getConfigurationByName(String name)
getDefaultConfiguration
public static MemoryConfiguration getDefaultConfiguration()
getCurrentConfiguration
public static MemoryConfiguration getCurrentConfiguration()
setCurrentConfiguration
public static boolean setCurrentConfiguration(MemoryConfiguration config)
getDefaultTextBaseAddress
public static int getDefaultTextBaseAddress()
getDefaultDataSegmentBaseAddress
public static int getDefaultDataSegmentBaseAddress()
getDefaultExternBaseAddress
public static int getDefaultExternBaseAddress()
getDefaultGlobalPointer
public static int getDefaultGlobalPointer()
getDefaultDataBaseAddress
public static int getDefaultDataBaseAddress()
getDefaultHeapBaseAddress
public static int getDefaultHeapBaseAddress()
getDefaultStackPointer
public static int getDefaultStackPointer()
getDefaultStackBaseAddress
public static int getDefaultStackBaseAddress()
getDefaultUserHighAddress
public static int getDefaultUserHighAddress()
getDefaultKernelBaseAddress
public static int getDefaultKernelBaseAddress()
getDefaultKernelTextBaseAddress
public static int getDefaultKernelTextBaseAddress()
getDefaultExceptionHandlerAddress
public static int getDefaultExceptionHandlerAddress()
getDefaultKernelDataBaseAddress
public static int getDefaultKernelDataBaseAddress()
getDefaultMemoryMapBaseAddress
public static int getDefaultMemoryMapBaseAddress()
getDefaultKernelHighAddress
public static int getDefaultKernelHighAddress()
getDefaultDataSegmentLimitAddress
public int getDefaultDataSegmentLimitAddress()
getDefaultTextLimitAddress
public int getDefaultTextLimitAddress()
getDefaultKernelDataSegmentLimitAddress
public int getDefaultKernelDataSegmentLimitAddress()
getDefaultKernelTextLimitAddress
public int getDefaultKernelTextLimitAddress()
getDefaultStackLimitAddress
public int getDefaultStackLimitAddress()
getMemoryMapLimitAddress
public int getMemoryMapLimitAddress()
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.hardware
mars.mips.hardware
Classes
AccessNotice
Coprocessor0
Coprocessor1
Memory
MemoryAccessNotice
MemoryConfiguration
MemoryConfigurations
Register
RegisterAccessNotice
RegisterFile
Exceptions
AddressErrorException
InvalidRegisterAccessException
mars.mips.hardware
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
Package mars.mips.hardware
Class Summary
AccessNotice Object provided to Observers of runtime access to MIPS memory or registers.
Coprocessor0 Represents Coprocessor 0.
Coprocessor1 Represents Coprocessor 1, the Floating Point Unit (FPU)
Memory Represents MIPS memory.
MemoryAccessNotice Object provided to Observers of runtime access to MIPS memory.
MemoryConfiguration Models the memory configuration for the simulated MIPS machine.
MemoryConfigurations Models the collection of MIPS memory configurations.
Register Abstraction to represent a register of a MIPS Assembler.
RegisterAccessNotice Object provided to Observers of runtime access to MIPS register.
RegisterFile Represents the collection of MIPS registers.
Exception Summary
AddressErrorException Represents MIPS AddressErrorException.
InvalidRegisterAccessException Represents attempt to access double precision register using an odd
(e.g.
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
mars.mips.hardware Class Hierarchy
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Hierarchy For Package mars.mips.hardware
Package Hierarchies:
All Packages
Class Hierarchy
java.lang.Object mars.mips.hardware.AccessNotice mars.mips.hardware.MemoryAccessNotice
mars.mips.hardware.RegisterAccessNotice
mars.mips.hardware.Coprocessor0
mars.mips.hardware.Coprocessor1
mars.mips.hardware.MemoryConfiguration
mars.mips.hardware.MemoryConfigurations
java.util.Observable mars.mips.hardware.Memory
mars.mips.hardware.Register
mars.mips.hardware.RegisterFile
java.lang.Throwable (implements java.io.Serializable)
java.lang.Exception mars.mips.hardware.AddressErrorException
mars.mips.hardware.InvalidRegisterAccessException
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Register
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.hardware
Class Register
java.lang.Object
java.util.Observable
mars.mips.hardware.Register
public class Register
extends Observable
Abstraction to represent a register of a MIPS Assembler.
Author:
Jason Bumgarner, Jason Shrewsbury, Ben Sherman
Constructor Summary
Register(String n,
int num,
int val)
Creates a new register with specified name, number, and value.
Method Summary
void changeResetValue(int reset)
Change the register’s reset value; the value to which it will be
set when resetValue() is called.
String getName()
Returns the name of the Register.
int getNumber()
Returns the number of the Register.
int getResetValue()
Returns the reset value of the Register.
int getValue()
Returns the value of the Register.
int getValueNoNotify()
Returns the value of the Register.
void resetValue()
Resets the value of the register to the value it was constructed with.
int setValue(int val)
Sets the value of the register to the val passed to it.
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
Register
public Register(String n,
int num,
int val)
Creates a new register with specified name, number, and value.
Parameters:
n – The name of the register.
num – The number of the register.
val – The inital (and reset) value of the register.
Method Detail
getName
public String getName()
Returns the name of the Register.
Returns:
name The name of the Register.
getValue
public int getValue()
Returns the value of the Register. Observers are notified
of the READ operation.
Returns:
value The value of the Register.
getValueNoNotify
public int getValueNoNotify()
Returns the value of the Register. Observers are not notified.
Added for release 3.8.
Returns:
value The value of the Register.
getResetValue
public int getResetValue()
Returns the reset value of the Register.
Returns:
The reset (initial) value of the Register.
getNumber
public int getNumber()
Returns the number of the Register.
Returns:
number The number of the Register.
setValue
public int setValue(int val)
Sets the value of the register to the val passed to it.
Observers are notified of the WRITE operation.
Parameters:
val – Value to set the Register to.
Returns:
previous value of register
resetValue
public void resetValue()
Resets the value of the register to the value it was constructed with.
Observers are not notified.
changeResetValue
public void changeResetValue(int reset)
Change the register’s reset value; the value to which it will be
set when resetValue() is called.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
RegisterAccessNotice
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.hardware
Class RegisterAccessNotice
java.lang.Object
mars.mips.hardware.AccessNotice
mars.mips.hardware.RegisterAccessNotice
public class RegisterAccessNotice
extends AccessNotice
Object provided to Observers of runtime access to MIPS register.
Observer can get the access type (R/W) and register number.
Author:
Pete Sanderson
Field Summary
Fields inherited from class mars.mips.hardware.AccessNotice
READ, WRITE
Method Summary
String getRegisterName()
Fetch the register number of register accessed.
String toString()
String representation indicates access type and which register
Methods inherited from class mars.mips.hardware.AccessNotice
accessIsFromGUI, accessIsFromMIPS, getAccessType, getThread
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Method Detail
getRegisterName
public String getRegisterName()
Fetch the register number of register accessed.
toString
public String toString()
String representation indicates access type and which register
Overrides:
toString in class Object
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
RegisterFile
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.hardware
Class RegisterFile
java.lang.Object
mars.mips.hardware.RegisterFile
public class RegisterFile
extends Object
Represents the collection of MIPS registers.
Author:
Jason Bumgarner, Jason Shrewsbury
Field Summary
static int GLOBAL_POINTER_REGISTER
static int STACK_POINTER_REGISTER
Constructor Summary
RegisterFile()
Method Summary
static void addRegistersObserver(Observer observer)
Each individual register is a separate object and Observable.
static void deleteRegistersObserver(Observer observer)
Each individual register is a separate object and Observable.
static int getInitialProgramCounter()
For returning the program counter’s initial (reset) value.
static int getNumber(String n)
For getting the number representation of the register.
static int getProgramCounter()
For returning the program counters value.
static Register getProgramCounterRegister()
Returns Register object for program counter.
static Register[] getRegisters()
For returning the set of registers.
static Register getUserRegister(String Rname)
Get register object corresponding to given name.
static int getValue(int num)
Returns the value of the register who’s number is num.
static void incrementPC()
Method to increment the Program counter in the general case (not a jump or branch).
static void initializeProgramCounter(boolean startAtMain)
Will initialize the Program Counter to either the default reset value, or the address
associated with source program global label “main”, if it exists as a text segment label
and the global setting is set.
static void initializeProgramCounter(int value)
For initializing the Program Counter.
static void resetRegisters()
Method to reinitialize the values of the registers.
static int setProgramCounter(int value)
For setting the Program Counter.
static void showRegisters()
Method for displaying the register values for debugging.
static int updateRegister(int num,
int val)
This method updates the register value who’s number is num.
static void updateRegister(String reg,
int val)
Sets the value of the register given to the value given.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
GLOBAL_POINTER_REGISTER
public static final int GLOBAL_POINTER_REGISTER
See Also:
Constant Field Values
STACK_POINTER_REGISTER
public static final int STACK_POINTER_REGISTER
See Also:
Constant Field Values
Constructor Detail
RegisterFile
public RegisterFile()
Method Detail
showRegisters
public static void showRegisters()
Method for displaying the register values for debugging.
updateRegister
public static int updateRegister(int num,
int val)
This method updates the register value who’s number is num. Also handles the lo and hi registers
Parameters:
num – Register to set the value of.
val – The desired value for the register.
updateRegister
public static void updateRegister(String reg,
int val)
Sets the value of the register given to the value given.
Parameters:
reg – Name of register to set the value of.
val – The desired value for the register.
getValue
public static int getValue(int num)
Returns the value of the register who’s number is num.
Parameters:
num – The register number.
Returns:
The value of the given register.
getNumber
public static int getNumber(String n)
For getting the number representation of the register.
Parameters:
n – The string formatted register name to look for.
Returns:
The number of the register represented by the string
or -1 if no match.
getRegisters
public static Register[] getRegisters()
For returning the set of registers.
Returns:
The set of registers.
getUserRegister
public static Register getUserRegister(String Rname)
Get register object corresponding to given name. If no match, return null.
Parameters:
Rname – The register name, either in $0 or $zero format.
Returns:
The register object,or null if not found.
initializeProgramCounter
public static void initializeProgramCounter(int value)
For initializing the Program Counter. Do not use this to implement jumps and
branches, as it will NOT record a backstep entry with the restore value.
If you need backstepping capability, use setProgramCounter instead.
Parameters:
value – The value to set the Program Counter to.
initializeProgramCounter
public static void initializeProgramCounter(boolean startAtMain)
Will initialize the Program Counter to either the default reset value, or the address
associated with source program global label “main”, if it exists as a text segment label
and the global setting is set.
Parameters:
startAtMain – If true, will set program counter to address of statement labeled
‘main’ (or other defined start label) if defined. If not defined, or if parameter false,
will set program counter to default reset value.
setProgramCounter
public static int setProgramCounter(int value)
For setting the Program Counter. Note that ordinary PC update should be done using
incrementPC() method. Use this only when processing jumps and branches.
Parameters:
value – The value to set the Program Counter to.
Returns:
previous PC value
getProgramCounter
public static int getProgramCounter()
For returning the program counters value.
Returns:
The program counters value as an int.
getProgramCounterRegister
public static Register getProgramCounterRegister()
Returns Register object for program counter. Use with caution.
Returns:
program counter’s Register object.
getInitialProgramCounter
public static int getInitialProgramCounter()
For returning the program counter’s initial (reset) value.
Returns:
The program counter’s initial value
resetRegisters
public static void resetRegisters()
Method to reinitialize the values of the registers.
NOTE: Should not be called from command-mode MARS because this
this method uses global settings from the registry. Command-mode must operate
using only the command switches, not registry settings. It can be called
from tools running stand-alone, and this is done in
AbstractMarsToolAndApplication.
incrementPC
public static void incrementPC()
Method to increment the Program counter in the general case (not a jump or branch).
addRegistersObserver
public static void addRegistersObserver(Observer observer)
Each individual register is a separate object and Observable. This handy method
will add the given Observer to each one. Currently does not apply to Program
Counter.
deleteRegistersObserver
public static void deleteRegistersObserver(Observer observer)
Each individual register is a separate object and Observable. This handy method
will delete the given Observer from each one. Currently does not apply to Program
Counter.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
BasicInstruction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions
Class BasicInstruction
java.lang.Object
mars.mips.instructions.Instruction
mars.mips.instructions.BasicInstruction
public class BasicInstruction
extends Instruction
Class to represent a basic instruction in the MIPS instruction set.
Basic instruction means it translates directly to a 32-bit binary machine
instruction.
Author:
Pete Sanderson and Ken Vollmar
Field Summary
Fields inherited from class mars.mips.instructions.Instruction
description, exampleFormat, INSTRUCTION_LENGTH, INSTRUCTION_LENGTH_BITS, mnemonic, operandMask, tokenList
Constructor Summary
BasicInstruction(String example,
BasicInstructionFormat instrFormat,
String operMask,
SimulationCode simCode)
BasicInstruction(String example,
String description,
BasicInstructionFormat instrFormat,
String operMask,
SimulationCode simCode)
BasicInstruction constructor.
Method Summary
BasicInstructionFormat getInstructionFormat()
Gets the operand format of the instruction.
int getOpcodeMask()
int getOpcodeMatch()
String getOperationMask()
Gets the 32-character operation mask.
SimulationCode getSimulationCode()
Gets the SimulationCode object.
Methods inherited from class mars.mips.instructions.Instruction
createExampleTokenList, extractOperator, getDescription, getExampleFormat, getInstructionLength, getName, getTokenList
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
BasicInstruction
public BasicInstruction(String example,
String description,
BasicInstructionFormat instrFormat,
String operMask,
SimulationCode simCode)
BasicInstruction constructor.
Parameters:
example – An example usage of the instruction, as a String.
instrFormat – The format is R, I, I-branch or J.
operMask – The opcode mask is a 32 character string that contains the opcode in binary in the appropriate bit positions and codes for operand positions (‘f’, ‘s’, ‘t’) in the remainding positions.
simCode – The inline definition of an object and class which anonymously implements the SimulationCode interface.
See Also:
SimulationCode
BasicInstruction
public BasicInstruction(String example,
BasicInstructionFormat instrFormat,
String operMask,
SimulationCode simCode)
Method Detail
getOperationMask
public String getOperationMask()
Gets the 32-character operation mask. Each mask position represents a
bit position in the 32-bit machine instruction. Operation codes and
unused bits are represented in the mask by 1’s and 0’s. Operand codes
are represented by ‘f’, ‘s’, and ‘t’ for bits occupied by first, secon
and third operand, respectively.
Returns:
The 32 bit mask, as a String
getInstructionFormat
public BasicInstructionFormat getInstructionFormat()
Gets the operand format of the instruction. MIPS defines 3 of these
R-format, I-format, and J-format. R-format is all registers. I-format
is address formed from register base with immediate offset. J-format
is for jump destination addresses. I have added one more:
I-branch-format, for branch destination addresses. These are a variation
of the I-format in that the computed value is address relative to the
Program Counter. All four formats are represented by static objects.
Returns:
The machine instruction format, R, I, J or I-branch.
getSimulationCode
public SimulationCode getSimulationCode()
Gets the SimulationCode object. It is really an object of an anonymous
class that implements the SimulationCode interface. Such an object has but one
method: Simulate().
Returns:
the SimulationCode object for this instruction.
See Also:
SimulationCode
getOpcodeMask
public int getOpcodeMask()
getOpcodeMatch
public int getOpcodeMatch()
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
BasicInstructionFormat
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions
Class BasicInstructionFormat
java.lang.Object
mars.mips.instructions.BasicInstructionFormat
public class BasicInstructionFormat
extends Object
These are the MIPS-defined formats of basic machine instructions. The R-format indicates
the instruction works only with registers. The I-format indicates the instruction
works with an immediate value (e.g. constant). The J-format indicates this is a Jump
instruction. The I-branch-format is defined by me, not MIPS, to to indicate this is
a Branch instruction, specifically to distinguish immediate
values used as target addresses.
Author:
Pete Sanderson
Field Summary
static BasicInstructionFormat I_BRANCH_FORMAT
static BasicInstructionFormat I_FORMAT
static BasicInstructionFormat J_FORMAT
static BasicInstructionFormat R_FORMAT
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
R_FORMAT
public static final BasicInstructionFormat R_FORMAT
I_FORMAT
public static final BasicInstructionFormat I_FORMAT
I_BRANCH_FORMAT
public static final BasicInstructionFormat I_BRANCH_FORMAT
J_FORMAT
public static final BasicInstructionFormat J_FORMAT
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
ExtendedInstruction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions
Class ExtendedInstruction
java.lang.Object
mars.mips.instructions.Instruction
mars.mips.instructions.ExtendedInstruction
public class ExtendedInstruction
extends Instruction
ExtendedInstruction represents a MIPS extended (a.k.a pseudo) instruction. This
assembly language instruction does not have a corresponding machine instruction. Instead
it is translated by the extended assembler into one or more basic instructions (operations
that have a corresponding machine instruction). The TranslationCode object is
responsible for performing the translation.
Author:
Pete Sanderson
Field Summary
Fields inherited from class mars.mips.instructions.Instruction
description, exampleFormat, INSTRUCTION_LENGTH, INSTRUCTION_LENGTH_BITS, mnemonic, operandMask, tokenList
Constructor Summary
ExtendedInstruction(String example,
String translation)
Constructor for ExtendedInstruction, where no instruction description or
compact translation is provided.
ExtendedInstruction(String example,
String translation,
String description)
Constructor for ExtendedInstruction.
ExtendedInstruction(String example,
String translation,
String compactTranslation,
String description)
Constructor for ExtendedInstruction.
Method Summary
ArrayList getBasicIntructionTemplateList()
Get ArrayList of Strings that represent list of templates for
basic instructions generated by this extended instruction.
ArrayList getCompactBasicIntructionTemplateList()
Get ArrayList of Strings that represent list of templates for
basic instructions generated by the “compact” or 16-bit version
of this extended instruction.
int getCompactInstructionLength()
Get length in bytes that this extended instruction requires in its
binary form if it includes an alternative expansion for compact
memory (16 bit addressing) configuration.
int getInstructionLength()
Get length in bytes that this extended instruction requires in its
binary form.
boolean hasCompactTranslation()
Determine whether or not this pseudo-instruction has a second
translation optimized for 16 bit address space: a compact version.
static String makeTemplateSubstitutions(MIPSprogram program,
String template,
TokenList theTokenList)
Given a basic instruction template and the list of tokens from an extended
instruction statement, substitute operands from the token list appropriately into the
template to generate the basic statement.
Methods inherited from class mars.mips.instructions.Instruction
createExampleTokenList, extractOperator, getDescription, getExampleFormat, getName, getTokenList
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
ExtendedInstruction
public ExtendedInstruction(String example,
String translation,
String compactTranslation,
String description)
Constructor for ExtendedInstruction.
Parameters:
example – A String containing example use of the MIPS extended instruction.
translation – Specifications for translating this instruction into a sequence
of one or more MIPS basic instructions.
compactTranslation – Alternative translation that can be used if running under
a compact (16 bit) memory configuration.
description – a helpful description to be included on help requests
The presence of an alternative “compact translation” can optimize code generation
by assuming that data label addresses are 16 bits instead of 32
ExtendedInstruction
public ExtendedInstruction(String example,
String translation,
String description)
Constructor for ExtendedInstruction. No compact translation is provided.
Parameters:
example – A String containing example use of the MIPS extended instruction.
translation – Specifications for translating this instruction into a sequence
of one or more MIPS basic instructions.
description – a helpful description to be included on help requests
ExtendedInstruction
public ExtendedInstruction(String example,
String translation)
Constructor for ExtendedInstruction, where no instruction description or
compact translation is provided.
Parameters:
example – A String containing example use of the MIPS extended instruction.
translation – Specifications for translating this instruction into a sequence
of one or more MIPS basic instructions.
Method Detail
getInstructionLength
public int getInstructionLength()
Get length in bytes that this extended instruction requires in its
binary form. The answer depends on how many basic instructions it
expands to. This may vary, if expansion includes a nop, depending on
whether or not delayed branches are enabled. Each requires 4 bytes.
Overrides:
getInstructionLength in class Instruction
Returns:
int length in bytes of corresponding binary instruction(s).
getBasicIntructionTemplateList
public ArrayList getBasicIntructionTemplateList()
Get ArrayList of Strings that represent list of templates for
basic instructions generated by this extended instruction.
Returns:
ArrayList of Strings.
getCompactInstructionLength
public int getCompactInstructionLength()
Get length in bytes that this extended instruction requires in its
binary form if it includes an alternative expansion for compact
memory (16 bit addressing) configuration. The answer depends on
how many basic instructions it expands to. This may vary, if
expansion includes a nop, depending on whether or not delayed
branches are enabled. Each requires 4 bytes.
Returns:
int length in bytes of corresponding binary instruction(s).
Returns 0 if an alternative expansion is not defined for this
instruction.
hasCompactTranslation
public boolean hasCompactTranslation()
Determine whether or not this pseudo-instruction has a second
translation optimized for 16 bit address space: a compact version.
getCompactBasicIntructionTemplateList
public ArrayList getCompactBasicIntructionTemplateList()
Get ArrayList of Strings that represent list of templates for
basic instructions generated by the “compact” or 16-bit version
of this extended instruction.
Returns:
ArrayList of Strings. Returns null if the instruction does not
have a compact alternative.
makeTemplateSubstitutions
public static String makeTemplateSubstitutions(MIPSprogram program,
String template,
TokenList theTokenList)
Given a basic instruction template and the list of tokens from an extended
instruction statement, substitute operands from the token list appropriately into the
template to generate the basic statement. Assumes the extended instruction statement has
been translated from source form to basic assembly form (e.g. register mnemonics
translated to corresponding register numbers).
Operand format of source statement is already verified correct.
Assume the template has correct number and positions of operands.
Template is String with special markers. In the list below, n represents token position (1,2,3,etc)
in source statement (operator is token 0, parentheses count but commas don’t):
RGn means substitute register found in n’th token of source statement
NRn means substitute next higher register than the one in n’th token of source code
OPn means substitute n’th token of source code as is
LLn means substitute low order 16 bits from label address in source token n.
LLnU means substitute low order 16 bits (unsigned) from label address in source token n.
LLnPm (m=1,2,3,4) means substitute low order 16 bits from label address in source token n, after adding m.
LHn means substitute high order 16 bits from label address in source token n. Must add 1 if address bit 15 is 1.
LHnPm (m=1,2,3,4) means substitute high order 16 bits from label address in source token n, after adding m. Must then add 1 if bit 15 is 1.
VLn means substitute low order 16 bits from 32 bit value in source token n.
VLnU means substitute low order 16 bits (unsigned) from 32 bit value in source token n.
VLnPm (m=1,2,3,4) means substitute low order 16 bits from 32 bit value in source token n, after adding m to value.
VLnPmU (m=1,2,3,4) means substitute low order 16 bits (unsigned) from 32 bit value in source token n, after adding m to value.
VHLn means substitute high order 16 bits from 32 bit value in source token n. Use this if later combined with low order 16 bits using “ori $1,$1,VLn”. See logical and branch operations.
VHn means substitute high order 16 bits from 32 bit value in source token n, then add 1 if value’s bit 15 is 1. Use this only if later instruction uses VLn($1) to calculate 32 bit address. See loads and stores.
VHLnPm (m=1,2,3,4) means substitute high order 16 bits from 32 bit value in source token n, after adding m. See VHLn.
VHnPm (m=1,2,3,4) means substitute high order 16 bits from 32 bit value in source token n, after adding m. Must then add 1 if bit 15 is 1. See VHn.
LLP is similar to LLn, but is needed for “label+100000” address offset. Immediate is added before taking low order 16.
LLPU is similar to LLnU, but is needed for “label+100000” address offset. Immediate is added before taking low order 16 (unsigned).
LLPPm (m=1,2,3,4) is similar to LLP except m is added along with mmediate before taking low order 16.
LHPA is similar to LHn, but is needed for “label+100000” address offset. Immediate is added before taking high order 16.
LHPN is similar to LHPA, used only by “la” instruction. Address resolved by “ori” so do not add 1 if bit 15 is 1.
LHPAPm (m=1,2,3,4) is similar to LHPA except value m is added along with immediate before taking high order 16.
LHL means substitute high order 16 bits from label address in token 2 of “la” (load address) source statement.
LAB means substitute textual label from last token of source statement. Used for various branches.
S32 means substitute the result of subtracting the constant value in last token from 32. Used by “ror”, “rol”.
DBNOP means Delayed Branching NOP – generate a “nop” instruction but only if delayed branching is enabled. Added in 3.4.1 release.
BROFFnm means substitute n if delayed branching is NOT enabled otherwise substitute m. n and m are single digit numbers indicating constant branch offset (in words). Added in 3.4.1 release.
Parameters:
template – a String containing template for basic statement.
tokenList – a TokenList containing tokens from extended instruction.
Returns:
String representing basic assembler statement.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Instruction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions
Class Instruction
java.lang.Object
mars.mips.instructions.Instruction
Direct Known Subclasses:
BasicInstruction, ExtendedInstruction
public abstract class Instruction
extends Object
Base class to represent member of MIPS instruction set.
Author:
Pete Sanderson and Ken Vollmar
Field Summary
protected String description
Description of instruction for display to user
protected String exampleFormat
Example usage of this instruction.
static int INSTRUCTION_LENGTH
Length in bytes of a machine instruction.
static int INSTRUCTION_LENGTH_BITS
protected String mnemonic
The instruction name.
static char[] operandMask
Characters used in instruction mask to indicate bit positions
for ‘f’irst, ‘s’econd, and ‘t’hird operands.
protected TokenList tokenList
List of tokens generated by tokenizing example usage (see exampleFormat).
Constructor Summary
Instruction()
Method Summary
protected void createExampleTokenList()
Used to build a token list from the example instruction
provided as constructor argument.
protected String extractOperator(String example)
Used by subclass constructors to extract operator mnemonic from the
instruction example.
String getDescription()
Get string describing the instruction.
String getExampleFormat()
Get string descriptor of instruction’s format.
int getInstructionLength()
Get length in bytes that this instruction requires in its binary form.
String getName()
Get operation mnemonic
TokenList getTokenList()
Get TokenList corresponding to correct instruction syntax.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
INSTRUCTION_LENGTH
public static final int INSTRUCTION_LENGTH
Length in bytes of a machine instruction. MIPS is a RISC architecture
so all instructions are the same length. Currently set to 4.
See Also:
Constant Field Values
INSTRUCTION_LENGTH_BITS
public static final int INSTRUCTION_LENGTH_BITS
See Also:
Constant Field Values
operandMask
public static char[] operandMask
Characters used in instruction mask to indicate bit positions
for ‘f’irst, ‘s’econd, and ‘t’hird operands.
mnemonic
protected String mnemonic
The instruction name.
exampleFormat
protected String exampleFormat
Example usage of this instruction. Is provided as subclass constructor argument.
description
protected String description
Description of instruction for display to user
tokenList
protected TokenList tokenList
List of tokens generated by tokenizing example usage (see exampleFormat).
Constructor Detail
Instruction
public Instruction()
Method Detail
getName
public String getName()
Get operation mnemonic
Returns:
operation mnemonic (e.g. addi, sw)
getExampleFormat
public String getExampleFormat()
Get string descriptor of instruction’s format. This is an example MIPS
assembler instruction usage which contains the operator and all operands.
Operands are separated by commas, an operand that begins with a ‘$’
represents a register, and an integer operand represents an immediate value
or address. Here are two examples: “nor $1,$2,$3” and “sw $1,100($2)”
Returns:
String representing example instruction format.
getDescription
public String getDescription()
Get string describing the instruction. This is not used internally by
MARS, but is for display to the user.
Returns:
String describing the instruction.
getTokenList
public TokenList getTokenList()
Get TokenList corresponding to correct instruction syntax.
For example, the instruction with format “sw $1,100($2)” yields token list
Returns:
TokenList object representing correct instruction usage.
getInstructionLength
public int getInstructionLength()
Get length in bytes that this instruction requires in its binary form.
Default is 4 (holds for all basic instructions), but can be overridden
in subclass.
Returns:
int length in bytes of corresponding binary instruction(s).
extractOperator
protected String extractOperator(String example)
Used by subclass constructors to extract operator mnemonic from the
instruction example.
createExampleTokenList
protected void createExampleTokenList()
Used to build a token list from the example instruction
provided as constructor argument. Parser uses this for syntax checking.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InstructionSet
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions
Class InstructionSet
java.lang.Object
mars.mips.instructions.InstructionSet
public class InstructionSet
extends Object
The list of Instruction objects, each of which represents a MIPS instruction.
The instruction may either be basic (translates into binary machine code) or
extended (translates into sequence of one or more basic instructions).
Author:
Pete Sanderson and Ken Vollmar
Constructor Summary
InstructionSet()
Creates a new InstructionSet object.
Method Summary
BasicInstruction findByBinaryCode(int binaryInstr)
ArrayList getInstructionList()
Retrieve the current instruction set.
ArrayList matchOperator(String name)
Given an operator mnemonic, will return the corresponding Instruction object(s)
from the instruction set.
void populate()
Adds all instructions to the set.
ArrayList prefixMatchOperator(String name)
Given a string, will return the Instruction object(s) from the instruction
set whose operator mnemonic prefix matches it.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InstructionSet
public InstructionSet()
Creates a new InstructionSet object.
Method Detail
getInstructionList
public ArrayList getInstructionList()
Retrieve the current instruction set.
populate
public void populate()
Adds all instructions to the set. A given extended instruction may have
more than one Instruction object, depending on how many formats it can have.
See Also:
Instruction,
BasicInstruction,
ExtendedInstruction
findByBinaryCode
public BasicInstruction findByBinaryCode(int binaryInstr)
matchOperator
public ArrayList matchOperator(String name)
Given an operator mnemonic, will return the corresponding Instruction object(s)
from the instruction set. Uses straight linear search technique.
Parameters:
name – operator mnemonic (e.g. addi, sw,…)
Returns:
list of corresponding Instruction object(s), or null if not found.
prefixMatchOperator
public ArrayList prefixMatchOperator(String name)
Given a string, will return the Instruction object(s) from the instruction
set whose operator mnemonic prefix matches it. Case-insensitive. For example
“s” will match “sw”, “sh”, “sb”, etc. Uses straight linear search technique.
Parameters:
name – a string
Returns:
list of matching Instruction object(s), or null if none match.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions
mars.mips.instructions
Interfaces
SimulationCode
Classes
BasicInstruction
BasicInstructionFormat
ExtendedInstruction
Instruction
InstructionSet
mars.mips.instructions
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
Package mars.mips.instructions
Interface Summary
SimulationCode Interface to represent the method for simulating the execution of a specific MIPS basic
instruction.
Class Summary
BasicInstruction Class to represent a basic instruction in the MIPS instruction set.
BasicInstructionFormat These are the MIPS-defined formats of basic machine instructions.
ExtendedInstruction ExtendedInstruction represents a MIPS extended (a.k.a pseudo) instruction.
Instruction Base class to represent member of MIPS instruction set.
InstructionSet The list of Instruction objects, each of which represents a MIPS instruction.
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
mars.mips.instructions Class Hierarchy
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Hierarchy For Package mars.mips.instructions
Package Hierarchies:
All Packages
Class Hierarchy
java.lang.Object mars.mips.instructions.BasicInstructionFormat
mars.mips.instructions.Instruction mars.mips.instructions.BasicInstruction
mars.mips.instructions.ExtendedInstruction
mars.mips.instructions.InstructionSet
Interface Hierarchy
mars.mips.instructions.SimulationCode
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
SimulationCode
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions
Interface SimulationCode
public interface SimulationCode
Interface to represent the method for simulating the execution of a specific MIPS basic
instruction. It will be implemented by the anonymous class created in the last
argument to the BasicInstruction constructor.
Author:
Pete Sanderson
Method Summary
void simulate(ProgramStatement statement)
Method to simulate the execution of a specific MIPS basic instruction.
Method Detail
simulate
void simulate(ProgramStatement statement)
throws ProcessingException
Method to simulate the execution of a specific MIPS basic instruction.
Parameters:
statement – A ProgramStatement representing the MIPS instruction to simulate.
Throws:
ProcessingException – This is a run-time exception generated during simulation.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
AbstractSyscall
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class AbstractSyscall
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
All Implemented Interfaces:
Syscall
Direct Known Subclasses:
SyscallClose, SyscallConfirmDialog, SyscallExit, SyscallExit2, SyscallInputDialogDouble, SyscallInputDialogFloat, SyscallInputDialogInt, SyscallInputDialogString, SyscallMessageDialog, SyscallMessageDialogDouble, SyscallMessageDialogFloat, SyscallMessageDialogInt, SyscallMessageDialogString, SyscallMidiOut, SyscallMidiOutSync, SyscallOpen, SyscallPrintChar, SyscallPrintDouble, SyscallPrintFloat, SyscallPrintInt, SyscallPrintIntBinary, SyscallPrintIntHex, SyscallPrintIntUnsigned, SyscallPrintString, SyscallRandDouble, SyscallRandFloat, SyscallRandInt, SyscallRandIntRange, SyscallRandSeed, SyscallRead, SyscallReadChar, SyscallReadDouble, SyscallReadFloat, SyscallReadInt, SyscallReadString, SyscallSbrk, SyscallSleep, SyscallTime, SyscallWrite
public abstract class AbstractSyscall
extends Object
implements Syscall
Abstract class that a MIPS syscall system service may extend. A qualifying service
must be a class in the mars.mips.instructions.syscalls package that
implements the Syscall interface, must be compiled into a .class file,
and its .class file must be in the same folder as Syscall.class.
Mars will detect a qualifying syscall upon startup, create an instance
using its no-argument constructor and add it to its syscall list.
When its service is invoked at runtime (“syscall” instruction
with its service number stored in register $v0), its simulate()
method will be invoked.
Constructor Summary
AbstractSyscall(int number,
String name)
Constructor is provided so subclass may initialize instance variables.
Method Summary
String getName()
Return the name you have chosen for this syscall.
int getNumber()
Return the assigned service number.
void setNumber(int num)
Set the service number.
abstract void simulate(ProgramStatement statement)
Performs syscall function.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
AbstractSyscall
public AbstractSyscall(int number,
String name)
Constructor is provided so subclass may initialize instance variables.
Parameters:
number – default assigned service number
name – service name which may be used for reference independent of number
Method Detail
getName
public String getName()
Return the name you have chosen for this syscall. This can be used by a MARS
user to refer to the service when choosing to override its default service
number in the configuration file.
Specified by:
getName in interface Syscall
Returns:
service name as a string
setNumber
public void setNumber(int num)
Set the service number. This is provided to allow MARS implementer or user
to override the default service number.
Specified by:
setNumber in interface Syscall
Parameters:
num – specified service number to override the default.
getNumber
public int getNumber()
Return the assigned service number. This is the number the MIPS programmer
must store into $v0 before issuing the SYSCALL instruction.
Specified by:
getNumber in interface Syscall
Returns:
assigned service number
simulate
public abstract void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function. It will be invoked when the service is invoked
at simulation time. Service is identified by value stored in $v0.
Specified by:
simulate in interface Syscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
mars.mips.instructions.syscalls
Interfaces
Syscall
Classes
AbstractSyscall
RandomStreams
SyscallClose
SyscallConfirmDialog
SyscallExit
SyscallExit2
SyscallInputDialogDouble
SyscallInputDialogFloat
SyscallInputDialogInt
SyscallInputDialogString
SyscallMessageDialog
SyscallMessageDialogDouble
SyscallMessageDialogFloat
SyscallMessageDialogInt
SyscallMessageDialogString
SyscallMidiOut
SyscallMidiOutSync
SyscallNumberOverride
SyscallOpen
SyscallPrintChar
SyscallPrintDouble
SyscallPrintFloat
SyscallPrintInt
SyscallPrintIntBinary
SyscallPrintIntHex
SyscallPrintIntUnsigned
SyscallPrintString
SyscallRandDouble
SyscallRandFloat
SyscallRandInt
SyscallRandIntRange
SyscallRandSeed
SyscallRead
SyscallReadChar
SyscallReadDouble
SyscallReadFloat
SyscallReadInt
SyscallReadString
SyscallSbrk
SyscallSleep
SyscallTime
SyscallWrite
mars.mips.instructions.syscalls
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
Package mars.mips.instructions.syscalls
Interface Summary
Syscall Interface for any MIPS syscall system service.
Class Summary
AbstractSyscall Abstract class that a MIPS syscall system service may extend.
RandomStreams This small class serves only to hold a static HashMap for storing
random number generators for use by all the random number generator
syscalls.
SyscallClose Service to close file descriptor given in $a0.
SyscallConfirmDialog Service to display a message to user.
SyscallExit Service to exit the MIPS program.
SyscallExit2 Service to exit the MIPS program with return value given in $a0.
SyscallInputDialogDouble Service to input data.
SyscallInputDialogFloat Service to input data.
SyscallInputDialogInt Service to input data.
SyscallInputDialogString Service to input data.
SyscallMessageDialog Service to display a message to user.
SyscallMessageDialogDouble Service to display a message to user.
SyscallMessageDialogFloat Service to display a message to user.
SyscallMessageDialogInt Service to display a message to user.
SyscallMessageDialogString Service to display a message to user.
SyscallMidiOut Service to output simulated MIDI tone to sound card.
SyscallMidiOutSync Service to output simulated MIDI tone to sound card.
SyscallNumberOverride Represents User override of default syscall number assignment.
SyscallOpen Service to open file name specified by $a0.
SyscallPrintChar Service to display character stored in $a0 on the console.
SyscallPrintDouble Service to display double whose bits are stored in $f12 & $f13 onto the console.
SyscallPrintFloat Service to display on the console float whose bits are stored in $f12
SyscallPrintInt Service to display integer stored in $a0 on the console.
SyscallPrintIntBinary Service to display integer stored in $a0 on the console.
SyscallPrintIntHex Service to display integer stored in $a0 on the console.
SyscallPrintIntUnsigned Service to display integer stored in $a0 on the console as unsigned decimal.
SyscallPrintString Service to display string stored starting at address in $a0 onto the console.
SyscallRandDouble Service to return a random floating point value.
SyscallRandFloat Service to return a random floating point value.
SyscallRandInt Service to return a random integer.
SyscallRandIntRange Service to return a random integer in a specified range.
SyscallRandSeed Service to set seed for the underlying Java pseudorandom number generator.
SyscallRead Service to read from file descriptor given in $a0.
SyscallReadChar Service to read a character from input console into $a0.
SyscallReadDouble Service to read the bits of console input double into $f0 and $f1.
SyscallReadFloat Service to read the bits of input float into $f0
SyscallReadInt Service to read an integer from input console into $v0.
SyscallReadString Service to read console input string into buffer starting at address in $a0.
SyscallSbrk Service to allocate amount of heap memory specified in $a0, putting address into $v0.
SyscallSleep Service to cause the MARS Java thread to sleep for (at least) the specified number of milliseconds.
SyscallTime Service to read a character from input console into $a0.
SyscallWrite Service to write to file descriptor given in $a0.
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
mars.mips.instructions.syscalls Class Hierarchy
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Hierarchy For Package mars.mips.instructions.syscalls
Package Hierarchies:
All Packages
Class Hierarchy
java.lang.Object mars.mips.instructions.syscalls.AbstractSyscall (implements mars.mips.instructions.syscalls.Syscall)
mars.mips.instructions.syscalls.SyscallClose
mars.mips.instructions.syscalls.SyscallConfirmDialog
mars.mips.instructions.syscalls.SyscallExit
mars.mips.instructions.syscalls.SyscallExit2
mars.mips.instructions.syscalls.SyscallInputDialogDouble
mars.mips.instructions.syscalls.SyscallInputDialogFloat
mars.mips.instructions.syscalls.SyscallInputDialogInt
mars.mips.instructions.syscalls.SyscallInputDialogString
mars.mips.instructions.syscalls.SyscallMessageDialog
mars.mips.instructions.syscalls.SyscallMessageDialogDouble
mars.mips.instructions.syscalls.SyscallMessageDialogFloat
mars.mips.instructions.syscalls.SyscallMessageDialogInt
mars.mips.instructions.syscalls.SyscallMessageDialogString
mars.mips.instructions.syscalls.SyscallMidiOut
mars.mips.instructions.syscalls.SyscallMidiOutSync
mars.mips.instructions.syscalls.SyscallOpen
mars.mips.instructions.syscalls.SyscallPrintChar
mars.mips.instructions.syscalls.SyscallPrintDouble
mars.mips.instructions.syscalls.SyscallPrintFloat
mars.mips.instructions.syscalls.SyscallPrintInt
mars.mips.instructions.syscalls.SyscallPrintIntBinary
mars.mips.instructions.syscalls.SyscallPrintIntHex
mars.mips.instructions.syscalls.SyscallPrintIntUnsigned
mars.mips.instructions.syscalls.SyscallPrintString
mars.mips.instructions.syscalls.SyscallRandDouble
mars.mips.instructions.syscalls.SyscallRandFloat
mars.mips.instructions.syscalls.SyscallRandInt
mars.mips.instructions.syscalls.SyscallRandIntRange
mars.mips.instructions.syscalls.SyscallRandSeed
mars.mips.instructions.syscalls.SyscallRead
mars.mips.instructions.syscalls.SyscallReadChar
mars.mips.instructions.syscalls.SyscallReadDouble
mars.mips.instructions.syscalls.SyscallReadFloat
mars.mips.instructions.syscalls.SyscallReadInt
mars.mips.instructions.syscalls.SyscallReadString
mars.mips.instructions.syscalls.SyscallSbrk
mars.mips.instructions.syscalls.SyscallSleep
mars.mips.instructions.syscalls.SyscallTime
mars.mips.instructions.syscalls.SyscallWrite
mars.mips.instructions.syscalls.RandomStreams
mars.mips.instructions.syscalls.SyscallNumberOverride
Interface Hierarchy
mars.mips.instructions.syscalls.Syscall
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
RandomStreams
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class RandomStreams
java.lang.Object
mars.mips.instructions.syscalls.RandomStreams
public class RandomStreams
extends Object
This small class serves only to hold a static HashMap for storing
random number generators for use by all the random number generator
syscalls.
Constructor Summary
RandomStreams()
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
RandomStreams
public RandomStreams()
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Syscall
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Interface Syscall
All Known Implementing Classes:
AbstractSyscall, SyscallClose, SyscallConfirmDialog, SyscallExit, SyscallExit2, SyscallInputDialogDouble, SyscallInputDialogFloat, SyscallInputDialogInt, SyscallInputDialogString, SyscallMessageDialog, SyscallMessageDialogDouble, SyscallMessageDialogFloat, SyscallMessageDialogInt, SyscallMessageDialogString, SyscallMidiOut, SyscallMidiOutSync, SyscallOpen, SyscallPrintChar, SyscallPrintDouble, SyscallPrintFloat, SyscallPrintInt, SyscallPrintIntBinary, SyscallPrintIntHex, SyscallPrintIntUnsigned, SyscallPrintString, SyscallRandDouble, SyscallRandFloat, SyscallRandInt, SyscallRandIntRange, SyscallRandSeed, SyscallRead, SyscallReadChar, SyscallReadDouble, SyscallReadFloat, SyscallReadInt, SyscallReadString, SyscallSbrk, SyscallSleep, SyscallTime, SyscallWrite
public interface Syscall
Interface for any MIPS syscall system service. A qualifying service
must be a class in the mars.mips.instructions.syscalls package that
implements the Syscall interface, must be compiled into a .class file,
and its .class file must be in the same folder as Syscall.class.
Mars will detect a qualifying syscall upon startup, create an instance
using its no-argument constructor and add it to its syscall list.
When its service is invoked at runtime (“syscall” instruction
with its service number stored in register $v0), its simulate()
method will be invoked.
Method Summary
String getName()
Return a name you have chosen for this syscall.
int getNumber()
Return the assigned service number.
void setNumber(int num)
Set the service number.
void simulate(ProgramStatement statement)
Performs syscall function.
Method Detail
getName
String getName()
Return a name you have chosen for this syscall. This can be used by a MARS
user to refer to the service when choosing to override its default service
number in the configuration file.
Returns:
service name as a string
setNumber
void setNumber(int num)
Set the service number. This is provided to allow MARS implementer or user
to override the default service number.
Parameters:
num – specified service number to override the default.
getNumber
int getNumber()
Return the assigned service number. This is the number the MIPS programmer
must store into $v0 before issuing the SYSCALL instruction.
Returns:
assigned service number
simulate
void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function. It will be invoked when the service is invoked
at simulation time. Service is identified by value stored in $v0.
Parameters:
statement – ProgramStatement for this syscall statement.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallClose
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallClose
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallClose
All Implemented Interfaces:
Syscall
public class SyscallClose
extends AbstractSyscall
Service to close file descriptor given in $a0.
Constructor Summary
SyscallClose()
Build an instance of the Close syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to close file descriptor given in $a0.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallClose
public SyscallClose()
Build an instance of the Close syscall. Default service number
is 16 and name is “Close”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to close file descriptor given in $a0.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallConfirmDialog
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallConfirmDialog
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallConfirmDialog
All Implemented Interfaces:
Syscall
public class SyscallConfirmDialog
extends AbstractSyscall
Service to display a message to user.
Constructor Summary
SyscallConfirmDialog()
Build an instance of the syscall with its default service number and name.
Method Summary
void simulate(ProgramStatement statement)
System call to display a message to user.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallConfirmDialog
public SyscallConfirmDialog()
Build an instance of the syscall with its default service number and name.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
System call to display a message to user.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallExit
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallExit
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallExit
All Implemented Interfaces:
Syscall
public class SyscallExit
extends AbstractSyscall
Service to exit the MIPS program.
Constructor Summary
SyscallExit()
Build an instance of the Exit syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to exit the MIPS program.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallExit
public SyscallExit()
Build an instance of the Exit syscall. Default service number
is 10 and name is “Exit”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to exit the MIPS program.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallExit2
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallExit2
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallExit2
All Implemented Interfaces:
Syscall
public class SyscallExit2
extends AbstractSyscall
Service to exit the MIPS program with return value given in $a0. Ignored if running from GUI.
Constructor Summary
SyscallExit2()
Build an instance of the Exit2 syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to exit the MIPS program with return value given in $a0.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallExit2
public SyscallExit2()
Build an instance of the Exit2 syscall. Default service number
is 17 and name is “Exit2”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to exit the MIPS program with return value given in $a0.
If running in command mode, MARS will exit with that value. If running under GUI,
return value is ignored.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallInputDialogDouble
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallInputDialogDouble
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallInputDialogDouble
All Implemented Interfaces:
Syscall
public class SyscallInputDialogDouble
extends AbstractSyscall
Service to input data.
Constructor Summary
SyscallInputDialogDouble()
Build an instance of the syscall with its default service number and name.
Method Summary
void simulate(ProgramStatement statement)
System call to input data.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallInputDialogDouble
public SyscallInputDialogDouble()
Build an instance of the syscall with its default service number and name.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
System call to input data.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallInputDialogFloat
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallInputDialogFloat
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallInputDialogFloat
All Implemented Interfaces:
Syscall
public class SyscallInputDialogFloat
extends AbstractSyscall
Service to input data.
Constructor Summary
SyscallInputDialogFloat()
Build an instance of the syscall with its default service number and name.
Method Summary
void simulate(ProgramStatement statement)
System call to input data.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallInputDialogFloat
public SyscallInputDialogFloat()
Build an instance of the syscall with its default service number and name.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
System call to input data.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallInputDialogInt
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallInputDialogInt
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallInputDialogInt
All Implemented Interfaces:
Syscall
public class SyscallInputDialogInt
extends AbstractSyscall
Service to input data.
Constructor Summary
SyscallInputDialogInt()
Build an instance of the syscall with its default service number and name.
Method Summary
void simulate(ProgramStatement statement)
System call to input data.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallInputDialogInt
public SyscallInputDialogInt()
Build an instance of the syscall with its default service number and name.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
System call to input data.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallInputDialogString
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallInputDialogString
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallInputDialogString
All Implemented Interfaces:
Syscall
public class SyscallInputDialogString
extends AbstractSyscall
Service to input data.
Constructor Summary
SyscallInputDialogString()
Build an instance of the syscall with its default service number and name.
Method Summary
void simulate(ProgramStatement statement)
System call to input data.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallInputDialogString
public SyscallInputDialogString()
Build an instance of the syscall with its default service number and name.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
System call to input data.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallMessageDialog
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallMessageDialog
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallMessageDialog
All Implemented Interfaces:
Syscall
public class SyscallMessageDialog
extends AbstractSyscall
Service to display a message to user.
Constructor Summary
SyscallMessageDialog()
Build an instance of the syscall with its default service number and name.
Method Summary
void simulate(ProgramStatement statement)
System call to display a message to user.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallMessageDialog
public SyscallMessageDialog()
Build an instance of the syscall with its default service number and name.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
System call to display a message to user.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallMessageDialogDouble
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallMessageDialogDouble
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallMessageDialogDouble
All Implemented Interfaces:
Syscall
public class SyscallMessageDialogDouble
extends AbstractSyscall
Service to display a message to user.
Constructor Summary
SyscallMessageDialogDouble()
Build an instance of the syscall with its default service number and name.
Method Summary
void simulate(ProgramStatement statement)
System call to display a message to user.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallMessageDialogDouble
public SyscallMessageDialogDouble()
Build an instance of the syscall with its default service number and name.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
System call to display a message to user.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallMessageDialogFloat
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallMessageDialogFloat
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallMessageDialogFloat
All Implemented Interfaces:
Syscall
public class SyscallMessageDialogFloat
extends AbstractSyscall
Service to display a message to user.
Constructor Summary
SyscallMessageDialogFloat()
Build an instance of the syscall with its default service number and name.
Method Summary
void simulate(ProgramStatement statement)
System call to display a message to user.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallMessageDialogFloat
public SyscallMessageDialogFloat()
Build an instance of the syscall with its default service number and name.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
System call to display a message to user.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallMessageDialogInt
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallMessageDialogInt
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallMessageDialogInt
All Implemented Interfaces:
Syscall
public class SyscallMessageDialogInt
extends AbstractSyscall
Service to display a message to user.
Constructor Summary
SyscallMessageDialogInt()
Build an instance of the syscall with its default service number and name.
Method Summary
void simulate(ProgramStatement statement)
System call to display a message to user.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallMessageDialogInt
public SyscallMessageDialogInt()
Build an instance of the syscall with its default service number and name.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
System call to display a message to user.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallMessageDialogString
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallMessageDialogString
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallMessageDialogString
All Implemented Interfaces:
Syscall
public class SyscallMessageDialogString
extends AbstractSyscall
Service to display a message to user.
Constructor Summary
SyscallMessageDialogString()
Build an instance of the syscall with its default service number and name.
Method Summary
void simulate(ProgramStatement statement)
System call to display a message to user.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallMessageDialogString
public SyscallMessageDialogString()
Build an instance of the syscall with its default service number and name.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
System call to display a message to user.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallMidiOut
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallMidiOut
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallMidiOut
All Implemented Interfaces:
Syscall
public class SyscallMidiOut
extends AbstractSyscall
Service to output simulated MIDI tone to sound card. The call returns
immediately upon generating the tone. By contrast, syscall 33
(MidiOutSync) does not return until tone duration has elapsed.
Constructor Summary
SyscallMidiOut()
Build an instance of the MIDI (simulated) out syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to send MIDI output to sound card.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallMidiOut
public SyscallMidiOut()
Build an instance of the MIDI (simulated) out syscall. Default service number
is 31 and name is “MidiOut”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to send MIDI output to sound card. This requires
four arguments in registers $a0 through $a3.
$a0 – pitch (note). Integer value from 0 to 127, with 60 being middle-C on a piano.
$a1 – duration. Integer value in milliseconds.
$a2 – instrument. Integer value from 0 to 127, with 0 being acoustic grand piano.
$a3 – volume. Integer value from 0 to 127.
Default values, in case any parameters are outside the above ranges, are $a0=60, $a1=1000,
$a2=0, $a3=100.
See MARS documentation elsewhere or www.midi.org for more information. Note that the pitch,
instrument and volume value ranges 0-127 are from javax.sound.midi; actual MIDI instruments
use the range 1-128.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallMidiOutSync
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallMidiOutSync
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallMidiOutSync
All Implemented Interfaces:
Syscall
public class SyscallMidiOutSync
extends AbstractSyscall
Service to output simulated MIDI tone to sound card. The call does
not return until the tone duration has elapsed. By contrast, syscall 31
(MidiOut) returns immediately upon generating the tone.
Constructor Summary
SyscallMidiOutSync()
Build an instance of the MIDI (simulated) out syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to send MIDI output to sound card.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallMidiOutSync
public SyscallMidiOutSync()
Build an instance of the MIDI (simulated) out syscall. Default service number
is 33 and name is “MidiOutSync”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to send MIDI output to sound card. The syscall does not
return until after the duration period ($a1) has elapsed. This requires
four arguments in registers $a0 through $a3.
$a0 – pitch (note). Integer value from 0 to 127, with 60 being middle-C on a piano.
$a1 – duration. Integer value in milliseconds.
$a2 – instrument. Integer value from 0 to 127, with 0 being acoustic grand piano.
$a3 – volume. Integer value from 0 to 127.
Default values, in case any parameters are outside the above ranges, are $a0=60, $a1=1000,
$a2=0, $a3=100.
See MARS documentation elsewhere or www.midi.org for more information. Note that the pitch,
instrument and volume value ranges 0-127 are from javax.sound.midi; actual MIDI instruments
use the range 1-128.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallNumberOverride
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallNumberOverride
java.lang.Object
mars.mips.instructions.syscalls.SyscallNumberOverride
public class SyscallNumberOverride
extends Object
Represents User override of default syscall number assignment.
Such overrides are specified in the config.txt file read when
MARS starts up.
Constructor Summary
SyscallNumberOverride(String serviceName,
String value)
Constructor is called with two strings: service name and desired
number.
Method Summary
String getName()
Get the service name as a String.
int getNumber()
Get the new service number as an int.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallNumberOverride
public SyscallNumberOverride(String serviceName,
String value)
Constructor is called with two strings: service name and desired
number. Will throw an exception is number is malformed, but does
not check validity of the service name or number.
Parameters:
serviceName – a String containing syscall service mnemonic.
value – a String containing its reassigned syscall service number.
If this number is previously assigned to a different syscall which does not
also receive a new number, then an error for duplicate numbers will
be issued at MARS launch.
Method Detail
getName
public String getName()
Get the service name as a String.
Returns:
the service name
getNumber
public int getNumber()
Get the new service number as an int.
Returns:
the service number
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallOpen
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallOpen
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallOpen
All Implemented Interfaces:
Syscall
public class SyscallOpen
extends AbstractSyscall
Service to open file name specified by $a0. File descriptor returned in $v0.
(this was changed from $a0 in MARS 3.7 for SPIM compatibility. The table
in COD erroneously shows $a0).
Constructor Summary
SyscallOpen()
Build an instance of the Open file syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to open file name specified by $a0.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallOpen
public SyscallOpen()
Build an instance of the Open file syscall. Default service number
is 13 and name is “Open”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to open file name specified by $a0. File descriptor returned
in $v0. Only supported flags ($a1) are read-only (0), write-only (1) and
write-append (9). write-only flag creates file if it does not exist, so it is technically
write-create. write-append will start writing at end of existing file.
Mode ($a2) is ignored.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallPrintChar
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallPrintChar
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallPrintChar
All Implemented Interfaces:
Syscall
public class SyscallPrintChar
extends AbstractSyscall
Service to display character stored in $a0 on the console.
Constructor Summary
SyscallPrintChar()
Build an instance of the Print Char syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to print on the console the character stored in $a0.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallPrintChar
public SyscallPrintChar()
Build an instance of the Print Char syscall. Default service number
is 11 and name is “PrintChar”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to print on the console the character stored in $a0.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallPrintDouble
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallPrintDouble
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallPrintDouble
All Implemented Interfaces:
Syscall
public class SyscallPrintDouble
extends AbstractSyscall
Service to display double whose bits are stored in $f12 & $f13 onto the console.
$f13 contains high order word of the double.
Constructor Summary
SyscallPrintDouble()
Build an instance of the Print Double syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to print double whose bits are stored in $f12 & $f13.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallPrintDouble
public SyscallPrintDouble()
Build an instance of the Print Double syscall. Default service number
is 3 and name is “PrintDouble”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to print double whose bits are stored in $f12 & $f13.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallPrintFloat
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallPrintFloat
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallPrintFloat
All Implemented Interfaces:
Syscall
public class SyscallPrintFloat
extends AbstractSyscall
Service to display on the console float whose bits are stored in $f12
Constructor Summary
SyscallPrintFloat()
Build an instance of the Print Float syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to display float whose bits are stored in $f12
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallPrintFloat
public SyscallPrintFloat()
Build an instance of the Print Float syscall. Default service number
is 2 and name is “PrintFloat”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to display float whose bits are stored in $f12
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallPrintInt
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallPrintInt
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallPrintInt
All Implemented Interfaces:
Syscall
public class SyscallPrintInt
extends AbstractSyscall
Service to display integer stored in $a0 on the console.
Constructor Summary
SyscallPrintInt()
Build an instance of the Print Integer syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to print on the console the integer stored in $a0.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallPrintInt
public SyscallPrintInt()
Build an instance of the Print Integer syscall. Default service number
is 1 and name is “PrintInt”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to print on the console the integer stored in $a0.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallPrintIntBinary
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallPrintIntBinary
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallPrintIntBinary
All Implemented Interfaces:
Syscall
public class SyscallPrintIntBinary
extends AbstractSyscall
Service to display integer stored in $a0 on the console.
Constructor Summary
SyscallPrintIntBinary()
Build an instance of the Print Integer syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to print on the console the integer stored in $a0, in hexadecimal format.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallPrintIntBinary
public SyscallPrintIntBinary()
Build an instance of the Print Integer syscall. Default service number
is 1 and name is “PrintInt”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to print on the console the integer stored in $a0, in hexadecimal format.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallPrintIntHex
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallPrintIntHex
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallPrintIntHex
All Implemented Interfaces:
Syscall
public class SyscallPrintIntHex
extends AbstractSyscall
Service to display integer stored in $a0 on the console.
Constructor Summary
SyscallPrintIntHex()
Build an instance of the Print Integer syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to print on the console the integer stored in $a0, in hexadecimal format.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallPrintIntHex
public SyscallPrintIntHex()
Build an instance of the Print Integer syscall. Default service number
is 1 and name is “PrintInt”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to print on the console the integer stored in $a0, in hexadecimal format.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallPrintIntUnsigned
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallPrintIntUnsigned
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallPrintIntUnsigned
All Implemented Interfaces:
Syscall
public class SyscallPrintIntUnsigned
extends AbstractSyscall
Service to display integer stored in $a0 on the console as unsigned decimal.
Constructor Summary
SyscallPrintIntUnsigned()
Build an instance of the Print Integer Unsigned syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to print on the console the integer stored in $a0.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallPrintIntUnsigned
public SyscallPrintIntUnsigned()
Build an instance of the Print Integer Unsigned syscall. Default service number
is 36 and name is “PrintIntUnsigned”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to print on the console the integer stored in $a0.
The value is treated as unsigned.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallPrintString
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallPrintString
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallPrintString
All Implemented Interfaces:
Syscall
public class SyscallPrintString
extends AbstractSyscall
Service to display string stored starting at address in $a0 onto the console.
Constructor Summary
SyscallPrintString()
Build an instance of the Print String syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to print string stored starting at address in $a0.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallPrintString
public SyscallPrintString()
Build an instance of the Print String syscall. Default service number
is 4 and name is “PrintString”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to print string stored starting at address in $a0.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallRandDouble
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallRandDouble
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallRandDouble
All Implemented Interfaces:
Syscall
public class SyscallRandDouble
extends AbstractSyscall
Service to return a random floating point value.
Constructor Summary
SyscallRandDouble()
Build an instance of the syscall with its default service number and name.
Method Summary
void simulate(ProgramStatement statement)
System call to the random number generator.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallRandDouble
public SyscallRandDouble()
Build an instance of the syscall with its default service number and name.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
System call to the random number generator.
Return in $f0 the next pseudorandom, uniformly distributed double value between 0.0 and 1.0
from this random number generator’s sequence.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallRandFloat
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallRandFloat
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallRandFloat
All Implemented Interfaces:
Syscall
public class SyscallRandFloat
extends AbstractSyscall
Service to return a random floating point value.
Constructor Summary
SyscallRandFloat()
Build an instance of the syscall with its default service number and name.
Method Summary
void simulate(ProgramStatement statement)
System call to the random number generator.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallRandFloat
public SyscallRandFloat()
Build an instance of the syscall with its default service number and name.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
System call to the random number generator.
Return in $f0 the next pseudorandom, uniformly distributed float value between 0.0 and 1.0
from this random number generator’s sequence.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallRandInt
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallRandInt
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallRandInt
All Implemented Interfaces:
Syscall
public class SyscallRandInt
extends AbstractSyscall
Service to return a random integer.
Constructor Summary
SyscallRandInt()
Build an instance of the syscall with its default service number and name.
Method Summary
void simulate(ProgramStatement statement)
System call to the random number generator.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallRandInt
public SyscallRandInt()
Build an instance of the syscall with its default service number and name.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
System call to the random number generator.
Return in $a0 the next pseudorandom, uniformly distributed int value from this random number generator’s sequence.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallRandIntRange
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallRandIntRange
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallRandIntRange
All Implemented Interfaces:
Syscall
public class SyscallRandIntRange
extends AbstractSyscall
Service to return a random integer in a specified range.
Constructor Summary
SyscallRandIntRange()
Build an instance of the syscall with its default service number and name.
Method Summary
void simulate(ProgramStatement statement)
System call to the random number generator, with an upper range specified.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallRandIntRange
public SyscallRandIntRange()
Build an instance of the syscall with its default service number and name.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
System call to the random number generator, with an upper range specified.
Return in $a0 the next pseudorandom, uniformly distributed int value between 0 (inclusive)
and the specified value (exclusive), drawn from this random number generator’s sequence.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallRandSeed
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallRandSeed
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallRandSeed
All Implemented Interfaces:
Syscall
public class SyscallRandSeed
extends AbstractSyscall
Service to set seed for the underlying Java pseudorandom number generator. No values are returned.
Constructor Summary
SyscallRandSeed()
Build an instance of the syscall with its default service number and name.
Method Summary
void simulate(ProgramStatement statement)
Set the seed of the underlying Java pseudorandom number generator.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallRandSeed
public SyscallRandSeed()
Build an instance of the syscall with its default service number and name.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Set the seed of the underlying Java pseudorandom number generator.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallRead
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallRead
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallRead
All Implemented Interfaces:
Syscall
public class SyscallRead
extends AbstractSyscall
Service to read from file descriptor given in $a0. $a1 specifies buffer
and $a2 specifies length. Number of characters read is returned in $v0.
(this was changed from $a0 in MARS 3.7 for SPIM compatibility. The table
in COD erroneously shows $a0). *
Constructor Summary
SyscallRead()
Build an instance of the Read file syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to read from file descriptor given in $a0.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallRead
public SyscallRead()
Build an instance of the Read file syscall. Default service number
is 14 and name is “Read”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to read from file descriptor given in $a0. $a1 specifies buffer
and $a2 specifies length. Number of characters read is returned in $v0 (starting MARS 3.7).
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallReadChar
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallReadChar
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallReadChar
All Implemented Interfaces:
Syscall
public class SyscallReadChar
extends AbstractSyscall
Service to read a character from input console into $a0.
Constructor Summary
SyscallReadChar()
Build an instance of the Read Char syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to read a character from input console into $a0
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallReadChar
public SyscallReadChar()
Build an instance of the Read Char syscall. Default service number
is 12 and name is “ReadChar”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to read a character from input console into $a0
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallReadDouble
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallReadDouble
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallReadDouble
All Implemented Interfaces:
Syscall
public class SyscallReadDouble
extends AbstractSyscall
Service to read the bits of console input double into $f0 and $f1.
$f1 contains high order word of the double.
Constructor Summary
SyscallReadDouble()
Build an instance of the Read Double syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to read the bits of input double into $f0 and $f1.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallReadDouble
public SyscallReadDouble()
Build an instance of the Read Double syscall. Default service number
is 7 and name is “ReadDouble”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to read the bits of input double into $f0 and $f1.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallReadFloat
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallReadFloat
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallReadFloat
All Implemented Interfaces:
Syscall
public class SyscallReadFloat
extends AbstractSyscall
Service to read the bits of input float into $f0
Constructor Summary
SyscallReadFloat()
Build an instance of the Read Float syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to read the bits of input float into $f0
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallReadFloat
public SyscallReadFloat()
Build an instance of the Read Float syscall. Default service number
is 6 and name is “ReadFloat”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to read the bits of input float into $f0
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallReadInt
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallReadInt
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallReadInt
All Implemented Interfaces:
Syscall
public class SyscallReadInt
extends AbstractSyscall
Service to read an integer from input console into $v0.
Constructor Summary
SyscallReadInt()
Build an instance of the Read Integer syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to read an integer from input console into $v0
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallReadInt
public SyscallReadInt()
Build an instance of the Read Integer syscall. Default service number
is 5 and name is “ReadInt”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to read an integer from input console into $v0
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallReadString
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallReadString
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallReadString
All Implemented Interfaces:
Syscall
public class SyscallReadString
extends AbstractSyscall
Service to read console input string into buffer starting at address in $a0.
Constructor Summary
SyscallReadString()
Build an instance of the Read String syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to read console input string into buffer starting at address in $a0.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallReadString
public SyscallReadString()
Build an instance of the Read String syscall. Default service number
is 8 and name is “ReadString”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to read console input string into buffer starting at address in $a0.
Follows semantics of UNIX ‘fgets’. For specified length n,
string can be no longer than n-1. If less than that, add
newline to end. In either case, then pad with null byte.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallSbrk
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallSbrk
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallSbrk
All Implemented Interfaces:
Syscall
public class SyscallSbrk
extends AbstractSyscall
Service to allocate amount of heap memory specified in $a0, putting address into $v0.
Constructor Summary
SyscallSbrk()
Build an instance of the Sbrk syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to allocate amount of heap memory specified in $a0, putting address into $v0.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallSbrk
public SyscallSbrk()
Build an instance of the Sbrk syscall. Default service number
is 9 and name is “Sbrk”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to allocate amount of heap memory specified in $a0, putting address into $v0.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallSleep
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallSleep
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallSleep
All Implemented Interfaces:
Syscall
public class SyscallSleep
extends AbstractSyscall
Service to cause the MARS Java thread to sleep for (at least) the specified number of milliseconds.
This timing will not be precise as the Java implementation will add some overhead.
Constructor Summary
SyscallSleep()
Build an instance of the syscall with its default service number and name.
Method Summary
void simulate(ProgramStatement statement)
System call to cause the MARS Java thread to sleep for (at least) the specified number of milliseconds.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallSleep
public SyscallSleep()
Build an instance of the syscall with its default service number and name.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
System call to cause the MARS Java thread to sleep for (at least) the specified number of milliseconds.
This timing will not be precise as the Java implementation will add some overhead.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallTime
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallTime
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallTime
All Implemented Interfaces:
Syscall
public class SyscallTime
extends AbstractSyscall
Service to read a character from input console into $a0.
Constructor Summary
SyscallTime()
Build an instance of the Read Char syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to place current system time into $a0 (low order 32 bits)
and $a1 (high order 32 bits).
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallTime
public SyscallTime()
Build an instance of the Read Char syscall. Default service number
is 12 and name is “ReadChar”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to place current system time into $a0 (low order 32 bits)
and $a1 (high order 32 bits).
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyscallWrite
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.mips.instructions.syscalls
Class SyscallWrite
java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
mars.mips.instructions.syscalls.SyscallWrite
All Implemented Interfaces:
Syscall
public class SyscallWrite
extends AbstractSyscall
Service to write to file descriptor given in $a0. $a1 specifies buffer
and $a2 specifies length. Number of characters written is returned in $v0
(this was changed from $a0 in MARS 3.7 for SPIM compatibility. The table
in COD erroneously shows $a0).
Constructor Summary
SyscallWrite()
Build an instance of the Write file syscall.
Method Summary
void simulate(ProgramStatement statement)
Performs syscall function to write to file descriptor given in $a0.
Methods inherited from class mars.mips.instructions.syscalls.AbstractSyscall
getName, getNumber, setNumber
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SyscallWrite
public SyscallWrite()
Build an instance of the Write file syscall. Default service number
is 15 and name is “Write”.
Method Detail
simulate
public void simulate(ProgramStatement statement)
throws ProcessingException
Performs syscall function to write to file descriptor given in $a0. $a1 specifies buffer
and $a2 specifies length. Number of characters written is returned in $v0, starting in MARS 3.7.
Specified by:
simulate in interface Syscall
Specified by:
simulate in class AbstractSyscall
Parameters:
statement – ProgramStatement object for this syscall instruction.
Throws:
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
MIPSprogram
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars
Class MIPSprogram
java.lang.Object
mars.MIPSprogram
public class MIPSprogram
extends Object
Internal representations of MIPS program. Connects source, tokens and machine code. Having
all these structures available facilitates construction of good messages,
debugging, and easy simulation.
Author:
Pete Sanderson
Constructor Summary
MIPSprogram()
Method Summary
ErrorList assemble(ArrayList MIPSprogramsToAssemble,
boolean extendedAssemblerEnabled)
Assembles the MIPS source program.
ErrorList assemble(ArrayList MIPSprogramsToAssemble,
boolean extendedAssemblerEnabled,
boolean warningsAreErrors)
Assembles the MIPS source program.
boolean backSteppingEnabled()
Returns status of BackStepper associated with this program.
MacroPool createMacroPool()
Instantiates a new MacroPool and sends reference of this
MIPSprogram to it
ArrayList createParsedList()
Produces new empty list to hold parsed source code statements.
BackStepper getBackStepper()
Returns BackStepper associated with this program.
String getFilename()
Produces name of associated source code file.
MacroPool getLocalMacroPool()
Gets local macro pool MacroPool for this program
SymbolTable getLocalSymbolTable()
Returns SymbolTable associated with this program.
ArrayList getMachineList()
Produces list of machine statements that are assembled from the program.
ArrayList getParsedList()
Produces existing list of parsed source code statements.
String getSourceLine(int i)
Produces specified line of MIPS source program.
ArrayList
Retrieve list of source statements that comprise the program.
ArrayList getSourceList()
Produces list of source statements that comprise the program.
Tokenizer getTokenizer()
Retrieves Tokenizer for this program
ArrayList getTokenList()
Produces list of tokens that comprise the program.
boolean inSteppedExecution()
Will be true only while in process of simulating a program statement
in step mode (e.g.
ArrayList prepareFilesForAssembly(ArrayList filenames,
String leadFilename,
String exceptionHandler)
Prepares the given list of files for assembly.
void readSource(String file)
Reads MIPS source code from file into structure.
void setLocalMacroPool(MacroPool macroPool)
Sets local macro pool MacroPool for this program
void setSourceLineList(ArrayList
Set list of source statements that comprise the program.
boolean simulate(int maxSteps)
Simulates execution of the MIPS program.
boolean simulate(int[] breakPoints)
Simulates execution of the MIPS program.
boolean simulateFromPC(int[] breakPoints,
int maxSteps,
AbstractAction a)
Simulates execution of the MIPS program.
boolean simulateStepAtPC(AbstractAction a)
Simulates execution of the MIPS program.
void tokenize()
Tokenizes the MIPS source program.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
MIPSprogram
public MIPSprogram()
Method Detail
getSourceList
public ArrayList getSourceList()
Produces list of source statements that comprise the program.
Returns:
ArrayList of String. Each String is one line of MIPS source code.
setSourceLineList
public void setSourceLineList(ArrayList
Set list of source statements that comprise the program.
Parameters:
sourceLineList – ArrayList of SourceLine.
Each SourceLine represents one line of MIPS source code.
getSourceLineList
public ArrayList
Retrieve list of source statements that comprise the program.
Returns:
ArrayList of SourceLine.
Each SourceLine represents one line of MIPS source cod
getFilename
public String getFilename()
Produces name of associated source code file.
Returns:
File name as String.
getTokenList
public ArrayList getTokenList()
Produces list of tokens that comprise the program.
Returns:
ArrayList of TokenList. Each TokenList is list of tokens generated by
corresponding line of MIPS source code.
See Also:
TokenList
getTokenizer
public Tokenizer getTokenizer()
Retrieves Tokenizer for this program
Returns:
Tokenizer
createParsedList
public ArrayList createParsedList()
Produces new empty list to hold parsed source code statements.
Returns:
ArrayList of ProgramStatement. Each ProgramStatement represents a parsed
MIPS statement.
See Also:
ProgramStatement
getParsedList
public ArrayList getParsedList()
Produces existing list of parsed source code statements.
Returns:
ArrayList of ProgramStatement. Each ProgramStatement represents a parsed
MIPS statement.
See Also:
ProgramStatement
getMachineList
public ArrayList getMachineList()
Produces list of machine statements that are assembled from the program.
Returns:
ArrayList of ProgramStatement. Each ProgramStatement represents an assembled
basic MIPS instruction.
See Also:
ProgramStatement
getBackStepper
public BackStepper getBackStepper()
Returns BackStepper associated with this program. It is created upon successful assembly.
Returns:
BackStepper object, null if there is none.
getLocalSymbolTable
public SymbolTable getLocalSymbolTable()
Returns SymbolTable associated with this program. It is created at assembly time,
and stores local labels (those not declared using .globl directive).
backSteppingEnabled
public boolean backSteppingEnabled()
Returns status of BackStepper associated with this program.
Returns:
true if enabled, false if disabled or non-existant.
getSourceLine
public String getSourceLine(int i)
Produces specified line of MIPS source program.
Parameters:
i – Line number of MIPS source program to get. Line 1 is first line.
Returns:
Returns specified line of MIPS source. If outside the line range,
it returns null. Line 1 is first line.
readSource
public void readSource(String file)
throws ProcessingException
Reads MIPS source code from file into structure. Will always read from file.
It is GUI responsibility to assure that source edits are written to file
when user selects compile or run/step options.
Parameters:
file – String containing name of MIPS source code file.
Throws:
ProcessingException – Will throw exception if there is any problem reading the file.
tokenize
public void tokenize()
throws ProcessingException
Tokenizes the MIPS source program. Program must have already been read from file.
Throws:
ProcessingException – Will throw exception if errors occured while tokenizing.
prepareFilesForAssembly
public ArrayList prepareFilesForAssembly(ArrayList filenames,
String leadFilename,
String exceptionHandler)
throws ProcessingException
Prepares the given list of files for assembly. This involves
reading and tokenizing all the source files. There may be only one.
Parameters:
filenames – ArrayList containing the source file name(s) in no particular order
leadFilename – String containing name of source file that needs to go first and
will be represented by “this” MIPSprogram object.
exceptionHandler – String containing name of source file containing exception
handler. This will be assembled first, even ahead of leadFilename, to allow it to
include “startup” instructions loaded beginning at 0x00400000. Specify null or
empty String to indicate there is no such designated exception handler.
Returns:
ArrayList containing one MIPSprogram object for each file to assemble.
objects for any additional files (send ArrayList to assembler)
Throws:
ProcessingException – Will throw exception if errors occured while reading or tokenizing.
assemble
public ErrorList assemble(ArrayList MIPSprogramsToAssemble,
boolean extendedAssemblerEnabled)
throws ProcessingException
Assembles the MIPS source program. All files comprising the program must have
already been tokenized. Assembler warnings are not considered errors.
Parameters:
MIPSprogramsToAssemble – ArrayList of MIPSprogram objects, each representing a tokenized source file.
extendedAssemblerEnabled – A boolean value – true means extended (pseudo) instructions
are permitted in source code and false means they are to be flagged as errors.
Returns:
ErrorList containing nothing or only warnings (otherwise would have thrown exception).
Throws:
ProcessingException – Will throw exception if errors occured while assembling.
assemble
public ErrorList assemble(ArrayList MIPSprogramsToAssemble,
boolean extendedAssemblerEnabled,
boolean warningsAreErrors)
throws ProcessingException
Assembles the MIPS source program. All files comprising the program must have
already been tokenized.
Parameters:
MIPSprogramsToAssemble – ArrayList of MIPSprogram objects, each representing a tokenized source file.
extendedAssemblerEnabled – A boolean value – true means extended (pseudo) instructions
are permitted in source code and false means they are to be flagged as errors
warningsAreErrors – A boolean value – true means assembler warnings will be considered errors and terminate
the assemble; false means the assembler will produce warning message but otherwise ignore warnings.
Returns:
ErrorList containing nothing or only warnings (otherwise would have thrown exception).
Throws:
ProcessingException – Will throw exception if errors occured while assembling.
simulate
public boolean simulate(int[] breakPoints)
throws ProcessingException
Simulates execution of the MIPS program. Program must have already been assembled.
Begins simulation at beginning of text segment and continues to completion.
Parameters:
breakPoints – int array of breakpoints (PC addresses). Can be null.
Returns:
true if execution completed and false otherwise
Throws:
ProcessingException – Will throw exception if errors occured while simulating.
simulate
public boolean simulate(int maxSteps)
throws ProcessingException
Simulates execution of the MIPS program. Program must have already been assembled.
Begins simulation at beginning of text segment and continues to completion or
until the specified maximum number of steps are simulated.
Parameters:
maxSteps – maximum number of steps to simulate.
Returns:
true if execution completed and false otherwise
Throws:
ProcessingException – Will throw exception if errors occured while simulating.
simulateFromPC
public boolean simulateFromPC(int[] breakPoints,
int maxSteps,
AbstractAction a)
throws ProcessingException
Simulates execution of the MIPS program. Program must have already been assembled.
Begins simulation at current program counter address and continues until stopped,
paused, maximum steps exceeded, or exception occurs.
Parameters:
breakPoints – int array of breakpoints (PC addresses). Can be null.
maxSteps – maximum number of instruction executions. Default -1 means no maximum.
a – the GUI component responsible for this call (GO normally). set to null if none.
Returns:
true if execution completed and false otherwise
Throws:
ProcessingException – Will throw exception if errors occured while simulating.
simulateStepAtPC
public boolean simulateStepAtPC(AbstractAction a)
throws ProcessingException
Simulates execution of the MIPS program. Program must have already been assembled.
Begins simulation at current program counter address and executes one step.
Parameters:
a – the GUI component responsible for this call (STEP normally). Set to null if none.
Returns:
true if execution completed and false otherwise
Throws:
ProcessingException – Will throw exception if errors occured while simulating.
inSteppedExecution
public boolean inSteppedExecution()
Will be true only while in process of simulating a program statement
in step mode (e.g. returning to GUI after each step). This is used to
prevent spurious AccessNotices from being sent from Memory and Register
to observers at other times (e.g. while updating the data and register
displays, while assembling program’s data segment, etc).
createMacroPool
public MacroPool createMacroPool()
Instantiates a new MacroPool and sends reference of this
MIPSprogram to it
Returns:
instatiated MacroPool
getLocalMacroPool
public MacroPool getLocalMacroPool()
Gets local macro pool MacroPool for this program
Returns:
MacroPool
setLocalMacroPool
public void setLocalMacroPool(MacroPool macroPool)
Sets local macro pool MacroPool for this program
Parameters:
macroPool – reference to MacroPool
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars
mars
Classes
ErrorList
ErrorMessage
Globals
MarsLaunch
MarsSplashScreen
MIPSprogram
ProgramStatement
Settings
Exceptions
ProcessingException
mars
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
Package mars
Class Summary
ErrorList Maintains list of generated error messages, regardless of source (tokenizing, parsing,
assembly, execution).
ErrorMessage Represents occurrance of an error detected during tokenizing, assembly or simulation.
Globals Collection of globally-available data structures.
MarsLaunch Launch the Mars application
MarsSplashScreen Produces MARS splash screen.
Adapted from http://www.java-tips.org/content/view/1267/2/
MIPSprogram Internal representations of MIPS program.
ProgramStatement Represents one assembly/machine statement.
Settings Contains various IDE settings.
Exception Summary
ProcessingException Class to represent error that occurs while assembling or running a MIPS program.
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
mars Class Hierarchy
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Hierarchy For Package mars
Package Hierarchies:
All Packages
Class Hierarchy
java.lang.Object java.awt.Component (implements java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable)
java.awt.Container java.awt.Window (implements javax.accessibility.Accessible)
javax.swing.JWindow (implements javax.accessibility.Accessible, javax.swing.RootPaneContainer)
mars.MarsSplashScreen
mars.ErrorList
mars.ErrorMessage
mars.Globals
mars.MarsLaunch
mars.MIPSprogram
java.util.Observable mars.Settings
mars.ProgramStatement
java.lang.Throwable (implements java.io.Serializable)
java.lang.Exception mars.ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
ProcessingException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars
Class ProcessingException
java.lang.Object
java.lang.Throwable
java.lang.Exception
mars.ProcessingException
All Implemented Interfaces:
Serializable
public class ProcessingException
extends Exception
Class to represent error that occurs while assembling or running a MIPS program.
Author:
Pete Sanderson
See Also:
Serialized Form
Constructor Summary
ProcessingException()
Constructor for ProcessingException.
ProcessingException(ErrorList e)
Constructor for ProcessingException.
ProcessingException(ErrorList e,
AddressErrorException aee)
Constructor for ProcessingException.
ProcessingException(ProgramStatement ps,
AddressErrorException aee)
Constructor for ProcessingException to handle address runtime exceptions
ProcessingException(ProgramStatement ps,
String m)
Constructor for ProcessingException to handle runtime exceptions
ProcessingException(ProgramStatement ps,
String m,
int cause)
Constructor for ProcessingException to handle runtime exceptions
Method Summary
ErrorList errors()
Produce the list of error messages.
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
ProcessingException
public ProcessingException(ErrorList e)
Constructor for ProcessingException.
Parameters:
e – An ErrorList which is an ArrayList of ErrorMessage objects. Each ErrorMessage
represents one processing error.
ProcessingException
public ProcessingException(ErrorList e,
AddressErrorException aee)
Constructor for ProcessingException.
Parameters:
e – An ErrorList which is an ArrayList of ErrorMessage objects. Each ErrorMessage
represents one processing error.
aee – AddressErrorException object containing specialized error message, cause, address
ProcessingException
public ProcessingException(ProgramStatement ps,
String m)
Constructor for ProcessingException to handle runtime exceptions
Parameters:
ps – a ProgramStatement of statement causing runtime exception
m – a String containing specialized error message
ProcessingException
public ProcessingException(ProgramStatement ps,
String m,
int cause)
Constructor for ProcessingException to handle runtime exceptions
Parameters:
ps – a ProgramStatement of statement causing runtime exception
m – a String containing specialized error message
cause – exception cause (see Exceptions class for list)
ProcessingException
public ProcessingException(ProgramStatement ps,
AddressErrorException aee)
Constructor for ProcessingException to handle address runtime exceptions
Parameters:
ps – a ProgramStatement of statement causing runtime exception
aee – AddressErrorException object containing specialized error message, cause, address
ProcessingException
public ProcessingException()
Constructor for ProcessingException.
No parameter and thus no error list. Use this for normal MIPS
program termination (e.g. syscall 10 for exit).
Method Detail
errors
public ErrorList errors()
Produce the list of error messages.
Returns:
Returns ErrorList of error messages.
See Also:
ErrorList,
ErrorMessage
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
ProgramStatement
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars
Class ProgramStatement
java.lang.Object
mars.ProgramStatement
public class ProgramStatement
extends Object
Represents one assembly/machine statement. This represents the “bare machine” level.
Pseudo-instructions have already been processed at this point and each assembly
statement generated by them is one of these.
Author:
Pete Sanderson and Jason Bumgarner
Constructor Summary
ProgramStatement(int binaryStatement,
int textAddress)
Constructor for ProgramStatement used only for writing a binary machine
instruction with no source code to refer back to.
ProgramStatement(MIPSprogram sourceMIPSprogram,
String source,
TokenList origTokenList,
TokenList strippedTokenList,
Instruction inst,
int textAddress,
int sourceLine)
Constructor for ProgramStatement when there are links back to all source and token
information.
Method Summary
void buildBasicStatementFromBasicInstruction(ErrorList errors)
Given specification of BasicInstruction for this operator, build the
corresponding assembly statement in basic assembly format (e.g.
void buildMachineStatementFromBasicStatement(ErrorList errors)
Given the current statement in Basic Assembly format (see above), build the
32-bit binary machine code statement.
int getAddress()
Produces Text Segment address where the binary machine statement is stored.
String getBasicAssemblyStatement()
Produces Basic Assembly statement for this MIPS source statement.
int getBinaryStatement()
Produces 32-bit binary machine statement as int.
Instruction getInstruction()
Produces Instruction object corresponding to this statement’s operator.
String getMachineStatement()
Produces binary machine statement as 32 character string, all ‘0’ and ‘1’ chars.
int getOperand(int i)
Produces operand value from given array position (first operand is position 0).
int[] getOperands()
Produces int array of operand values for this statement.
TokenList getOriginalTokenList()
Produces token list generated from original source statement.
String getPrintableBasicAssemblyStatement()
Produces printable Basic Assembly statement for this MIPS source
statement.
String getSource()
Produces MIPS source statement.
String getSourceFile()
Produces String name of the source file containing this statement.
int getSourceLine()
Produces line number of MIPS source statement.
MIPSprogram getSourceMIPSprogram()
Produces MIPSprogram object representing the source file containing this statement.
TokenList getStrippedTokenList()
Produces token list stripped of all but operator and operand tokens.
void setBasicAssemblyStatement(String statement)
Assigns given String to be Basic Assembly statement equivalent to this source line.
void setBinaryStatement(int binaryCode)
Assigns given int to be binary machine code equivalent to this source line.
void setMachineStatement(String statement)
Assigns given String to be binary machine code (32 characters, all of them 0 or 1)
equivalent to this source line.
void setSource(String src)
associates MIPS source statement.
String toString()
Crude attempt at building String representation of this complex structure.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
ProgramStatement
public ProgramStatement(MIPSprogram sourceMIPSprogram,
String source,
TokenList origTokenList,
TokenList strippedTokenList,
Instruction inst,
int textAddress,
int sourceLine)
Constructor for ProgramStatement when there are links back to all source and token
information. These can be used by a debugger later on.
Parameters:
sourceMIPSprogram – The MIPSprogram object that contains this statement
source – The corresponding MIPS source statement.
origTokenList – Complete list of Token objects (includes labels, comments, parentheses, etc)
strippedTokenList – List of Token objects with all but operators and operands removed.
inst – The Instruction object for this statement’s operator.
textAddress – The Text Segment address in memory where the binary machine code for this statement
is stored.
ProgramStatement
public ProgramStatement(int binaryStatement,
int textAddress)
Constructor for ProgramStatement used only for writing a binary machine
instruction with no source code to refer back to. Originally supported
only NOP instruction (all zeroes), but extended in release 4.4 to support
all basic instructions. This was required for the self-modifying code
feature.
Parameters:
binaryStatement – The 32-bit machine code.
textAddress – The Text Segment address in memory where the binary machine code for this statement
is stored.
Method Detail
buildBasicStatementFromBasicInstruction
public void buildBasicStatementFromBasicInstruction(ErrorList errors)
Given specification of BasicInstruction for this operator, build the
corresponding assembly statement in basic assembly format (e.g. substituting
register numbers for register names, replacing labels by values).
Parameters:
errors – The list of assembly errors encountered so far. May add to it here.
buildMachineStatementFromBasicStatement
public void buildMachineStatementFromBasicStatement(ErrorList errors)
Given the current statement in Basic Assembly format (see above), build the
32-bit binary machine code statement.
Parameters:
errors – The list of assembly errors encountered so far. May add to it here.
toString
public String toString()
Crude attempt at building String representation of this complex structure.
Overrides:
toString in class Object
Returns:
A String representing the ProgramStatement.
setBasicAssemblyStatement
public void setBasicAssemblyStatement(String statement)
Assigns given String to be Basic Assembly statement equivalent to this source line.
Parameters:
statement – A String containing equivalent Basic Assembly statement.
setMachineStatement
public void setMachineStatement(String statement)
Assigns given String to be binary machine code (32 characters, all of them 0 or 1)
equivalent to this source line.
Parameters:
statement – A String containing equivalent machine code.
setBinaryStatement
public void setBinaryStatement(int binaryCode)
Assigns given int to be binary machine code equivalent to this source line.
Parameters:
binaryCode – An int containing equivalent binary machine code.
setSource
public void setSource(String src)
associates MIPS source statement. Used by assembler when generating basic
statements during macro expansion of extended statement.
Parameters:
src – a MIPS source statement.
getSourceMIPSprogram
public MIPSprogram getSourceMIPSprogram()
Produces MIPSprogram object representing the source file containing this statement.
Returns:
The MIPSprogram object. May be null…
getSourceFile
public String getSourceFile()
Produces String name of the source file containing this statement.
Returns:
The file name.
getSource
public String getSource()
Produces MIPS source statement.
Returns:
The MIPS source statement.
getSourceLine
public int getSourceLine()
Produces line number of MIPS source statement.
Returns:
The MIPS source statement line number.
getBasicAssemblyStatement
public String getBasicAssemblyStatement()
Produces Basic Assembly statement for this MIPS source statement.
All numeric values are in decimal.
Returns:
The Basic Assembly statement.
getPrintableBasicAssemblyStatement
public String getPrintableBasicAssemblyStatement()
Produces printable Basic Assembly statement for this MIPS source
statement. This is generated dynamically and any addresses and
values will be rendered in hex or decimal depending on the current
setting.
Returns:
The Basic Assembly statement.
getMachineStatement
public String getMachineStatement()
Produces binary machine statement as 32 character string, all ‘0’ and ‘1’ chars.
Returns:
The String version of 32-bit binary machine code.
getBinaryStatement
public int getBinaryStatement()
Produces 32-bit binary machine statement as int.
Returns:
The int version of 32-bit binary machine code.
getOriginalTokenList
public TokenList getOriginalTokenList()
Produces token list generated from original source statement.
Returns:
The TokenList of Token objects generated from original source.
getStrippedTokenList
public TokenList getStrippedTokenList()
Produces token list stripped of all but operator and operand tokens.
Returns:
The TokenList of Token objects generated by stripping original list of all
except operator and operand tokens.
getInstruction
public Instruction getInstruction()
Produces Instruction object corresponding to this statement’s operator.
Returns:
The Instruction that matches the operator used in this statement.
getAddress
public int getAddress()
Produces Text Segment address where the binary machine statement is stored.
Returns:
address in Text Segment of this binary machine statement.
getOperands
public int[] getOperands()
Produces int array of operand values for this statement.
Returns:
int array of operand values (if any) required by this statement’s operator.
getOperand
public int getOperand(int i)
Produces operand value from given array position (first operand is position 0).
Parameters:
i – Operand position in array (first operand is position 0).
Returns:
Operand value at given operand array position. If < 0 or >= numOperands, it returns -1.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Settings
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars
Class Settings
java.lang.Object
java.util.Observable
mars.Settings
public class Settings
extends Observable
Contains various IDE settings. Persistent settings are maintained for the
current user and on the current machine using
Java’s Preference objects. Failing that, default setting values come from
Settings.properties file. If both of those fail, default values come from
static arrays defined in this class. The latter can can be modified prior to
instantiating Settings object.
NOTE: If the Preference objects fail due to security exceptions, changes to
settings will not carry over from one MARS session to the next.
Actual implementation of the Preference objects is platform-dependent.
For Windows, they are stored in Registry. To see, run regedit and browse to:
HKEY_CURRENT_USER\Software\JavaSoft\Prefs\mars
Author:
Pete Sanderson
Field Summary
static int ASSEMBLE_ALL_ENABLED
Flag to determine whether only the current editor source file (enabled false) or
all files in its directory (enabled true) will be assembled when assembly is selected.
static int ASSEMBLE_ON_OPEN_ENABLED
Flag to determine whether or not a file is immediately and automatically assembled
upon opening.
static int AUTO_INDENT
Flag to control whether or not language-aware editor will use auto-indent feature
static int BARE_MACHINE_ENABLED
Flag to determine whether or not program being assembled is limited to
using register numbers instead of names.
static int CARET_BLINK_RATE
Caret blink rate in milliseconds, 0 means don’t blink.
static int DATA_SEGMENT_HIGHLIGHTING
Flag to control whether or not highlighting is applied to data segment window
static int DATASEGMENT_HIGHLIGHT_BACKGROUND
RGB color for text segment highlighted background
static int DATASEGMENT_HIGHLIGHT_FONT
Font for text segment highlighted background
static int DATASEGMENT_HIGHLIGHT_FOREGROUND
RGB color for text segment highlighted foreground
static boolean[] defaultBooleanSettingsValues
Last resort default values for boolean settings; will use only if neither
the Preferences nor the properties file work.
static int DELAYED_BRANCHING_ENABLED
Flag to determine whether or not delayed branching is in effect at MIPS execution.
static int DISPLAY_ADDRESSES_IN_HEX
Default setting for displaying addresses and values in hexidecimal in the Execute
pane.
static int DISPLAY_VALUES_IN_HEX
static int EDITOR_CURRENT_LINE_HIGHLIGHTING
Flag to control whether or not editor will highlight the line currently being edited
static int EDITOR_FONT
Font for the text editor
static int EDITOR_LINE_NUMBERS_DISPLAYED
Flag to determine whether or not the editor will display line numbers.
static int EDITOR_POPUP_PREFIX_LENGTH
Number of letters to be matched by editor’s instruction guide before popup generated (if popup enabled)
static int EDITOR_TAB_SIZE
Editor tab size in characters.
static int EVEN_ROW_BACKGROUND
RGB color for table even row background (text, data, register displays)
static int EVEN_ROW_FONT
Font for table even row background (text, data, register displays)
static int EVEN_ROW_FOREGROUND
RGB color for table even row foreground (text, data, register displays)
static int EXCEPTION_HANDLER
Current specified exception handler file (a MIPS assembly source file)
static int EXCEPTION_HANDLER_ENABLED
Flag to determine whether the currently selected exception handler source file will
be included in each assembly operation.
static int EXTENDED_ASSEMBLER_ENABLED
Flag to determine whether or not program being assembled is limited to
basic MIPS instructions and formats.
static int GENERIC_TEXT_EDITOR
Flag to control whether or not to use generic text editor instead of language-aware styled editor
static int LABEL_SORT_STATE
State for sorting label window display
static int LABEL_WINDOW_VISIBILITY
Default visibilty of label window (symbol table).
static int MEMORY_CONFIGURATION
Identifier of current memory configuration
static int ODD_ROW_BACKGROUND
RGB color for table odd row background (text, data, register displays)
static int ODD_ROW_FONT
Font for table odd row background (text, data, register displays)
static int ODD_ROW_FOREGROUND
RGB color for table odd row foreground (text, data, register displays)
static int POPUP_INSTRUCTION_GUIDANCE
Flag to control whether or not editor will provide popup instruction guidance while typing
static int POPUP_SYSCALL_INPUT
Flag to control whether or not simulator will use popup dialog for input syscalls
static int PROGRAM_ARGUMENTS
Flag to determine whether or not to display and use program arguments
static int REGISTER_HIGHLIGHT_BACKGROUND
RGB color for register highlighted background
static int REGISTER_HIGHLIGHT_FONT
Font for register highlighted background
static int REGISTER_HIGHLIGHT_FOREGROUND
RGB color for register highlighted foreground
static int REGISTERS_HIGHLIGHTING
Flag to control whether or not highlighting is applied to register windows
static int SELF_MODIFYING_CODE_ENABLED
Flag to determine whether a program can write binary code to the text or data segment and
execute that code.
static int START_AT_MAIN
Flag to control whether or not assembler automatically initializes program counter to ‘main’s address
static int TEXT_COLUMN_ORDER
Order of text segment table columns
static int TEXTSEGMENT_DELAYSLOT_HIGHLIGHT_BACKGROUND
RGB color for text segment delay slot highlighted background
static int TEXTSEGMENT_DELAYSLOT_HIGHLIGHT_FONT
Font for text segment delay slot highlighted background
static int TEXTSEGMENT_DELAYSLOT_HIGHLIGHT_FOREGROUND
RGB color for text segment delay slot highlighted foreground
static int TEXTSEGMENT_HIGHLIGHT_BACKGROUND
RGB color for text segment highlighted background
static int TEXTSEGMENT_HIGHLIGHT_FONT
Font for table odd row foreground (text, data, register displays)
static int TEXTSEGMENT_HIGHLIGHT_FOREGROUND
RGB color for text segment highlighted foreground
static int WARNINGS_ARE_ERRORS
Flag to determine whether or not assembler warnings are considered errors.
Constructor Summary
Settings()
Create Settings object and set to saved values.
Settings(boolean gui)
Create Settings object and set to saved values.
Method Summary
boolean getAssembleAllEnabled()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.ASSEMBLE_ALL_ENABLED)
boolean getAssembleOnOpenEnabled()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.ASSEMBLE_ON_OPEN_ENABLED)
boolean getBackSteppingEnabled()
Return whether backstepping is permitted at this time.
boolean getBareMachineEnabled()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.BARE_MACHINE_ENABLED)
boolean getBooleanSetting(int id)
Fetch value of a boolean setting given its identifier.
int getCaretBlinkRate()
Retrieve the caret blink rate in milliseconds.
Color getColorSettingByKey(String key)
Get Color object for specified settings key.
Color getColorSettingByPosition(int position)
Get Color object for specified settings name (a static constant).
boolean getDataSegmentHighlighting()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.DATA_SEGMENT_HIGHLIGHTING)
Color getDefaultColorSettingByKey(String key)
Get default Color value for specified settings key.
Color getDefaultColorSettingByPosition(int position)
Get default Color object for specified settings name (a static constant).
SyntaxStyle getDefaultEditorSyntaxStyleByPosition(int index)
int getDefaultEditorTabSize()
Get the text editor default tab size in characters
Font getDefaultFontByPosition(int fontSettingPosition)
Retrieve a default Font setting
boolean getDelayedBranchingEnabled()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.DELAYED_BRANCHING_ENABLED)
boolean getDisplayAddressesInHex()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.DISPLAY_ADDRESSES_IN_HEX)
boolean getDisplayValuesInHex()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.DISPLAY_VALUES_IN_HEX)
Font getEditorFont()
Current editor font.
boolean getEditorLineNumbersDisplayed()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.EDITOR_LINE_NUMBERS_DISPLAYED)
int getEditorPopupPrefixLength()
Get number of letters to be matched by editor’s instruction guide before popup generated (if popup enabled).
SyntaxStyle getEditorSyntaxStyleByPosition(int index)
int getEditorTabSize()
Get the tab size in characters.
String getExceptionHandler()
Name of currently selected exception handler file.
boolean getExceptionHandlerEnabled()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.EXCEPTION_HANDLER_ENABLED)
boolean getExtendedAssemblerEnabled()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.EXTENDED_ASSEMBLER_ENABLED)
Font getFontByPosition(int fontSettingPosition)
Retrieve a Font setting
String getLabelSortState()
Get the saved state of the Labels Window sorting (can sort by either
label or address and either ascending or descending order).
boolean getLabelWindowVisibility()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.LABEL_WINDOW_VISIBILITY)
String getMemoryConfiguration()
Returns identifier of current built-in memory configuration.
boolean getProgramArguments()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.PROGRAM_ARGUMENTS)
boolean getRegistersHighlighting()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.REGISTERS_HIGHLIGHTING)
boolean getStartAtMain()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.START_AT_MAIN)
int[] getTextColumnOrder()
Order of text segment display columns (there are 5, numbered 0 to 4).
boolean getWarningsAreErrors()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.WARNINGS_ARE_ERRORS)
void reset(boolean gui)
Reset settings to default values, as described in the constructor comments.
void setAssembleAllEnabled(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.ASSEMBLE_ALL_ENABLED)
void setAssembleOnOpenEnabled(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.ASSEMBLE_ON_OPEN_ENABLED)
void setBooleanSetting(int id,
boolean value)
Set value of a boolean setting given its id and the value.
void setBooleanSettingNonPersistent(int id,
boolean value)
Temporarily establish boolean setting.
void setCaretBlinkRate(int rate)
Set the caret blinking rate in milliseconds.
void setColorSettingByKey(String key,
Color color)
Set Color object for specified settings key.
void setColorSettingByPosition(int position,
Color color)
Set Color object for specified settings name (a static constant).
void setDataSegmentHighlighting(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DATA_SEGMENT_HIGHLIGHTING)
void setDelayedBranchingEnabled(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DELAYED_BRANCHING_ENABLED)
void setDelayedBranchingEnabledNonPersistent(boolean value)
Deprecated. Use setBooleanSettingNonPersistent(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DELAYED_BRANCHING_ENABLED)
void setDisplayAddressesInHex(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DISPLAY_ADDRESSES_IN_HEX)
void setDisplayValuesInHex(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DISPLAY_VALUES_IN_HEX)
void setEditorFont(Font font)
Set editor font to the specified Font object and write it to persistent storage.
void setEditorLineNumbersDisplayed(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.EDITOR_LINE_NUMBERS_DISPLAYED)
void setEditorPopupPrefixLength(int length)
Set number of letters to be matched by editor’s instruction guide before popup generated (if popup enabled).
void setEditorSyntaxStyleByPosition(int index,
SyntaxStyle syntaxStyle)
void setEditorTabSize(int size)
Set the tab size in characters.
void setExceptionHandler(String newFilename)
Set name of exception handler file and write it to persistent storage.
void setExceptionHandlerEnabled(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.EXCEPTION_HANDLER_ENABLED)
void setExtendedAssemblerEnabled(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.EXTENDED_ASSEMBLER_ENABLED)
void setFontByPosition(int fontSettingPosition,
Font font)
Store a Font setting
void setLabelSortState(String state)
Store the current state of the Labels Window sorter.
void setLabelWindowVisibility(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.LABEL_WINDOW_VISIBILITY)
void setMemoryConfiguration(String config)
Store the identifier of the memory configuration.
void setProgramArguments(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.PROGRAM_ARGUMENTS)
void setRegistersHighlighting(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.REGISTERS_HIGHLIGHTING)
void setStartAtMain(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.START_AT_MAIN)
void setTextColumnOrder(int[] columnOrder)
Store the current order of Text Segment window table columns, so the ordering
can be preserved and restored.
void setWarningsAreErrors(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.WARNINGS_ARE_ERRORS)
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
EXTENDED_ASSEMBLER_ENABLED
public static final int EXTENDED_ASSEMBLER_ENABLED
Flag to determine whether or not program being assembled is limited to
basic MIPS instructions and formats.
See Also:
Constant Field Values
BARE_MACHINE_ENABLED
public static final int BARE_MACHINE_ENABLED
Flag to determine whether or not program being assembled is limited to
using register numbers instead of names. NOTE: Its default value is
false and the IDE provides no means to change it!
See Also:
Constant Field Values
ASSEMBLE_ON_OPEN_ENABLED
public static final int ASSEMBLE_ON_OPEN_ENABLED
Flag to determine whether or not a file is immediately and automatically assembled
upon opening. Handy when using externa editor like mipster.
See Also:
Constant Field Values
ASSEMBLE_ALL_ENABLED
public static final int ASSEMBLE_ALL_ENABLED
Flag to determine whether only the current editor source file (enabled false) or
all files in its directory (enabled true) will be assembled when assembly is selected.
See Also:
Constant Field Values
LABEL_WINDOW_VISIBILITY
public static final int LABEL_WINDOW_VISIBILITY
Default visibilty of label window (symbol table). Default only, dynamic status
maintained by ExecutePane
See Also:
Constant Field Values
DISPLAY_ADDRESSES_IN_HEX
public static final int DISPLAY_ADDRESSES_IN_HEX
Default setting for displaying addresses and values in hexidecimal in the Execute
pane.
See Also:
Constant Field Values
DISPLAY_VALUES_IN_HEX
public static final int DISPLAY_VALUES_IN_HEX
See Also:
Constant Field Values
EXCEPTION_HANDLER_ENABLED
public static final int EXCEPTION_HANDLER_ENABLED
Flag to determine whether the currently selected exception handler source file will
be included in each assembly operation.
See Also:
Constant Field Values
DELAYED_BRANCHING_ENABLED
public static final int DELAYED_BRANCHING_ENABLED
Flag to determine whether or not delayed branching is in effect at MIPS execution.
This means we simulate the pipeline and statement FOLLOWING a successful branch
is executed before branch is taken. DPS 14 June 2007.
See Also:
Constant Field Values
EDITOR_LINE_NUMBERS_DISPLAYED
public static final int EDITOR_LINE_NUMBERS_DISPLAYED
Flag to determine whether or not the editor will display line numbers.
See Also:
Constant Field Values
WARNINGS_ARE_ERRORS
public static final int WARNINGS_ARE_ERRORS
Flag to determine whether or not assembler warnings are considered errors.
See Also:
Constant Field Values
PROGRAM_ARGUMENTS
public static final int PROGRAM_ARGUMENTS
Flag to determine whether or not to display and use program arguments
See Also:
Constant Field Values
DATA_SEGMENT_HIGHLIGHTING
public static final int DATA_SEGMENT_HIGHLIGHTING
Flag to control whether or not highlighting is applied to data segment window
See Also:
Constant Field Values
REGISTERS_HIGHLIGHTING
public static final int REGISTERS_HIGHLIGHTING
Flag to control whether or not highlighting is applied to register windows
See Also:
Constant Field Values
START_AT_MAIN
public static final int START_AT_MAIN
Flag to control whether or not assembler automatically initializes program counter to ‘main’s address
See Also:
Constant Field Values
EDITOR_CURRENT_LINE_HIGHLIGHTING
public static final int EDITOR_CURRENT_LINE_HIGHLIGHTING
Flag to control whether or not editor will highlight the line currently being edited
See Also:
Constant Field Values
POPUP_INSTRUCTION_GUIDANCE
public static final int POPUP_INSTRUCTION_GUIDANCE
Flag to control whether or not editor will provide popup instruction guidance while typing
See Also:
Constant Field Values
POPUP_SYSCALL_INPUT
public static final int POPUP_SYSCALL_INPUT
Flag to control whether or not simulator will use popup dialog for input syscalls
See Also:
Constant Field Values
GENERIC_TEXT_EDITOR
public static final int GENERIC_TEXT_EDITOR
Flag to control whether or not to use generic text editor instead of language-aware styled editor
See Also:
Constant Field Values
AUTO_INDENT
public static final int AUTO_INDENT
Flag to control whether or not language-aware editor will use auto-indent feature
See Also:
Constant Field Values
SELF_MODIFYING_CODE_ENABLED
public static final int SELF_MODIFYING_CODE_ENABLED
Flag to determine whether a program can write binary code to the text or data segment and
execute that code.
See Also:
Constant Field Values
defaultBooleanSettingsValues
public static boolean[] defaultBooleanSettingsValues
Last resort default values for boolean settings; will use only if neither
the Preferences nor the properties file work. If you wish to change them,
do so before instantiating the Settings object.
Values are matched to keys by list position.
EXCEPTION_HANDLER
public static final int EXCEPTION_HANDLER
Current specified exception handler file (a MIPS assembly source file)
See Also:
Constant Field Values
TEXT_COLUMN_ORDER
public static final int TEXT_COLUMN_ORDER
Order of text segment table columns
See Also:
Constant Field Values
LABEL_SORT_STATE
public static final int LABEL_SORT_STATE
State for sorting label window display
See Also:
Constant Field Values
MEMORY_CONFIGURATION
public static final int MEMORY_CONFIGURATION
Identifier of current memory configuration
See Also:
Constant Field Values
CARET_BLINK_RATE
public static final int CARET_BLINK_RATE
Caret blink rate in milliseconds, 0 means don’t blink.
See Also:
Constant Field Values
EDITOR_TAB_SIZE
public static final int EDITOR_TAB_SIZE
Editor tab size in characters.
See Also:
Constant Field Values
EDITOR_POPUP_PREFIX_LENGTH
public static final int EDITOR_POPUP_PREFIX_LENGTH
Number of letters to be matched by editor’s instruction guide before popup generated (if popup enabled)
See Also:
Constant Field Values
EDITOR_FONT
public static final int EDITOR_FONT
Font for the text editor
See Also:
Constant Field Values
EVEN_ROW_FONT
public static final int EVEN_ROW_FONT
Font for table even row background (text, data, register displays)
See Also:
Constant Field Values
ODD_ROW_FONT
public static final int ODD_ROW_FONT
Font for table odd row background (text, data, register displays)
See Also:
Constant Field Values
TEXTSEGMENT_HIGHLIGHT_FONT
public static final int TEXTSEGMENT_HIGHLIGHT_FONT
Font for table odd row foreground (text, data, register displays)
See Also:
Constant Field Values
TEXTSEGMENT_DELAYSLOT_HIGHLIGHT_FONT
public static final int TEXTSEGMENT_DELAYSLOT_HIGHLIGHT_FONT
Font for text segment delay slot highlighted background
See Also:
Constant Field Values
DATASEGMENT_HIGHLIGHT_FONT
public static final int DATASEGMENT_HIGHLIGHT_FONT
Font for text segment highlighted background
See Also:
Constant Field Values
REGISTER_HIGHLIGHT_FONT
public static final int REGISTER_HIGHLIGHT_FONT
Font for register highlighted background
See Also:
Constant Field Values
EVEN_ROW_BACKGROUND
public static final int EVEN_ROW_BACKGROUND
RGB color for table even row background (text, data, register displays)
See Also:
Constant Field Values
EVEN_ROW_FOREGROUND
public static final int EVEN_ROW_FOREGROUND
RGB color for table even row foreground (text, data, register displays)
See Also:
Constant Field Values
ODD_ROW_BACKGROUND
public static final int ODD_ROW_BACKGROUND
RGB color for table odd row background (text, data, register displays)
See Also:
Constant Field Values
ODD_ROW_FOREGROUND
public static final int ODD_ROW_FOREGROUND
RGB color for table odd row foreground (text, data, register displays)
See Also:
Constant Field Values
TEXTSEGMENT_HIGHLIGHT_BACKGROUND
public static final int TEXTSEGMENT_HIGHLIGHT_BACKGROUND
RGB color for text segment highlighted background
See Also:
Constant Field Values
TEXTSEGMENT_HIGHLIGHT_FOREGROUND
public static final int TEXTSEGMENT_HIGHLIGHT_FOREGROUND
RGB color for text segment highlighted foreground
See Also:
Constant Field Values
TEXTSEGMENT_DELAYSLOT_HIGHLIGHT_BACKGROUND
public static final int TEXTSEGMENT_DELAYSLOT_HIGHLIGHT_BACKGROUND
RGB color for text segment delay slot highlighted background
See Also:
Constant Field Values
TEXTSEGMENT_DELAYSLOT_HIGHLIGHT_FOREGROUND
public static final int TEXTSEGMENT_DELAYSLOT_HIGHLIGHT_FOREGROUND
RGB color for text segment delay slot highlighted foreground
See Also:
Constant Field Values
DATASEGMENT_HIGHLIGHT_BACKGROUND
public static final int DATASEGMENT_HIGHLIGHT_BACKGROUND
RGB color for text segment highlighted background
See Also:
Constant Field Values
DATASEGMENT_HIGHLIGHT_FOREGROUND
public static final int DATASEGMENT_HIGHLIGHT_FOREGROUND
RGB color for text segment highlighted foreground
See Also:
Constant Field Values
REGISTER_HIGHLIGHT_BACKGROUND
public static final int REGISTER_HIGHLIGHT_BACKGROUND
RGB color for register highlighted background
See Also:
Constant Field Values
REGISTER_HIGHLIGHT_FOREGROUND
public static final int REGISTER_HIGHLIGHT_FOREGROUND
RGB color for register highlighted foreground
See Also:
Constant Field Values
Constructor Detail
Settings
public Settings()
Create Settings object and set to saved values. If saved values not found, will set
based on defaults stored in Settings.properties file. If file problems, will set based
on defaults stored in this class.
Settings
public Settings(boolean gui)
Create Settings object and set to saved values. If saved values not found, will set
based on defaults stored in Settings.properties file. If file problems, will set based
on defaults stored in this class.
Parameters:
gui – true if running the graphical IDE, false if running from command line.
Ignored as of release 3.6 but retained for compatability.
Method Detail
getBackSteppingEnabled
public boolean getBackSteppingEnabled()
Return whether backstepping is permitted at this time. Backstepping is ability to undo execution
steps one at a time. Available only in the IDE. This is not a persistent setting and is not under
MARS user control.
Returns:
true if backstepping is permitted, false otherwise.
reset
public void reset(boolean gui)
Reset settings to default values, as described in the constructor comments.
Parameters:
gui – true if running from GUI IDE and false if running from command mode.
Ignored as of release 3.6 but retained for compatibility.
setEditorSyntaxStyleByPosition
public void setEditorSyntaxStyleByPosition(int index,
SyntaxStyle syntaxStyle)
getEditorSyntaxStyleByPosition
public SyntaxStyle getEditorSyntaxStyleByPosition(int index)
getDefaultEditorSyntaxStyleByPosition
public SyntaxStyle getDefaultEditorSyntaxStyleByPosition(int index)
getBooleanSetting
public boolean getBooleanSetting(int id)
Fetch value of a boolean setting given its identifier.
Parameters:
id – int containing the setting’s identifier (constants listed above)
Returns:
corresponding boolean setting.
Throws:
IllegalArgumentException – if identifier is invalid.
getBareMachineEnabled
public boolean getBareMachineEnabled()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.BARE_MACHINE_ENABLED)
Setting for whether user programs limited to “bare machine” formatted basic instructions.
This was added 8 Aug 2006 but is fixed at false for now, due to uncertainty as to what
exactly constitutes “bare machine”.
Returns:
true if only bare machine instructions allowed, false otherwise.
getExtendedAssemblerEnabled
public boolean getExtendedAssemblerEnabled()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.EXTENDED_ASSEMBLER_ENABLED)
Setting for whether user programs can use pseudo-instructions or extended addressing modes
or alternative instruction formats (all are implemented as pseudo-instructions).
Returns:
true if pseudo-instructions and formats permitted, false otherwise.
getAssembleOnOpenEnabled
public boolean getAssembleOnOpenEnabled()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.ASSEMBLE_ON_OPEN_ENABLED)
Setting for whether selected program will be automatically assembled upon opening. This
can be useful if user employs an external editor such as MIPSter.
Returns:
true if file is to be automatically assembled upon opening and false otherwise.
getDisplayAddressesInHex
public boolean getDisplayAddressesInHex()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.DISPLAY_ADDRESSES_IN_HEX)
Setting for whether Addresses in the Execute pane will be displayed in hexadecimal.
Returns:
true if addresses are displayed in hexadecimal and false otherwise (decimal).
getDisplayValuesInHex
public boolean getDisplayValuesInHex()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.DISPLAY_VALUES_IN_HEX)
Setting for whether values in the Execute pane will be displayed in hexadecimal.
Returns:
true if values are displayed in hexadecimal and false otherwise (decimal).
getAssembleAllEnabled
public boolean getAssembleAllEnabled()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.ASSEMBLE_ALL_ENABLED)
Setting for whether the assemble operation applies only to the file currently open in
the editor or whether it applies to all files in that file’s directory (primitive project
capability). If the “assemble on open” setting is set, this “assemble all” setting will
be applied as soon as the file is opened.
Returns:
true if all files are to be assembled, false if only the file open in editor.
getExceptionHandlerEnabled
public boolean getExceptionHandlerEnabled()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.EXCEPTION_HANDLER_ENABLED)
Setting for whether the currently selected exception handler
(a MIPS source file) will be automatically included in each
assemble operation.
Returns:
true if exception handler is to be included in assemble, false otherwise.
getDelayedBranchingEnabled
public boolean getDelayedBranchingEnabled()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.DELAYED_BRANCHING_ENABLED)
Setting for whether delayed branching will be applied during MIPS
program execution. If enabled, the statement following a successful
branch will be executed and then the branch is taken! This simulates
pipelining and all MIPS processors do it. However it is confusing to
assembly language students so is disabled by default. SPIM does same thing.
Returns:
true if delayed branching is enabled, false otherwise.
getLabelWindowVisibility
public boolean getLabelWindowVisibility()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.LABEL_WINDOW_VISIBILITY)
Setting concerning whether or not to display the Labels Window — symbol table.
Returns:
true if label window is to be displayed, false otherwise.
getEditorLineNumbersDisplayed
public boolean getEditorLineNumbersDisplayed()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.EDITOR_LINE_NUMBERS_DISPLAYED)
Setting concerning whether or not the editor will display line numbers.
Returns:
true if line numbers are to be displayed, false otherwise.
getWarningsAreErrors
public boolean getWarningsAreErrors()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.WARNINGS_ARE_ERRORS)
Setting concerning whether or not assembler will consider warnings to be errors.
Returns:
true if warnings are considered errors, false otherwise.
getProgramArguments
public boolean getProgramArguments()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.PROGRAM_ARGUMENTS)
Setting concerning whether or not program arguments can be entered and used.
Returns:
true if program arguments can be entered/used, false otherwise.
getDataSegmentHighlighting
public boolean getDataSegmentHighlighting()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.DATA_SEGMENT_HIGHLIGHTING)
Setting concerning whether or not highlighting is applied to Data Segment window.
Returns:
true if highlighting is to be applied, false otherwise.
getRegistersHighlighting
public boolean getRegistersHighlighting()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.REGISTERS_HIGHLIGHTING)
Setting concerning whether or not highlighting is applied to Registers,
Coprocessor0, and Coprocessor1 windows.
Returns:
true if highlighting is to be applied, false otherwise.
getStartAtMain
public boolean getStartAtMain()
Deprecated. Use getBooleanSetting(int id) with the appropriate boolean setting ID
(e.g. Settings.START_AT_MAIN)
Setting concerning whether or not assembler will automatically initialize
the program counter to address of statement labeled ‘main’ if defined.
Returns:
true if it initializes to ‘main’, false otherwise.
getExceptionHandler
public String getExceptionHandler()
Name of currently selected exception handler file.
Returns:
String pathname of current exception handler file, empty if none.
getMemoryConfiguration
public String getMemoryConfiguration()
Returns identifier of current built-in memory configuration.
Returns:
String identifier of current built-in memory configuration, empty if none.
getEditorFont
public Font getEditorFont()
Current editor font. Retained for compatibility but replaced
by: getFontByPosition(Settings.EDITOR_FONT)
Returns:
Font object for current editor font.
getFontByPosition
public Font getFontByPosition(int fontSettingPosition)
Retrieve a Font setting
Parameters:
fontSettingPosition – constant that identifies which item
Returns:
Font object for given item
getDefaultFontByPosition
public Font getDefaultFontByPosition(int fontSettingPosition)
Retrieve a default Font setting
Parameters:
fontSettingPosition – constant that identifies which item
Returns:
Font object for given item
getTextColumnOrder
public int[] getTextColumnOrder()
Order of text segment display columns (there are 5, numbered 0 to 4).
Returns:
Array of int indicating the order. Original order is 0 1 2 3 4.
getCaretBlinkRate
public int getCaretBlinkRate()
Retrieve the caret blink rate in milliseconds. Blink rate of 0 means
do not blink.
Returns:
int blink rate in milliseconds
getEditorTabSize
public int getEditorTabSize()
Get the tab size in characters.
Returns:
tab size in characters.
getEditorPopupPrefixLength
public int getEditorPopupPrefixLength()
Get number of letters to be matched by editor’s instruction guide before popup generated (if popup enabled).
Should be 1 or 2. If 1, the popup will be generated after first letter typed, based on all matches; if 2,
the popup will be generated after second letter typed.
Returns:
number of letters (should be 1 or 2).
getDefaultEditorTabSize
public int getDefaultEditorTabSize()
Get the text editor default tab size in characters
Returns:
tab size in characters
getLabelSortState
public String getLabelSortState()
Get the saved state of the Labels Window sorting (can sort by either
label or address and either ascending or descending order).
Default state is 0, by ascending addresses.
Returns:
State value 0-7, as a String.
getColorSettingByKey
public Color getColorSettingByKey(String key)
Get Color object for specified settings key.
Returns null if key is not found or its value is not a valid color encoding.
Parameters:
key – the Setting key
Returns:
corresponding Color, or null if key not found or value not valid color
getDefaultColorSettingByKey
public Color getDefaultColorSettingByKey(String key)
Get default Color value for specified settings key.
Returns null if key is not found or its value is not a valid color encoding.
Parameters:
key – the Setting key
Returns:
corresponding default Color, or null if key not found or value not valid color
getColorSettingByPosition
public Color getColorSettingByPosition(int position)
Get Color object for specified settings name (a static constant).
Returns null if argument invalid or its value is not a valid color encoding.
Parameters:
position – the Setting name (see list of static constants)
Returns:
corresponding Color, or null if argument invalid or value not valid color
getDefaultColorSettingByPosition
public Color getDefaultColorSettingByPosition(int position)
Get default Color object for specified settings name (a static constant).
Returns null if argument invalid or its value is not a valid color encoding.
Parameters:
position – the Setting name (see list of static constants)
Returns:
corresponding default Color, or null if argument invalid or value not valid color
setBooleanSetting
public void setBooleanSetting(int id,
boolean value)
Set value of a boolean setting given its id and the value.
Parameters:
id – int containing the setting’s identifier (constants listed above)
value – boolean value to store
Throws:
IllegalArgumentException – if identifier is not valid.
setExtendedAssemblerEnabled
public void setExtendedAssemblerEnabled(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.EXTENDED_ASSEMBLER_ENABLED)
Establish setting for whether or not pseudo-instructions and formats are permitted
in user programs. User can change this setting via the IDE. If setting changes,
new setting will be written to properties file.
Parameters:
value – True to permit, false otherwise.
setAssembleOnOpenEnabled
public void setAssembleOnOpenEnabled(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.ASSEMBLE_ON_OPEN_ENABLED)
Establish setting for whether a file will be automatically assembled as soon as it
is opened. This is handy for those using an external text editor such as Mipster.
If setting changes, new setting will be written to properties file.
Parameters:
value – True to automatically assemble, false otherwise.
setAssembleAllEnabled
public void setAssembleAllEnabled(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.ASSEMBLE_ALL_ENABLED)
Establish setting for whether a file will be assembled by itself (false) or along
with all other files in its directory (true). This permits multi-file programs
and a primitive “project” capability. If setting changes,
new setting will be written to properties file.
Parameters:
value – True to assemble all, false otherwise.
setDisplayAddressesInHex
public void setDisplayAddressesInHex(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DISPLAY_ADDRESSES_IN_HEX)
Establish setting for whether addresses in the Execute pane will be displayed
in hexadecimal format.
Parameters:
value – True to display addresses in hexadecimal, false for decimal.
setDisplayValuesInHex
public void setDisplayValuesInHex(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DISPLAY_VALUES_IN_HEX)
Establish setting for whether values in the Execute pane will be displayed
in hexadecimal format.
Parameters:
value – True to display values in hexadecimal, false for decimal.
setLabelWindowVisibility
public void setLabelWindowVisibility(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.LABEL_WINDOW_VISIBILITY)
Establish setting for whether the labels window (i.e. symbol table) will
be displayed as part of the Text Segment display. If setting changes,
new setting will be written to properties file.
Parameters:
value – True to dispay labels window, false otherwise.
setExceptionHandlerEnabled
public void setExceptionHandlerEnabled(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.EXCEPTION_HANDLER_ENABLED)
Establish setting for whether the currently selected exception handler
(a MIPS source file) will be automatically included in each
assemble operation. If setting changes, new setting will be written
to properties file.
Parameters:
value – True to assemble exception handler, false otherwise.
setDelayedBranchingEnabled
public void setDelayedBranchingEnabled(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DELAYED_BRANCHING_ENABLED)
Establish setting for whether delayed branching will be applied during
MIPS program execution. If enabled, the statement following a successful
branch will be executed and then the branch is taken! This simulates
pipelining and all MIPS processors do it. However it is confusing to
assembly language students so is disabled by default. SPIM does same thing.
Parameters:
value – True to enable delayed branching, false otherwise.
setEditorLineNumbersDisplayed
public void setEditorLineNumbersDisplayed(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.EDITOR_LINE_NUMBERS_DISPLAYED)
Establish setting for whether line numbers will be displayed by the
text editor.
Parameters:
value – True to display line numbers, false otherwise.
setWarningsAreErrors
public void setWarningsAreErrors(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.WARNINGS_ARE_ERRORS)
Establish setting for whether assembler warnings will be considered errors.
Parameters:
value – True to consider warnings to be errors, false otherwise.
setProgramArguments
public void setProgramArguments(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.PROGRAM_ARGUMENTS)
Establish setting for whether program arguments can be ented/used.
Parameters:
value – True if program arguments can be entered/used, false otherwise.
setDataSegmentHighlighting
public void setDataSegmentHighlighting(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DATA_SEGMENT_HIGHLIGHTING)
Establish setting for whether highlighting is to be applied to
Data Segment window.
Parameters:
value – True if highlighting is to be applied, false otherwise.
setRegistersHighlighting
public void setRegistersHighlighting(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.REGISTERS_HIGHLIGHTING)
Establish setting for whether highlighting is to be applied to
Registers, Coprocessor0 and Coprocessor1 windows.
Parameters:
value – True if highlighting is to be applied, false otherwise.
setStartAtMain
public void setStartAtMain(boolean value)
Deprecated. Use setBooleanSetting(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.START_AT_MAIN)
Establish setting for whether assembler will automatically initialize
program counter to address of statement labeled ‘main’ if defined.
Parameters:
value – True if PC set to address of ‘main’, false otherwise.
setBooleanSettingNonPersistent
public void setBooleanSettingNonPersistent(int id,
boolean value)
Temporarily establish boolean setting. This setting will NOT be written to persisent
store! Currently this is used only when running MARS from the command line
Parameters:
id – setting identifier. These are defined for this class as static final int.
value – True to enable the setting, false otherwise.
setDelayedBranchingEnabledNonPersistent
public void setDelayedBranchingEnabledNonPersistent(boolean value)
Deprecated. Use setBooleanSettingNonPersistent(int id, boolean value) with the appropriate boolean setting ID
(e.g. Settings.DELAYED_BRANCHING_ENABLED)
Establish setting for whether delayed branching will be applied during
MIPS program execution. This setting will NOT be written to persisent
store! This method should be called only to temporarily set this
setting — currently this is needed only when running MARS from the
command line.
Parameters:
value – True to enabled delayed branching, false otherwise.
setExceptionHandler
public void setExceptionHandler(String newFilename)
Set name of exception handler file and write it to persistent storage.
Parameters:
newFilename – name of exception handler file
setMemoryConfiguration
public void setMemoryConfiguration(String config)
Store the identifier of the memory configuration.
Parameters:
config – A string that identifies the current built-in memory configuration
setCaretBlinkRate
public void setCaretBlinkRate(int rate)
Set the caret blinking rate in milliseconds. Rate of 0 means no blinking.
Parameters:
rate – blink rate in milliseconds
setEditorTabSize
public void setEditorTabSize(int size)
Set the tab size in characters.
Parameters:
size – tab size in characters.
setEditorPopupPrefixLength
public void setEditorPopupPrefixLength(int length)
Set number of letters to be matched by editor’s instruction guide before popup generated (if popup enabled).
Should be 1 or 2. If 1, the popup will be generated after first letter typed, based on all matches; if 2,
the popup will be generated after second letter typed.
Parameters:
number – of letters (should be 1 or 2).
setEditorFont
public void setEditorFont(Font font)
Set editor font to the specified Font object and write it to persistent storage.
This method retained for compatibility but replaced by:
setFontByPosition(Settings.EDITOR_FONT, font)
Parameters:
font – Font object to be used by text editor.
setFontByPosition
public void setFontByPosition(int fontSettingPosition,
Font font)
Store a Font setting
Parameters:
fontSettingPosition – Constant that identifies the item the font goes with
setTextColumnOrder
public void setTextColumnOrder(int[] columnOrder)
Store the current order of Text Segment window table columns, so the ordering
can be preserved and restored.
Parameters:
columnOrder – An array of int indicating column order.
setLabelSortState
public void setLabelSortState(String state)
Store the current state of the Labels Window sorter. There are 8 possible states
as described in LabelsWindow.java
Parameters:
state – The current labels window sorting state, as a String.
setColorSettingByKey
public void setColorSettingByKey(String key,
Color color)
Set Color object for specified settings key. Has no effect if key is invalid.
Parameters:
key – the Setting key
color – the Color to save
setColorSettingByPosition
public void setColorSettingByPosition(int position,
Color color)
Set Color object for specified settings name (a static constant). Has no effect if invalid.
Parameters:
position – the Setting name (see list of static constants)
color – the Color to save
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
BackStepper
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.simulator
Class BackStepper
java.lang.Object
mars.simulator.BackStepper
public class BackStepper
extends Object
Used to “step backward” through execution, undoing each instruction.
Author:
Pete Sanderson
Constructor Summary
BackStepper()
Create a fresh BackStepper.
Method Summary
int addConditionFlagClear(int flag)
Add a new “back step” (the undo action) to the stack.
int addConditionFlagSet(int flag)
Add a new “back step” (the undo action) to the stack.
int addCoprocessor0Restore(int register,
int value)
Add a new “back step” (the undo action) to the stack.
int addCoprocessor1Restore(int register,
int value)
Add a new “back step” (the undo action) to the stack.
int addDoNothing(int pc)
Add a new “back step” (the undo action) to the stack.
int addMemoryRestoreByte(int address,
int value)
Add a new “back step” (the undo action) to the stack.
int addMemoryRestoreHalf(int address,
int value)
Add a new “back step” (the undo action) to the stack.
int addMemoryRestoreRawWord(int address,
int value)
Add a new “back step” (the undo action) to the stack.
int addMemoryRestoreWord(int address,
int value)
Add a new “back step” (the undo action) to the stack.
int addPCRestore(int value)
Add a new “back step” (the undo action) to the stack.
int addRegisterFileRestore(int register,
int value)
Add a new “back step” (the undo action) to the stack.
void backStep()
Carry out a “back step”, which will undo the latest execution step.
boolean empty()
Test whether there are steps that can be undone.
boolean enabled()
Determine whether execution “undo” steps are currently being recorded.
boolean inDelaySlot()
Determine whether the next back-step action occurred as the result of
an instruction that executed in the “delay slot” of a delayed branch.
void setEnabled(boolean state)
Set enable status.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
BackStepper
public BackStepper()
Create a fresh BackStepper. It is enabled, which means all
subsequent instruction executions will have their “undo” action
recorded here.
Method Detail
enabled
public boolean enabled()
Determine whether execution “undo” steps are currently being recorded.
Returns:
true if undo steps being recorded, false if not.
setEnabled
public void setEnabled(boolean state)
Set enable status.
Parameters:
state – If true, will begin (or continue) recoding “undo” steps. If false, will stop.
empty
public boolean empty()
Test whether there are steps that can be undone.
Returns:
true if there are no steps to be undone, false otherwise.
inDelaySlot
public boolean inDelaySlot()
Determine whether the next back-step action occurred as the result of
an instruction that executed in the “delay slot” of a delayed branch.
Returns:
true if next backstep is instruction that executed in delay slot,
false otherwise.
backStep
public void backStep()
Carry out a “back step”, which will undo the latest execution step.
Does nothing if backstepping not enabled or if there are no steps to undo.
addMemoryRestoreRawWord
public int addMemoryRestoreRawWord(int address,
int value)
Add a new “back step” (the undo action) to the stack. The action here
is to restore a raw memory word value (setRawWord).
Parameters:
address – The affected memory address.
value – The “restore” value to be stored there.
Returns:
the argument value
addMemoryRestoreWord
public int addMemoryRestoreWord(int address,
int value)
Add a new “back step” (the undo action) to the stack. The action here
is to restore a memory word value.
Parameters:
address – The affected memory address.
value – The “restore” value to be stored there.
Returns:
the argument value
addMemoryRestoreHalf
public int addMemoryRestoreHalf(int address,
int value)
Add a new “back step” (the undo action) to the stack. The action here
is to restore a memory half-word value.
Parameters:
address – The affected memory address.
value – The “restore” value to be stored there, in low order half.
Returns:
the argument value
addMemoryRestoreByte
public int addMemoryRestoreByte(int address,
int value)
Add a new “back step” (the undo action) to the stack. The action here
is to restore a memory byte value.
Parameters:
address – The affected memory address.
value – The “restore” value to be stored there, in low order byte.
Returns:
the argument value
addRegisterFileRestore
public int addRegisterFileRestore(int register,
int value)
Add a new “back step” (the undo action) to the stack. The action here
is to restore a register file register value.
Parameters:
register – The affected register number.
value – The “restore” value to be stored there.
Returns:
the argument value
addPCRestore
public int addPCRestore(int value)
Add a new “back step” (the undo action) to the stack. The action here
is to restore the program counter.
Parameters:
value – The “restore” value to be stored there.
Returns:
the argument value
addCoprocessor0Restore
public int addCoprocessor0Restore(int register,
int value)
Add a new “back step” (the undo action) to the stack. The action here
is to restore a coprocessor 0 register value.
Parameters:
register – The affected register number.
value – The “restore” value to be stored there.
Returns:
the argument value
addCoprocessor1Restore
public int addCoprocessor1Restore(int register,
int value)
Add a new “back step” (the undo action) to the stack. The action here
is to restore a coprocessor 1 register value.
Parameters:
register – The affected register number.
value – The “restore” value to be stored there.
Returns:
the argument value
addConditionFlagSet
public int addConditionFlagSet(int flag)
Add a new “back step” (the undo action) to the stack. The action here
is to set the given coprocessor 1 condition flag (to 1).
Parameters:
flag – The condition flag number.
Returns:
the argument value
addConditionFlagClear
public int addConditionFlagClear(int flag)
Add a new “back step” (the undo action) to the stack. The action here
is to clear the given coprocessor 1 condition flag (to 0).
Parameters:
flag – The condition flag number.
Returns:
the argument value
addDoNothing
public int addDoNothing(int pc)
Add a new “back step” (the undo action) to the stack. The action here
is to do nothing! This is just a place holder so when user is backstepping
through the program no instructions will be skipped. Cosmetic. If the top of the
stack has the same PC counter, the do-nothing action will not be added.
Returns:
0
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
DelayedBranch
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.simulator
Class DelayedBranch
java.lang.Object
mars.simulator.DelayedBranch
public class DelayedBranch
extends Object
Represents a (potential) delayed branch. Note it is necessary only when
delayed branching is enabled. Here’s the protocol for using it:
(1) When a runtime decision to branch is made (by either a branch or jump
instruction’s simulate() method in InstructionSet), then if delayed branching
is enabled, the register() method is called with the branch target address but
the program counter is NOT set to the branch target address.
(2) At the end of that instruction cycle, the simulate() method in Simulator
will detect the registered branch, and set its trigger. Don’t do anything yet
because the next instruction cycle is the delay slot and needs to complete.
(3) At the end of the next (delay slot) instruction cycle, the simulate()
method in Simulator will detect the triggered branch, set the program
counter to its target value and clear the delayed branch.
The only interesting situation is when the delay slot itself contains a
successful branch! I tried this with SPIM (e.g. beq followed by b)
and it treats it as if nothing was there and continues the delay slot
into the next cycle. The eventual branch taken is the original one (as one
would hope) but in the meantime the first statement following the sequence
of successful branches will constitute the delay slot and will be executed!
Since only one pending delayed branch can be taken at a time, everything
here is done with statics. The class itself represents the potential branch.
Author:
Pete Sanderson
Constructor Summary
DelayedBranch()
Method Summary
static void register(int targetAddress)
Register the fact that a successful branch is to occur.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
DelayedBranch
public DelayedBranch()
Method Detail
register
public static void register(int targetAddress)
Register the fact that a successful branch is to occur. This is called in
the instruction’s simulated execution (its simulate() method in InstructionSet).
If a branch is registered but not triggered, this registration will be ignored
(cannot happen if class usage protocol is followed). If a branch is currently
registered and triggered, reset the state back to registered (but not triggered)
in order to carry over the delay slot for another execution cycle. This is the
only public member of the class.
Parameters:
targetAddress – The address to branch to after executing the next instruction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Exceptions
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.simulator
Class Exceptions
java.lang.Object
mars.simulator.Exceptions
public class Exceptions
extends Object
Represents an error/interrupt that occurs during execution (simulation).
Author:
Pete Sanderson
Field Summary
static int ADDRESS_EXCEPTION_LOAD
static int ADDRESS_EXCEPTION_STORE
static int ARITHMETIC_OVERFLOW_EXCEPTION
static int BREAKPOINT_EXCEPTION
static int DIVIDE_BY_ZERO_EXCEPTION
static int EXTERNAL_INTERRUPT_DISPLAY
static int EXTERNAL_INTERRUPT_KEYBOARD
The exception number is stored in coprocessor 0 cause register ($13)
Note: the codes for External Interrupts have been modified from MIPS
specs in order to encode two pieces of information.
static int FLOATING_POINT_OVERFLOW
static int FLOATING_POINT_UNDERFLOW
static int RESERVED_INSTRUCTION_EXCEPTION
static int SYSCALL_EXCEPTION
static int TRAP_EXCEPTION
Constructor Summary
Exceptions()
Method Summary
static void setRegisters(int cause)
Given MIPS exception cause code, will place that code into
coprocessor 0 CAUSE register ($13), set the EPC register to
“current” program counter, and set Exception Level bit in STATUS register.
static void setRegisters(int cause,
int addr)
Given MIPS exception cause code and bad address, place the bad address into VADDR
register ($8) then call overloaded setRegisters with the cause code to do the rest.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
EXTERNAL_INTERRUPT_KEYBOARD
public static final int EXTERNAL_INTERRUPT_KEYBOARD
The exception number is stored in coprocessor 0 cause register ($13)
Note: the codes for External Interrupts have been modified from MIPS
specs in order to encode two pieces of information. According
to spec, there is one External Interrupt code, 0. But then
how to distinguish keyboard interrupt from display interrupt?
The Cause register has Interupt Pending bits that can be set.
Bit 8 represents keyboard, bit 9 represents display. Those
bits are included into this code, but shifted right two positions
since the interrupt code will be shifted left two positions
for inserting cause code into bit positions 2-6 in Cause register.
DPS 23 July 2008.
See Also:
Constant Field Values
EXTERNAL_INTERRUPT_DISPLAY
public static final int EXTERNAL_INTERRUPT_DISPLAY
See Also:
Constant Field Values
ADDRESS_EXCEPTION_LOAD
public static final int ADDRESS_EXCEPTION_LOAD
See Also:
Constant Field Values
ADDRESS_EXCEPTION_STORE
public static final int ADDRESS_EXCEPTION_STORE
See Also:
Constant Field Values
SYSCALL_EXCEPTION
public static final int SYSCALL_EXCEPTION
See Also:
Constant Field Values
BREAKPOINT_EXCEPTION
public static final int BREAKPOINT_EXCEPTION
See Also:
Constant Field Values
RESERVED_INSTRUCTION_EXCEPTION
public static final int RESERVED_INSTRUCTION_EXCEPTION
See Also:
Constant Field Values
ARITHMETIC_OVERFLOW_EXCEPTION
public static final int ARITHMETIC_OVERFLOW_EXCEPTION
See Also:
Constant Field Values
TRAP_EXCEPTION
public static final int TRAP_EXCEPTION
See Also:
Constant Field Values
DIVIDE_BY_ZERO_EXCEPTION
public static final int DIVIDE_BY_ZERO_EXCEPTION
See Also:
Constant Field Values
FLOATING_POINT_OVERFLOW
public static final int FLOATING_POINT_OVERFLOW
See Also:
Constant Field Values
FLOATING_POINT_UNDERFLOW
public static final int FLOATING_POINT_UNDERFLOW
See Also:
Constant Field Values
Constructor Detail
Exceptions
public Exceptions()
Method Detail
setRegisters
public static void setRegisters(int cause)
Given MIPS exception cause code, will place that code into
coprocessor 0 CAUSE register ($13), set the EPC register to
“current” program counter, and set Exception Level bit in STATUS register.
Parameters:
cause – The cause code (see Exceptions for a list)
setRegisters
public static void setRegisters(int cause,
int addr)
Given MIPS exception cause code and bad address, place the bad address into VADDR
register ($8) then call overloaded setRegisters with the cause code to do the rest.
Parameters:
cause – The cause code (see Exceptions for a list). Should be address exception.
addr – The address that caused the exception.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.simulator
mars.simulator
Interfaces
Simulator.StopListener
Classes
BackStepper
DelayedBranch
Exceptions
ProgramArgumentList
Simulator
SimulatorNotice
SwingWorker
mars.simulator
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
Package mars.simulator
Interface Summary
Simulator.StopListener
Class Summary
BackStepper Used to “step backward” through execution, undoing each instruction.
DelayedBranch Represents a (potential) delayed branch.
Exceptions Represents an error/interrupt that occurs during execution (simulation).
ProgramArgumentList Models Program Arguments, one or more strings provided to the MIPS
program at runtime.
Simulator Used to simulate the execution of an assembled MIPS program.
SimulatorNotice Object provided to Observers of the Simulator.
SwingWorker This is the 3rd version of SwingWorker (also known as
SwingWorker 3), an abstract class that you subclass to
perform GUI-related work in a dedicated thread.
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
mars.simulator Class Hierarchy
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Hierarchy For Package mars.simulator
Package Hierarchies:
All Packages
Class Hierarchy
java.lang.Object mars.simulator.BackStepper
mars.simulator.DelayedBranch
mars.simulator.Exceptions
java.util.Observable mars.simulator.Simulator
mars.simulator.ProgramArgumentList
mars.simulator.SimulatorNotice
mars.simulator.SwingWorker
Interface Hierarchy
mars.simulator.Simulator.StopListener
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
ProgramArgumentList
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.simulator
Class ProgramArgumentList
java.lang.Object
mars.simulator.ProgramArgumentList
public class ProgramArgumentList
extends Object
Models Program Arguments, one or more strings provided to the MIPS
program at runtime. Equivalent to C’s main(int argc, char **argv) or
Java’s main(String[] args).
Author:
Pete Sanderson
Constructor Summary
ProgramArgumentList(ArrayList list)
Constructor that gets list from ArrayList of String, one argument per element.
ProgramArgumentList(ArrayList list,
int startPosition)
Constructor that gets list from section of String ArrayList, one
argument per element.
ProgramArgumentList(String args)
Constructor that parses string to produce list.
ProgramArgumentList(String[] list)
Constructor that gets list from String array, one argument per element.
ProgramArgumentList(String[] list,
int startPosition)
Constructor that gets list from section of String array, one
argument per element.
Method Summary
void storeProgramArguments()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
ProgramArgumentList
public ProgramArgumentList(String args)
Constructor that parses string to produce list. Delimiters
are the default Java StringTokenizer delimiters (space, tab,
newline, return, formfeed)
Parameters:
args – String containing delimiter-separated arguments
ProgramArgumentList
public ProgramArgumentList(String[] list)
Constructor that gets list from String array, one argument per element.
Parameters:
list – Array of String, each element containing one argument
ProgramArgumentList
public ProgramArgumentList(String[] list,
int startPosition)
Constructor that gets list from section of String array, one
argument per element.
Parameters:
args – Array of String, each element containing one argument
startPosition – Index of array element containing the first argument; all remaining
elements are assumed to contain an argument.
ProgramArgumentList
public ProgramArgumentList(ArrayList list)
Constructor that gets list from ArrayList of String, one argument per element.
Parameters:
list – ArrayList of String, each element containing one argument
ProgramArgumentList
public ProgramArgumentList(ArrayList list,
int startPosition)
Constructor that gets list from section of String ArrayList, one
argument per element.
Parameters:
args – ArrayList of String, each element containing one argument
startPosition – Index of array element containing the first argument; all remaining
elements are assumed to contain an argument.
Method Detail
storeProgramArguments
public void storeProgramArguments()
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Simulator
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.simulator
Class Simulator
java.lang.Object
java.util.Observable
mars.simulator.Simulator
public class Simulator
extends Observable
Used to simulate the execution of an assembled MIPS program.
Author:
Pete Sanderson
Nested Class Summary
static interface Simulator.StopListener
Field Summary
static int BREAKPOINT
various reasons for simulate to end…
static int CLIFF_TERMINATION
static int EXCEPTION
static int externalInterruptingDevice
static int MAX_STEPS
static int NO_DEVICE
static int NORMAL_TERMINATION
static int PAUSE_OR_STOP
Method Summary
void addStopListener(Simulator.StopListener l)
static Simulator getInstance()
Returns the Simulator object
static boolean inDelaySlot()
Determine whether or not the next instruction to be executed is in a
“delay slot”.
void removeStopListener(Simulator.StopListener l)
boolean simulate(MIPSprogram p,
int pc,
int maxSteps,
int[] breakPoints,
AbstractAction actor)
Simulate execution of given MIPS program.
void stopExecution(AbstractAction actor)
Set the volatile stop boolean variable checked by the execution
thread at the end of each MIPS instruction execution.
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
NO_DEVICE
public static final int NO_DEVICE
See Also:
Constant Field Values
externalInterruptingDevice
public static volatile int externalInterruptingDevice
BREAKPOINT
public static final int BREAKPOINT
various reasons for simulate to end…
See Also:
Constant Field Values
EXCEPTION
public static final int EXCEPTION
See Also:
Constant Field Values
MAX_STEPS
public static final int MAX_STEPS
See Also:
Constant Field Values
NORMAL_TERMINATION
public static final int NORMAL_TERMINATION
See Also:
Constant Field Values
CLIFF_TERMINATION
public static final int CLIFF_TERMINATION
See Also:
Constant Field Values
PAUSE_OR_STOP
public static final int PAUSE_OR_STOP
See Also:
Constant Field Values
Method Detail
getInstance
public static Simulator getInstance()
Returns the Simulator object
Returns:
the Simulator object in use
inDelaySlot
public static boolean inDelaySlot()
Determine whether or not the next instruction to be executed is in a
“delay slot”. This means delayed branching is enabled, the branch
condition has evaluated true, and the next instruction executed will
be the one following the branch. It is said to occupy the “delay slot.”
Normally programmers put a nop instruction here but it can be anything.
Returns:
true if next instruction is in delay slot, false otherwise.
simulate
public boolean simulate(MIPSprogram p,
int pc,
int maxSteps,
int[] breakPoints,
AbstractAction actor)
throws ProcessingException
Simulate execution of given MIPS program. It must have already been assembled.
Parameters:
p – The MIPSprogram to be simulated.
pc – address of first instruction to simulate; this goes into program counter
maxSteps – maximum number of steps to perform before returning false (0 or less means no max)
breakPoints – array of breakpoint program counter values, use null if none
actor – the GUI component responsible for this call, usually GO or STEP. null if none.
Returns:
true if execution completed, false otherwise
Throws:
ProcessingException – Throws exception if run-time exception occurs.
stopExecution
public void stopExecution(AbstractAction actor)
Set the volatile stop boolean variable checked by the execution
thread at the end of each MIPS instruction execution. If variable
is found to be true, the execution thread will depart
gracefully so the main thread handling the GUI can take over.
This is used by both STOP and PAUSE features.
addStopListener
public void addStopListener(Simulator.StopListener l)
removeStopListener
public void removeStopListener(Simulator.StopListener l)
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Simulator.StopListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.simulator
Interface Simulator.StopListener
Enclosing class:
Simulator
public static interface Simulator.StopListener
Method Summary
void stopped(Simulator s)
Method Detail
stopped
void stopped(Simulator s)
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SimulatorNotice
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.simulator
Class SimulatorNotice
java.lang.Object
mars.simulator.SimulatorNotice
public class SimulatorNotice
extends Object
Object provided to Observers of the Simulator.
They are notified at important phases of the runtime simulator,
such as start and stop of simulation.
Author:
Pete Sanderson
Field Summary
static int SIMULATOR_START
static int SIMULATOR_STOP
Constructor Summary
SimulatorNotice(int action,
int maxSteps,
double runSpeed,
int programCounter)
Constructor will be called only within this package, so assume
address and length are in valid ranges.
Method Summary
int getAction()
Fetch the memory address that was accessed.
int getMaxSteps()
Fetch the length in bytes of the access operation (4,2,1).
int getProgramCounter()
Fetch the value of the access operation (the value read or written).
double getRunSpeed()
Fetch the value of the access operation (the value read or written).
String toString()
String representation indicates access type, address and length in bytes
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
SIMULATOR_START
public static final int SIMULATOR_START
See Also:
Constant Field Values
SIMULATOR_STOP
public static final int SIMULATOR_STOP
See Also:
Constant Field Values
Constructor Detail
SimulatorNotice
public SimulatorNotice(int action,
int maxSteps,
double runSpeed,
int programCounter)
Constructor will be called only within this package, so assume
address and length are in valid ranges.
Method Detail
getAction
public int getAction()
Fetch the memory address that was accessed.
getMaxSteps
public int getMaxSteps()
Fetch the length in bytes of the access operation (4,2,1).
getRunSpeed
public double getRunSpeed()
Fetch the value of the access operation (the value read or written).
getProgramCounter
public int getProgramCounter()
Fetch the value of the access operation (the value read or written).
toString
public String toString()
String representation indicates access type, address and length in bytes
Overrides:
toString in class Object
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SwingWorker
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.simulator
Class SwingWorker
java.lang.Object
mars.simulator.SwingWorker
public abstract class SwingWorker
extends Object
This is the 3rd version of SwingWorker (also known as
SwingWorker 3), an abstract class that you subclass to
perform GUI-related work in a dedicated thread. For
instructions on and examples of using this class, see:
http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
Note that the API changed slightly in the 3rd version:
You must now invoke start() on the SwingWorker after
creating it.
Constructor Summary
SwingWorker(boolean useSwing)
Start a thread that will call the construct method
and then exit.
Method Summary
abstract Object construct()
Compute the value to be returned by the get method.
void finished()
Called on the event dispatching thread (not on the worker thread)
after the construct method has returned.
Object get()
Return the value created by the construct method.
protected Object getValue()
Get the value produced by the worker thread, or null if it
hasn’t been constructed yet.
void interrupt()
A new method that interrupts the worker thread.
void start()
Start the worker thread.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SwingWorker
public SwingWorker(boolean useSwing)
Start a thread that will call the construct method
and then exit.
Parameters:
useSwing – Set true if MARS is running from GUI, false otherwise.
Method Detail
getValue
protected Object getValue()
Get the value produced by the worker thread, or null if it
hasn’t been constructed yet.
construct
public abstract Object construct()
Compute the value to be returned by the get method.
finished
public void finished()
Called on the event dispatching thread (not on the worker thread)
after the construct method has returned.
interrupt
public void interrupt()
A new method that interrupts the worker thread. Call this method
to force the worker to stop what it’s doing.
get
public Object get()
Return the value created by the construct method.
Returns null if either the constructing thread or the current
thread was interrupted before a value was produced.
Returns:
the value created by the construct method
start
public void start()
Start the worker thread.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
AbstractMarsToolAndApplication.ConnectButton
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class AbstractMarsToolAndApplication.ConnectButton
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.AbstractButton
javax.swing.JButton
mars.tools.AbstractMarsToolAndApplication.ConnectButton
All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, SwingConstants
Enclosing class:
AbstractMarsToolAndApplication
protected class AbstractMarsToolAndApplication.ConnectButton
extends JButton
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JButton
JButton.AccessibleJButton
Nested classes/interfaces inherited from class javax.swing.AbstractButton
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class javax.swing.AbstractButton
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
AbstractMarsToolAndApplication.ConnectButton()
Method Summary
void connect()
void disconnect()
boolean isConnected()
Methods inherited from class javax.swing.JButton
getAccessibleContext, getUIClassID, isDefaultButton, isDefaultCapable, paramString, removeNotify, setDefaultCapable, updateUI
Methods inherited from class javax.swing.AbstractButton
actionPropertyChanged, addActionListener, addChangeListener, addImpl, addItemListener, checkHorizontalKey, checkVerticalKey, configurePropertiesFromAction, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHideActionText, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, init, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, isSelected, paintBorder, removeActionListener, removeChangeListener, removeItemListener, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setEnabled, setFocusPainted, setHideActionText, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
AbstractMarsToolAndApplication.ConnectButton
public AbstractMarsToolAndApplication.ConnectButton()
Method Detail
connect
public void connect()
disconnect
public void disconnect()
isConnected
public boolean isConnected()
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
AbstractMarsToolAndApplication.EnterKeyListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class AbstractMarsToolAndApplication.EnterKeyListener
java.lang.Object
java.awt.event.KeyAdapter
mars.tools.AbstractMarsToolAndApplication.EnterKeyListener
All Implemented Interfaces:
KeyListener, EventListener
Enclosing class:
AbstractMarsToolAndApplication
protected class AbstractMarsToolAndApplication.EnterKeyListener
extends KeyAdapter
Constructor Summary
AbstractMarsToolAndApplication.EnterKeyListener(AbstractButton who)
Method Summary
void keyPressed(KeyEvent e)
Methods inherited from class java.awt.event.KeyAdapter
keyReleased, keyTyped
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
AbstractMarsToolAndApplication.EnterKeyListener
public AbstractMarsToolAndApplication.EnterKeyListener(AbstractButton who)
Method Detail
keyPressed
public void keyPressed(KeyEvent e)
Specified by:
keyPressed in interface KeyListener
Overrides:
keyPressed in class KeyAdapter
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
AbstractMarsToolAndApplication
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class AbstractMarsToolAndApplication
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
mars.tools.AbstractMarsToolAndApplication
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Observer, Accessible, RootPaneContainer, WindowConstants, MarsTool
Direct Known Subclasses:
BHTSimulator, BitmapDisplay, CacheSimulator, DigitalLabSim, FloatRepresentation, InstructionCounter, InstructionStatistics, IntroToTools, KeyboardAndDisplaySimulator, MemoryReferenceVisualization
public abstract class AbstractMarsToolAndApplication
extends JFrame
implements MarsTool, Observer
An abstract class that provides generic components to facilitate implementation of
a MarsTool and/or stand-alone Mars-based application. Provides default definitions
of both the action() method required to implement MarsTool and the go() method
conventionally used to launch a Mars-based stand-alone application. It also provides
generic definitions for interactively controlling the application. The generic controls
for MarsTools are 3 buttons: connect/disconnect to MIPS resource (memory and/or
registers), reset, and close (exit). The generic controls for stand-alone Mars apps
include: button that triggers a file open dialog, a text field to display status
messages, the run-speed slider to control execution rate when running a MIPS program,
a button that assembles and runs the current MIPS program, a button to interrupt
the running MIPS program, a reset button, and an exit button.
Pete Sanderson, 14 November 2006.
See Also:
Serialized Form
Nested Class Summary
protected class AbstractMarsToolAndApplication.ConnectButton
protected class AbstractMarsToolAndApplication.EnterKeyListener
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
protected AbstractMarsToolAndApplication.ConnectButton connectButton
protected boolean isBeingUsedAsAMarsTool
protected Window theWindow
protected AbstractMarsToolAndApplication thisMarsApp
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
protected AbstractMarsToolAndApplication(String title,
String heading)
Simple constructor
Method Summary
void action()
Required MarsTool method to carry out Tool functions.
protected void addAsObserver()
Add this app/tool as an Observer of desired MIPS Observables (memory and registers).
protected void addAsObserver(int lowEnd,
int highEnd)
Add this app/tool as an Observer of the specified subrange of MIPS memory.
protected void addAsObserver(Register reg)
Add this app/tool as an Observer of the specified MIPS register.
protected JComponent buildButtonAreaMarsTool()
The MarsTool default set of controls has one row of 3 buttons.
protected JComponent buildButtonAreaStandAlone()
The Mars stand-alone app default set of controls has two rows of controls.
protected JComponent buildHeadingArea()
Constructs GUI header as label with default positioning and font.
protected abstract JComponent buildMainDisplayArea()
Abstract method that must be instantiated by subclass to build the main display area
of the GUI.
protected void deleteAsObserver()
Delete this app/tool as an Observer of MIPS Observables (memory and registers).
protected void deleteAsObserver(Register reg)
Delete this app/tool as an Observer of the specified MIPS register
protected JComponent getHelpComponent()
Override this method to provide a JComponent (probably a JButton) of your choice
to be placed just left of the Close/Exit button.
abstract String getName()
Required MarsTool method to return Tool name.
void go()
Run the simulator as stand-alone application.
protected void initializePostGUI()
Method that will be called once just after the GUI is constructed in the go() and action()
methods.
protected void initializePreGUI()
Method that will be called once just before the GUI is constructed in the go() and action()
methods.
protected boolean isObserving()
Query method to let you know if the tool/app is (or could be) currently
“observing” any MIPS resources.
protected void performSpecialClosingDuties()
This method is called when tool/app is exited either through the close/exit button or the window’s X box.
protected void processMIPSUpdate(Observable resource,
AccessNotice notice)
Override this method to process a received notice from MIPS Observable (memory or register)
It will only be called if the notice was generated as the result of MIPS instruction execution.
protected void reset()
Method that will be called each time the default Reset button is clicked.
void update(Observable resource,
Object accessNotice)
Called when receiving notice of access to MIPS memory or registers.
protected void updateDisplay()
Override this method to implement updating of GUI after each MIPS instruction is executed,
while running in “timed” mode (user specifies execution speed on the slider control).
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
Field Detail
isBeingUsedAsAMarsTool
protected boolean isBeingUsedAsAMarsTool
thisMarsApp
protected AbstractMarsToolAndApplication thisMarsApp
theWindow
protected Window theWindow
connectButton
protected AbstractMarsToolAndApplication.ConnectButton connectButton
Constructor Detail
AbstractMarsToolAndApplication
protected AbstractMarsToolAndApplication(String title,
String heading)
Simple constructor
Parameters:
title – String containing title bar text
Method Detail
getName
public abstract String getName()
Required MarsTool method to return Tool name. Must be defined by subclass.
Specified by:
getName in interface MarsTool
Overrides:
getName in class Component
Returns:
Tool name. MARS will display this in menu item.
buildMainDisplayArea
protected abstract JComponent buildMainDisplayArea()
Abstract method that must be instantiated by subclass to build the main display area
of the GUI. It will be placed in the CENTER area of a BorderLayout. The title
is in the NORTH area, and the controls are in the SOUTH area.
go
public void go()
Run the simulator as stand-alone application. For this default implementation,
the user-defined main display of the user interface is identical for both stand-alone
and MARS Tools menu use, but the control buttons are different because the stand-alone
must include a mechansim for controlling the opening, assembling, and executing of
an underlying MIPS program. The generic controls include: a button that triggers a
file open dialog, a text field to display status messages, the run-speed slider
to control execution rate when running a MIPS program, a button that assembles and
runs the current MIPS program, a reset button, and an exit button.
This method calls 3 methods that can be defined/overriden in the subclass: initializePreGUI()
for any special initialization that must be completed before building the user
interface (e.g. data structures whose properties determine default GUI settings),
initializePostGUI() for any special initialization that cannot be
completed until after the building the user interface (e.g. data structure whose
properties are determined by default GUI settings), and buildMainDisplayArea()
to contain application-specific displays of parameters and results.
action
public void action()
Required MarsTool method to carry out Tool functions. It is invoked when MARS
user selects this tool from the Tools menu. This default implementation provides
generic definitions for interactively controlling the tool. The generic controls
for MarsTools are 3 buttons: connect/disconnect to MIPS resource (memory and/or
registers), reset, and close (exit). Like “go()” above, this default version
calls 3 methods that can be defined/overriden in the subclass: initializePreGUI()
for any special initialization that must be completed before building the user
interface (e.g. data structures whose properties determine default GUI settings),
initializePostGUI() for any special initialization that cannot be
completed until after the building the user interface (e.g. data structure whose
properties are determined by default GUI settings), and buildMainDisplayArea()
to contain application-specific displays of parameters and results.
Specified by:
action in interface MarsTool
initializePreGUI
protected void initializePreGUI()
Method that will be called once just before the GUI is constructed in the go() and action()
methods. Use it to initialize any data structures needed for the application whose values
will be needed to determine the initial state of GUI components. By default it does nothing.
initializePostGUI
protected void initializePostGUI()
Method that will be called once just after the GUI is constructed in the go() and action()
methods. Use it to initialize data structures needed for the application whose values
may depend on the initial state of GUI components. By default it does nothing.
reset
protected void reset()
Method that will be called each time the default Reset button is clicked.
Use it to reset any data structures and/or GUI components. By default it does nothing.
buildHeadingArea
protected JComponent buildHeadingArea()
Constructs GUI header as label with default positioning and font. May be overridden.
buildButtonAreaMarsTool
protected JComponent buildButtonAreaMarsTool()
The MarsTool default set of controls has one row of 3 buttons. It includes a dual-purpose button to
attach or detach simulator to MIPS memory, a button to reset the cache, and one to close the tool.
buildButtonAreaStandAlone
protected JComponent buildButtonAreaStandAlone()
The Mars stand-alone app default set of controls has two rows of controls. It includes a text field for
displaying status messages, a button to trigger an open file dialog, the MARS run speed slider
to control timed execution, a button to assemble and run the program, a reset button
whose action is determined by the subclass reset() method, and an exit button.
update
public void update(Observable resource,
Object accessNotice)
Called when receiving notice of access to MIPS memory or registers. Default
implementation of method required by Observer interface. This method will filter out
notices originating from the MARS GUI or from direct user editing of memory or register
displays. Only notices arising from MIPS program access are allowed in.
It then calls two methods to be overridden by the subclass (since they do
nothing by default): processMIPSUpdate() then updateDisplay().
Specified by:
update in interface Observer
Parameters:
resource – the attached MIPS resource
accessNotice – AccessNotice information provided by the resource
processMIPSUpdate
protected void processMIPSUpdate(Observable resource,
AccessNotice notice)
Override this method to process a received notice from MIPS Observable (memory or register)
It will only be called if the notice was generated as the result of MIPS instruction execution.
By default it does nothing. After this method is complete, the updateDisplay() method will be
invoked automatically.
performSpecialClosingDuties
protected void performSpecialClosingDuties()
This method is called when tool/app is exited either through the close/exit button or the window’s X box.
Override it to perform any special housecleaning needed. By default it does nothing.
addAsObserver
protected void addAsObserver()
Add this app/tool as an Observer of desired MIPS Observables (memory and registers).
By default, will add as an Observer of the entire Data Segment in memory.
Override if you want something different. Note that the Memory methods to add an
Observer to memory are flexible (you can register for a range of addresses) but
may throw an AddressErrorException that you need to catch.
This method is called whenever the default “Connect” button on a MarsTool or the
default “Assemble and run” on a stand-alone Mars app is selected. The corresponding
NOTE: if you do not want to register as an Observer of the entire data segment
(starts at address 0x10000000) then override this to either do some alternative
or nothing at all. This method is also overloaded to allow arbitrary memory
subrange.
addAsObserver
protected void addAsObserver(int lowEnd,
int highEnd)
Add this app/tool as an Observer of the specified subrange of MIPS memory. Note
that this method is not invoked automatically like the no-argument version, but
if you use this method, you can still take advantage of provided default deleteAsObserver()
since it will remove the app as a memory observer regardless of the subrange
or number of subranges it is registered for.
Parameters:
lowEnd – low end of memory address range.
highEnd – high end of memory address range; must be >= lowEnd
addAsObserver
protected void addAsObserver(Register reg)
Add this app/tool as an Observer of the specified MIPS register.
deleteAsObserver
protected void deleteAsObserver()
Delete this app/tool as an Observer of MIPS Observables (memory and registers).
By default, will delete as an Observer of memory.
Override if you want something different.
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).
deleteAsObserver
protected void deleteAsObserver(Register reg)
Delete this app/tool as an Observer of the specified MIPS register
isObserving
protected boolean isObserving()
Query method to let you know if the tool/app is (or could be) currently
“observing” any MIPS resources. When running as a MarsTool, this
will be true by default after clicking the “Connect to MIPS” button until “Disconnect
from MIPS” is clicked. When running as a stand-alone app, this will be
true by default after clicking the “Assemble and Run” button until until
program execution has terminated either normally or by clicking the “Stop”
button. The phrase “or could be” was added above because depending on how
the tool/app operates, it may be possible to run the MIPS program without
first registering as an Observer — i.e. addAsObserver() is overridden and
takes no action.
Returns:
true if tool/app is (or could be) currently active as an Observer.
updateDisplay
protected void updateDisplay()
Override this method to implement updating of GUI after each MIPS instruction is executed,
while running in “timed” mode (user specifies execution speed on the slider control).
Does nothing by default.
getHelpComponent
protected JComponent getHelpComponent()
Override this method to provide a JComponent (probably a JButton) of your choice
to be placed just left of the Close/Exit button. Its anticipated use is for a
“help” button that launches a help message or dialog. But it can be any valid
JComponent that doesn’t mind co-existing among a bunch of JButtons.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
BHTableModel
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class BHTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
mars.tools.BHTableModel
All Implemented Interfaces:
Serializable, TableModel
public class BHTableModel
extends AbstractTableModel
Simulates the actual functionality of a Branch History Table (BHT).
The BHT consists of a number of BHT entries which are used to perform branch prediction.
The entries of the BHT are stored as a Vector of BHTEntry objects.
The number of entries is configurable but has to be a power of 2.
The history kept by each BHT entry is also configurable during run-time.
A change of the configuration however causes a complete reset of the BHT.
The typical interaction is as follows:
Construction of a BHT with a certain number of entries with a given history size.
When encountering a branch instruction the index of the relevant BHT entry is calculated via the getIdxForAddress(int) method.
The current prediction of the BHT entry at the calculated index is obtained via the getPredictionAtIdx(int) method.
After detecting if the branch was really taken or not, this feedback is provided to the BHT by the updatePredictionAtIdx(int, boolean) method.
Additionally it serves as TableModel that can be directly used to render the state of the BHT in a JTable.
Feedback provided to the BHT causes a change of the internal state and a repaint of the table(s) associated to this model.
Author:
ingo.kofler@itec.uni-klu.ac.at
See Also:
Serialized Form
Field Summary
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
Constructor Summary
BHTableModel(int numEntries,
int historySize,
boolean initVal)
Constructs a new BHT with given number of entries and history size.
Method Summary
Class getColumnClass(int i)
Returns the class/type of the i-th column of the table.
int getColumnCount()
Returns the number of columns.
String getColumnName(int i)
Returns the name of the i-th column of the table.
int getIdxForAddress(int address)
Returns the index into the BHT for a given branch instruction address.
boolean getPredictionAtIdx(int index)
Retrieve the prediction for the i-th BHT entry.
int getRowCount()
Returns the number of entries of the BHT.
Object getValueAt(int row,
int col)
Returns the value of the cell at the given row and column
Required by the TableModel interface.
void initBHT(int numEntries,
int historySize,
boolean initVal)
Initializes the BHT with the given size and history.
void updatePredictionAtIdx(int index,
boolean branchTaken)
Updates the BHT entry with the outcome of the branch instruction.
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
BHTableModel
public BHTableModel(int numEntries,
int historySize,
boolean initVal)
Constructs a new BHT with given number of entries and history size.
Parameters:
numEntries – number of entries in the BHT
historySize – size of the history (in bits/number of past branches)
Method Detail
getColumnName
public String getColumnName(int i)
Returns the name of the i-th column of the table.
Required by the TableModel interface.
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel
Parameters:
i – the index of the column
Returns:
name of the i-th column
getColumnClass
public Class getColumnClass(int i)
Returns the class/type of the i-th column of the table.
Required by the TableModel interface.
Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel
Parameters:
i – the index of the column
Returns:
class representing the type of the i-th column
getColumnCount
public int getColumnCount()
Returns the number of columns.
Required by the TableModel interface.
Returns:
currently the constant 6
getRowCount
public int getRowCount()
Returns the number of entries of the BHT.
Required by the TableModel interface.
Returns:
number of rows / entries of the BHT
getValueAt
public Object getValueAt(int row,
int col)
Returns the value of the cell at the given row and column
Required by the TableModel interface.
Parameters:
row – the row index
col – the column index
Returns:
the value of the cell
initBHT
public void initBHT(int numEntries,
int historySize,
boolean initVal)
Initializes the BHT with the given size and history.
All previous data like the BHT entries’ history and statistics will get lost.
A refresh of the table that use this BHT as model will be triggered.
Parameters:
numEntries – number of entries in the BHT (has to be a power of 2)
historySize – size of the history to consider
initVal – initial value for each entry (true means take branch, false do not take branch)
getIdxForAddress
public int getIdxForAddress(int address)
Returns the index into the BHT for a given branch instruction address.
A simple direct mapping is used.
Parameters:
address – the address of the branch instruction
Returns:
the index into the BHT
getPredictionAtIdx
public boolean getPredictionAtIdx(int index)
Retrieve the prediction for the i-th BHT entry.
Parameters:
index – the index of the entry in the BHT
Returns:
the prediction to take (true) or do not take (false) the branch
updatePredictionAtIdx
public void updatePredictionAtIdx(int index,
boolean branchTaken)
Updates the BHT entry with the outcome of the branch instruction.
This causes a change in the model and signals to update the connected table(s).
Parameters:
index – the index of the entry in the BHT
branchTaken –
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
BHTEntry
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class BHTEntry
java.lang.Object
mars.tools.BHTEntry
public class BHTEntry
extends Object
Represents a single entry of the Branch History Table.
The entry holds the information about former branch predictions and outcomes.
The number of past branch outcomes can be configured and is called the history.
The semantics of the history of size n is as follows.
The entry will change its prediction, if it mispredicts the branch n times in series.
The prediction of the entry can be obtained by the getPrediction() method.
Feedback of taken or not taken branches is provided to the entry via the updatePrediction(boolean) method.
This causes the history and the prediction to be updated.
Additionally the entry keeps track about how many times the prediction was correct or incorrect.
The statistics can be obtained by the methods getStatsPredCorrect(), getStatsPredIncorrect() and getStatsPredPrecision().
Author:
ingo.kofler@itec.uni-klu.ac.at
Constructor Summary
BHTEntry(int historySize,
boolean initVal)
Constructs a BHT entry with a given history size.
Method Summary
String getHistoryAsStr()
Builds a string representation of the BHT entry’s history.
boolean getPrediction()
Returns the branch prediction based on the history.
String getPredictionAsStr()
Returns a string representation of the BHT entry’s current prediction.
int getStatsPredCorrect()
Get the absolute number of correct predictions.
int getStatsPredIncorrect()
Get the absolute number of mispredictions.
double getStatsPredPrecision()
Get the percentage of correct predictions.
void updatePrediction(boolean branchTaken)
Updates the entry’s history and prediction.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
BHTEntry
public BHTEntry(int historySize,
boolean initVal)
Constructs a BHT entry with a given history size.
The size of the history can only be set via the constructor and cannot be changed afterwards.
Parameters:
historySize – number of past branch outcomes to remember
initVal – the initial value of the entry (take or do not take)
Method Detail
getPrediction
public boolean getPrediction()
Returns the branch prediction based on the history.
Returns:
true if prediction is to take the branch, false otherwise
updatePrediction
public void updatePrediction(boolean branchTaken)
Updates the entry’s history and prediction.
This method provides feedback for a prediction.
The history and the statistics are updated accordingly.
Based on the updated history a new prediction is calculated
Parameters:
branchTaken – signals if the branch was taken (true) or not (false)
getStatsPredIncorrect
public int getStatsPredIncorrect()
Get the absolute number of mispredictions.
Returns:
number of incorrect predictions (mispredictions)
getStatsPredCorrect
public int getStatsPredCorrect()
Get the absolute number of correct predictions.
Returns:
number of correct predictions
getStatsPredPrecision
public double getStatsPredPrecision()
Get the percentage of correct predictions.
Returns:
the percentage of correct predictions
getHistoryAsStr
public String getHistoryAsStr()
Builds a string representation of the BHT entry’s history.
The history is a sequence of flags that signal if the branch was taken (T) or not taken (NT).
Returns:
a string representation of the BHT entry’s history
getPredictionAsStr
public String getPredictionAsStr()
Returns a string representation of the BHT entry’s current prediction.
The prediction can be either to TAKE or do NOT TAKE the branch.
Returns:
a string representation of the BHT entry’s current prediction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
BHTSimGUI
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class BHTSimGUI
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
mars.tools.BHTSimGUI
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
public class BHTSimGUI
extends JPanel
Represents the GUI of the BHT Simulator Tool.
The GUI consists of mainly four parts:
A configuration panel to select the number of entries and the history size
A information panel that displays the most recent branch instruction including its address and BHT index
A table representing the BHT with all entries and their internal state and statistics
A log panel that summarizes the predictions in a textual form
Author:
ingo.kofler@itec.uni-klu.ac.at
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
static String BHT_DO_NOT_TAKE_BRANCH
constant for the String representing “do not take the branch”
static String BHT_TAKE_BRANCH
constant for the String representing “take the branch”
static Color COLOR_PREDICTION_CORRECT
constant for the color to signal a correct prediction
static Color COLOR_PREDICTION_INCORRECT
constant for the color to signal a misprediction
static Color COLOR_PREPREDICTION
constant for the color that highlights the current BHT entry
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
BHTSimGUI()
Creates the GUI components of the BHT Simulator
The GUI is a subclass of JPanel which is integrated in the GUI of the MARS tool
Method Summary
JComboBox getCbBHTentries()
Returns the combo box for selecting the number of BHT entries.
JComboBox getCbBHThistory()
Returns the combo box for selecting the size of the BHT history.
JComboBox getCbBHTinitVal()
Returns the combo box for selecting the initial value of the BHT
JTable getTabBHT()
Returns the table representing the BHT.
JTextArea getTaLog()
Returns the text area for log purposes.
JTextField getTfAddress()
Returns the text field for displaying the address of the most recent branch instruction
JTextField getTfIndex()
Returns the text field for displaying the corresponding index into the BHT
JTextField getTfInstruction()
Returns the text field for displaying the most recent branch instruction
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
COLOR_PREPREDICTION
public static final Color COLOR_PREPREDICTION
constant for the color that highlights the current BHT entry
COLOR_PREDICTION_CORRECT
public static final Color COLOR_PREDICTION_CORRECT
constant for the color to signal a correct prediction
COLOR_PREDICTION_INCORRECT
public static final Color COLOR_PREDICTION_INCORRECT
constant for the color to signal a misprediction
BHT_TAKE_BRANCH
public static final String BHT_TAKE_BRANCH
constant for the String representing “take the branch”
See Also:
Constant Field Values
BHT_DO_NOT_TAKE_BRANCH
public static final String BHT_DO_NOT_TAKE_BRANCH
constant for the String representing “do not take the branch”
See Also:
Constant Field Values
Constructor Detail
BHTSimGUI
public BHTSimGUI()
Creates the GUI components of the BHT Simulator
The GUI is a subclass of JPanel which is integrated in the GUI of the MARS tool
Method Detail
getCbBHTentries
public JComboBox getCbBHTentries()
Returns the combo box for selecting the number of BHT entries.
Returns:
the reference to the combo box
getCbBHThistory
public JComboBox getCbBHThistory()
Returns the combo box for selecting the size of the BHT history.
Returns:
the reference to the combo box
getCbBHTinitVal
public JComboBox getCbBHTinitVal()
Returns the combo box for selecting the initial value of the BHT
Returns:
the reference to the combo box
getTabBHT
public JTable getTabBHT()
Returns the table representing the BHT.
Returns:
the reference to the table
getTaLog
public JTextArea getTaLog()
Returns the text area for log purposes.
Returns:
the reference to the text area
getTfInstruction
public JTextField getTfInstruction()
Returns the text field for displaying the most recent branch instruction
Returns:
the reference to the text field
getTfAddress
public JTextField getTfAddress()
Returns the text field for displaying the address of the most recent branch instruction
Returns:
the reference to the text field
getTfIndex
public JTextField getTfIndex()
Returns the text field for displaying the corresponding index into the BHT
Returns:
the reference to the text field
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
BHTSimulator
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class BHTSimulator
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
mars.tools.AbstractMarsToolAndApplication
mars.tools.BHTSimulator
All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Observer, Accessible, RootPaneContainer, WindowConstants, MarsTool
public class BHTSimulator
extends AbstractMarsToolAndApplication
implements ActionListener
A MARS tool for simulating branch prediction with a Branch History Table (BHT)
The simulation is based on observing the access to the instruction memory area (text segment).
If a branch instruction is encountered, a prediction based on a BHT is performed.
The outcome of the branch is compared with the prediction and the prediction is updated accordingly.
Statistics about the correct and incorrect number of predictions can be obtained for each BHT entry.
The number of entries in the BHT and the history that is considered for each prediction can be configured interactively.
A change of the configuration however causes a re-initialization of the BHT.
The tool can be used to show how branch prediction works in case of loops and how effective such simple methods are.
In case of nested loops the difference of BHT with 1 or 2 Bit history can be explored and visualized.
Author:
ingo.kofler@itec.uni-klu.ac.at
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class mars.tools.AbstractMarsToolAndApplication
AbstractMarsToolAndApplication.ConnectButton, AbstractMarsToolAndApplication.EnterKeyListener
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
static int BHT_DEFAULT_HISTORY
constant for the default history size
static boolean BHT_DEFAULT_INITVAL
constant for the default inital value
static int BHT_DEFAULT_SIZE
constant for the default size of the BHT
static String BHT_HEADING
the heading of the tool
static String BHT_NAME
the name of the tool
static String BHT_VERSION
the version of the tool
Fields inherited from class mars.tools.AbstractMarsToolAndApplication
connectButton, isBeingUsedAsAMarsTool, theWindow, thisMarsApp
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
BHTSimulator()
Creates a BHT Simulator with given name and heading.
Method Summary
void actionPerformed(ActionEvent event)
Handles the actions when selecting another value in one of the two combo boxes.
protected void addAsObserver()
Adds BHTSimulator as observer of the text segment.
protected JComponent buildMainDisplayArea()
Creates a GUI and initialize the GUI with the default values.
protected static int extractBranchAddress(ProgramStatement stmt)
Extracts the target address of the branch.
String getName()
Returns the name of the tool.
protected void handleExecBranchInst(int branchInstAddr,
boolean branchTaken)
Handles the execution of the branch instruction.
protected void handlePreBranchInst(ProgramStatement stmt)
Handles the execution branch instruction.
protected static boolean isBranchInstruction(ProgramStatement stmt)
Determines if the instruction is a branch instruction or not.
protected void processMIPSUpdate(Observable resource,
AccessNotice notice)
Callback for text segment access by the MIPS simulator.
protected void reset()
Performs a reset of the simulator.
protected void resetSimulator()
Resets the simulator by clearing the GUI elements and resetting the BHT.
protected static boolean willBranch(ProgramStatement stmt)
Checks if the branch instruction delivered as parameter will branch or not.
Methods inherited from class mars.tools.AbstractMarsToolAndApplication
action, addAsObserver, addAsObserver, buildButtonAreaMarsTool, buildButtonAreaStandAlone, buildHeadingArea, deleteAsObserver, deleteAsObserver, getHelpComponent, go, initializePostGUI, initializePreGUI, isObserving, performSpecialClosingDuties, update, updateDisplay
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
Field Detail
BHT_DEFAULT_SIZE
public static final int BHT_DEFAULT_SIZE
constant for the default size of the BHT
See Also:
Constant Field Values
BHT_DEFAULT_HISTORY
public static final int BHT_DEFAULT_HISTORY
constant for the default history size
See Also:
Constant Field Values
BHT_DEFAULT_INITVAL
public static final boolean BHT_DEFAULT_INITVAL
constant for the default inital value
See Also:
Constant Field Values
BHT_NAME
public static final String BHT_NAME
the name of the tool
See Also:
Constant Field Values
BHT_VERSION
public static final String BHT_VERSION
the version of the tool
See Also:
Constant Field Values
BHT_HEADING
public static final String BHT_HEADING
the heading of the tool
See Also:
Constant Field Values
Constructor Detail
BHTSimulator
public BHTSimulator()
Creates a BHT Simulator with given name and heading.
Method Detail
addAsObserver
protected void addAsObserver()
Adds BHTSimulator as observer of the text segment.
Overrides:
addAsObserver in class AbstractMarsToolAndApplication
buildMainDisplayArea
protected JComponent buildMainDisplayArea()
Creates a GUI and initialize the GUI with the default values.
Specified by:
buildMainDisplayArea in class AbstractMarsToolAndApplication
getName
public String getName()
Returns the name of the tool.
Specified by:
getName in interface MarsTool
Specified by:
getName in class AbstractMarsToolAndApplication
Returns:
the tool’s name as String
reset
protected void reset()
Performs a reset of the simulator.
This causes the BHT to be reseted and the log messages to be cleared.
Overrides:
reset in class AbstractMarsToolAndApplication
actionPerformed
public void actionPerformed(ActionEvent event)
Handles the actions when selecting another value in one of the two combo boxes.
Selecting a different BHT size or history causes a reset of the simulator.
Specified by:
actionPerformed in interface ActionListener
resetSimulator
protected void resetSimulator()
Resets the simulator by clearing the GUI elements and resetting the BHT.
handlePreBranchInst
protected void handlePreBranchInst(ProgramStatement stmt)
Handles the execution branch instruction.
This method is called each time a branch instruction is executed.
Based on the address of the instruction the corresponding index into the BHT is calculated.
The prediction is obtained from the BHT at the calculated index and is visualized appropriately.
Parameters:
stmt – the branch statement that is executed
handleExecBranchInst
protected void handleExecBranchInst(int branchInstAddr,
boolean branchTaken)
Handles the execution of the branch instruction.
The correctness of the prediction is visualized in both the table and the log message area.
The BHT is updated based on the information if the branch instruction was taken or not.
Parameters:
branchInstAddr – the address of the branch instruction
branchTaken – the information if the branch is taken or not (determined in a step before)
isBranchInstruction
protected static boolean isBranchInstruction(ProgramStatement stmt)
Determines if the instruction is a branch instruction or not.
Parameters:
stmt – the statement to investigate
Returns:
true, if stmt is a branch instruction, otherwise false
willBranch
protected static boolean willBranch(ProgramStatement stmt)
Checks if the branch instruction delivered as parameter will branch or not.
Parameters:
stmt – the branch instruction to be investigated
Returns:
true if the branch will be taken, otherwise false
extractBranchAddress
protected static int extractBranchAddress(ProgramStatement stmt)
Extracts the target address of the branch.
In MIPS the target address is encoded as 16-bit value.
The target address is encoded relative to the address of the instruction after the branch instruction
Parameters:
stmt – the branch instruction
Returns:
the address of the instruction that is executed if the branch is taken
processMIPSUpdate
protected void processMIPSUpdate(Observable resource,
AccessNotice notice)
Callback for text segment access by the MIPS simulator.
The method is called each time the text segment is accessed to fetch the next instruction.
If the next instruction to execute was a branch instruction, the branch prediction is performed and visualized.
In case the last instruction was a branch instruction, the outcome of the branch prediction is analyzed and visualized.
Overrides:
processMIPSUpdate in class AbstractMarsToolAndApplication
Parameters:
resource – the observed resource
notice – signals the type of access (memory, register etc.)
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
BitmapDisplay
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class BitmapDisplay
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
mars.tools.AbstractMarsToolAndApplication
mars.tools.BitmapDisplay
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Observer, Accessible, RootPaneContainer, WindowConstants, MarsTool
public class BitmapDisplay
extends AbstractMarsToolAndApplication
Bitmapp display simulator. It can be run either as a stand-alone Java application having
access to the mars package, or through MARS as an item in its Tools menu. It makes
maximum use of methods inherited from its abstract superclass AbstractMarsToolAndApplication.
Pete Sanderson, verison 1.0, 23 December 2010.
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class mars.tools.AbstractMarsToolAndApplication
AbstractMarsToolAndApplication.ConnectButton, AbstractMarsToolAndApplication.EnterKeyListener
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class mars.tools.AbstractMarsToolAndApplication
connectButton, isBeingUsedAsAMarsTool, theWindow, thisMarsApp
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
BitmapDisplay()
Simple constructor, likely used by the MARS Tools menu mechanism
BitmapDisplay(String title,
String heading)
Simple constructor, likely used to run a stand-alone bitmap display tool.
Method Summary
protected void addAsObserver()
Override the inherited method, which registers us as an Observer over the static data segment
(starting address 0x10010000) only.
protected JComponent buildMainDisplayArea()
Method that constructs the main display area.
protected JComponent getHelpComponent()
Overrides default method, to provide a Help button for this tool/app.
String getName()
Required MarsTool method to return Tool name.
protected void initializePostGUI()
The only post-GUI initialization is to create the initial Grid object based on the default settings
of the various combo boxes.
protected void initializePreGUI()
Initialize all JComboBox choice structures not already initialized at declaration.
static void main(String[] args)
Main provided for pure stand-alone use.
protected void processMIPSUpdate(Observable memory,
AccessNotice accessNotice)
Update display when connected MIPS program accesses (data) memory.
protected void reset()
Method to reset counters and display when the Reset button selected.
protected void updateDisplay()
Updates display immediately after each update (AccessNotice) is processed, after
display configuration changes as needed, and after each execution step when Mars
is running in timed mode.
Methods inherited from class mars.tools.AbstractMarsToolAndApplication
action, addAsObserver, addAsObserver, buildButtonAreaMarsTool, buildButtonAreaStandAlone, buildHeadingArea, deleteAsObserver, deleteAsObserver, go, isObserving, performSpecialClosingDuties, update
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
Constructor Detail
BitmapDisplay
public BitmapDisplay(String title,
String heading)
Simple constructor, likely used to run a stand-alone bitmap display tool.
Parameters:
title – String containing title for title bar
heading – String containing text for heading shown in upper part of window.
BitmapDisplay
public BitmapDisplay()
Simple constructor, likely used by the MARS Tools menu mechanism
Method Detail
main
public static void main(String[] args)
Main provided for pure stand-alone use. Recommended stand-alone use is to write a
driver program that instantiates a Bitmap object then invokes its go() method.
“stand-alone” means it is not invoked from the MARS Tools menu. “Pure” means there
is no driver program to invoke the application.
getName
public String getName()
Required MarsTool method to return Tool name.
Specified by:
getName in interface MarsTool
Specified by:
getName in class AbstractMarsToolAndApplication
Returns:
Tool name. MARS will display this in menu item.
addAsObserver
protected void addAsObserver()
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
the memory range as selected by the base address combo box and capacity of the visualization display
(number of visualization elements times the number of memory words each one represents).
It does so by calling the inherited 2-parameter overload of this method.
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:
addAsObserver in class AbstractMarsToolAndApplication
buildMainDisplayArea
protected JComponent buildMainDisplayArea()
Method that constructs the main display area. It is organized vertically
into two major components: the display configuration which an be modified
using combo boxes, and the visualization display which is updated as the
attached MIPS program executes.
Specified by:
buildMainDisplayArea in class AbstractMarsToolAndApplication
Returns:
the GUI component containing these two areas
processMIPSUpdate
protected void processMIPSUpdate(Observable memory,
AccessNotice accessNotice)
Update display when connected MIPS program accesses (data) memory.
Overrides:
processMIPSUpdate in class AbstractMarsToolAndApplication
Parameters:
memory – the attached memory
accessNotice – information provided by memory in MemoryAccessNotice object
initializePreGUI
protected void initializePreGUI()
Initialize all JComboBox choice structures not already initialized at declaration.
Overrides inherited method that does nothing.
Overrides:
initializePreGUI in class AbstractMarsToolAndApplication
initializePostGUI
protected void initializePostGUI()
The only post-GUI initialization is to create the initial Grid object based on the default settings
of the various combo boxes. Overrides inherited method that does nothing.
Overrides:
initializePostGUI in class AbstractMarsToolAndApplication
reset
protected void reset()
Method to reset counters and display when the Reset button selected.
Overrides inherited method that does nothing.
Overrides:
reset in class AbstractMarsToolAndApplication
updateDisplay
protected void updateDisplay()
Updates display immediately after each update (AccessNotice) is processed, after
display configuration changes as needed, and after each execution step when Mars
is running in timed mode. Overrides inherited method that does nothing.
Overrides:
updateDisplay in class AbstractMarsToolAndApplication
getHelpComponent
protected JComponent getHelpComponent()
Overrides default method, to provide a Help button for this tool/app.
Overrides:
getHelpComponent in class AbstractMarsToolAndApplication
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
CacheSimulator
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class CacheSimulator
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
mars.tools.AbstractMarsToolAndApplication
mars.tools.CacheSimulator
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Observer, Accessible, RootPaneContainer, WindowConstants, MarsTool
public class CacheSimulator
extends AbstractMarsToolAndApplication
A data cache simulator. It can be run either as a stand-alone Java application having
access to the mars package, or through MARS as an item in its Tools menu. It makes
maximum use of methods inherited from its abstract superclass AbstractMarsToolOrApp.
Pete Sanderson, v 1.0: 16-18 October 2006, v 1.1: 7 November 2006. v 1.2: 23 December 2010.
Version 1.2 fixes a bug in the hit/miss animator under full or N-way set associative. It was
animating the block of initial access (first block of set). Now it animates the block
of final access (where address found or stored). Also added log display to GUI (previously System.out).
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class mars.tools.AbstractMarsToolAndApplication
AbstractMarsToolAndApplication.ConnectButton, AbstractMarsToolAndApplication.EnterKeyListener
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class mars.tools.AbstractMarsToolAndApplication
connectButton, isBeingUsedAsAMarsTool, theWindow, thisMarsApp
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
CacheSimulator()
Simple constructor, likely used by the MARS Tools menu mechanism
CacheSimulator(String title,
String heading)
Simple constructor, likely used to run a stand-alone cache simulator.
Method Summary
protected JComponent buildMainDisplayArea()
Method that constructs the main cache simulator display area.
String getName()
Required MarsTool method to return Tool name.
protected void initializePostGUI()
The only post-GUI initialization is to create the initial cache object based on the default settings
of the various combo boxes.
protected void initializePreGUI()
Initialize all JComboBox choice structures not already initialized at declaration.
static void main(String[] args)
Main provided for pure stand-alone use.
protected void processMIPSUpdate(Observable memory,
AccessNotice accessNotice)
Apply caching policies and update display when connected MIPS program accesses (data) memory.
protected void reset()
Method to reset cache, counters and display when the Reset button selected.
protected void updateDisplay()
Updates display immediately after each update (AccessNotice) is processed, after
cache configuration changes as needed, and after each execution step when Mars
is running in timed mode.
Methods inherited from class mars.tools.AbstractMarsToolAndApplication
action, addAsObserver, addAsObserver, addAsObserver, buildButtonAreaMarsTool, buildButtonAreaStandAlone, buildHeadingArea, deleteAsObserver, deleteAsObserver, getHelpComponent, go, isObserving, performSpecialClosingDuties, update
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
Constructor Detail
CacheSimulator
public CacheSimulator(String title,
String heading)
Simple constructor, likely used to run a stand-alone cache simulator.
Parameters:
title – String containing title for title bar
heading – String containing text for heading shown in upper part of window.
CacheSimulator
public CacheSimulator()
Simple constructor, likely used by the MARS Tools menu mechanism
Method Detail
main
public static void main(String[] args)
Main provided for pure stand-alone use. Recommended stand-alone use is to write a
driver program that instantiates a CacheSimulator object then invokes its go() method.
“stand-alone” means it is not invoked from the MARS Tools menu. “Pure” means there
is no driver program to invoke the Cache Simulator.
getName
public String getName()
Required MarsTool method to return Tool name.
Specified by:
getName in interface MarsTool
Specified by:
getName in class AbstractMarsToolAndApplication
Returns:
Tool name. MARS will display this in menu item.
buildMainDisplayArea
protected JComponent buildMainDisplayArea()
Method that constructs the main cache simulator display area. It is organized vertically
into three major components: the cache configuration which an be modified
using combo boxes, the cache performance which is updated as the
attached MIPS program executes, and the runtime log which is optionally used
to display log of each cache access.
Specified by:
buildMainDisplayArea in class AbstractMarsToolAndApplication
Returns:
the GUI component containing these three areas
processMIPSUpdate
protected void processMIPSUpdate(Observable memory,
AccessNotice accessNotice)
Apply caching policies and update display when connected MIPS program accesses (data) memory.
Overrides:
processMIPSUpdate in class AbstractMarsToolAndApplication
Parameters:
memory – the attached memory
accessNotice – information provided by memory in MemoryAccessNotice object
initializePreGUI
protected void initializePreGUI()
Initialize all JComboBox choice structures not already initialized at declaration.
Also creates initial default cache object. Overrides inherited method that does nothing.
Overrides:
initializePreGUI in class AbstractMarsToolAndApplication
initializePostGUI
protected void initializePostGUI()
The only post-GUI initialization is to create the initial cache object based on the default settings
of the various combo boxes. Overrides inherited method that does nothing.
Overrides:
initializePostGUI in class AbstractMarsToolAndApplication
reset
protected void reset()
Method to reset cache, counters and display when the Reset button selected.
Overrides inherited method that does nothing.
Overrides:
reset in class AbstractMarsToolAndApplication
updateDisplay
protected void updateDisplay()
Updates display immediately after each update (AccessNotice) is processed, after
cache configuration changes as needed, and after each execution step when Mars
is running in timed mode. Overrides inherited method that does nothing.
Overrides:
updateDisplay in class AbstractMarsToolAndApplication
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
DigitalLabSim.HexaKeyboard.EcouteurClick
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class DigitalLabSim.HexaKeyboard.EcouteurClick
java.lang.Object
mars.tools.DigitalLabSim.HexaKeyboard.EcouteurClick
All Implemented Interfaces:
MouseListener, EventListener
Enclosing class:
DigitalLabSim.HexaKeyboard
public class DigitalLabSim.HexaKeyboard.EcouteurClick
extends Object
implements MouseListener
Constructor Summary
DigitalLabSim.HexaKeyboard.EcouteurClick(int val)
Method Summary
void mouseClicked(MouseEvent arg0)
void mouseEntered(MouseEvent arg0)
void mouseExited(MouseEvent arg0)
void mousePressed(MouseEvent arg0)
void mouseReleased(MouseEvent arg0)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
DigitalLabSim.HexaKeyboard.EcouteurClick
public DigitalLabSim.HexaKeyboard.EcouteurClick(int val)
Method Detail
mouseEntered
public void mouseEntered(MouseEvent arg0)
Specified by:
mouseEntered in interface MouseListener
mouseExited
public void mouseExited(MouseEvent arg0)
Specified by:
mouseExited in interface MouseListener
mousePressed
public void mousePressed(MouseEvent arg0)
Specified by:
mousePressed in interface MouseListener
mouseReleased
public void mouseReleased(MouseEvent arg0)
Specified by:
mouseReleased in interface MouseListener
mouseClicked
public void mouseClicked(MouseEvent arg0)
Specified by:
mouseClicked in interface MouseListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
DigitalLabSim.HexaKeyboard
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class DigitalLabSim.HexaKeyboard
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
mars.tools.DigitalLabSim.HexaKeyboard
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Enclosing class:
DigitalLabSim
public class DigitalLabSim.HexaKeyboard
extends JPanel
See Also:
Serialized Form
Nested Class Summary
class DigitalLabSim.HexaKeyboard.EcouteurClick
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
JButton[] button
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
DigitalLabSim.HexaKeyboard()
Method Summary
void resetHexaKeyboard()
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
button
public JButton[] button
Constructor Detail
DigitalLabSim.HexaKeyboard
public DigitalLabSim.HexaKeyboard()
Method Detail
resetHexaKeyboard
public void resetHexaKeyboard()
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
DigitalLabSim
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class DigitalLabSim
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
mars.tools.AbstractMarsToolAndApplication
mars.tools.DigitalLabSim
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Observer, Accessible, RootPaneContainer, WindowConstants, MarsTool
public class DigitalLabSim
extends AbstractMarsToolAndApplication
See Also:
Serialized Form
Nested Class Summary
class DigitalLabSim.HexaKeyboard
class DigitalLabSim.OneSecondCounter
class DigitalLabSim.SevenSegmentDisplay
class DigitalLabSim.SevenSegmentPanel
Nested classes/interfaces inherited from class mars.tools.AbstractMarsToolAndApplication
AbstractMarsToolAndApplication.ConnectButton, AbstractMarsToolAndApplication.EnterKeyListener
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
static int EXTERNAL_INTERRUPT_HEXA_KEYBOARD
static int EXTERNAL_INTERRUPT_TIMER
Fields inherited from class mars.tools.AbstractMarsToolAndApplication
connectButton, isBeingUsedAsAMarsTool, theWindow, thisMarsApp
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
DigitalLabSim()
DigitalLabSim(String title,
String heading)
Method Summary
protected void addAsObserver()
Add this app/tool as an Observer of desired MIPS Observables (memory and registers).
protected JComponent buildMainDisplayArea()
Abstract method that must be instantiated by subclass to build the main display area
of the GUI.
protected JComponent getHelpComponent()
Override this method to provide a JComponent (probably a JButton) of your choice
to be placed just left of the Close/Exit button.
String getName()
Required MarsTool method to return Tool name.
static void main(String[] args)
protected void reset()
Method that will be called each time the default Reset button is clicked.
void update(Observable ressource,
Object accessNotice)
Called when receiving notice of access to MIPS memory or registers.
void updateHexaKeyboard(char row)
void updateOneSecondCounter(char value)
void updateSevenSegment(int number,
char value)
Methods inherited from class mars.tools.AbstractMarsToolAndApplication
action, addAsObserver, addAsObserver, buildButtonAreaMarsTool, buildButtonAreaStandAlone, buildHeadingArea, deleteAsObserver, deleteAsObserver, go, initializePostGUI, initializePreGUI, isObserving, performSpecialClosingDuties, processMIPSUpdate, updateDisplay
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
Field Detail
EXTERNAL_INTERRUPT_TIMER
public static final int EXTERNAL_INTERRUPT_TIMER
See Also:
Constant Field Values
EXTERNAL_INTERRUPT_HEXA_KEYBOARD
public static final int EXTERNAL_INTERRUPT_HEXA_KEYBOARD
See Also:
Constant Field Values
Constructor Detail
DigitalLabSim
public DigitalLabSim(String title,
String heading)
DigitalLabSim
public DigitalLabSim()
Method Detail
main
public static void main(String[] args)
getName
public String getName()
Description copied from class: AbstractMarsToolAndApplication
Required MarsTool method to return Tool name. Must be defined by subclass.
Specified by:
getName in interface MarsTool
Specified by:
getName in class AbstractMarsToolAndApplication
Returns:
Tool name. MARS will display this in menu item.
addAsObserver
protected void addAsObserver()
Description copied from class: AbstractMarsToolAndApplication
Add this app/tool as an Observer of desired MIPS Observables (memory and registers).
By default, will add as an Observer of the entire Data Segment in memory.
Override if you want something different. Note that the Memory methods to add an
Observer to memory are flexible (you can register for a range of addresses) but
may throw an AddressErrorException that you need to catch.
This method is called whenever the default “Connect” button on a MarsTool or the
default “Assemble and run” on a stand-alone Mars app is selected. The corresponding
NOTE: if you do not want to register as an Observer of the entire data segment
(starts at address 0x10000000) then override this to either do some alternative
or nothing at all. This method is also overloaded to allow arbitrary memory
subrange.
Overrides:
addAsObserver in class AbstractMarsToolAndApplication
update
public void update(Observable ressource,
Object accessNotice)
Description copied from class: AbstractMarsToolAndApplication
Called when receiving notice of access to MIPS memory or registers. Default
implementation of method required by Observer interface. This method will filter out
notices originating from the MARS GUI or from direct user editing of memory or register
displays. Only notices arising from MIPS program access are allowed in.
It then calls two methods to be overridden by the subclass (since they do
nothing by default): processMIPSUpdate() then updateDisplay().
Specified by:
update in interface Observer
Overrides:
update in class AbstractMarsToolAndApplication
Parameters:
ressource – the attached MIPS resource
accessNotice – AccessNotice information provided by the resource
reset
protected void reset()
Description copied from class: AbstractMarsToolAndApplication
Method that will be called each time the default Reset button is clicked.
Use it to reset any data structures and/or GUI components. By default it does nothing.
Overrides:
reset in class AbstractMarsToolAndApplication
buildMainDisplayArea
protected JComponent buildMainDisplayArea()
Description copied from class: AbstractMarsToolAndApplication
Abstract method that must be instantiated by subclass to build the main display area
of the GUI. It will be placed in the CENTER area of a BorderLayout. The title
is in the NORTH area, and the controls are in the SOUTH area.
Specified by:
buildMainDisplayArea in class AbstractMarsToolAndApplication
getHelpComponent
protected JComponent getHelpComponent()
Description copied from class: AbstractMarsToolAndApplication
Override this method to provide a JComponent (probably a JButton) of your choice
to be placed just left of the Close/Exit button. Its anticipated use is for a
“help” button that launches a help message or dialog. But it can be any valid
JComponent that doesn’t mind co-existing among a bunch of JButtons.
Overrides:
getHelpComponent in class AbstractMarsToolAndApplication
updateSevenSegment
public void updateSevenSegment(int number,
char value)
updateHexaKeyboard
public void updateHexaKeyboard(char row)
updateOneSecondCounter
public void updateOneSecondCounter(char value)
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
DigitalLabSim.OneSecondCounter
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class DigitalLabSim.OneSecondCounter
java.lang.Object
mars.tools.DigitalLabSim.OneSecondCounter
Enclosing class:
DigitalLabSim
public class DigitalLabSim.OneSecondCounter
extends Object
Constructor Summary
DigitalLabSim.OneSecondCounter()
Method Summary
void resetOneSecondCounter()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
DigitalLabSim.OneSecondCounter
public DigitalLabSim.OneSecondCounter()
Method Detail
resetOneSecondCounter
public void resetOneSecondCounter()
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
DigitalLabSim.SevenSegmentDisplay
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class DigitalLabSim.SevenSegmentDisplay
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
mars.tools.DigitalLabSim.SevenSegmentDisplay
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable
Enclosing class:
DigitalLabSim
public class DigitalLabSim.SevenSegmentDisplay
extends JComponent
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
char aff
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
DigitalLabSim.SevenSegmentDisplay(char aff)
Method Summary
void modifyDisplay(char val)
void paint(Graphics g)
void SwitchSegment(Graphics g,
char segment)
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
aff
public char aff
Constructor Detail
DigitalLabSim.SevenSegmentDisplay
public DigitalLabSim.SevenSegmentDisplay(char aff)
Method Detail
modifyDisplay
public void modifyDisplay(char val)
SwitchSegment
public void SwitchSegment(Graphics g,
char segment)
paint
public void paint(Graphics g)
Overrides:
paint in class JComponent
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
DigitalLabSim.SevenSegmentPanel
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class DigitalLabSim.SevenSegmentPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
mars.tools.DigitalLabSim.SevenSegmentPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Enclosing class:
DigitalLabSim
public class DigitalLabSim.SevenSegmentPanel
extends JPanel
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
DigitalLabSim.SevenSegmentDisplay[] display
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
DigitalLabSim.SevenSegmentPanel()
Method Summary
void modifyDisplay(int num,
char val)
void resetSevenSegment()
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
display
public DigitalLabSim.SevenSegmentDisplay[] display
Constructor Detail
DigitalLabSim.SevenSegmentPanel
public DigitalLabSim.SevenSegmentPanel()
Method Detail
modifyDisplay
public void modifyDisplay(int num,
char val)
resetSevenSegment
public void resetSevenSegment()
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
FloatRepresentation
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class FloatRepresentation
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
mars.tools.AbstractMarsToolAndApplication
mars.tools.FloatRepresentation
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Observer, Accessible, RootPaneContainer, WindowConstants, MarsTool
public class FloatRepresentation
extends AbstractMarsToolAndApplication
Tool to help students learn about IEEE 754 representation of 32 bit
floating point values. This representation is used by MIPS “float”
directive and instructions and also the Java (and most other languages)
“float” data type. As written, it can ALMOST be adapted to 64 bit by
changing a few constants.
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class mars.tools.AbstractMarsToolAndApplication
AbstractMarsToolAndApplication.ConnectButton, AbstractMarsToolAndApplication.EnterKeyListener
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class mars.tools.AbstractMarsToolAndApplication
connectButton, isBeingUsedAsAMarsTool, theWindow, thisMarsApp
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
FloatRepresentation()
Simple constructor, likely used by the MARS Tools menu mechanism
FloatRepresentation(String title,
String heading)
Simple constructor, likely used to run a stand-alone memory reference visualizer.
Method Summary
protected void addAsObserver()
Override the inherited method, which registers us as an Observer over the static data segment
(starting address 0x10010000) only.
protected JComponent buildDisplayArea()
protected JComponent buildMainDisplayArea()
Method that constructs the main display area.
protected void deleteAsObserver()
Delete this app/tool as an Observer of the attached register.
String getName()
Fetch tool name (for display in MARS Tools menu)
static void main(String[] args)
Main provided for pure stand-alone use.
protected void reset()
Method to reset display values to 0 when the Reset button selected.
void update(Observable register,
Object accessNotice)
Override inherited update() to update display when “attached” register is modified
either by MIPS program or by user editing it on the MARS user interface.
Methods inherited from class mars.tools.AbstractMarsToolAndApplication
action, addAsObserver, addAsObserver, buildButtonAreaMarsTool, buildButtonAreaStandAlone, buildHeadingArea, deleteAsObserver, getHelpComponent, go, initializePostGUI, initializePreGUI, isObserving, performSpecialClosingDuties, processMIPSUpdate, updateDisplay
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
Constructor Detail
FloatRepresentation
public FloatRepresentation(String title,
String heading)
Simple constructor, likely used to run a stand-alone memory reference visualizer.
Parameters:
title – String containing title for title bar
heading – String containing text for heading shown in upper part of window.
FloatRepresentation
public FloatRepresentation()
Simple constructor, likely used by the MARS Tools menu mechanism
Method Detail
main
public static void main(String[] args)
Main provided for pure stand-alone use. Recommended stand-alone use is to write a
driver program that instantiates a FloatRepresentation object then invokes its go() method.
“stand-alone” means it is not invoked from the MARS Tools menu. “Pure” means there
is no driver program to invoke the application.
getName
public String getName()
Fetch tool name (for display in MARS Tools menu)
Specified by:
getName in interface MarsTool
Specified by:
getName in class AbstractMarsToolAndApplication
Returns:
String containing tool name
addAsObserver
protected void addAsObserver()
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:
addAsObserver in class AbstractMarsToolAndApplication
deleteAsObserver
protected void deleteAsObserver()
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:
deleteAsObserver in class AbstractMarsToolAndApplication
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 AbstractMarsToolAndApplication
Returns:
the GUI component containing the application/tool-specific part of the user interface
update
public void update(Observable register,
Object accessNotice)
Override inherited update() to update display when “attached” register is modified
either by MIPS program or by user editing it on the MARS user interface.
The latter is the reason for overriding the inherited update() method.
The inherited method will filter out notices triggered by the MARS GUI or the user.
Specified by:
update in interface Observer
Overrides:
update in class AbstractMarsToolAndApplication
Parameters:
register – the attached register
accessNotice – information provided by register in RegisterAccessNotice object
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 AbstractMarsToolAndApplication
buildDisplayArea
protected JComponent buildDisplayArea()
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InstructionCounter
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class InstructionCounter
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
mars.tools.AbstractMarsToolAndApplication
mars.tools.InstructionCounter
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Observer, Accessible, RootPaneContainer, WindowConstants, MarsTool
public class InstructionCounter
extends AbstractMarsToolAndApplication
Instruction counter tool. Can be used to know how many instructions
were executed to complete a given program.
Code slightly based on MemoryReferenceVisualization.
Author:
Felipe Lessa
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class mars.tools.AbstractMarsToolAndApplication
AbstractMarsToolAndApplication.ConnectButton, AbstractMarsToolAndApplication.EnterKeyListener
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
protected int counter
Number of instructions executed until now.
protected int counterI
Number of instructions of type I.
protected int counterJ
Number of instructions of type J.
protected int counterR
Number of instructions of type R.
protected int lastAddress
The last address we saw.
Fields inherited from class mars.tools.AbstractMarsToolAndApplication
connectButton, isBeingUsedAsAMarsTool, theWindow, thisMarsApp
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
InstructionCounter()
Simple construction, likely used by the MARS Tools menu mechanism.
InstructionCounter(String title,
String heading)
Simple constructor, likely used to run a stand-alone memory reference visualizer.
Method Summary
protected void addAsObserver()
Add this app/tool as an Observer of desired MIPS Observables (memory and registers).
protected JComponent buildMainDisplayArea()
Abstract method that must be instantiated by subclass to build the main display area
of the GUI.
String getName()
Required MarsTool method to return Tool name.
protected void initializePreGUI()
Method that will be called once just before the GUI is constructed in the go() and action()
methods.
protected void processMIPSUpdate(Observable resource,
AccessNotice notice)
Override this method to process a received notice from MIPS Observable (memory or register)
It will only be called if the notice was generated as the result of MIPS instruction execution.
protected void reset()
Method that will be called each time the default Reset button is clicked.
protected void updateDisplay()
Override this method to implement updating of GUI after each MIPS instruction is executed,
while running in “timed” mode (user specifies execution speed on the slider control).
Methods inherited from class mars.tools.AbstractMarsToolAndApplication
action, addAsObserver, addAsObserver, buildButtonAreaMarsTool, buildButtonAreaStandAlone, buildHeadingArea, deleteAsObserver, deleteAsObserver, getHelpComponent, go, initializePostGUI, isObserving, performSpecialClosingDuties, update
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
Field Detail
counter
protected int counter
Number of instructions executed until now.
counterR
protected int counterR
Number of instructions of type R.
counterI
protected int counterI
Number of instructions of type I.
counterJ
protected int counterJ
Number of instructions of type J.
lastAddress
protected int lastAddress
The last address we saw. We ignore it because the only way for a
program to execute twice the same instruction is to enter an infinite
loop, which is not insteresting in the POV of counting instructions.
Constructor Detail
InstructionCounter
public InstructionCounter(String title,
String heading)
Simple constructor, likely used to run a stand-alone memory reference visualizer.
Parameters:
title – String containing title for title bar
heading – String containing text for heading shown in upper part of window.
InstructionCounter
public InstructionCounter()
Simple construction, likely used by the MARS Tools menu mechanism.
Method Detail
getName
public String getName()
Description copied from class: AbstractMarsToolAndApplication
Required MarsTool method to return Tool name. Must be defined by subclass.
Specified by:
getName in interface MarsTool
Specified by:
getName in class AbstractMarsToolAndApplication
Returns:
Tool name. MARS will display this in menu item.
buildMainDisplayArea
protected JComponent buildMainDisplayArea()
Description copied from class: AbstractMarsToolAndApplication
Abstract method that must be instantiated by subclass to build the main display area
of the GUI. It will be placed in the CENTER area of a BorderLayout. The title
is in the NORTH area, and the controls are in the SOUTH area.
Specified by:
buildMainDisplayArea in class AbstractMarsToolAndApplication
addAsObserver
protected void addAsObserver()
Description copied from class: AbstractMarsToolAndApplication
Add this app/tool as an Observer of desired MIPS Observables (memory and registers).
By default, will add as an Observer of the entire Data Segment in memory.
Override if you want something different. Note that the Memory methods to add an
Observer to memory are flexible (you can register for a range of addresses) but
may throw an AddressErrorException that you need to catch.
This method is called whenever the default “Connect” button on a MarsTool or the
default “Assemble and run” on a stand-alone Mars app is selected. The corresponding
NOTE: if you do not want to register as an Observer of the entire data segment
(starts at address 0x10000000) then override this to either do some alternative
or nothing at all. This method is also overloaded to allow arbitrary memory
subrange.
Overrides:
addAsObserver in class AbstractMarsToolAndApplication
processMIPSUpdate
protected void processMIPSUpdate(Observable resource,
AccessNotice notice)
Description copied from class: AbstractMarsToolAndApplication
Override this method to process a received notice from MIPS Observable (memory or register)
It will only be called if the notice was generated as the result of MIPS instruction execution.
By default it does nothing. After this method is complete, the updateDisplay() method will be
invoked automatically.
Overrides:
processMIPSUpdate in class AbstractMarsToolAndApplication
initializePreGUI
protected void initializePreGUI()
Description copied from class: AbstractMarsToolAndApplication
Method that will be called once just before the GUI is constructed in the go() and action()
methods. Use it to initialize any data structures needed for the application whose values
will be needed to determine the initial state of GUI components. By default it does nothing.
Overrides:
initializePreGUI in class AbstractMarsToolAndApplication
reset
protected void reset()
Description copied from class: AbstractMarsToolAndApplication
Method that will be called each time the default Reset button is clicked.
Use it to reset any data structures and/or GUI components. By default it does nothing.
Overrides:
reset in class AbstractMarsToolAndApplication
updateDisplay
protected void updateDisplay()
Description copied from class: AbstractMarsToolAndApplication
Override this method to implement updating of GUI after each MIPS instruction is executed,
while running in “timed” mode (user specifies execution speed on the slider control).
Does nothing by default.
Overrides:
updateDisplay in class AbstractMarsToolAndApplication
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InstructionStatistics
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class InstructionStatistics
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
mars.tools.AbstractMarsToolAndApplication
mars.tools.InstructionStatistics
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Observer, Accessible, RootPaneContainer, WindowConstants, MarsTool
public class InstructionStatistics
extends AbstractMarsToolAndApplication
A MARS tool for obtaining instruction statistics by instruction category.
The code of this tools is initially based on the Instruction counter tool by Felipe Lassa.
Author:
Ingo Kofler
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class mars.tools.AbstractMarsToolAndApplication
AbstractMarsToolAndApplication.ConnectButton, AbstractMarsToolAndApplication.EnterKeyListener
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
protected int lastAddress
The last address we saw.
Fields inherited from class mars.tools.AbstractMarsToolAndApplication
connectButton, isBeingUsedAsAMarsTool, theWindow, thisMarsApp
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
InstructionStatistics()
Simple construction, likely used by the MARS Tools menu mechanism.
InstructionStatistics(String title,
String heading)
Simple constructor, likely used to run a stand-alone enhanced instruction counter.
Method Summary
protected void addAsObserver()
registers the tool as observer for the text segment of the MIPS program
protected JComponent buildMainDisplayArea()
creates the display area for the tool as required by the API
protected int getInstructionCategory(ProgramStatement stmt)
decodes the instruction and determines the category of the instruction.
String getName()
returns the name of the tool
protected void initializePreGUI()
performs initialization tasks of the counters before the GUI is created.
protected void processMIPSUpdate(Observable resource,
AccessNotice notice)
method that is called each time the MIPS simulator accesses the text segment.
protected void reset()
resets the counter values of the tool and updates the display.
protected void updateDisplay()
updates the text fields and progress bars according to the current counter values.
Methods inherited from class mars.tools.AbstractMarsToolAndApplication
action, addAsObserver, addAsObserver, buildButtonAreaMarsTool, buildButtonAreaStandAlone, buildHeadingArea, deleteAsObserver, deleteAsObserver, getHelpComponent, go, initializePostGUI, isObserving, performSpecialClosingDuties, update
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
Field Detail
lastAddress
protected int lastAddress
The last address we saw. We ignore it because the only way for a
program to execute twice the same instruction is to enter an infinite
loop, which is not insteresting in the POV of counting instructions.
Constructor Detail
InstructionStatistics
public InstructionStatistics(String title,
String heading)
Simple constructor, likely used to run a stand-alone enhanced instruction counter.
Parameters:
title – String containing title for title bar
heading – String containing text for heading shown in upper part of window.
InstructionStatistics
public InstructionStatistics()
Simple construction, likely used by the MARS Tools menu mechanism.
Method Detail
getName
public String getName()
returns the name of the tool
Specified by:
getName in interface MarsTool
Specified by:
getName in class AbstractMarsToolAndApplication
Returns:
the tools’s name
buildMainDisplayArea
protected JComponent buildMainDisplayArea()
creates the display area for the tool as required by the API
Specified by:
buildMainDisplayArea in class AbstractMarsToolAndApplication
Returns:
a panel that holds the GUI of the tool
addAsObserver
protected void addAsObserver()
registers the tool as observer for the text segment of the MIPS program
Overrides:
addAsObserver in class AbstractMarsToolAndApplication
getInstructionCategory
protected int getInstructionCategory(ProgramStatement stmt)
decodes the instruction and determines the category of the instruction.
The instruction is decoded by extracting the operation and function code of the 32-bit instruction.
Only the most relevant instructions are decoded and categorized.
Parameters:
stmt – the instruction to decode
Returns:
the category of the instruction
See Also:
CATEGORY_ALU,
CATEGORY_JUMP,
CATEGORY_BRANCH,
CATEGORY_MEM,
CATEGORY_OTHER
processMIPSUpdate
protected void processMIPSUpdate(Observable resource,
AccessNotice notice)
method that is called each time the MIPS simulator accesses the text segment.
Before an instruction is executed by the simulator, the instruction is fetched from the program memory.
This memory access is observed and the corresponding instruction is decoded and categorized by the tool.
According to the category the counter values are increased and the display gets updated.
Overrides:
processMIPSUpdate in class AbstractMarsToolAndApplication
Parameters:
resource – the observed resource
notice – signals the type of access (memory, register etc.)
initializePreGUI
protected void initializePreGUI()
performs initialization tasks of the counters before the GUI is created.
Overrides:
initializePreGUI in class AbstractMarsToolAndApplication
reset
protected void reset()
resets the counter values of the tool and updates the display.
Overrides:
reset in class AbstractMarsToolAndApplication
updateDisplay
protected void updateDisplay()
updates the text fields and progress bars according to the current counter values.
Overrides:
updateDisplay in class AbstractMarsToolAndApplication
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
IntroToTools
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class IntroToTools
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
mars.tools.AbstractMarsToolAndApplication
mars.tools.IntroToTools
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Observer, Accessible, RootPaneContainer, WindowConstants, MarsTool
public class IntroToTools
extends AbstractMarsToolAndApplication
The “hello world” of MarsTools!
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class mars.tools.AbstractMarsToolAndApplication
AbstractMarsToolAndApplication.ConnectButton, AbstractMarsToolAndApplication.EnterKeyListener
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class mars.tools.AbstractMarsToolAndApplication
connectButton, isBeingUsedAsAMarsTool, theWindow, thisMarsApp
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
IntroToTools()
Simple constructor, likely used by the MARS Tools menu mechanism
IntroToTools(String title,
String heading)
Simple constructor, likely used to run a stand-alone memory reference visualizer.
Method Summary
protected JComponent buildMainDisplayArea()
Implementation of the inherited abstract method to build the main
display area of the GUI.
String getName()
Required method to return Tool name.
static void main(String[] args)
Main provided for pure stand-alone use.
Methods inherited from class mars.tools.AbstractMarsToolAndApplication
action, addAsObserver, addAsObserver, addAsObserver, buildButtonAreaMarsTool, buildButtonAreaStandAlone, buildHeadingArea, deleteAsObserver, deleteAsObserver, getHelpComponent, go, initializePostGUI, initializePreGUI, isObserving, performSpecialClosingDuties, processMIPSUpdate, reset, update, updateDisplay
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
Constructor Detail
IntroToTools
public IntroToTools(String title,
String heading)
Simple constructor, likely used to run a stand-alone memory reference visualizer.
Parameters:
title – String containing title for title bar
heading – String containing text for heading shown in upper part of window.
IntroToTools
public IntroToTools()
Simple constructor, likely used by the MARS Tools menu mechanism
Method Detail
main
public static void main(String[] args)
Main provided for pure stand-alone use. Recommended stand-alone use is to write a
driver program that instantiates a MemoryReferenceVisualization object then invokes its go() method.
“stand-alone” means it is not invoked from the MARS Tools menu. “Pure” means there
is no driver program to invoke the application.
getName
public String getName()
Required method to return Tool name.
Specified by:
getName in interface MarsTool
Specified by:
getName in class AbstractMarsToolAndApplication
Returns:
Tool name. MARS will display this in menu item.
buildMainDisplayArea
protected JComponent buildMainDisplayArea()
Implementation of the inherited abstract method to build the main
display area of the GUI. It will be placed in the CENTER area of a
BorderLayout. The title is in the NORTH area, and the controls are
in the SOUTH area.
Specified by:
buildMainDisplayArea in class AbstractMarsToolAndApplication
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
KeyboardAndDisplaySimulator
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class KeyboardAndDisplaySimulator
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
mars.tools.AbstractMarsToolAndApplication
mars.tools.KeyboardAndDisplaySimulator
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Observer, Accessible, RootPaneContainer, WindowConstants, MarsTool
public class KeyboardAndDisplaySimulator
extends AbstractMarsToolAndApplication
Keyboard and Display Simulator. It can be run either as a stand-alone Java application having
access to the mars package, or through MARS as an item in its Tools menu. It makes
maximum use of methods inherited from its abstract superclass AbstractMarsToolAndApplication.
Pete Sanderson
Version 1.0, 24 July 2008.
Version 1.1, 24 November 2008 corrects two omissions: (1) the tool failed to register as an observer
of kernel text memory when counting instruction executions for transmitter ready bit
reset delay, and (2) the tool failed to test the Status register’s Exception Level bit before
raising the exception that results in the interrupt (if the Exception Level bit is 1, that
means an interrupt is being processed, so disable further interrupts).
Version 1.2, 6 August 2009, soft-codes the MMIO register locations for new memory configuration
feature of MARS 3.7. Previously memory segment addresses were fixed and final. Now they
can be modified dynamically so the tool has to get its values dynamically as well.
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class mars.tools.AbstractMarsToolAndApplication
AbstractMarsToolAndApplication.ConnectButton, AbstractMarsToolAndApplication.EnterKeyListener
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
static Dimension preferredTextAreaDimension
static int RECEIVER_CONTROL
static int RECEIVER_DATA
static int TRANSMITTER_CONTROL
static int TRANSMITTER_DATA
Fields inherited from class mars.tools.AbstractMarsToolAndApplication
connectButton, isBeingUsedAsAMarsTool, theWindow, thisMarsApp
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
KeyboardAndDisplaySimulator()
Simple constructor, likely used by the MARS Tools menu mechanism
KeyboardAndDisplaySimulator(String title,
String heading)
Simple constructor, likely used to run a stand-alone keyboard/display simulator.
Method Summary
protected void addAsObserver()
Override the inherited method, which registers us as an Observer over the static data segment
(starting address 0x10010000) only.
protected JComponent buildMainDisplayArea()
Method that constructs the main display area.
protected JComponent getHelpComponent()
Overrides default method, to provide a Help button for this tool/app.
String getName()
Required MarsTool method to return Tool name.
protected void initializePostGUI()
Initialization code to be executed after the GUI is configured.
protected void initializePreGUI()
Method that will be called once just before the GUI is constructed in the go() and action()
methods.
static void main(String[] args)
Main provided for pure stand-alone use.
protected void processMIPSUpdate(Observable memory,
AccessNotice accessNotice)
Update display when connected MIPS program accesses (data) memory.
protected void reset()
Method to reset counters and display when the Reset button selected.
Methods inherited from class mars.tools.AbstractMarsToolAndApplication
action, addAsObserver, addAsObserver, buildButtonAreaMarsTool, buildButtonAreaStandAlone, buildHeadingArea, deleteAsObserver, deleteAsObserver, go, isObserving, performSpecialClosingDuties, update, updateDisplay
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
Field Detail
preferredTextAreaDimension
public static Dimension preferredTextAreaDimension
RECEIVER_CONTROL
public static int RECEIVER_CONTROL
RECEIVER_DATA
public static int RECEIVER_DATA
TRANSMITTER_CONTROL
public static int TRANSMITTER_CONTROL
TRANSMITTER_DATA
public static int TRANSMITTER_DATA
Constructor Detail
KeyboardAndDisplaySimulator
public KeyboardAndDisplaySimulator(String title,
String heading)
Simple constructor, likely used to run a stand-alone keyboard/display simulator.
Parameters:
title – String containing title for title bar
heading – String containing text for heading shown in upper part of window.
KeyboardAndDisplaySimulator
public KeyboardAndDisplaySimulator()
Simple constructor, likely used by the MARS Tools menu mechanism
Method Detail
main
public static void main(String[] args)
Main provided for pure stand-alone use. Recommended stand-alone use is to write a
driver program that instantiates a KeyboardAndDisplaySimulator object then invokes its go() method.
“stand-alone” means it is not invoked from the MARS Tools menu. “Pure” means there
is no driver program to invoke the application.
getName
public String getName()
Required MarsTool method to return Tool name.
Specified by:
getName in interface MarsTool
Specified by:
getName in class AbstractMarsToolAndApplication
Returns:
Tool name. MARS will display this in menu item.
initializePreGUI
protected void initializePreGUI()
Description copied from class: AbstractMarsToolAndApplication
Method that will be called once just before the GUI is constructed in the go() and action()
methods. Use it to initialize any data structures needed for the application whose values
will be needed to determine the initial state of GUI components. By default it does nothing.
Overrides:
initializePreGUI in class AbstractMarsToolAndApplication
addAsObserver
protected void addAsObserver()
Override the inherited method, which registers us as an Observer over the static data segment
(starting address 0x10010000) only.
When user enters keystroke, set RECEIVER_CONTROL and RECEIVER_DATA using the action listener.
When user loads word (lw) from RECEIVER_DATA (we are notified of the read), then clear RECEIVER_CONTROL.
When user stores word (sw) to TRANSMITTER_DATA (we are notified of the write), then clear TRANSMITTER_CONTROL, read TRANSMITTER_DATA,
echo the character to display, wait for delay period, then set TRANSMITTER_CONTROL.
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:
addAsObserver in class AbstractMarsToolAndApplication
buildMainDisplayArea
protected JComponent buildMainDisplayArea()
Method that constructs the main display area. It is organized vertically
into two major components: the display and the keyboard. The display itself
is a JTextArea and it echoes characters placed into the low order byte of
the Transmitter Data location, 0xffff000c. They keyboard is also a JTextArea
places each typed character into the Receive Data location 0xffff0004.
Specified by:
buildMainDisplayArea in class AbstractMarsToolAndApplication
Returns:
the GUI component containing these two areas
processMIPSUpdate
protected void processMIPSUpdate(Observable memory,
AccessNotice accessNotice)
Update display when connected MIPS program accesses (data) memory.
Overrides:
processMIPSUpdate in class AbstractMarsToolAndApplication
Parameters:
memory – the attached memory
accessNotice – information provided by memory in MemoryAccessNotice object
initializePostGUI
protected void initializePostGUI()
Initialization code to be executed after the GUI is configured. Overrides inherited default.
Overrides:
initializePostGUI in class AbstractMarsToolAndApplication
reset
protected void reset()
Method to reset counters and display when the Reset button selected.
Overrides inherited method that does nothing.
Overrides:
reset in class AbstractMarsToolAndApplication
getHelpComponent
protected JComponent getHelpComponent()
Overrides default method, to provide a Help button for this tool/app.
Overrides:
getHelpComponent in class AbstractMarsToolAndApplication
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
MarsBot
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class MarsBot
java.lang.Object
mars.tools.MarsBot
All Implemented Interfaces:
Observer, MarsTool
public class MarsBot
extends Object
implements Observer, MarsTool
Simple Demo of Mars tool capability
Constructor Summary
MarsBot()
Method Summary
void action()
Performs tool functions.
String getName()
Return a name you have chosen for this tool.
void update(Observable o,
Object arg)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
MarsBot
public MarsBot()
Method Detail
getName
public String getName()
Description copied from interface: MarsTool
Return a name you have chosen for this tool. It will appear as the
menu item.
Specified by:
getName in interface MarsTool
action
public void action()
Description copied from interface: MarsTool
Performs tool functions. It will be invoked when the tool is selected
from the Tools menu.
Specified by:
action in interface MarsTool
update
public void update(Observable o,
Object arg)
Specified by:
update in interface Observer
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
MarsTool
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Interface MarsTool
All Known Implementing Classes:
AbstractMarsToolAndApplication, BHTSimulator, BitmapDisplay, CacheSimulator, DigitalLabSim, FloatRepresentation, InstructionCounter, InstructionStatistics, IntroToTools, KeyboardAndDisplaySimulator, MarsBot, MemoryReferenceVisualization, ScavengerHunt, ScreenMagnifier
public interface MarsTool
Interface for any tool that interacts with an executing MIPS program.
A qualifying tool must be a class in the Tools package that
implements the MarsTool interface, must be compiled into a .class file,
and its .class file must be in the same Tools folder as MarsTool.class.
Mars will detect a qualifying tool upon startup, create an instance
using its no-argument constructor and add it to its Tools menu.
When its menu item is selected, the action() method will be invoked.
A tool may receive communication from MIPS system resources
(registers or memory) by registering as an Observer with
Mars.Memory and/or Mars.Register objects.
It may also
communicate directly with those resources through their
published methods PROVIDED any such communication is
wrapped inside a block synchronized on the
Mars.Globals.memoryAndRegistersLock object.
Method Summary
void action()
Performs tool functions.
String getName()
Return a name you have chosen for this tool.
Method Detail
getName
String getName()
Return a name you have chosen for this tool. It will appear as the
menu item.
action
void action()
Performs tool functions. It will be invoked when the tool is selected
from the Tools menu.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
MemoryReferenceVisualization
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class MemoryReferenceVisualization
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
mars.tools.AbstractMarsToolAndApplication
mars.tools.MemoryReferenceVisualization
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Observer, Accessible, RootPaneContainer, WindowConstants, MarsTool
public class MemoryReferenceVisualization
extends AbstractMarsToolAndApplication
Memory reference visualization. It can be run either as a stand-alone Java application having
access to the mars package, or through MARS as an item in its Tools menu. It makes
maximum use of methods inherited from its abstract superclass AbstractMarsToolAndApplication.
Pete Sanderson, verison 1.0, 14 November 2006.
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class mars.tools.AbstractMarsToolAndApplication
AbstractMarsToolAndApplication.ConnectButton, AbstractMarsToolAndApplication.EnterKeyListener
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class mars.tools.AbstractMarsToolAndApplication
connectButton, isBeingUsedAsAMarsTool, theWindow, thisMarsApp
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
MemoryReferenceVisualization()
Simple constructor, likely used by the MARS Tools menu mechanism
MemoryReferenceVisualization(String title,
String heading)
Simple constructor, likely used to run a stand-alone memory reference visualizer.
Method Summary
protected void addAsObserver()
Override the inherited method, which registers us as an Observer over the static data segment
(starting address 0x10010000) only.
protected JComponent buildMainDisplayArea()
Method that constructs the main display area.
protected JComponent getHelpComponent()
Overrides default method, to provide a Help button for this tool/app.
String getName()
Required MarsTool method to return Tool name.
protected void initializePostGUI()
The only post-GUI initialization is to create the initial Grid object based on the default settings
of the various combo boxes.
protected void initializePreGUI()
Initialize all JComboBox choice structures not already initialized at declaration.
static void main(String[] args)
Main provided for pure stand-alone use.
protected void processMIPSUpdate(Observable memory,
AccessNotice accessNotice)
Update display when connected MIPS program accesses (data) memory.
protected void reset()
Method to reset counters and display when the Reset button selected.
protected void updateDisplay()
Updates display immediately after each update (AccessNotice) is processed, after
display configuration changes as needed, and after each execution step when Mars
is running in timed mode.
Methods inherited from class mars.tools.AbstractMarsToolAndApplication
action, addAsObserver, addAsObserver, buildButtonAreaMarsTool, buildButtonAreaStandAlone, buildHeadingArea, deleteAsObserver, deleteAsObserver, go, isObserving, performSpecialClosingDuties, update
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
Constructor Detail
MemoryReferenceVisualization
public MemoryReferenceVisualization(String title,
String heading)
Simple constructor, likely used to run a stand-alone memory reference visualizer.
Parameters:
title – String containing title for title bar
heading – String containing text for heading shown in upper part of window.
MemoryReferenceVisualization
public MemoryReferenceVisualization()
Simple constructor, likely used by the MARS Tools menu mechanism
Method Detail
main
public static void main(String[] args)
Main provided for pure stand-alone use. Recommended stand-alone use is to write a
driver program that instantiates a MemoryReferenceVisualization object then invokes its go() method.
“stand-alone” means it is not invoked from the MARS Tools menu. “Pure” means there
is no driver program to invoke the application.
getName
public String getName()
Required MarsTool method to return Tool name.
Specified by:
getName in interface MarsTool
Specified by:
getName in class AbstractMarsToolAndApplication
Returns:
Tool name. MARS will display this in menu item.
addAsObserver
protected void addAsObserver()
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
the memory range as selected by the base address combo box and capacity of the visualization display
(number of visualization elements times the number of memory words each one represents).
It does so by calling the inherited 2-parameter overload of this method.
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:
addAsObserver in class AbstractMarsToolAndApplication
buildMainDisplayArea
protected JComponent buildMainDisplayArea()
Method that constructs the main display area. It is organized vertically
into two major components: the display configuration which an be modified
using combo boxes, and the visualization display which is updated as the
attached MIPS program executes.
Specified by:
buildMainDisplayArea in class AbstractMarsToolAndApplication
Returns:
the GUI component containing these two areas
processMIPSUpdate
protected void processMIPSUpdate(Observable memory,
AccessNotice accessNotice)
Update display when connected MIPS program accesses (data) memory.
Overrides:
processMIPSUpdate in class AbstractMarsToolAndApplication
Parameters:
memory – the attached memory
accessNotice – information provided by memory in MemoryAccessNotice object
initializePreGUI
protected void initializePreGUI()
Initialize all JComboBox choice structures not already initialized at declaration.
Overrides inherited method that does nothing.
Overrides:
initializePreGUI in class AbstractMarsToolAndApplication
initializePostGUI
protected void initializePostGUI()
The only post-GUI initialization is to create the initial Grid object based on the default settings
of the various combo boxes. Overrides inherited method that does nothing.
Overrides:
initializePostGUI in class AbstractMarsToolAndApplication
reset
protected void reset()
Method to reset counters and display when the Reset button selected.
Overrides inherited method that does nothing.
Overrides:
reset in class AbstractMarsToolAndApplication
updateDisplay
protected void updateDisplay()
Updates display immediately after each update (AccessNotice) is processed, after
display configuration changes as needed, and after each execution step when Mars
is running in timed mode. Overrides inherited method that does nothing.
Overrides:
updateDisplay in class AbstractMarsToolAndApplication
getHelpComponent
protected JComponent getHelpComponent()
Overrides default method, to provide a Help button for this tool/app.
Overrides:
getHelpComponent in class AbstractMarsToolAndApplication
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
mars.tools
Interfaces
MarsTool
Classes
AbstractMarsToolAndApplication
BHTableModel
BHTEntry
BHTSimGUI
BHTSimulator
BitmapDisplay
CacheSimulator
DigitalLabSim
FloatRepresentation
InstructionCounter
InstructionStatistics
IntroToTools
KeyboardAndDisplaySimulator
MarsBot
MemoryReferenceVisualization
ScavengerHunt
ScreenMagnifier
mars.tools
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
Package mars.tools
Interface Summary
MarsTool Interface for any tool that interacts with an executing MIPS program.
Class Summary
AbstractMarsToolAndApplication An abstract class that provides generic components to facilitate implementation of
a MarsTool and/or stand-alone Mars-based application.
BHTableModel Simulates the actual functionality of a Branch History Table (BHT).
BHTEntry Represents a single entry of the Branch History Table.
BHTSimGUI Represents the GUI of the BHT Simulator Tool.
BHTSimulator A MARS tool for simulating branch prediction with a Branch History Table (BHT)
BitmapDisplay Bitmapp display simulator.
CacheSimulator A data cache simulator.
DigitalLabSim
FloatRepresentation Tool to help students learn about IEEE 754 representation of 32 bit
floating point values.
InstructionCounter Instruction counter tool.
InstructionStatistics A MARS tool for obtaining instruction statistics by instruction category.
IntroToTools The “hello world” of MarsTools!
KeyboardAndDisplaySimulator Keyboard and Display Simulator.
MarsBot Simple Demo of Mars tool capability
MemoryReferenceVisualization Memory reference visualization.
ScavengerHunt Demo of Mars tool capability.
ScreenMagnifier Handy little tool to magnify a selected section of the screen
by a given scale and display it.
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
mars.tools Class Hierarchy
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Hierarchy For Package mars.tools
Package Hierarchies:
All Packages
Class Hierarchy
java.lang.Object javax.swing.table.AbstractTableModel (implements java.io.Serializable, javax.swing.table.TableModel)
mars.tools.BHTableModel
mars.tools.BHTEntry
java.awt.Component (implements java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable)
java.awt.Container javax.swing.JComponent (implements java.io.Serializable)
javax.swing.AbstractButton (implements java.awt.ItemSelectable, javax.swing.SwingConstants)
javax.swing.JButton (implements javax.accessibility.Accessible)
mars.tools.AbstractMarsToolAndApplication.ConnectButton
mars.tools.DigitalLabSim.SevenSegmentDisplay
javax.swing.JPanel (implements javax.accessibility.Accessible)
mars.tools.BHTSimGUI
mars.tools.DigitalLabSim.HexaKeyboard
mars.tools.DigitalLabSim.SevenSegmentPanel
java.awt.Window (implements javax.accessibility.Accessible)
java.awt.Frame (implements java.awt.MenuContainer)
javax.swing.JFrame (implements javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants)
mars.tools.AbstractMarsToolAndApplication (implements mars.tools.MarsTool, java.util.Observer)
mars.tools.BHTSimulator (implements java.awt.event.ActionListener)
mars.tools.BitmapDisplay
mars.tools.CacheSimulator
mars.tools.DigitalLabSim
mars.tools.FloatRepresentation
mars.tools.InstructionCounter
mars.tools.InstructionStatistics
mars.tools.IntroToTools
mars.tools.KeyboardAndDisplaySimulator
mars.tools.MemoryReferenceVisualization
mars.tools.DigitalLabSim.HexaKeyboard.EcouteurClick (implements java.awt.event.MouseListener)
mars.tools.DigitalLabSim.OneSecondCounter
java.awt.event.KeyAdapter (implements java.awt.event.KeyListener)
mars.tools.AbstractMarsToolAndApplication.EnterKeyListener
mars.tools.MarsBot (implements mars.tools.MarsTool, java.util.Observer)
mars.tools.ScavengerHunt (implements mars.tools.MarsTool, java.util.Observer)
mars.tools.ScreenMagnifier (implements mars.tools.MarsTool)
Interface Hierarchy
mars.tools.MarsTool
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
ScavengerHunt
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class ScavengerHunt
java.lang.Object
mars.tools.ScavengerHunt
All Implemented Interfaces:
Observer, MarsTool
public class ScavengerHunt
extends Object
implements Observer, MarsTool
Demo of Mars tool capability. Ken Vollmar, 27 Oct 2006 KenVollmar@missouristate.edu
This tool displays movements by a series of players in a game of ScavengerHunt.
Players will read and write MIPS memory-mapped locations to move and regain energy.
See accompanying documentation for memory-mapped addresses, rules of the game, etc.
Constructor Summary
ScavengerHunt()
Method Summary
void action()
Performs tool functions.
String getName()
Return a name you have chosen for this tool.
void update(Observable o,
Object arg)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
ScavengerHunt
public ScavengerHunt()
Method Detail
getName
public String getName()
Description copied from interface: MarsTool
Return a name you have chosen for this tool. It will appear as the
menu item.
Specified by:
getName in interface MarsTool
action
public void action()
Description copied from interface: MarsTool
Performs tool functions. It will be invoked when the tool is selected
from the Tools menu.
Specified by:
action in interface MarsTool
update
public void update(Observable o,
Object arg)
Specified by:
update in interface Observer
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
ScreenMagnifier
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.tools
Class ScreenMagnifier
java.lang.Object
mars.tools.ScreenMagnifier
All Implemented Interfaces:
MarsTool
public class ScreenMagnifier
extends Object
implements MarsTool
Handy little tool to magnify a selected section of the screen
by a given scale and display it. The screen image snapshot
will be of the screen pixels beneath the tool’s frame. The
scale can be adjusted. The image is displayed in the tool’s
scrollable panel. You can highlight items on the image using
the scribbler (hold down mouse button and move it on the
image). The magnification scale adjustment is on the tool’s
window, but other settings can be modified on a button-
triggered dialog. It will capture the contents of the
underlying MARS graphical user interface, but NOT the
contents of other Mars Tools frames.
Author:
Pete Sanderson
Constructor Summary
ScreenMagnifier()
Method Summary
void action()
Performs tool functions.
String getName()
Return a name you have chosen for this tool.
static void main(String[] args)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
ScreenMagnifier
public ScreenMagnifier()
Method Detail
getName
public String getName()
Description copied from interface: MarsTool
Return a name you have chosen for this tool. It will appear as the
menu item.
Specified by:
getName in interface MarsTool
action
public void action()
Description copied from interface: MarsTool
Performs tool functions. It will be invoked when the tool is selected
from the Tools menu.
Specified by:
action in interface MarsTool
main
public static void main(String[] args)
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Binary
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.util
Class Binary
java.lang.Object
mars.util.Binary
public class Binary
extends Object
Some utility methods for working with binary representations.
Author:
Pete Sanderson, Ken Vollmar, and Jason Bumgarner
Constructor Summary
Binary()
Method Summary
static char binaryStringToHexDigit(String value)
Translate String consisting of ‘1’s and ‘0’s into char equivalent of the corresponding
hexadecimal digit.
static String binaryStringToHexString(String value)
Translate String consisting of ‘1’s and ‘0’s into String equivalent of the corresponding
hexadecimal value.
static int binaryStringToInt(String value)
Translate String consisting of ‘1’s and ‘0’s into an int value having that binary representation.
static long binaryStringToLong(String value)
Translate String consisting of ‘1’s and ‘0’s into a long value having that binary representation.
static int bitValue(int value,
int bit)
Returns the bit value of the given bit position of the given int value.
static int bitValue(long value,
int bit)
Returns the bit value of the given bit position of the given long value.
static int clearBit(int value,
int bit)
Sets the specified bit of the specified value to 0, and returns the result.
static int getByte(int value,
int bite)
Gets the specified byte of the specified value.
static String hexStringToBinaryString(String value)
Translate String consisting of hexadecimal digits into String consisting of
corresponding binary digits (‘1’s and ‘0’s).
static int highOrderLongToInt(long longValue)
Returns int representing the bit values of the high order 32 bits of given
64 bit long value.
static String intToAscii(int d)
Produce ASCII string equivalent of integer value, interpreting it as 4 one-byte
characters.
static String intToBinaryString(int value)
Translate int value into a String consisting of ‘1’s and ‘0’s.
static String intToBinaryString(int value,
int length)
Translate int value into a String consisting of ‘1’s and ‘0’s.
static String intToHalfHexString(int d)
Returns a 6 character string representing the 16-bit hexadecimal equivalent of the
given integer value.
static String intToHexString(int d)
Prefix a hexadecimal-indicating string “0x” to the string which is
returned by the method “Integer.toHexString”.
static boolean isHex(String v)
Parsing method to see if a string represents a hex number.
static boolean isOctal(String v)
Parsing method to see if a string represents an octal number.
static String longToBinaryString(long value)
Translate long value into a String consisting of ‘1’s and ‘0’s.
static String longToBinaryString(long value,
int length)
Translate long value into a String consisting of ‘1’s and ‘0’s.
static String longToHexString(long value)
Prefix a hexadecimal-indicating string “0x” to the string equivalent to the
hexadecimal value in the long parameter.
static int lowOrderLongToInt(long longValue)
Returns int representing the bit values of the low order 32 bits of given
64 bit long value.
static int setBit(int value,
int bit)
Sets the specified bit of the specified value to 1, and returns the result.
static int setByte(int value,
int bite,
int replace)
Sets the specified byte of the specified value to the low order 8 bits of
specified replacement value, and returns the result.
static int stringToInt(String s)
Attempt to validate given string whose characters represent a 32 bit integer.
static long stringToLong(String s)
Attempt to validate given string whose characters represent a 64 bit long.
static long twoIntsToLong(int highOrder,
int lowOrder)
Returns long (64 bit integer) combining the bit values of two given 32 bit
integer values.
static String unsignedIntToIntString(int d)
Produce String equivalent of integer value interpreting it as an unsigned integer.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
Binary
public Binary()
Method Detail
intToBinaryString
public static String intToBinaryString(int value,
int length)
Translate int value into a String consisting of ‘1’s and ‘0’s.
Parameters:
value – The int value to convert.
length – The number of bit positions, starting at least significant, to process.
Returns:
String consisting of ‘1’ and ‘0’ characters corresponding to the requested binary sequence.
intToBinaryString
public static String intToBinaryString(int value)
Translate int value into a String consisting of ‘1’s and ‘0’s. Assumes all 32 bits are
to be translated.
Parameters:
value – The int value to convert.
Returns:
String consisting of ‘1’ and ‘0’ characters corresponding to the requested binary sequence.
longToBinaryString
public static String longToBinaryString(long value,
int length)
Translate long value into a String consisting of ‘1’s and ‘0’s.
Parameters:
value – The long value to convert.
length – The number of bit positions, starting at least significant, to process.
Returns:
String consisting of ‘1’ and ‘0’ characters corresponding to the requested binary sequence.
longToBinaryString
public static String longToBinaryString(long value)
Translate long value into a String consisting of ‘1’s and ‘0’s. Assumes all 64 bits are
to be translated.
Parameters:
value – The long value to convert.
Returns:
String consisting of ‘1’ and ‘0’ characters corresponding to the requested binary sequence.
binaryStringToInt
public static int binaryStringToInt(String value)
Translate String consisting of ‘1’s and ‘0’s into an int value having that binary representation.
The String is assumed to be at most 32 characters long. No error checking is performed.
String position 0 has most-significant bit, position length-1 has least-significant.
Parameters:
value – The String value to convert.
Returns:
int whose binary value corresponds to decoded String.
binaryStringToLong
public static long binaryStringToLong(String value)
Translate String consisting of ‘1’s and ‘0’s into a long value having that binary representation.
The String is assumed to be at most 64 characters long. No error checking is performed.
String position 0 has most-significant bit, position length-1 has least-significant.
Parameters:
value – The String value to convert.
Returns:
long whose binary value corresponds to decoded String.
binaryStringToHexString
public static String binaryStringToHexString(String value)
Translate String consisting of ‘1’s and ‘0’s into String equivalent of the corresponding
hexadecimal value. No length limit.
String position 0 has most-significant bit, position length-1 has least-significant.
Parameters:
value – The String value to convert.
Returns:
String containing ‘0’, ‘1’, …’F’ characters which form hexadecimal
equivalent of decoded String.
hexStringToBinaryString
public static String hexStringToBinaryString(String value)
Translate String consisting of hexadecimal digits into String consisting of
corresponding binary digits (‘1’s and ‘0’s). No length limit.
String position 0 will have most-significant bit, position length-1 has least-significant.
Parameters:
value – String containing ‘0’, ‘1’, …’f’
characters which form hexadecimal. Letters may be either upper or lower case.
Works either with or without leading “Ox”.
Returns:
String with equivalent value in binary.
binaryStringToHexDigit
public static char binaryStringToHexDigit(String value)
Translate String consisting of ‘1’s and ‘0’s into char equivalent of the corresponding
hexadecimal digit. String limited to length 4.
String position 0 has most-significant bit, position length-1 has least-significant.
Parameters:
value – The String value to convert.
Returns:
char ‘0’, ‘1’, …’F’ which form hexadecimal equivalent of decoded String.
If string length > 4, returns ‘0’.
intToHexString
public static String intToHexString(int d)
Prefix a hexadecimal-indicating string “0x” to the string which is
returned by the method “Integer.toHexString”. Prepend leading zeroes
to that string as necessary to make it always eight hexadecimal digits.
Parameters:
d – The int value to convert.
Returns:
String containing ‘0’, ‘1’, …’F’ which form hexadecimal equivalent of int.
intToHalfHexString
public static String intToHalfHexString(int d)
Returns a 6 character string representing the 16-bit hexadecimal equivalent of the
given integer value. First two characters are “0x”. It assumes value will “fit”
in 16 bits. If non-negative, prepend leading zeroes to that string as necessary
to make it always four hexadecimal digits. If negative, chop off the first
four ‘f’ digits so result is always four hexadecimal digits
Parameters:
d – The int value to convert.
Returns:
String containing ‘0’, ‘1’, …’F’ which form hexadecimal equivalent of int.
longToHexString
public static String longToHexString(long value)
Prefix a hexadecimal-indicating string “0x” to the string equivalent to the
hexadecimal value in the long parameter. Prepend leading zeroes
to that string as necessary to make it always sixteen hexadecimal digits.
Parameters:
value – The long value to convert.
Returns:
String containing ‘0’, ‘1’, …’F’ which form hexadecimal equivalent of long.
unsignedIntToIntString
public static String unsignedIntToIntString(int d)
Produce String equivalent of integer value interpreting it as an unsigned integer.
For instance, -1 (0xffffffff) produces “4294967295” instead of “-1”.
Parameters:
d – The int value to interpret.
Returns:
String which forms unsigned 32 bit equivalent of int.
intToAscii
public static String intToAscii(int d)
Produce ASCII string equivalent of integer value, interpreting it as 4 one-byte
characters. If the value in a given byte does not correspond to a printable
character, it will be assigned a default character (defined in config.properties)
for a placeholder.
Parameters:
d – The int value to interpret
Returns:
String that represents ASCII equivalent
stringToInt
public static int stringToInt(String s)
throws NumberFormatException
Attempt to validate given string whose characters represent a 32 bit integer.
Integer.decode() is insufficient because it will not allow incorporation of
hex two’s complement (i.e. 0x80…0 through 0xff…f). Allows
optional negative (-) sign but no embedded spaces.
Parameters:
s – candidate string
Returns:
returns int value represented by given string
Throws:
NumberFormatException – if string cannot be translated into an int
stringToLong
public static long stringToLong(String s)
throws NumberFormatException
Attempt to validate given string whose characters represent a 64 bit long.
Long.decode() is insufficient because it will not allow incorporation of
hex two’s complement (i.e. 0x80…0 through 0xff…f). Allows
optional negative (-) sign but no embedded spaces.
Parameters:
s – candidate string
Returns:
returns long value represented by given string
Throws:
NumberFormatException – if string cannot be translated into a long
highOrderLongToInt
public static int highOrderLongToInt(long longValue)
Returns int representing the bit values of the high order 32 bits of given
64 bit long value.
Parameters:
longValue – The long value from which to extract bits.
Returns:
int containing high order 32 bits of argument
lowOrderLongToInt
public static int lowOrderLongToInt(long longValue)
Returns int representing the bit values of the low order 32 bits of given
64 bit long value.
Parameters:
longValue – The long value from which to extract bits.
Returns:
int containing low order 32 bits of argument
twoIntsToLong
public static long twoIntsToLong(int highOrder,
int lowOrder)
Returns long (64 bit integer) combining the bit values of two given 32 bit
integer values.
Parameters:
highOrder – Integer to form the high-order 32 bits of result.
lowOrder – Integer to form the high-order 32 bits of result.
Returns:
long containing concatenated 32 bit int values.
bitValue
public static int bitValue(int value,
int bit)
Returns the bit value of the given bit position of the given int value.
Parameters:
value – The value to read the bit from.
bit – bit position in range 0 (least significant) to 31 (most)
Returns:
0 if the bit position contains 0, and 1 otherwise.
bitValue
public static int bitValue(long value,
int bit)
Returns the bit value of the given bit position of the given long value.
Parameters:
value – The value to read the bit from.
bit – bit position in range 0 (least significant) to 63 (most)
Returns:
0 if the bit position contains 0, and 1 otherwise.
setBit
public static int setBit(int value,
int bit)
Sets the specified bit of the specified value to 1, and returns the result.
Parameters:
value – The value in which the bit is to be set.
bit – bit position in range 0 (least significant) to 31 (most)
Returns:
value possibly modified with given bit set to 1.
clearBit
public static int clearBit(int value,
int bit)
Sets the specified bit of the specified value to 0, and returns the result.
Parameters:
value – The value in which the bit is to be set.
bit – bit position in range 0 (least significant) to 31 (most)
Returns:
value possibly modified with given bit set to 0.
setByte
public static int setByte(int value,
int bite,
int replace)
Sets the specified byte of the specified value to the low order 8 bits of
specified replacement value, and returns the result.
Parameters:
value – The value in which the byte is to be set.
bite – byte position in range 0 (least significant) to 3 (most)
replace – value to place into that byte position – use low order 8 bits
Returns:
value modified value.
getByte
public static int getByte(int value,
int bite)
Gets the specified byte of the specified value.
Parameters:
value – The value in which the byte is to be retrieved.
bite – byte position in range 0 (least significant) to 3 (most)
Returns:
zero-extended byte value in low order byte.
isHex
public static boolean isHex(String v)
Parsing method to see if a string represents a hex number.
As per http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Integer.html#decode(java.lang.String),
a string represents a hex number if the string is in the forms:
Signopt 0x HexDigits
Signopt 0X HexDigits
Signopt # HexDigits
Parameters:
v – String containing numeric digits (could be decimal, octal, or hex)
Returns:
Returns true if string represents a hex number, else returns false.
isOctal
public static boolean isOctal(String v)
Parsing method to see if a string represents an octal number.
As per http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Integer.html#decode(java.lang.String),
a string represents an octal number if the string is in the forms:
Signopt 0 OctalDigits
Parameters:
v – String containing numeric digits (could be decimal, octal, or hex)
Returns:
Returns true if string represents an octal number, else returns false.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
EditorFont
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.util
Class EditorFont
java.lang.Object
mars.util.EditorFont
public class EditorFont
extends Object
Specialized Font class designed to be used by both the
settings menu methods and the Settings class.
Author:
Pete Sanderson
Field Summary
static int DEFAULT_SIZE
static int DEFAULT_STYLE_INT
static String DEFAULT_STYLE_STRING
static int MAX_SIZE
static int MIN_SIZE
Constructor Summary
EditorFont()
Method Summary
static Font createFontFromStringValues(String family,
String style,
String size)
Creates a new Font object based on the given String specifications.
static String[] getAllFamilies()
Obtain an array of all available font family names.
static String[] getCommonFamilies()
Obtain an array of common font family names.
static String[] getFontStyleStrings()
Get array containing String values for font style names.
static String sizeIntToSizeString(int size)
Given an int representing font size, returns corresponding string.
static int sizeStringToSizeInt(String size)
Given a String representing font size, returns corresponding int.
static String styleIntToStyleString(int style)
Given an int that represents a font style from the Font class,
returns the corresponding String.
static int styleStringToStyleInt(String style)
Given a string that represents a font style, returns the
corresponding final int defined in Font: PLAIN, BOLD, ITALIC.
static String substituteSpacesForTabs(String string)
static String substituteSpacesForTabs(String string,
int tabSize)
Handy utility to produce a string that substitutes spaces for all tab characters
in the given string.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
DEFAULT_STYLE_STRING
public static final String DEFAULT_STYLE_STRING
DEFAULT_STYLE_INT
public static final int DEFAULT_STYLE_INT
MIN_SIZE
public static final int MIN_SIZE
See Also:
Constant Field Values
MAX_SIZE
public static final int MAX_SIZE
See Also:
Constant Field Values
DEFAULT_SIZE
public static final int DEFAULT_SIZE
See Also:
Constant Field Values
Constructor Detail
EditorFont
public EditorFont()
Method Detail
getCommonFamilies
public static String[] getCommonFamilies()
Obtain an array of common font family names. These are guaranteed to
be available at runtime, as they were checked against the local
GraphicsEnvironment.
Returns:
Array of strings, each is a common and available font family name.
getAllFamilies
public static String[] getAllFamilies()
Obtain an array of all available font family names. These are guaranteed to
be available at runtime, as they come from the local GraphicsEnvironment.
Returns:
Array of strings, each is an available font family name.
getFontStyleStrings
public static String[] getFontStyleStrings()
Get array containing String values for font style names.
styleStringToStyleInt
public static int styleStringToStyleInt(String style)
Given a string that represents a font style, returns the
corresponding final int defined in Font: PLAIN, BOLD, ITALIC. It
is not case-sensitive.
Parameters:
style – String representing the font style name
Returns:
The int value of the corresponding Font style constant. If the
string does not match any style name, returns Font.PLAIN.
styleIntToStyleString
public static String styleIntToStyleString(int style)
Given an int that represents a font style from the Font class,
returns the corresponding String.
Parameters:
style – Must be one of Font.PLAIN, Font.BOLD, Font.ITALIC.
Returns:
The String representation of that style. If the parameter
is not one of the above, returns “Plain”.
sizeIntToSizeString
public static String sizeIntToSizeString(int size)
Given an int representing font size, returns corresponding string.
Parameters:
size – Int representing size.
Returns:
String value of parameter, unless it is less than MIN_SIZE (returns MIN_SIZE
as String) or greater than MAX_SIZE (returns MAX_SIZE as String).
sizeStringToSizeInt
public static int sizeStringToSizeInt(String size)
Given a String representing font size, returns corresponding int.
Parameters:
size – String representing size.
Returns:
int value of parameter, unless it is less than MIN_SIZE (returns
MIN_SIZE) or greater than MAX_SIZE (returns MAX_SIZE). If the string
cannot be parsed as a decimal integer, it returns DEFAULT_SIZE.
createFontFromStringValues
public static Font createFontFromStringValues(String family,
String style,
String size)
Creates a new Font object based on the given String specifications. This
is different than Font’s constructor, which requires ints for style and size.
It assures that defaults and size limits are applied when necessary.
Parameters:
family – String containing font family.
style – String containing font style. A list of available styles can
be obtained from getFontStyleStrings(). The default of styleStringToStyleInt()
is substituted if necessary.
size – String containing font size. The defaults and limits of
sizeStringToSizeInt() are substituted if necessary.
substituteSpacesForTabs
public static String substituteSpacesForTabs(String string)
substituteSpacesForTabs
public static String substituteSpacesForTabs(String string,
int tabSize)
Handy utility to produce a string that substitutes spaces for all tab characters
in the given string. The number of spaces generated is based on the position of
the tab character and the specified tab size.
Parameters:
string – The original string
tabSize – The number of spaces each tab character represents
Returns:
New string in which spaces are substituted for tabs
Throws:
NullPointerException – if string is null
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
FilenameFinder
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.util
Class FilenameFinder
java.lang.Object
mars.util.FilenameFinder
public class FilenameFinder
extends Object
Utility class to perform necessary file-related search
operations. One is to find file names in JAR file,
another is to find names of files in given directory
of normal file system.
Author:
Pete Sanderson
Field Summary
static String MATCH_ALL_EXTENSIONS
Constructor Summary
FilenameFinder()
Method Summary
static boolean fileExtensionMatch(String name,
String extension)
Determine if given filename ends with given extension.
static String getExtension(File file)
Get the filename extension of the specified File.
static FileFilter getFileFilter(ArrayList extensions,
String description)
Get a FileFilter that will filter files based on the given list of filename extensions.
static FileFilter getFileFilter(ArrayList extensions,
String description,
boolean acceptDirectories)
Get a FileFilter that will filter files based on the given list of filename extensions.
static FileFilter getFileFilter(String extension,
String description)
Get a FileFilter that will filter files based on the given filename extension.
static FileFilter getFileFilter(String extension,
String description,
boolean acceptDirectories)
Get a FileFilter that will filter files based on the given filename extension.
static ArrayList getFilenameList(ArrayList nameList,
ArrayList fileExtensions)
Return list of file names.
static ArrayList getFilenameList(ArrayList nameList,
String fileExtension)
Return list of file names.
static ArrayList getFilenameList(ClassLoader classLoader,
String directoryPath,
ArrayList fileExtensions)
Locate files and return list of file names.
static ArrayList getFilenameList(ClassLoader classLoader,
String directoryPath,
String fileExtension)
Locate files and return list of file names.
static ArrayList getFilenameList(String directoryPath,
ArrayList fileExtensions)
Locate files and return list of file names.
static ArrayList getFilenameList(String directoryPath,
String fileExtension)
Locate files and return list of file names.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
MATCH_ALL_EXTENSIONS
public static String MATCH_ALL_EXTENSIONS
Constructor Detail
FilenameFinder
public FilenameFinder()
Method Detail
getFilenameList
public static ArrayList getFilenameList(ClassLoader classLoader,
String directoryPath,
String fileExtension)
Locate files and return list of file names. Given a known relative directory path,
it will locate it and build list of all names of files in that directory
having the given file extension. If the “known file path” doesn’t work
because MARS is running from an executable JAR file, it will locate the
directory in the JAR file and proceed from there. NOTE: since this uses
the class loader to get the resource, the directory path needs to be
relative to classpath, not absolute. To work with an arbitrary file system,
use the other version of this overloaded method. Will NOT match directories
that happen to have the desired extension.
Parameters:
classLoader – class loader to use
directoryPath – Search will be confined to this directory. Use “/” as
separator but do NOT include starting or ending “/” (e.g. mars/tools)
fileExtension – Only files with this extension will be added
to the list. Do NOT include the “.” in extension.
Returns:
array list of matching file names as Strings. If none, list is empty.
getFilenameList
public static ArrayList getFilenameList(ClassLoader classLoader,
String directoryPath,
ArrayList fileExtensions)
Locate files and return list of file names. Given a known relative directory path,
it will locate it and build list of all names of files in that directory
having the given file extension. If the “known file path” doesn’t work
because MARS is running from an executable JAR file, it will locate the
directory in the JAR file and proceed from there. NOTE: since this uses
the class loader to get the resource, the directory path needs to be
relative to classpath, not absolute. To work with an arbitrary file system,
use the other version of this overloaded method.
Parameters:
classLoader – class loader to use
directoryPath – Search will be confined to this directory. Use “/” as
separator but do NOT include starting or ending “/” (e.g. mars/tools)
fileExtensions – ArrayList of Strings containing file extensions.
Only files with an extension in this list will be added to the list.
Do NOT include the “.”, eg “class” not “.class”. If Arraylist or
extension null or empty, all files are added.
Returns:
array list of matching file names as Strings. If none, list is empty.
getFilenameList
public static ArrayList getFilenameList(String directoryPath,
String fileExtension)
Locate files and return list of file names. Given a known directory path,
it will locate it and build list of all names of files in that directory
having the given file extension. If file extenion is null or empty, all
filenames are returned. Returned list contains absolute filename paths.
Parameters:
directoryPath – Search will be confined to this directory.
fileExtension – Only files with this extension will be added to the list.
Do NOT include “.” in extension.
If null or empty string, all files are added.
Returns:
array list of matching file names (absolute path). If none, list is empty.
getFilenameList
public static ArrayList getFilenameList(String directoryPath,
ArrayList fileExtensions)
Locate files and return list of file names. Given a known directory path,
it will locate it and build list of all names of files in that directory
having the given file extension. If file extenion is null or empty, all
filenames are returned. Returned list contains absolute filename paths.
Parameters:
directoryPath – Search will be confined to this directory.
fileExtensions – ArrayList of Strings containing file extensions.
Only files with an extension in this list will be added
to the list. Do NOT include the “.” in extensions. If Arraylist or
extension null or empty, all files are added.
Returns:
array list of matching file names (absolute path). If none, list is empty.
getFilenameList
public static ArrayList getFilenameList(ArrayList nameList,
String fileExtension)
Return list of file names. Given a list of file names, it will return the list
of all having the given file extension. If file extenion is null or empty, all
filenames are returned. Returned list contains absolute filename paths.
Parameters:
nameList – ArrayList of String containing file names.
fileExtension – Only files with this extension will be added to the list.
If null or empty string, all files are added. Do NOT include “.” in extension.
Returns:
array list of matching file names (absolute path). If none, list is empty.
getFilenameList
public static ArrayList getFilenameList(ArrayList nameList,
ArrayList fileExtensions)
Return list of file names. Given a list of file names, it will return the list
of all having the given file extension. If file extenion is null or empty, all
filenames are returned. Returned list contains absolute filename paths.
Parameters:
nameList – ArrayList of String containing file names.
fileExtensions – ArrayList of Strings containing file extensions.
Only files with an extension in this list will be added
to the list. Do NOT include the “.” in extensions. If Arraylist or
extension null or empty, all files are added.
Returns:
array list of matching file names (absolute path). If none, list is empty.
getExtension
public static String getExtension(File file)
Get the filename extension of the specified File.
Parameters:
file – the File object representing the file of interest
Returns:
The filename extension (everything that follows
last ‘.’ in filename) or null if none.
getFileFilter
public static FileFilter getFileFilter(ArrayList extensions,
String description,
boolean acceptDirectories)
Get a FileFilter that will filter files based on the given list of filename extensions.
Parameters:
extensions – ArrayList of Strings, each string is acceptable filename extension.
description – String containing description to be added in parentheses after list of extensions.
acceptDirectories – boolean value true if directories are accepted by the filter, false otherwise.
Returns:
a FileFilter object that accepts files with given extensions, and directories if so indicated.
getFileFilter
public static FileFilter getFileFilter(ArrayList extensions,
String description)
Get a FileFilter that will filter files based on the given list of filename extensions.
All directories are accepted by the filter.
Parameters:
extensions – ArrayList of Strings, each string is acceptable filename extension
description – String containing description to be added in parentheses after list of extensions.
Returns:
a FileFilter object that accepts files with given extensions, and directories if so indicated.
getFileFilter
public static FileFilter getFileFilter(String extension,
String description,
boolean acceptDirectories)
Get a FileFilter that will filter files based on the given filename extension.
Parameters:
extension – String containing acceptable filename extension.
description – String containing description to be added in parentheses after list of extensions.
acceptDirectories – boolean value true if directories are accepted by the filter, false otherwise.
Returns:
a FileFilter object that accepts files with given extensions, and directories if so indicated.
getFileFilter
public static FileFilter getFileFilter(String extension,
String description)
Get a FileFilter that will filter files based on the given filename extension.
All directories are accepted by the filter.
Parameters:
extension – String containing acceptable filename extension
description – String containing description to be added in parentheses after list of extensions.
Returns:
a FileFilter object that accepts files with given extensions, and directories if so indicated.
fileExtensionMatch
public static boolean fileExtensionMatch(String name,
String extension)
Determine if given filename ends with given extension.
Parameters:
name – A String containing the file name
extension – A String containing the file extension. Leading period is optional.
Returns:
Returns true if filename ends with given extension, false otherwise.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
MemoryDump
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.util
Class MemoryDump
java.lang.Object
mars.util.MemoryDump
public class MemoryDump
extends Object
Field Summary
static ArrayList dumpTriples
A list of segmentname/dumpformat/filename triples which should be dumped
Constructor Summary
MemoryDump()
Method Summary
static int getAddressOfFirstNull(int baseAddress,
int limitAddress)
Look for first “null” memory value in an address range.
static int[] getBaseAddresses(String[] segments)
Get the MIPS memory base address(es) of the specified segment name(s).
static int[] getLimitAddresses(String[] segments)
Get the MIPS memory limit address(es) of the specified segment name(s).
static Integer[] getSegmentBounds(String segment)
Return array with segment address bounds for specified segment.
static String[] getSegmentNames()
Get the names of segments available for memory dump.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
dumpTriples
public static ArrayList dumpTriples
A list of segmentname/dumpformat/filename triples which should be dumped
Constructor Detail
MemoryDump
public MemoryDump()
Method Detail
getSegmentBounds
public static Integer[] getSegmentBounds(String segment)
Return array with segment address bounds for specified segment.
Parameters:
segment – String with segment name (initially “.text” and “.data”)
Returns:
array of two Integer, the base and limit address for that segment. Null if parameter
name does not match a known segment name.
getSegmentNames
public static String[] getSegmentNames()
Get the names of segments available for memory dump.
Returns:
array of Strings, each string is segment name (e.g. “.text”, “.data”)
getBaseAddresses
public static int[] getBaseAddresses(String[] segments)
Get the MIPS memory base address(es) of the specified segment name(s).
If invalid segment name is provided, will throw NullPointerException, so
I recommend getting segment names from getSegmentNames().
Parameters:
segments – Array of Strings containing segment names (“.text”, “.data”)
Returns:
Array of int containing corresponding base addresses.
getLimitAddresses
public static int[] getLimitAddresses(String[] segments)
Get the MIPS memory limit address(es) of the specified segment name(s).
If invalid segment name is provided, will throw NullPointerException, so
I recommend getting segment names from getSegmentNames().
Parameters:
segments – Array of Strings containing segment names (“.text”, “.data”)
Returns:
Array of int containing corresponding limit addresses.
getAddressOfFirstNull
public static int getAddressOfFirstNull(int baseAddress,
int limitAddress)
throws AddressErrorException
Look for first “null” memory value in an address range. For text segment (binary code), this
represents a word that does not contain an instruction. Normally use this to find the end of
the program. For data segment, this represents the first block of simulated memory (block length
currently 4K words) that has not been referenced by an assembled/executing program.
Parameters:
baseAddress – lowest MIPS address to be searched; the starting point
limitAddress – highest MIPS address to be searched
Returns:
lowest address within specified range that contains “null” value as described above.
Throws:
AddressErrorException – if the base address is not on a word boundary
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.util
mars.util
Classes
Binary
EditorFont
FilenameFinder
MemoryDump
PropertiesFile
SystemIO
mars.util
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
Package mars.util
Class Summary
Binary Some utility methods for working with binary representations.
EditorFont Specialized Font class designed to be used by both the
settings menu methods and the Settings class.
FilenameFinder Utility class to perform necessary file-related search
operations.
MemoryDump
PropertiesFile Provides means to work with “.properties” files which are used to store
various MARS settings.
SystemIO Provides standard i/o services needed to simulate the MIPS syscall
routines.
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
mars.util Class Hierarchy
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Hierarchy For Package mars.util
Package Hierarchies:
All Packages
Class Hierarchy
java.lang.Object mars.util.Binary
mars.util.EditorFont
mars.util.FilenameFinder
mars.util.MemoryDump
mars.util.PropertiesFile
mars.util.SystemIO
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
PropertiesFile
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.util
Class PropertiesFile
java.lang.Object
mars.util.PropertiesFile
public class PropertiesFile
extends Object
Provides means to work with “.properties” files which are used to store
various MARS settings.
Author:
Pete Sanderson
Constructor Summary
PropertiesFile()
Method Summary
static Properties loadPropertiesFromFile(String file)
Produce Properties (a Hashtable) object containing key-value pairs
from specified properties file.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
PropertiesFile
public PropertiesFile()
Method Detail
loadPropertiesFromFile
public static Properties loadPropertiesFromFile(String file)
Produce Properties (a Hashtable) object containing key-value pairs
from specified properties file. This may be used as an alternative
to readPropertiesFile() which uses a different implementation.
Parameters:
file – Properties filename. Do NOT include the file extension as
it is assumed to be “.properties” and is added here.
Returns:
Properties (Hashtable) of key-value pairs read from the file.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SystemIO
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.util
Class SystemIO
java.lang.Object
mars.util.SystemIO
public class SystemIO
extends Object
Provides standard i/o services needed to simulate the MIPS syscall
routines. These methods will detect whether the simulator is being
run from the command line or through the GUI, then do I/O to
System.in and System.out in the former situation, and interact with
the GUI in the latter.
Author:
Pete Sanderson and Ken Vollmar
Field Summary
static String fileErrorString
String used for description of file error
static int SYSCALL_BUFSIZE
Buffer size for syscalls for file I/O
static int SYSCALL_MAXFILES
Maximum number of files that can be open
Constructor Summary
SystemIO()
Method Summary
static void closeFile(int fd)
Close the file with specified file descriptor
static String getFileErrorMessage()
Retrieve file operation or error message
static int openFile(String filename,
int flags)
Open a file for either reading or writing.
static void printString(String string)
Implements syscall having 4 in $v0, to print a string.
static int readChar(int serviceNumber)
Implements syscall having 12 in $v0, to read a char value.
static double readDouble(int serviceNumber)
Implements syscall to read a double value.
static float readFloat(int serviceNumber)
Implements syscall to read a float value.
static int readFromFile(int fd,
byte[] myBuffer,
int lengthRequested)
Read bytes from file.
static int readInteger(int serviceNumber)
Implements syscall to read an integer value.
static String readString(int serviceNumber,
int maxLength)
Implements syscall to read a string.
static void resetFiles()
Reset all files — clears out the file descriptor table.
static int writeToFile(int fd,
byte[] myBuffer,
int lengthRequested)
Write bytes to file.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
SYSCALL_BUFSIZE
public static final int SYSCALL_BUFSIZE
Buffer size for syscalls for file I/O
See Also:
Constant Field Values
SYSCALL_MAXFILES
public static final int SYSCALL_MAXFILES
Maximum number of files that can be open
See Also:
Constant Field Values
fileErrorString
public static String fileErrorString
String used for description of file error
Constructor Detail
SystemIO
public SystemIO()
Method Detail
readInteger
public static int readInteger(int serviceNumber)
Implements syscall to read an integer value.
Client is responsible for catching NumberFormatException.
Parameters:
serviceNumber – the number assigned to Read Int syscall (default 5)
Returns:
int value corresponding to user input
readFloat
public static float readFloat(int serviceNumber)
Implements syscall to read a float value.
Client is responsible for catching NumberFormatException.
Parameters:
serviceNumber – the number assigned to Read Float syscall (default 6)
Returns:
float value corresponding to user input
Feb 14 2005 Ken Vollmar
readDouble
public static double readDouble(int serviceNumber)
Implements syscall to read a double value.
Client is responsible for catching NumberFormatException.
Parameters:
serviceNumber – the number assigned to Read Double syscall (default 7)
Returns:
double value corresponding to user input
1 Aug 2005 DPS, based on Ken Vollmar’s readFloat
printString
public static void printString(String string)
Implements syscall having 4 in $v0, to print a string.
readString
public static String readString(int serviceNumber,
int maxLength)
Implements syscall to read a string.
Parameters:
serviceNumber – the number assigned to Read String syscall (default 8)
maxLength – the maximum string length
Returns:
the entered string, truncated to maximum length if necessary
readChar
public static int readChar(int serviceNumber)
Implements syscall having 12 in $v0, to read a char value.
Parameters:
serviceNumber – the number assigned to Read Char syscall (default 12)
Returns:
int value with lowest byte corresponding to user input
writeToFile
public static int writeToFile(int fd,
byte[] myBuffer,
int lengthRequested)
Write bytes to file.
Parameters:
fd – file descriptor
myBuffer – byte array containing characters to write
lengthRequested – number of bytes to write
Returns:
number of bytes written, or -1 on error
readFromFile
public static int readFromFile(int fd,
byte[] myBuffer,
int lengthRequested)
Read bytes from file.
Parameters:
fd – file descriptor
myBuffer – byte array to contain bytes read
lengthRequested – number of bytes to read
Returns:
number of bytes read, 0 on EOF, or -1 on error
openFile
public static int openFile(String filename,
int flags)
Open a file for either reading or writing. Note that read/write flag is NOT
IMPLEMENTED. Also note that file permission modes are also NOT IMPLEMENTED.
Parameters:
filename – string containing filename
flag – 0 for read, 1 for write
Returns:
file descriptor in the range 0 to SYSCALL_MAXFILES-1, or -1 if error
closeFile
public static void closeFile(int fd)
Close the file with specified file descriptor
Parameters:
fd – the file descriptor of an open file
resetFiles
public static void resetFiles()
Reset all files — clears out the file descriptor table.
getFileErrorMessage
public static String getFileErrorMessage()
Retrieve file operation or error message
Returns:
string containing message
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
AbstractFontSettingDialog
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class AbstractFontSettingDialog
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
mars.venus.AbstractFontSettingDialog
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants
public abstract class AbstractFontSettingDialog
extends JDialog
Abstract class for a font selection dialog.
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialog
Nested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityType
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
protected Font currentFont
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPE
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
AbstractFontSettingDialog(Frame owner,
String title,
boolean modality,
Font currentFont)
Create a new font chooser.
Method Summary
protected abstract void apply(Font font)
Apply the given font.
protected abstract Component buildControlPanel()
protected JPanel buildDialogPanel()
protected void closeDialog()
Font getFont()
protected void performApply()
protected void reset()
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setTitle, setUndecorated, setVisible, show, toBack
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
currentFont
protected Font currentFont
Constructor Detail
AbstractFontSettingDialog
public AbstractFontSettingDialog(Frame owner,
String title,
boolean modality,
Font currentFont)
Create a new font chooser. Has pertinent JDialog parameters.
Will do everything except make it visible.
Method Detail
buildDialogPanel
protected JPanel buildDialogPanel()
buildControlPanel
protected abstract Component buildControlPanel()
getFont
public Font getFont()
Specified by:
getFont in interface MenuContainer
Overrides:
getFont in class Component
performApply
protected void performApply()
closeDialog
protected void closeDialog()
reset
protected void reset()
apply
protected abstract void apply(Font font)
Apply the given font. Left for the client to define.
Parameters:
font – a font to be applied by the client.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Coprocessor0Window
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class Coprocessor0Window
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
mars.venus.Coprocessor0Window
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Observer, Accessible
public class Coprocessor0Window
extends JPanel
implements Observer
Sets up a window to display registers in the UI.
Author:
Sanderson, Bumgarner
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
Coprocessor0Window()
Constructor which sets up a fresh window with a table that contains the register values.
Method Summary
void clearHighlighting()
Clear highlight background color from any row currently highlighted.
void clearWindow()
Reset and redisplay registers
void refresh()
Refresh the table, triggering re-rendering.
Object[][] setupWindow()
Sets up the data for the window.
void update(Observable observable,
Object obj)
Required by Observer interface.
void updateRegisters()
Update register display using current display base (10 or 16)
void updateRegisters(int base)
Update register display using specified display base
void updateRegisterValue(int number,
int val,
int base)
This method handles the updating of the GUI.
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
Coprocessor0Window
public Coprocessor0Window()
Constructor which sets up a fresh window with a table that contains the register values.
Method Detail
setupWindow
public Object[][] setupWindow()
Sets up the data for the window.
Returns:
The array object with the data for the window.
clearWindow
public void clearWindow()
Reset and redisplay registers
clearHighlighting
public void clearHighlighting()
Clear highlight background color from any row currently highlighted.
refresh
public void refresh()
Refresh the table, triggering re-rendering.
updateRegisters
public void updateRegisters()
Update register display using current display base (10 or 16)
updateRegisters
public void updateRegisters(int base)
Update register display using specified display base
Parameters:
base – number base for display (10 or 16)
updateRegisterValue
public void updateRegisterValue(int number,
int val,
int base)
This method handles the updating of the GUI.
Parameters:
number – The number of the register to update.
val – New value.
update
public void update(Observable observable,
Object obj)
Required by Observer interface. Called when notified by an Observable that we are registered with.
Observables include:
The Simulator object, which lets us know when it starts and stops running
A register object, which lets us know of register operations
The Simulator keeps us informed of when simulated MIPS execution is active.
This is the only time we care about register operations.
Specified by:
update in interface Observer
Parameters:
observable – The Observable object who is notifying us
obj – Auxiliary object with additional information.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Coprocessor1Window
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class Coprocessor1Window
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
mars.venus.Coprocessor1Window
All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Observer, Accessible
public class Coprocessor1Window
extends JPanel
implements ActionListener, Observer
Sets up a window to display Coprocessor 1 registers in the Registers pane of the UI.
Author:
Pete Sanderson 2005
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
Coprocessor1Window()
Constructor which sets up a fresh window with a table that contains the register values.
Method Summary
void actionPerformed(ActionEvent e)
Called when user clicks on a condition flag checkbox.
void clearHighlighting()
Clear highlight background color from any row currently highlighted.
void clearWindow()
Reset and redisplay registers.
void refresh()
Refresh the table, triggering re-rendering.
Object[][] setupWindow()
Sets up the data for the window.
void update(Observable observable,
Object obj)
Required by Observer interface.
void updateDoubleRegisterValue(int number,
int base)
This method handles the updating of the GUI.
void updateFloatRegisterValue(int number,
int val,
int base)
This method handles the updating of the GUI.
void updateRegisters()
Redisplay registers using current display number base (10 or 16)
void updateRegisters(int base)
Redisplay registers using specified display number base (10 or 16)
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
Coprocessor1Window
public Coprocessor1Window()
Constructor which sets up a fresh window with a table that contains the register values.
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Called when user clicks on a condition flag checkbox.
Updates both the display and the underlying Coprocessor 1 flag.
Specified by:
actionPerformed in interface ActionListener
Parameters:
e – component that triggered this call
setupWindow
public Object[][] setupWindow()
Sets up the data for the window.
Returns:
The array object with the data for the window.
clearWindow
public void clearWindow()
Reset and redisplay registers.
clearHighlighting
public void clearHighlighting()
Clear highlight background color from any row currently highlighted.
refresh
public void refresh()
Refresh the table, triggering re-rendering.
updateRegisters
public void updateRegisters()
Redisplay registers using current display number base (10 or 16)
updateRegisters
public void updateRegisters(int base)
Redisplay registers using specified display number base (10 or 16)
Parameters:
base – number base for display (10 or 16)
updateFloatRegisterValue
public void updateFloatRegisterValue(int number,
int val,
int base)
This method handles the updating of the GUI. Does not affect actual register.
Parameters:
number – The number of the float register whose display to update.
val – New value.
base – the number base for display (e.g. 10, 16)
updateDoubleRegisterValue
public void updateDoubleRegisterValue(int number,
int base)
This method handles the updating of the GUI. Does not affect actual register.
Parameters:
number – The number of the double register to update.
base – the number base for display (e.g. 10, 16)
update
public void update(Observable observable,
Object obj)
Required by Observer interface. Called when notified by an Observable that we are registered with.
Observables include:
The Simulator object, which lets us know when it starts and stops running
A register object, which lets us know of register operations
The Simulator keeps us informed of when simulated MIPS execution is active.
This is the only time we care about register operations.
Specified by:
update in interface Observer
Parameters:
observable – The Observable object who is notifying us
obj – Auxiliary object with additional information.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
DataSegmentWindow
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class DataSegmentWindow
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JInternalFrame
mars.venus.DataSegmentWindow
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Observer, Accessible, RootPaneContainer, WindowConstants
public class DataSegmentWindow
extends JInternalFrame
implements Observer
Represents the Data Segment window, which is a type of JInternalFrame.
Author:
Sanderson and Bumgarner
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JInternalFrame
JInternalFrame.AccessibleJInternalFrame, JInternalFrame.JDesktopIcon
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class javax.swing.JInternalFrame
closable, CONTENT_PANE_PROPERTY, desktopIcon, FRAME_ICON_PROPERTY, frameIcon, GLASS_PANE_PROPERTY, iconable, IS_CLOSED_PROPERTY, IS_ICON_PROPERTY, IS_MAXIMUM_PROPERTY, IS_SELECTED_PROPERTY, isClosed, isIcon, isMaximum, isSelected, LAYERED_PANE_PROPERTY, maximizable, MENU_BAR_PROPERTY, resizable, ROOT_PANE_PROPERTY, rootPane, rootPaneCheckingEnabled, title, TITLE_PROPERTY
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
DataSegmentWindow(NumberDisplayBaseChooser[] choosers)
Constructor for the Data Segment window.
Method Summary
void clearHighlighting()
Clear highlight background color from any cell currently highlighted.
void clearWindow()
Removes the table from its frame, typically done when a file is closed.
void resetMemoryRange()
Reset range of memory addresses to base address of currently selected segment and update display.
void resetValues()
Reset all data display values to 0
void setupTable()
Generates and displays fresh table, typically done upon successful assembly.
void update(Observable observable,
Object obj)
Required by Observer interface.
void updateBaseAddressComboBox()
void updateCell(int address,
int value)
Update data display to show this value (I’m not sure it is being called).
void updateDataAddresses()
Redisplay the addresses.
void updateModelForMemoryRange(int firstAddr)
Update table model with contents of new memory “chunk”.
void updateValues()
Update data display to show all values
Methods inherited from class javax.swing.JInternalFrame
addImpl, addInternalFrameListener, createRootPane, dispose, doDefaultCloseAction, fireInternalFrameEvent, getAccessibleContext, getContentPane, getDefaultCloseOperation, getDesktopIcon, getDesktopPane, getFocusCycleRootAncestor, getFocusOwner, getFrameIcon, getGlassPane, getInternalFrameListeners, getJMenuBar, getLastCursor, getLayer, getLayeredPane, getMenuBar, getMostRecentFocusOwner, getNormalBounds, getRootPane, getTitle, getUI, getUIClassID, getWarningString, hide, isClosable, isClosed, isFocusCycleRoot, isIcon, isIconifiable, isMaximizable, isMaximum, isResizable, isRootPaneCheckingEnabled, isSelected, moveToBack, moveToFront, pack, paintComponent, paramString, remove, removeInternalFrameListener, reshape, restoreSubcomponentFocus, setClosable, setClosed, setContentPane, setCursor, setDefaultCloseOperation, setDesktopIcon, setFocusCycleRoot, setFrameIcon, setGlassPane, setIcon, setIconifiable, setJMenuBar, setLayer, setLayer, setLayeredPane, setLayout, setMaximizable, setMaximum, setMenuBar, setNormalBounds, setResizable, setRootPane, setRootPaneCheckingEnabled, setSelected, setTitle, setUI, show, toBack, toFront, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
DataSegmentWindow
public DataSegmentWindow(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 Detail
updateBaseAddressComboBox
public void updateBaseAddressComboBox()
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 firstAddr)
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:
firstAddr – the first address in the memory range to be placed in the model.
updateCell
public void updateCell(int address,
int value)
Update data display to show this value (I’m not sure it is being called).
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
resetMemoryRange
public void resetMemoryRange()
Reset range of memory addresses to base address of currently selected segment and update display.
resetValues
public void resetValues()
Reset all data display values to 0
update
public void update(Observable observable,
Object obj)
Required by Observer interface. Called when notified by an Observable that we are registered with.
Observables include:
The Simulator object, which lets us know when it starts and stops running
A delegate of the Memory object, which lets us know of memory operations
The Simulator keeps us informed of when simulated MIPS execution is active.
This is the only time we care about memory operations.
Specified by:
update in interface Observer
Parameters:
observable – The Observable object who is notifying us
obj – Auxiliary object with additional information.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
EditCopyAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class EditCopyAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.EditCopyAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class EditCopyAction
extends GuiAction
Action for the Edit -> Copy menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
EditCopyAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
EditCopyAction
public EditCopyAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
EditCutAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class EditCutAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.EditCutAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class EditCutAction
extends GuiAction
Action for the Edit -> Cut menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
EditCutAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
EditCutAction
public EditCutAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
EditFindReplaceAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class EditFindReplaceAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.EditFindReplaceAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class EditFindReplaceAction
extends GuiAction
Action for the Edit -> Find/Replace menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
EditFindReplaceAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
EditFindReplaceAction
public EditFindReplaceAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Editor
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class Editor
java.lang.Object
mars.venus.Editor
public class Editor
extends Object
Manage the file being edited.
Currently only manages one file at a time, but can be expanded.
Field Summary
static int MAX_BLINK_RATE
static int MAX_TAB_SIZE
static int MIN_BLINK_RATE
static int MIN_TAB_SIZE
Constructor Summary
Editor(VenusUI ui)
Create editor.
Method Summary
boolean close()
Perform “close” operation on current tab’s file.
boolean closeAll()
Close all currently open files.
boolean editsSavedOrAbandoned()
Called by several of the Action objects when there is potential
loss of editing changes.
String getCurrentOpenDirectory()
Get name of current directory for Open operation.
String getCurrentSaveDirectory()
Get name of current directory for Save or Save As operation.
String getNextDefaultFilename()
Generates a default file name
void newFile()
Perform “new” operation to create an empty tab.
boolean open()
Open file in a new tab.
boolean save()
Perform “save” operation on current tab’s file.
boolean saveAll()
Perform save operation on all open files (tabs).
boolean saveAs()
Perform “save as” operation on current tab’s file.
void setEditTabbedPane(EditTabbedPane editTabbedPane)
Set associated EditTabbedPane.
void setTitle(String path,
String name,
int status)
Places name of file currently being edited into its edit tab and
the application’s title bar.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
MIN_TAB_SIZE
public static final int MIN_TAB_SIZE
See Also:
Constant Field Values
MAX_TAB_SIZE
public static final int MAX_TAB_SIZE
See Also:
Constant Field Values
MIN_BLINK_RATE
public static final int MIN_BLINK_RATE
See Also:
Constant Field Values
MAX_BLINK_RATE
public static final int MAX_BLINK_RATE
See Also:
Constant Field Values
Constructor Detail
Editor
public Editor(VenusUI ui)
Create editor.
Parameters:
ui – the GUI that owns this editor
Method Detail
setEditTabbedPane
public void setEditTabbedPane(EditTabbedPane editTabbedPane)
Set associated EditTabbedPane. This is container for any/all open files.
Parameters:
editTabbedPane – an existing editTabbedPane object
getCurrentOpenDirectory
public String getCurrentOpenDirectory()
Get name of current directory for Open operation.
Returns:
String containing directory pathname. Returns null if there is
no EditTabbedPane. Returns default, directory MARS is launched from, if
no Opens have been performed.
getCurrentSaveDirectory
public String getCurrentSaveDirectory()
Get name of current directory for Save or Save As operation.
Returns:
String containing directory pathname. Returns null if there is
no EditTabbedPane. Returns default, directory MARS is launched from, if
no Save or Save As operations have been performed.
getNextDefaultFilename
public String getNextDefaultFilename()
Generates a default file name
Returns:
returns string mipsN.asm, where N is 1,2,3,…
setTitle
public void setTitle(String path,
String name,
int status)
Places name of file currently being edited into its edit tab and
the application’s title bar. The edit tab will contain only
the filename, the title bar will contain full pathname.
If file has been modified since created, opened or saved, as
indicated by value of the status parameter, the name and path
will be followed with an ‘*’. If newly-created file has not
yet been saved, the title bar will show (temporary) file name
but not path.
Parameters:
path – Full pathname for file
name – Name of file (last component of path)
status – Edit status of file. See FileStatus static constants.
newFile
public void newFile()
Perform “new” operation to create an empty tab.
close
public boolean close()
Perform “close” operation on current tab’s file.
Returns:
true if succeeded, else false.
closeAll
public boolean closeAll()
Close all currently open files.
Returns:
true if succeeded, else false.
save
public boolean save()
Perform “save” operation on current tab’s file.
Returns:
true if succeeded, else false.
saveAs
public boolean saveAs()
Perform “save as” operation on current tab’s file.
Returns:
true if succeeded, else false.
saveAll
public boolean saveAll()
Perform save operation on all open files (tabs).
Returns:
true if succeeded, else false.
open
public boolean open()
Open file in a new tab.
Returns:
true if succeeded, else false.
editsSavedOrAbandoned
public boolean editsSavedOrAbandoned()
Called by several of the Action objects when there is potential
loss of editing changes. Specifically: if there is a current
file open for editing and its modify flag is true, then give user
a dialog box with choice to save, discard edits, or cancel and
carry out the decision. This applies to File->New, File->Open,
File->Close, and File->Exit.
Returns:
false means user selected Cancel so caller should do that.
Return of true means caller can proceed (edits were saved or discarded).
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
GenericTextArea
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.generic
Class GenericTextArea
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JTextArea
mars.venus.editors.generic.GenericTextArea
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable, MARSTextEditingArea
public class GenericTextArea
extends JTextArea
implements MARSTextEditingArea
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JTextArea
JTextArea.AccessibleJTextArea
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBinding
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface mars.venus.editors.MARSTextEditingArea
TEXT_FOUND, TEXT_NOT_FOUND, TEXT_REPLACED_FOUND_NEXT, TEXT_REPLACED_NOT_FOUND_NEXT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
GenericTextArea(EditPane editPain,
JComponent lineNumbers)
Method Summary
void discardAllUndoableEdits()
Tell UndoManager to discard all its collected undoable edits.
int doFindText(String find,
boolean caseSensitive)
Finds next occurrence of text in a forward search of a string.
int doReplace(String find,
String replace,
boolean caseSensitive)
Finds and replaces next occurrence of text in a string in a forward search.
int doReplaceAll(String find,
String replace,
boolean caseSensitive)
Finds and replaces ALL occurrences of text in a string in a forward search.
Component getOuterComponent()
UndoManager getUndoManager()
Returns the undo manager for this editing area
int nextIndex(String input,
String find,
int start,
boolean caseSensitive)
Returns next posn of word in text – forward search.
void redo()
Redo previous edit
void setCaretBlinkRate(int rate)
Set the caret blinking rate in milliseconds.
void setCaretVisible(boolean vis)
Control caret visibility
void setLineHighlightEnabled(boolean highlight)
Does nothing, but required by the interface.
void setSelectionVisible(boolean vis)
Control selection visibility
void setSourceCode(String s,
boolean editable)
For initalizing the source code when opening an ASM file
void setText(String s)
Override inherited setText to temporarily remove UndoableEditListener because this
operation is not undoable.
void undo()
Undo previous edit
void updateSyntaxStyles()
Does nothing, but required by the interface.
Methods inherited from class javax.swing.JTextArea
append, createDefaultModel, getAccessibleContext, getColumns, getColumnWidth, getLineCount, getLineEndOffset, getLineOfOffset, getLineStartOffset, getLineWrap, getPreferredScrollableViewportSize, getPreferredSize, getRowHeight, getRows, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getTabSize, getUIClassID, getWrapStyleWord, insert, paramString, replaceRange, setColumns, setFont, setLineWrap, setRows, setTabSize, setWrapStyleWord
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getActions, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPrintable, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, print, print, print, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDocument, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, write
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface mars.venus.editors.MARSTextEditingArea
copy, cut, getCaretPosition, getDocument, getFont, getFontMetrics, getSelectedText, getSelectionEnd, getSelectionStart, getText, grabFocus, paste, replaceSelection, requestFocusInWindow, revalidate, select, selectAll, setBackground, setCaretPosition, setEditable, setEnabled, setFont, setSelectionEnd, setSelectionStart, setTabSize
Constructor Detail
GenericTextArea
public GenericTextArea(EditPane editPain,
JComponent lineNumbers)
Method Detail
setLineHighlightEnabled
public void setLineHighlightEnabled(boolean highlight)
Does nothing, but required by the interface. This editor does not support
highlighting of the line currently being edited.
Specified by:
setLineHighlightEnabled in interface MARSTextEditingArea
updateSyntaxStyles
public void updateSyntaxStyles()
Does nothing, but required by the interface. This editor does not support
syntax styling (colors, bold/italic).
Specified by:
updateSyntaxStyles in interface MARSTextEditingArea
setCaretBlinkRate
public void setCaretBlinkRate(int rate)
Set the caret blinking rate in milliseconds. If rate is 0
it will not blink. If negative, do nothing.
Specified by:
setCaretBlinkRate in interface MARSTextEditingArea
Parameters:
rate – blinking rate in milliseconds
getOuterComponent
public Component getOuterComponent()
Specified by:
getOuterComponent in interface MARSTextEditingArea
setSourceCode
public void setSourceCode(String s,
boolean editable)
For initalizing the source code when opening an ASM file
Specified by:
setSourceCode in interface MARSTextEditingArea
Parameters:
s – String containing text
editable – set true if code is editable else false
discardAllUndoableEdits
public void discardAllUndoableEdits()
Tell UndoManager to discard all its collected undoable edits.
Specified by:
discardAllUndoableEdits in interface MARSTextEditingArea
setText
public void setText(String s)
Override inherited setText to temporarily remove UndoableEditListener because this
operation is not undoable.
Specified by:
setText in interface MARSTextEditingArea
Overrides:
setText in class JTextComponent
Parameters:
s – String with new contents for the editing area. Replaces current content.
setCaretVisible
public void setCaretVisible(boolean vis)
Control caret visibility
Specified by:
setCaretVisible in interface MARSTextEditingArea
Parameters:
vis – true to display caret, false to hide it
setSelectionVisible
public void setSelectionVisible(boolean vis)
Control selection visibility
Specified by:
setSelectionVisible in interface MARSTextEditingArea
Parameters:
vis – true to display selection, false to hide it
getUndoManager
public UndoManager getUndoManager()
Returns the undo manager for this editing area
Specified by:
getUndoManager in interface MARSTextEditingArea
Returns:
the undo manager
undo
public void undo()
Undo previous edit
Specified by:
undo in interface MARSTextEditingArea
redo
public void redo()
Redo previous edit
Specified by:
redo in interface MARSTextEditingArea
doFindText
public int doFindText(String find,
boolean caseSensitive)
Finds next occurrence of text in a forward search of a string. Search begins
at the current cursor location, and wraps around when the end of the string
is reached.
Specified by:
doFindText in interface MARSTextEditingArea
Parameters:
find – the text to locate in the string
caseSensitive – true if search is to be case-sensitive, false otherwise
Returns:
TEXT_FOUND or TEXT_NOT_FOUND, depending on the result.
nextIndex
public int nextIndex(String input,
String find,
int start,
boolean caseSensitive)
Returns next posn of word in text – forward search. If end of string is
reached during the search, will wrap around to the beginning one time.
Parameters:
input – the string to search
find – the string to find
start – the character position to start the search
caseSensitive – true for case sensitive. false to ignore case
Returns:
next indexed position of found text or -1 if not found
doReplace
public int doReplace(String find,
String replace,
boolean caseSensitive)
Finds and replaces next occurrence of text in a string in a forward search.
If cursor is initially at end
of matching selection, will immediately replace then find and select the
next occurrence if any. Otherwise it performs a find operation. The replace
can be undone with one undo operation.
Specified by:
doReplace in interface MARSTextEditingArea
Parameters:
find – the text to locate in the string
replace – the text to replace the find text with – if the find text exists
caseSensitive – true for case sensitive. false to ignore case
Returns:
Returns TEXT_FOUND if not initially at end of selected match and matching
occurrence is found. Returns TEXT_NOT_FOUND if the text is not matched.
Returns TEXT_REPLACED_NOT_FOUND_NEXT if replacement is successful but there are
no additional matches. Returns TEXT_REPLACED_FOUND_NEXT if reaplacement is
successful and there is at least one additional match.
doReplaceAll
public int doReplaceAll(String find,
String replace,
boolean caseSensitive)
Finds and replaces ALL occurrences of text in a string in a forward search.
All replacements are bundled into one CompoundEdit, so one Undo operation will
undo all of them.
Specified by:
doReplaceAll in interface MARSTextEditingArea
Parameters:
find – the text to locate in the string
replace – the text to replace the find text with – if the find text exists
caseSensitive – true for case sensitive. false to ignore case
Returns:
the number of occurrences that were matched and replaced.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.generic
mars.venus.editors.generic
Classes
GenericTextArea
mars.venus.editors.generic
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
Package mars.venus.editors.generic
Class Summary
GenericTextArea
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
mars.venus.editors.generic Class Hierarchy
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Hierarchy For Package mars.venus.editors.generic
Package Hierarchies:
All Packages
Class Hierarchy
java.lang.Object java.awt.Component (implements java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable)
java.awt.Container javax.swing.JComponent (implements java.io.Serializable)
javax.swing.text.JTextComponent (implements javax.accessibility.Accessible, javax.swing.Scrollable)
javax.swing.JTextArea mars.venus.editors.generic.GenericTextArea (implements mars.venus.editors.MARSTextEditingArea)
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
DefaultInputHandler
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class DefaultInputHandler
java.lang.Object
java.awt.event.KeyAdapter
mars.venus.editors.jeditsyntax.InputHandler
mars.venus.editors.jeditsyntax.DefaultInputHandler
All Implemented Interfaces:
KeyListener, EventListener
public class DefaultInputHandler
extends InputHandler
The default input handler. It maps sequences of keystrokes into actions
and inserts key typed events into the text area.
Author:
Slava Pestov
Nested Class Summary
Nested classes/interfaces inherited from class mars.venus.editors.jeditsyntax.InputHandler
InputHandler.backspace, InputHandler.backspace_word, InputHandler.clip_copy, InputHandler.clip_cut, InputHandler.clip_paste, InputHandler.delete, InputHandler.delete_word, InputHandler.document_end, InputHandler.document_home, InputHandler.end, InputHandler.home, InputHandler.insert_break, InputHandler.insert_char, InputHandler.insert_tab, InputHandler.MacroRecorder, InputHandler.next_char, InputHandler.next_line, InputHandler.next_page, InputHandler.next_word, InputHandler.NonRecordable, InputHandler.NonRepeatable, InputHandler.overwrite, InputHandler.prev_char, InputHandler.prev_line, InputHandler.prev_page, InputHandler.prev_word, InputHandler.repeat, InputHandler.select_all, InputHandler.toggle_rect, InputHandler.Wrapper
Field Summary
Fields inherited from class mars.venus.editors.jeditsyntax.InputHandler
BACKSPACE, BACKSPACE_WORD, CLIP_COPY, CLIP_CUT, CLIP_PASTE, DELETE, DELETE_WORD, DOCUMENT_END, DOCUMENT_HOME, END, grabAction, HOME, INSERT_BREAK, INSERT_CHAR, INSERT_TAB, NEXT_CHAR, NEXT_LINE, NEXT_PAGE, NEXT_WORD, OVERWRITE, PREV_CHAR, PREV_LINE, PREV_PAGE, PREV_WORD, recorder, repeat, REPEAT, repeatCount, SELECT_ALL, SELECT_DOC_END, SELECT_DOC_HOME, SELECT_END, SELECT_HOME, SELECT_NEXT_CHAR, SELECT_NEXT_LINE, SELECT_NEXT_PAGE, SELECT_NEXT_WORD, SELECT_PREV_CHAR, SELECT_PREV_LINE, SELECT_PREV_PAGE, SELECT_PREV_WORD, SMART_HOME_END_PROPERTY, TOGGLE_RECT
Constructor Summary
DefaultInputHandler()
Creates a new input handler with no key bindings defined.
Method Summary
void addDefaultKeyBindings()
Sets up the default key bindings.
void addKeyBinding(String keyBinding,
ActionListener action)
Adds a key binding to this input handler.
InputHandler copy()
Returns a copy of this input handler that shares the same
key bindings.
void keyPressed(KeyEvent evt)
Handle a key pressed event.
void keyTyped(KeyEvent evt)
Handle a key typed event.
static KeyStroke parseKeyStroke(String keyStroke)
Converts a string to a keystroke.
void removeAllKeyBindings()
Removes all key bindings from this input handler.
void removeKeyBinding(String keyBinding)
Removes a key binding from this input handler.
Methods inherited from class mars.venus.editors.jeditsyntax.InputHandler
executeAction, getAction, getActionName, getActions, getMacroRecorder, getRepeatCount, getTextArea, grabNextKeyStroke, handleGrabAction, isRepeatEnabled, setMacroRecorder, setRepeatCount, setRepeatEnabled
Methods inherited from class java.awt.event.KeyAdapter
keyReleased
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
DefaultInputHandler
public DefaultInputHandler()
Creates a new input handler with no key bindings defined.
Method Detail
addDefaultKeyBindings
public void addDefaultKeyBindings()
Sets up the default key bindings.
Specified by:
addDefaultKeyBindings in class InputHandler
addKeyBinding
public void addKeyBinding(String keyBinding,
ActionListener action)
Adds a key binding to this input handler. The key binding is
a list of white space separated key strokes of the form
[modifiers+]key where modifier is C for Control, A for Alt,
or S for Shift, and key is either a character (a-z) or a field
name in the KeyEvent class prefixed with VK_ (e.g., BACK_SPACE)
Specified by:
addKeyBinding in class InputHandler
Parameters:
keyBinding – The key binding
action – The action
removeKeyBinding
public void removeKeyBinding(String keyBinding)
Removes a key binding from this input handler. This is not yet
implemented.
Specified by:
removeKeyBinding in class InputHandler
Parameters:
keyBinding – The key binding
removeAllKeyBindings
public void removeAllKeyBindings()
Removes all key bindings from this input handler.
Specified by:
removeAllKeyBindings in class InputHandler
copy
public InputHandler copy()
Returns a copy of this input handler that shares the same
key bindings. Setting key bindings in the copy will also
set them in the original.
Specified by:
copy in class InputHandler
keyPressed
public void keyPressed(KeyEvent evt)
Handle a key pressed event. This will look up the binding for
the key stroke and execute it.
Specified by:
keyPressed in interface KeyListener
Overrides:
keyPressed in class KeyAdapter
keyTyped
public void keyTyped(KeyEvent evt)
Handle a key typed event. This inserts the key into the text area.
Specified by:
keyTyped in interface KeyListener
Overrides:
keyTyped in class KeyAdapter
parseKeyStroke
public static KeyStroke parseKeyStroke(String keyStroke)
Converts a string to a keystroke. The string should be of the
form modifiers+shortcut where modifiers
is any combination of A for Alt, C for Control, S for Shift
or M for Meta, and shortcut is either a single character,
or a keycode name from the KeyEvent class, without
the VK_ prefix.
Parameters:
keyStroke – A string description of the key stroke
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.backspace
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.backspace
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.backspace
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.backspace
extends Object
implements ActionListener
Constructor Summary
InputHandler.backspace()
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.backspace
public InputHandler.backspace()
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.backspace_word
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.backspace_word
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.backspace_word
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.backspace_word
extends Object
implements ActionListener
Constructor Summary
InputHandler.backspace_word()
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.backspace_word
public InputHandler.backspace_word()
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.clip_copy
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.clip_copy
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.clip_copy
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.clip_copy
extends Object
implements ActionListener
Constructor Summary
InputHandler.clip_copy()
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.clip_copy
public InputHandler.clip_copy()
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.clip_cut
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.clip_cut
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.clip_cut
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.clip_cut
extends Object
implements ActionListener
Constructor Summary
InputHandler.clip_cut()
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.clip_cut
public InputHandler.clip_cut()
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.clip_paste
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.clip_paste
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.clip_paste
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.clip_paste
extends Object
implements ActionListener
Constructor Summary
InputHandler.clip_paste()
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.clip_paste
public InputHandler.clip_paste()
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.delete
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.delete
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.delete
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.delete
extends Object
implements ActionListener
Constructor Summary
InputHandler.delete()
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.delete
public InputHandler.delete()
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.delete_word
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.delete_word
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.delete_word
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.delete_word
extends Object
implements ActionListener
Constructor Summary
InputHandler.delete_word()
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.delete_word
public InputHandler.delete_word()
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.document_end
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.document_end
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.document_end
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.document_end
extends Object
implements ActionListener
Constructor Summary
InputHandler.document_end(boolean select)
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.document_end
public InputHandler.document_end(boolean select)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.document_home
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.document_home
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.document_home
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.document_home
extends Object
implements ActionListener
Constructor Summary
InputHandler.document_home(boolean select)
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.document_home
public InputHandler.document_home(boolean select)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.end
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.end
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.end
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.end
extends Object
implements ActionListener
Constructor Summary
InputHandler.end(boolean select)
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.end
public InputHandler.end(boolean select)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.home
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.home
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.home
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.home
extends Object
implements ActionListener
Constructor Summary
InputHandler.home(boolean select)
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.home
public InputHandler.home(boolean select)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler
java.lang.Object
java.awt.event.KeyAdapter
mars.venus.editors.jeditsyntax.InputHandler
All Implemented Interfaces:
KeyListener, EventListener
Direct Known Subclasses:
DefaultInputHandler
public abstract class InputHandler
extends KeyAdapter
An input handler converts the user’s key strokes into concrete actions.
It also takes care of macro recording and action repetition.
This class provides all the necessary support code for an input
handler, but doesn’t actually do any key binding logic. It is up
to the implementations of this class to do so.
Author:
Slava Pestov
See Also:
08/12/2002 Clipboard actions (Oliver Henning)
Nested Class Summary
static class InputHandler.backspace
static class InputHandler.backspace_word
static class InputHandler.clip_copy
static class InputHandler.clip_cut
static class InputHandler.clip_paste
static class InputHandler.delete
static class InputHandler.delete_word
static class InputHandler.document_end
static class InputHandler.document_home
static class InputHandler.end
static class InputHandler.home
static class InputHandler.insert_break
static class InputHandler.insert_char
static class InputHandler.insert_tab
static interface InputHandler.MacroRecorder
Macro recorder.
static class InputHandler.next_char
static class InputHandler.next_line
static class InputHandler.next_page
static class InputHandler.next_word
static interface InputHandler.NonRecordable
If an action implements this interface, it should not be recorded
by the macro recorder.
static interface InputHandler.NonRepeatable
If an action implements this interface, it should not be repeated.
static class InputHandler.overwrite
static class InputHandler.prev_char
static class InputHandler.prev_line
static class InputHandler.prev_page
static class InputHandler.prev_word
static class InputHandler.repeat
static class InputHandler.select_all
static class InputHandler.toggle_rect
static interface InputHandler.Wrapper
For use by EditAction.Wrapper only.
Field Summary
static ActionListener BACKSPACE
static ActionListener BACKSPACE_WORD
static ActionListener CLIP_COPY
static ActionListener CLIP_CUT
static ActionListener CLIP_PASTE
static ActionListener DELETE
static ActionListener DELETE_WORD
static ActionListener DOCUMENT_END
static ActionListener DOCUMENT_HOME
static ActionListener END
protected ActionListener grabAction
static ActionListener HOME
static ActionListener INSERT_BREAK
static ActionListener INSERT_CHAR
static ActionListener INSERT_TAB
static ActionListener NEXT_CHAR
static ActionListener NEXT_LINE
static ActionListener NEXT_PAGE
static ActionListener NEXT_WORD
static ActionListener OVERWRITE
static ActionListener PREV_CHAR
static ActionListener PREV_LINE
static ActionListener PREV_PAGE
static ActionListener PREV_WORD
protected InputHandler.MacroRecorder recorder
protected boolean repeat
static ActionListener REPEAT
protected int repeatCount
static ActionListener SELECT_ALL
static ActionListener SELECT_DOC_END
static ActionListener SELECT_DOC_HOME
static ActionListener SELECT_END
static ActionListener SELECT_HOME
static ActionListener SELECT_NEXT_CHAR
static ActionListener SELECT_NEXT_LINE
static ActionListener SELECT_NEXT_PAGE
static ActionListener SELECT_NEXT_WORD
static ActionListener SELECT_PREV_CHAR
static ActionListener SELECT_PREV_LINE
static ActionListener SELECT_PREV_PAGE
static ActionListener SELECT_PREV_WORD
static String SMART_HOME_END_PROPERTY
If this client property is set to Boolean.TRUE on the text area,
the home/end keys will support ‘smart’ BRIEF-like behaviour
(one press = start/end of line, two presses = start/end of
viewscreen, three presses = start/end of document).
static ActionListener TOGGLE_RECT
Constructor Summary
InputHandler()
Method Summary
abstract void addDefaultKeyBindings()
Adds the default key bindings to this input handler.
abstract void addKeyBinding(String keyBinding,
ActionListener action)
Adds a key binding to this input handler.
abstract InputHandler copy()
Returns a copy of this input handler that shares the same
key bindings.
void executeAction(ActionListener listener,
Object source,
String actionCommand)
Executes the specified action, repeating and recording it as
necessary.
static ActionListener getAction(String name)
Returns a named text area action.
static String getActionName(ActionListener listener)
Returns the name of the specified text area action.
static Enumeration getActions()
Returns an enumeration of all available actions.
InputHandler.MacroRecorder getMacroRecorder()
Returns the macro recorder.
int getRepeatCount()
Returns the number of times the next action will be repeated.
static JEditTextArea getTextArea(EventObject evt)
Returns the text area that fired the specified event.
void grabNextKeyStroke(ActionListener listener)
Grabs the next key typed event and invokes the specified
action with the key as a the action command.
protected void handleGrabAction(KeyEvent evt)
If a key is being grabbed, this method should be called with
the appropriate key event.
boolean isRepeatEnabled()
Returns if repeating is enabled.
abstract void removeAllKeyBindings()
Removes all key bindings from this input handler.
abstract void removeKeyBinding(String keyBinding)
Removes a key binding from this input handler.
void setMacroRecorder(InputHandler.MacroRecorder recorder)
Sets the macro recorder.
void setRepeatCount(int repeatCount)
Sets the number of times the next action will be repeated.
void setRepeatEnabled(boolean repeat)
Enables repeating.
Methods inherited from class java.awt.event.KeyAdapter
keyPressed, keyReleased, keyTyped
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
SMART_HOME_END_PROPERTY
public static final String SMART_HOME_END_PROPERTY
If this client property is set to Boolean.TRUE on the text area,
the home/end keys will support ‘smart’ BRIEF-like behaviour
(one press = start/end of line, two presses = start/end of
viewscreen, three presses = start/end of document). By default,
this property is not set.
See Also:
Constant Field Values
BACKSPACE
public static final ActionListener BACKSPACE
BACKSPACE_WORD
public static final ActionListener BACKSPACE_WORD
DELETE
public static final ActionListener DELETE
DELETE_WORD
public static final ActionListener DELETE_WORD
END
public static final ActionListener END
DOCUMENT_END
public static final ActionListener DOCUMENT_END
SELECT_ALL
public static final ActionListener SELECT_ALL
SELECT_END
public static final ActionListener SELECT_END
SELECT_DOC_END
public static final ActionListener SELECT_DOC_END
INSERT_BREAK
public static final ActionListener INSERT_BREAK
INSERT_TAB
public static final ActionListener INSERT_TAB
HOME
public static final ActionListener HOME
DOCUMENT_HOME
public static final ActionListener DOCUMENT_HOME
SELECT_HOME
public static final ActionListener SELECT_HOME
SELECT_DOC_HOME
public static final ActionListener SELECT_DOC_HOME
NEXT_CHAR
public static final ActionListener NEXT_CHAR
NEXT_LINE
public static final ActionListener NEXT_LINE
NEXT_PAGE
public static final ActionListener NEXT_PAGE
NEXT_WORD
public static final ActionListener NEXT_WORD
SELECT_NEXT_CHAR
public static final ActionListener SELECT_NEXT_CHAR
SELECT_NEXT_LINE
public static final ActionListener SELECT_NEXT_LINE
SELECT_NEXT_PAGE
public static final ActionListener SELECT_NEXT_PAGE
SELECT_NEXT_WORD
public static final ActionListener SELECT_NEXT_WORD
OVERWRITE
public static final ActionListener OVERWRITE
PREV_CHAR
public static final ActionListener PREV_CHAR
PREV_LINE
public static final ActionListener PREV_LINE
PREV_PAGE
public static final ActionListener PREV_PAGE
PREV_WORD
public static final ActionListener PREV_WORD
SELECT_PREV_CHAR
public static final ActionListener SELECT_PREV_CHAR
SELECT_PREV_LINE
public static final ActionListener SELECT_PREV_LINE
SELECT_PREV_PAGE
public static final ActionListener SELECT_PREV_PAGE
SELECT_PREV_WORD
public static final ActionListener SELECT_PREV_WORD
REPEAT
public static final ActionListener REPEAT
TOGGLE_RECT
public static final ActionListener TOGGLE_RECT
CLIP_COPY
public static final ActionListener CLIP_COPY
CLIP_PASTE
public static final ActionListener CLIP_PASTE
CLIP_CUT
public static final ActionListener CLIP_CUT
INSERT_CHAR
public static final ActionListener INSERT_CHAR
grabAction
protected ActionListener grabAction
repeat
protected boolean repeat
repeatCount
protected int repeatCount
recorder
protected InputHandler.MacroRecorder recorder
Constructor Detail
InputHandler
public InputHandler()
Method Detail
getAction
public static ActionListener getAction(String name)
Returns a named text area action.
Parameters:
name – The action name
getActionName
public static String getActionName(ActionListener listener)
Returns the name of the specified text area action.
Parameters:
listener – The action
getActions
public static Enumeration getActions()
Returns an enumeration of all available actions.
addDefaultKeyBindings
public abstract void addDefaultKeyBindings()
Adds the default key bindings to this input handler.
This should not be called in the constructor of this
input handler, because applications might load the
key bindings from a file, etc.
addKeyBinding
public abstract void addKeyBinding(String keyBinding,
ActionListener action)
Adds a key binding to this input handler.
Parameters:
keyBinding – The key binding (the format of this is
input-handler specific)
action – The action
removeKeyBinding
public abstract void removeKeyBinding(String keyBinding)
Removes a key binding from this input handler.
Parameters:
keyBinding – The key binding
removeAllKeyBindings
public abstract void removeAllKeyBindings()
Removes all key bindings from this input handler.
grabNextKeyStroke
public void grabNextKeyStroke(ActionListener listener)
Grabs the next key typed event and invokes the specified
action with the key as a the action command.
Parameters:
action – The action
isRepeatEnabled
public boolean isRepeatEnabled()
Returns if repeating is enabled. When repeating is enabled,
actions will be executed multiple times. This is usually
invoked with a special key stroke in the input handler.
setRepeatEnabled
public void setRepeatEnabled(boolean repeat)
Enables repeating. When repeating is enabled, actions will be
executed multiple times. Once repeating is enabled, the input
handler should read a number from the keyboard.
getRepeatCount
public int getRepeatCount()
Returns the number of times the next action will be repeated.
setRepeatCount
public void setRepeatCount(int repeatCount)
Sets the number of times the next action will be repeated.
Parameters:
repeatCount – The repeat count
getMacroRecorder
public InputHandler.MacroRecorder getMacroRecorder()
Returns the macro recorder. If this is non-null, all executed
actions should be forwarded to the recorder.
setMacroRecorder
public void setMacroRecorder(InputHandler.MacroRecorder recorder)
Sets the macro recorder. If this is non-null, all executed
actions should be forwarded to the recorder.
Parameters:
recorder – The macro recorder
copy
public abstract InputHandler copy()
Returns a copy of this input handler that shares the same
key bindings. Setting key bindings in the copy will also
set them in the original.
executeAction
public void executeAction(ActionListener listener,
Object source,
String actionCommand)
Executes the specified action, repeating and recording it as
necessary.
Parameters:
listener – The action listener
source – The event source
actionCommand – The action command
getTextArea
public static JEditTextArea getTextArea(EventObject evt)
Returns the text area that fired the specified event.
Parameters:
evt – The event
handleGrabAction
protected void handleGrabAction(KeyEvent evt)
If a key is being grabbed, this method should be called with
the appropriate key event. It executes the grab action with
the typed character as the parameter.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.insert_break
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.insert_break
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.insert_break
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.insert_break
extends Object
implements ActionListener
Constructor Summary
InputHandler.insert_break()
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.insert_break
public InputHandler.insert_break()
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.insert_char
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.insert_char
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.insert_char
All Implemented Interfaces:
ActionListener, EventListener, InputHandler.NonRepeatable
Enclosing class:
InputHandler
public static class InputHandler.insert_char
extends Object
implements ActionListener, InputHandler.NonRepeatable
Constructor Summary
InputHandler.insert_char()
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.insert_char
public InputHandler.insert_char()
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.insert_tab
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.insert_tab
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.insert_tab
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.insert_tab
extends Object
implements ActionListener
Constructor Summary
InputHandler.insert_tab()
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.insert_tab
public InputHandler.insert_tab()
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.MacroRecorder
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Interface InputHandler.MacroRecorder
Enclosing class:
InputHandler
public static interface InputHandler.MacroRecorder
Macro recorder.
Method Summary
void actionPerformed(ActionListener listener,
String actionCommand)
Method Detail
actionPerformed
void actionPerformed(ActionListener listener,
String actionCommand)
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.next_char
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.next_char
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.next_char
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.next_char
extends Object
implements ActionListener
Constructor Summary
InputHandler.next_char(boolean select)
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.next_char
public InputHandler.next_char(boolean select)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.next_line
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.next_line
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.next_line
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.next_line
extends Object
implements ActionListener
Constructor Summary
InputHandler.next_line(boolean select)
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.next_line
public InputHandler.next_line(boolean select)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.next_page
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.next_page
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.next_page
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.next_page
extends Object
implements ActionListener
Constructor Summary
InputHandler.next_page(boolean select)
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.next_page
public InputHandler.next_page(boolean select)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.next_word
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.next_word
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.next_word
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.next_word
extends Object
implements ActionListener
Constructor Summary
InputHandler.next_word(boolean select)
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.next_word
public InputHandler.next_word(boolean select)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.NonRecordable
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Interface InputHandler.NonRecordable
All Known Implementing Classes:
InputHandler.repeat
Enclosing class:
InputHandler
public static interface InputHandler.NonRecordable
If an action implements this interface, it should not be recorded
by the macro recorder. Instead, it will do its own recording.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.NonRepeatable
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Interface InputHandler.NonRepeatable
All Known Implementing Classes:
InputHandler.insert_char
Enclosing class:
InputHandler
public static interface InputHandler.NonRepeatable
If an action implements this interface, it should not be repeated.
Instead, it will handle the repetition itself.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.overwrite
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.overwrite
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.overwrite
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.overwrite
extends Object
implements ActionListener
Constructor Summary
InputHandler.overwrite()
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.overwrite
public InputHandler.overwrite()
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.prev_char
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.prev_char
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.prev_char
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.prev_char
extends Object
implements ActionListener
Constructor Summary
InputHandler.prev_char(boolean select)
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.prev_char
public InputHandler.prev_char(boolean select)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.prev_line
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.prev_line
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.prev_line
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.prev_line
extends Object
implements ActionListener
Constructor Summary
InputHandler.prev_line(boolean select)
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.prev_line
public InputHandler.prev_line(boolean select)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.prev_page
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.prev_page
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.prev_page
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.prev_page
extends Object
implements ActionListener
Constructor Summary
InputHandler.prev_page(boolean select)
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.prev_page
public InputHandler.prev_page(boolean select)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.prev_word
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.prev_word
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.prev_word
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.prev_word
extends Object
implements ActionListener
Constructor Summary
InputHandler.prev_word(boolean select)
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.prev_word
public InputHandler.prev_word(boolean select)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.repeat
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.repeat
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.repeat
All Implemented Interfaces:
ActionListener, EventListener, InputHandler.NonRecordable
Enclosing class:
InputHandler
public static class InputHandler.repeat
extends Object
implements ActionListener, InputHandler.NonRecordable
Constructor Summary
InputHandler.repeat()
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.repeat
public InputHandler.repeat()
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.select_all
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.select_all
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.select_all
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.select_all
extends Object
implements ActionListener
Constructor Summary
InputHandler.select_all()
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.select_all
public InputHandler.select_all()
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.toggle_rect
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class InputHandler.toggle_rect
java.lang.Object
mars.venus.editors.jeditsyntax.InputHandler.toggle_rect
All Implemented Interfaces:
ActionListener, EventListener
Enclosing class:
InputHandler
public static class InputHandler.toggle_rect
extends Object
implements ActionListener
Constructor Summary
InputHandler.toggle_rect()
Method Summary
void actionPerformed(ActionEvent evt)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
InputHandler.toggle_rect
public InputHandler.toggle_rect()
Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
InputHandler.Wrapper
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Interface InputHandler.Wrapper
Enclosing class:
InputHandler
public static interface InputHandler.Wrapper
For use by EditAction.Wrapper only.
Since:
jEdit 2.2final
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
JEditBasedTextArea
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class JEditBasedTextArea
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
mars.venus.editors.jeditsyntax.JEditTextArea
mars.venus.editors.jeditsyntax.JEditBasedTextArea
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, CaretListener, MARSTextEditingArea
public class JEditBasedTextArea
extends JEditTextArea
implements MARSTextEditingArea, CaretListener
Adaptor subclass for JEditTextArea
Provides those methods required by the MARSTextEditingArea interface
that are not defined by JEditTextArea. This permits JEditTextArea
to be used within MARS largely without modification. DPS 4-20-2010
Since:
4.0
Author:
Pete Sanderson
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class mars.venus.editors.jeditsyntax.JEditTextArea
biasLeft, blink, BOTTOM, bracketLine, bracketPosition, caretBlinkRate, caretBlinks, caretEvent, caretTimer, caretVisible, CENTER, document, documentHandler, editable, electricScroll, firstLine, focusedComponent, horizontal, horizontalOffset, inputHandler, LEFT_OF_SCROLLBAR, lineSegment, listenerList, magicCaret, overwrite, painter, popup, rectSelect, RIGHT, scrollBarsInitialized, selectionEnd, selectionEndLine, selectionStart, selectionStartLine, unredoing, vertical, visibleLines
Fields inherited from class javax.swing.JComponent
accessibleContext, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface mars.venus.editors.MARSTextEditingArea
TEXT_FOUND, TEXT_NOT_FOUND, TEXT_REPLACED_FOUND_NEXT, TEXT_REPLACED_NOT_FOUND_NEXT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
JEditBasedTextArea(EditPane editPain,
JComponent lineNumbers)
Method Summary
void caretUpdate(CaretEvent e)
Display caret position on the edit pane.
void discardAllUndoableEdits()
Get rid of any accumulated undoable edits.
int doFindText(String find,
boolean caseSensitive)
Finds next occurrence of text in a forward search of a string.
int doReplace(String find,
String replace,
boolean caseSensitive)
Finds and replaces next occurrence of text in a string in a forward search.
int doReplaceAll(String find,
String replace,
boolean caseSensitive)
Finds and replaces ALL occurrences of text in a string in a forward search.
Font getFont()
Component getOuterComponent()
UndoManager getUndoManager()
Returns the undo manager for this editing area
int nextIndex(String input,
String find,
int start,
boolean caseSensitive)
Returns next posn of word in text – forward search.
void redo()
Redo previous edit
void replaceSelection(String replacementText)
Same as setSelectedText but named for compatibility with
JTextComponent method replaceSelection.
void setCaretBlinkRate(int rate)
Set the caret blinking rate in milliseconds.
void setFont(Font f)
void setLineHighlightEnabled(boolean highlight)
Use for highlighting the line currently being edited.
void setSelectionVisible(boolean vis)
void setSourceCode(String s,
boolean editable)
void setTabSize(int chars)
Set the number of characters a tab will expand to.
void undo()
Undo previous edit
void updateSyntaxStyles()
Update the syntax style table, which is obtained from
SyntaxUtilities.
Methods inherited from class mars.venus.editors.jeditsyntax.JEditTextArea
_offsetToX, addCaretListener, blinkCaret, copy, cut, documentChanged, fireCaretEvent, getAutoIndent, getBracketLine, getBracketPosition, getCaretLine, getCaretPosition, getDocument, getDocumentLength, getElectricScroll, getFirstLine, getHorizontalOffset, getInputHandler, getLeadingWhiteSpace, getLineCount, getLineEndOffset, getLineLength, getLineOfOffset, getLineStartOffset, getLineText, getLineText, getMagicCaretPosition, getMarkLine, getMarkPosition, getPainter, getRightClickPopup, getSelectedText, getSelectionEnd, getSelectionEnd, getSelectionEndLine, getSelectionStart, getSelectionStart, getSelectionStartLine, getSyntaxSensitiveToolTipText, getText, getText, getText, getTokenMarker, getVisibleLines, isCaretBlinkEnabled, isCaretVisible, isEditable, isOverwriteEnabled, isSelectionRectangular, lineToY, offsetToX, overwriteSetSelectedText, paste, processKeyEvent, recalculateVisibleLines, removeCaretListener, removeNotify, scrollTo, scrollToCaret, select, selectAll, selectNone, setCaretBlinkEnabled, setCaretPosition, setCaretVisible, setDocument, setEditable, setElectricScroll, setFirstLine, setHorizontalOffset, setInputHandler, setMagicCaretPosition, setOrigin, setOverwriteEnabled, setRightClickPopup, setSelectedText, setSelectionEnd, setSelectionRectangular, setSelectionStart, setText, setTokenMarker, updateBracketHighlight, updateScrollBars, xToOffset, xyToOffset, yToLine
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface mars.venus.editors.MARSTextEditingArea
copy, cut, getCaretPosition, getDocument, getFontMetrics, getSelectedText, getSelectionEnd, getSelectionStart, getText, grabFocus, paste, requestFocusInWindow, revalidate, select, selectAll, setBackground, setCaretPosition, setCaretVisible, setEditable, setEnabled, setSelectionEnd, setSelectionStart, setText
Constructor Detail
JEditBasedTextArea
public JEditBasedTextArea(EditPane editPain,
JComponent lineNumbers)
Method Detail
setFont
public void setFont(Font f)
Specified by:
setFont in interface MARSTextEditingArea
Overrides:
setFont in class JComponent
getFont
public Font getFont()
Specified by:
getFont in interface MenuContainer
Specified by:
getFont in interface MARSTextEditingArea
Overrides:
getFont in class Component
setLineHighlightEnabled
public void setLineHighlightEnabled(boolean highlight)
Use for highlighting the line currently being edited.
Specified by:
setLineHighlightEnabled in interface MARSTextEditingArea
Parameters:
highlight – true to enable line highlighting, false to disable.
setCaretBlinkRate
public void setCaretBlinkRate(int rate)
Set the caret blinking rate in milliseconds. If rate is 0
will disable blinking. If negative, do nothing.
Specified by:
setCaretBlinkRate in interface MARSTextEditingArea
Parameters:
rate – blinking rate in milliseconds
setTabSize
public void setTabSize(int chars)
Set the number of characters a tab will expand to.
Specified by:
setTabSize in interface MARSTextEditingArea
Parameters:
chars – number of characters
updateSyntaxStyles
public void updateSyntaxStyles()
Update the syntax style table, which is obtained from
SyntaxUtilities.
Specified by:
updateSyntaxStyles in interface MARSTextEditingArea
getOuterComponent
public Component getOuterComponent()
Specified by:
getOuterComponent in interface MARSTextEditingArea
discardAllUndoableEdits
public void discardAllUndoableEdits()
Get rid of any accumulated undoable edits. It is useful to call
this method after opening a file into the text area. The
act of setting its text content upon reading the file will generate
an undoable edit. Normally you don’t want a freshly-opened file
to appear with its Undo action enabled. But it will unless you
call this after setting the text.
Specified by:
discardAllUndoableEdits in interface MARSTextEditingArea
caretUpdate
public void caretUpdate(CaretEvent e)
Display caret position on the edit pane.
Specified by:
caretUpdate in interface CaretListener
Parameters:
e – A CaretEvent
replaceSelection
public void replaceSelection(String replacementText)
Same as setSelectedText but named for compatibility with
JTextComponent method replaceSelection.
DPS, 14 Apr 2010
Specified by:
replaceSelection in interface MARSTextEditingArea
Parameters:
replacementText – The replacement text for the selection
setSelectionVisible
public void setSelectionVisible(boolean vis)
Specified by:
setSelectionVisible in interface MARSTextEditingArea
setSourceCode
public void setSourceCode(String s,
boolean editable)
Specified by:
setSourceCode in interface MARSTextEditingArea
getUndoManager
public UndoManager getUndoManager()
Returns the undo manager for this editing area
Specified by:
getUndoManager in interface MARSTextEditingArea
Returns:
the undo manager
undo
public void undo()
Undo previous edit
Specified by:
undo in interface MARSTextEditingArea
redo
public void redo()
Redo previous edit
Specified by:
redo in interface MARSTextEditingArea
doFindText
public int doFindText(String find,
boolean caseSensitive)
Finds next occurrence of text in a forward search of a string. Search begins
at the current cursor location, and wraps around when the end of the string
is reached.
Specified by:
doFindText in interface MARSTextEditingArea
Parameters:
find – the text to locate in the string
caseSensitive – true if search is to be case-sensitive, false otherwise
Returns:
TEXT_FOUND or TEXT_NOT_FOUND, depending on the result.
nextIndex
public int nextIndex(String input,
String find,
int start,
boolean caseSensitive)
Returns next posn of word in text – forward search. If end of string is
reached during the search, will wrap around to the beginning one time.
Parameters:
input – the string to search
find – the string to find
start – the character position to start the search
caseSensitive – true for case sensitive. false to ignore case
Returns:
next indexed position of found text or -1 if not found
doReplace
public int doReplace(String find,
String replace,
boolean caseSensitive)
Finds and replaces next occurrence of text in a string in a forward search.
If cursor is initially at end
of matching selection, will immediately replace then find and select the
next occurrence if any. Otherwise it performs a find operation. The replace
can be undone with one undo operation.
Specified by:
doReplace in interface MARSTextEditingArea
Parameters:
find – the text to locate in the string
replace – the text to replace the find text with – if the find text exists
caseSensitive – true for case sensitive. false to ignore case
Returns:
Returns TEXT_FOUND if not initially at end of selected match and matching
occurrence is found. Returns TEXT_NOT_FOUND if the text is not matched.
Returns TEXT_REPLACED_NOT_FOUND_NEXT if replacement is successful but there are
no additional matches. Returns TEXT_REPLACED_FOUND_NEXT if reaplacement is
successful and there is at least one additional match.
doReplaceAll
public int doReplaceAll(String find,
String replace,
boolean caseSensitive)
Finds and replaces ALL occurrences of text in a string in a forward search.
All replacements are bundled into one CompoundEdit, so one Undo operation will
undo all of them.
Specified by:
doReplaceAll in interface MARSTextEditingArea
Parameters:
find – the text to locate in the string
replace – the text to replace the find text with – if the find text exists
caseSensitive – true for case sensitive. false to ignore case
Returns:
the number of occurrences that were matched and replaced.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
JEditTextArea
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class JEditTextArea
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
mars.venus.editors.jeditsyntax.JEditTextArea
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
JEditBasedTextArea
public class JEditTextArea
extends JComponent
jEdit’s text area component. It is more suited for editing program
source code than JEditorPane, because it drops the unnecessary features
(images, variable-width lines, and so on) and adds a whole bunch of
useful goodies such as:
More flexible key binding scheme
Supports macro recorders
Rectangular selection
Bracket highlighting
Syntax highlighting
Command repetition
Block caret can be enabled
It is also faster and doesn’t have as many problems. It can be used
in other applications; the only other part of jEdit it depends on is
the syntax package.
To use it in your app, treat it like any other component, for example:
JEditTextArea ta = new JEditTextArea();
ta.setTokenMarker(new JavaTokenMarker());
ta.setText(“public class Test {\n”
+ ” public static void main(String[] args) {\n”
+ ” System.out.println(\”Hello World\”);\n”
+ ” }\n”
+ “}”);
Author:
Slava Pestov
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
protected boolean biasLeft
protected boolean blink
protected static String BOTTOM
protected int bracketLine
protected int bracketPosition
protected int caretBlinkRate
protected boolean caretBlinks
protected mars.venus.editors.jeditsyntax.JEditTextArea.MutableCaretEvent caretEvent
protected static Timer caretTimer
protected boolean caretVisible
protected static String CENTER
protected SyntaxDocument document
protected mars.venus.editors.jeditsyntax.JEditTextArea.DocumentHandler documentHandler
protected boolean editable
protected int electricScroll
protected int firstLine
protected static JEditTextArea focusedComponent
protected JScrollBar horizontal
protected int horizontalOffset
protected InputHandler inputHandler
static String LEFT_OF_SCROLLBAR
Adding components with this name to the text area will place
them left of the horizontal scroll bar.
protected Segment lineSegment
protected EventListenerList listenerList
protected int magicCaret
protected boolean overwrite
protected TextAreaPainter painter
protected JPopupMenu popup
protected boolean rectSelect
protected static String RIGHT
protected boolean scrollBarsInitialized
protected int selectionEnd
protected int selectionEndLine
protected int selectionStart
protected int selectionStartLine
protected boolean unredoing
protected JScrollBar vertical
protected int visibleLines
Fields inherited from class javax.swing.JComponent
accessibleContext, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
JEditTextArea(JComponent lineNumbers)
Creates a new JEditTextArea with the default settings.
JEditTextArea(TextAreaDefaults defaults,
JComponent lineNumbers)
Method Summary
int _offsetToX(int line,
int offset)
Converts an offset in a line into an x co-ordinate.
void addCaretListener(CaretListener listener)
Adds a caret change listener to this text area.
void blinkCaret()
Blinks the caret.
void copy()
Places the selected text into the clipboard.
void cut()
Deletes the selected text from the text area and places it
into the clipboard.
protected void documentChanged(DocumentEvent evt)
protected void fireCaretEvent()
String getAutoIndent()
Constructs string for auto-indent feature.
int getBracketLine()
Returns the line of the highlighted bracket (the bracket
matching the one before the caret)
int getBracketPosition()
Returns the position of the highlighted bracket (the bracket
matching the one before the caret)
int getCaretLine()
Returns the caret line.
int getCaretPosition()
Returns the caret position.
Document getDocument()
Returns the document this text area is editing.
int getDocumentLength()
Returns the length of the document.
int getElectricScroll()
Returns the number of lines from the top and button of the
text area that are always visible.
int getFirstLine()
Returns the line displayed at the text area’s origin.
int getHorizontalOffset()
Returns the horizontal offset of drawn lines.
InputHandler getInputHandler()
Returns the input handler.
String getLeadingWhiteSpace()
Makes a copy of leading white space (tab or space) from the current line and
returns it.
int getLineCount()
Returns the number of lines in the document.
int getLineEndOffset(int line)
Returns the end offset of the specified line.
int getLineLength(int line)
Returns the length of the specified line.
int getLineOfOffset(int offset)
Returns the line containing the specified offset.
int getLineStartOffset(int line)
Returns the start offset of the specified line.
String getLineText(int lineIndex)
Returns the text on the specified line.
void getLineText(int lineIndex,
Segment segment)
Copies the text on the specified line into a segment.
int getMagicCaretPosition()
Returns the `magic’ caret position.
int getMarkLine()
Returns the mark line.
int getMarkPosition()
Returns the mark position.
TextAreaPainter getPainter()
Returns the object responsible for painting this text area.
JPopupMenu getRightClickPopup()
Returns the right click popup menu.
String getSelectedText()
Returns the selected text, or null if no selection is active.
int getSelectionEnd()
Returns the selection end offset.
int getSelectionEnd(int line)
Returns the offset where the selection ends on the specified
line.
int getSelectionEndLine()
Returns the selection end line.
int getSelectionStart()
Returns the selection start offset.
int getSelectionStart(int line)
Returns the offset where the selection starts on the specified
line.
int getSelectionStartLine()
Returns the selection start line.
String getSyntaxSensitiveToolTipText(int x,
int y)
Return any relevant tool tip text for token at specified position.
String getText()
Returns the entire text of this text area.
String getText(int start,
int len)
Returns the specified substring of the document.
void getText(int start,
int len,
Segment segment)
Copies the specified substring of the document into a segment.
TokenMarker getTokenMarker()
Returns the document’s token marker.
int getVisibleLines()
Returns the number of lines visible in this text area.
boolean isCaretBlinkEnabled()
Returns true if the caret is blinking, false otherwise.
boolean isCaretVisible()
Returns true if the caret is visible, false otherwise.
boolean isEditable()
Returns true if this text area is editable, false otherwise.
boolean isOverwriteEnabled()
Returns true if overwrite mode is enabled, false otherwise.
boolean isSelectionRectangular()
Returns true if the selection is rectangular, false otherwise.
int lineToY(int line)
Converts a line index to a y co-ordinate.
int offsetToX(int line,
int offset)
Converts an offset in a line into an x co-ordinate.
void overwriteSetSelectedText(String str)
Similar to setSelectedText(), but overstrikes the
appropriate number of characters if overwrite mode is enabled.
void paste()
Inserts the clipboard contents into the text.
void processKeyEvent(KeyEvent evt)
Forwards key events directly to the input handler.
void recalculateVisibleLines()
Recalculates the number of visible lines.
void removeCaretListener(CaretListener listener)
Removes a caret change listener from this text area.
void removeNotify()
Called by the AWT when this component is removed from it’s parent.
boolean scrollTo(int line,
int offset)
Ensures that the specified line and offset is visible by scrolling
the text area if necessary.
boolean scrollToCaret()
Ensures that the caret is visible by scrolling the text area if
necessary.
void select(int start,
int end)
Selects from the start offset to the end offset.
void selectAll()
Selects all text in the document.
void selectNone()
Moves the mark to the caret position.
void setCaretBlinkEnabled(boolean caretBlinks)
Toggles caret blinking.
void setCaretPosition(int caret)
Sets the caret position.
void setCaretVisible(boolean caretVisible)
Sets if the caret should be visible.
void setDocument(SyntaxDocument document)
Sets the document this text area is editing.
void setEditable(boolean editable)
Sets if this component is editable.
void setElectricScroll(int electricScroll)
Sets the number of lines from the top and bottom of the text
area that are always visible
void setFirstLine(int firstLine)
Sets the line displayed at the text area’s origin and
updates the scroll bars.
void setHorizontalOffset(int horizontalOffset)
Sets the horizontal offset of drawn lines.
void setInputHandler(InputHandler inputHandler)
Sets the input handler.
void setMagicCaretPosition(int magicCaret)
Sets the `magic’ caret position.
boolean setOrigin(int firstLine,
int horizontalOffset)
A fast way of changing both the first line and horizontal
offset.
void setOverwriteEnabled(boolean overwrite)
Sets if overwrite mode should be enabled.
void setRightClickPopup(JPopupMenu popup)
Sets the right click popup menu.
void setSelectedText(String selectedText)
Replaces the selection with the specified text.
void setSelectionEnd(int selectionEnd)
Sets the selection end.
void setSelectionRectangular(boolean rectSelect)
Sets if the selection should be rectangular.
void setSelectionStart(int selectionStart)
Sets the selection start.
void setText(String text)
Sets the entire text of this text area.
void setTokenMarker(TokenMarker tokenMarker)
Sets the document’s token marker.
protected void updateBracketHighlight(int newCaretPosition)
void updateScrollBars()
Updates the state of the scroll bars.
int xToOffset(int line,
int x)
Converts an x co-ordinate to an offset within a line.
int xyToOffset(int x,
int y)
Converts a point to an offset, from the start of the text.
int yToLine(int y)
Converts a y co-ordinate to a line index.
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
LEFT_OF_SCROLLBAR
public static String LEFT_OF_SCROLLBAR
Adding components with this name to the text area will place
them left of the horizontal scroll bar. In jEdit, the status
bar is added this way.
CENTER
protected static String CENTER
RIGHT
protected static String RIGHT
BOTTOM
protected static String BOTTOM
focusedComponent
protected static JEditTextArea focusedComponent
caretTimer
protected static Timer caretTimer
painter
protected TextAreaPainter painter
popup
protected JPopupMenu popup
listenerList
protected EventListenerList listenerList
caretEvent
protected mars.venus.editors.jeditsyntax.JEditTextArea.MutableCaretEvent caretEvent
caretBlinks
protected boolean caretBlinks
caretVisible
protected boolean caretVisible
blink
protected boolean blink
editable
protected boolean editable
caretBlinkRate
protected int caretBlinkRate
firstLine
protected int firstLine
visibleLines
protected int visibleLines
electricScroll
protected int electricScroll
horizontalOffset
protected int horizontalOffset
vertical
protected JScrollBar vertical
horizontal
protected JScrollBar horizontal
scrollBarsInitialized
protected boolean scrollBarsInitialized
inputHandler
protected InputHandler inputHandler
document
protected SyntaxDocument document
documentHandler
protected mars.venus.editors.jeditsyntax.JEditTextArea.DocumentHandler documentHandler
lineSegment
protected Segment lineSegment
selectionStart
protected int selectionStart
selectionStartLine
protected int selectionStartLine
selectionEnd
protected int selectionEnd
selectionEndLine
protected int selectionEndLine
biasLeft
protected boolean biasLeft
bracketPosition
protected int bracketPosition
bracketLine
protected int bracketLine
magicCaret
protected int magicCaret
overwrite
protected boolean overwrite
rectSelect
protected boolean rectSelect
unredoing
protected boolean unredoing
Constructor Detail
JEditTextArea
public JEditTextArea(JComponent lineNumbers)
Creates a new JEditTextArea with the default settings.
JEditTextArea
public JEditTextArea(TextAreaDefaults defaults,
JComponent lineNumbers)
Method Detail
getPainter
public final TextAreaPainter getPainter()
Returns the object responsible for painting this text area.
getInputHandler
public final InputHandler getInputHandler()
Returns the input handler.
setInputHandler
public void setInputHandler(InputHandler inputHandler)
Sets the input handler.
Parameters:
inputHandler – The new input handler
isCaretBlinkEnabled
public final boolean isCaretBlinkEnabled()
Returns true if the caret is blinking, false otherwise.
setCaretBlinkEnabled
public void setCaretBlinkEnabled(boolean caretBlinks)
Toggles caret blinking.
Parameters:
caretBlinks – True if the caret should blink, false otherwise
isCaretVisible
public final boolean isCaretVisible()
Returns true if the caret is visible, false otherwise.
setCaretVisible
public void setCaretVisible(boolean caretVisible)
Sets if the caret should be visible.
Parameters:
caretVisible – True if the caret should be visible, false
otherwise
blinkCaret
public final void blinkCaret()
Blinks the caret.
getElectricScroll
public final int getElectricScroll()
Returns the number of lines from the top and button of the
text area that are always visible.
setElectricScroll
public final void setElectricScroll(int electricScroll)
Sets the number of lines from the top and bottom of the text
area that are always visible
Parameters:
electricScroll – The number of lines always visible from
the top or bottom
updateScrollBars
public void updateScrollBars()
Updates the state of the scroll bars. This should be called
if the number of lines in the document changes, or when the
size of the text are changes.
getFirstLine
public final int getFirstLine()
Returns the line displayed at the text area’s origin.
setFirstLine
public void setFirstLine(int firstLine)
Sets the line displayed at the text area’s origin and
updates the scroll bars.
getVisibleLines
public final int getVisibleLines()
Returns the number of lines visible in this text area.
recalculateVisibleLines
public final void recalculateVisibleLines()
Recalculates the number of visible lines. This should not
be called directly.
getHorizontalOffset
public final int getHorizontalOffset()
Returns the horizontal offset of drawn lines.
setHorizontalOffset
public void setHorizontalOffset(int horizontalOffset)
Sets the horizontal offset of drawn lines. This can be used to
implement horizontal scrolling.
Parameters:
horizontalOffset – offset The new horizontal offset
setOrigin
public boolean setOrigin(int firstLine,
int horizontalOffset)
A fast way of changing both the first line and horizontal
offset.
Parameters:
firstLine – The new first line
horizontalOffset – The new horizontal offset
Returns:
True if any of the values were changed, false otherwise
scrollToCaret
public boolean scrollToCaret()
Ensures that the caret is visible by scrolling the text area if
necessary.
Returns:
True if scrolling was actually performed, false if the
caret was already visible
scrollTo
public boolean scrollTo(int line,
int offset)
Ensures that the specified line and offset is visible by scrolling
the text area if necessary.
Parameters:
line – The line to scroll to
offset – The offset in the line to scroll to
Returns:
True if scrolling was actually performed, false if the
line and offset was already visible
lineToY
public int lineToY(int line)
Converts a line index to a y co-ordinate.
Parameters:
line – The line
yToLine
public int yToLine(int y)
Converts a y co-ordinate to a line index.
Parameters:
y – The y co-ordinate
offsetToX
public final int offsetToX(int line,
int offset)
Converts an offset in a line into an x co-ordinate. This is a
slow version that can be used any time.
Parameters:
line – The line
offset – The offset, from the start of the line
_offsetToX
public int _offsetToX(int line,
int offset)
Converts an offset in a line into an x co-ordinate. This is a
fast version that should only be used if no changes were made
to the text since the last repaint.
Parameters:
line – The line
offset – The offset, from the start of the line
xToOffset
public int xToOffset(int line,
int x)
Converts an x co-ordinate to an offset within a line.
Parameters:
line – The line
x – The x co-ordinate
xyToOffset
public int xyToOffset(int x,
int y)
Converts a point to an offset, from the start of the text.
Parameters:
x – The x co-ordinate of the point
y – The y co-ordinate of the point
getDocument
public final Document getDocument()
Returns the document this text area is editing.
setDocument
public void setDocument(SyntaxDocument document)
Sets the document this text area is editing.
Parameters:
document – The document
getTokenMarker
public final TokenMarker getTokenMarker()
Returns the document’s token marker. Equivalent to calling
getDocument().getTokenMarker().
setTokenMarker
public final void setTokenMarker(TokenMarker tokenMarker)
Sets the document’s token marker. Equivalent to caling
getDocument().setTokenMarker().
Parameters:
tokenMarker – The token marker
getDocumentLength
public final int getDocumentLength()
Returns the length of the document. Equivalent to calling
getDocument().getLength().
getLineCount
public final int getLineCount()
Returns the number of lines in the document.
getLineOfOffset
public final int getLineOfOffset(int offset)
Returns the line containing the specified offset.
Parameters:
offset – The offset
getLineStartOffset
public int getLineStartOffset(int line)
Returns the start offset of the specified line.
Parameters:
line – The line
Returns:
The start offset of the specified line, or -1 if the line is
invalid
getLineEndOffset
public int getLineEndOffset(int line)
Returns the end offset of the specified line.
Parameters:
line – The line
Returns:
The end offset of the specified line, or -1 if the line is
invalid.
getLineLength
public int getLineLength(int line)
Returns the length of the specified line.
Parameters:
line – The line
getText
public String getText()
Returns the entire text of this text area.
setText
public void setText(String text)
Sets the entire text of this text area.
getText
public final String getText(int start,
int len)
Returns the specified substring of the document.
Parameters:
start – The start offset
len – The length of the substring
Returns:
The substring, or null if the offsets are invalid
getText
public final void getText(int start,
int len,
Segment segment)
Copies the specified substring of the document into a segment.
If the offsets are invalid, the segment will contain a null string.
Parameters:
start – The start offset
len – The length of the substring
segment – The segment
getLineText
public final String getLineText(int lineIndex)
Returns the text on the specified line.
Parameters:
lineIndex – The line
Returns:
The text, or null if the line is invalid
getLineText
public final void getLineText(int lineIndex,
Segment segment)
Copies the text on the specified line into a segment. If the line
is invalid, the segment will contain a null string.
Parameters:
lineIndex – The line
getSelectionStart
public final int getSelectionStart()
Returns the selection start offset.
getSelectionStart
public int getSelectionStart(int line)
Returns the offset where the selection starts on the specified
line.
getSelectionStartLine
public final int getSelectionStartLine()
Returns the selection start line.
setSelectionStart
public final void setSelectionStart(int selectionStart)
Sets the selection start. The new selection will be the new
selection start and the old selection end.
Parameters:
selectionStart – The selection start
See Also:
select(int,int)
getSelectionEnd
public final int getSelectionEnd()
Returns the selection end offset.
getSelectionEnd
public int getSelectionEnd(int line)
Returns the offset where the selection ends on the specified
line.
getSelectionEndLine
public final int getSelectionEndLine()
Returns the selection end line.
setSelectionEnd
public final void setSelectionEnd(int selectionEnd)
Sets the selection end. The new selection will be the old
selection start and the new selection end.
Parameters:
selectionEnd – The selection end
See Also:
select(int,int)
getCaretPosition
public final int getCaretPosition()
Returns the caret position. This will either be the selection
start or the selection end, depending on which direction the
selection was made in.
getCaretLine
public final int getCaretLine()
Returns the caret line.
getMarkPosition
public final int getMarkPosition()
Returns the mark position. This will be the opposite selection
bound to the caret position.
See Also:
getCaretPosition()
getMarkLine
public final int getMarkLine()
Returns the mark line.
setCaretPosition
public final void setCaretPosition(int caret)
Sets the caret position. The new selection will consist of the
caret position only (hence no text will be selected)
Parameters:
caret – The caret position
See Also:
select(int,int)
selectAll
public final void selectAll()
Selects all text in the document.
selectNone
public final void selectNone()
Moves the mark to the caret position.
select
public void select(int start,
int end)
Selects from the start offset to the end offset. This is the
general selection method used by all other selecting methods.
The caret position will be start if start < end, and end
if end > start.
Parameters:
start – The start offset
end – The end offset
getSelectedText
public final String getSelectedText()
Returns the selected text, or null if no selection is active.
setSelectedText
public void setSelectedText(String selectedText)
Replaces the selection with the specified text.
Parameters:
selectedText – The replacement text for the selection
isEditable
public final boolean isEditable()
Returns true if this text area is editable, false otherwise.
setEditable
public final void setEditable(boolean editable)
Sets if this component is editable.
Parameters:
editable – True if this text area should be editable,
false otherwise
getRightClickPopup
public final JPopupMenu getRightClickPopup()
Returns the right click popup menu.
setRightClickPopup
public final void setRightClickPopup(JPopupMenu popup)
Sets the right click popup menu.
Parameters:
popup – The popup
getMagicCaretPosition
public final int getMagicCaretPosition()
Returns the `magic’ caret position. This can be used to preserve
the column position when moving up and down lines.
setMagicCaretPosition
public final void setMagicCaretPosition(int magicCaret)
Sets the `magic’ caret position. This can be used to preserve
the column position when moving up and down lines.
Parameters:
magicCaret – The magic caret position
overwriteSetSelectedText
public void overwriteSetSelectedText(String str)
Similar to setSelectedText(), but overstrikes the
appropriate number of characters if overwrite mode is enabled.
Parameters:
str – The string
See Also:
setSelectedText(String),
isOverwriteEnabled()
isOverwriteEnabled
public final boolean isOverwriteEnabled()
Returns true if overwrite mode is enabled, false otherwise.
setOverwriteEnabled
public final void setOverwriteEnabled(boolean overwrite)
Sets if overwrite mode should be enabled.
Parameters:
overwrite – True if overwrite mode should be enabled,
false otherwise.
isSelectionRectangular
public final boolean isSelectionRectangular()
Returns true if the selection is rectangular, false otherwise.
setSelectionRectangular
public final void setSelectionRectangular(boolean rectSelect)
Sets if the selection should be rectangular.
Parameters:
overwrite – True if the selection should be rectangular,
false otherwise.
getBracketPosition
public final int getBracketPosition()
Returns the position of the highlighted bracket (the bracket
matching the one before the caret)
getBracketLine
public final int getBracketLine()
Returns the line of the highlighted bracket (the bracket
matching the one before the caret)
addCaretListener
public final void addCaretListener(CaretListener listener)
Adds a caret change listener to this text area.
Parameters:
listener – The listener
removeCaretListener
public final void removeCaretListener(CaretListener listener)
Removes a caret change listener from this text area.
Parameters:
listener – The listener
cut
public void cut()
Deletes the selected text from the text area and places it
into the clipboard.
copy
public void copy()
Places the selected text into the clipboard.
paste
public void paste()
Inserts the clipboard contents into the text.
removeNotify
public void removeNotify()
Called by the AWT when this component is removed from it’s parent.
This stops clears the currently focused component.
Overrides:
removeNotify in class JComponent
processKeyEvent
public void processKeyEvent(KeyEvent evt)
Forwards key events directly to the input handler.
This is slightly faster than using a KeyListener
because some Swing overhead is avoided.
Overrides:
processKeyEvent in class JComponent
fireCaretEvent
protected void fireCaretEvent()
updateBracketHighlight
protected void updateBracketHighlight(int newCaretPosition)
documentChanged
protected void documentChanged(DocumentEvent evt)
getSyntaxSensitiveToolTipText
public String getSyntaxSensitiveToolTipText(int x,
int y)
Return any relevant tool tip text for token at specified position. Keyword match
must be exact. DPS 24-May-2010
Parameters:
x – x-coordinate of current position
y – y-coordinate of current position
Returns:
String containing appropriate tool tip text. Possibly HTML-encoded.
getAutoIndent
public String getAutoIndent()
Constructs string for auto-indent feature. Returns empty string
if auto-intent is disabled or if line has no leading white space.
Uses getLeadingWhiteSpace(). Is used by InputHandler when processing
key press for Enter key. DPS 31-Dec-2010
Returns:
String containing auto-indent characters to be inserted into text
getLeadingWhiteSpace
public String getLeadingWhiteSpace()
Makes a copy of leading white space (tab or space) from the current line and
returns it. DPS 31-Dec-2010
Returns:
String containing leading white space of current line. Empty string if none.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
KeywordMap
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class KeywordMap
java.lang.Object
mars.venus.editors.jeditsyntax.KeywordMap
public class KeywordMap
extends Object
A KeywordMap is similar to a hashtable in that it maps keys
to values. However, the `keys’ are Swing segments. This allows lookups of
text substrings without the overhead of creating a new string object.
This class is used by CTokenMarker to map keywords to ids.
Author:
Slava Pestov, Mike Dillon
Field Summary
protected int mapLength
Constructor Summary
KeywordMap(boolean ignoreCase)
Creates a new KeywordMap.
KeywordMap(boolean ignoreCase,
int mapLength)
Creates a new KeywordMap.
Method Summary
void add(String keyword,
byte id)
Adds a key-value mapping.
boolean getIgnoreCase()
Returns true if the keyword map is set to be case insensitive,
false otherwise.
protected int getSegmentMapKey(Segment s,
int off,
int len)
protected int getStringMapKey(String s)
byte lookup(Segment text,
int offset,
int length)
Looks up a key.
void setIgnoreCase(boolean ignoreCase)
Sets if the keyword map should be case insensitive.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
mapLength
protected int mapLength
Constructor Detail
KeywordMap
public KeywordMap(boolean ignoreCase)
Creates a new KeywordMap.
Parameters:
ignoreCase – True if keys are case insensitive
KeywordMap
public KeywordMap(boolean ignoreCase,
int mapLength)
Creates a new KeywordMap.
Parameters:
ignoreCase – True if the keys are case insensitive
mapLength – The number of `buckets’ to create.
A value of 52 will give good performance for most maps.
Method Detail
lookup
public byte lookup(Segment text,
int offset,
int length)
Looks up a key.
Parameters:
text – The text segment
offset – The offset of the substring within the text segment
length – The length of the substring
add
public void add(String keyword,
byte id)
Adds a key-value mapping.
Parameters:
keyword – The key
getIgnoreCase
public boolean getIgnoreCase()
Returns true if the keyword map is set to be case insensitive,
false otherwise.
setIgnoreCase
public void setIgnoreCase(boolean ignoreCase)
Sets if the keyword map should be case insensitive.
Parameters:
ignoreCase – True if the keyword map should be case
insensitive, false otherwise
getStringMapKey
protected int getStringMapKey(String s)
getSegmentMapKey
protected int getSegmentMapKey(Segment s,
int off,
int len)
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
mars.venus.editors.jeditsyntax
Interfaces
InputHandler.MacroRecorder
InputHandler.NonRecordable
InputHandler.NonRepeatable
InputHandler.Wrapper
TextAreaPainter.Highlight
Classes
DefaultInputHandler
InputHandler
InputHandler.backspace
InputHandler.backspace_word
InputHandler.clip_copy
InputHandler.clip_cut
InputHandler.clip_paste
InputHandler.delete
InputHandler.delete_word
InputHandler.document_end
InputHandler.document_home
InputHandler.end
InputHandler.home
InputHandler.insert_break
InputHandler.insert_char
InputHandler.insert_tab
InputHandler.next_char
InputHandler.next_line
InputHandler.next_page
InputHandler.next_word
InputHandler.overwrite
InputHandler.prev_char
InputHandler.prev_line
InputHandler.prev_page
InputHandler.prev_word
InputHandler.repeat
InputHandler.select_all
InputHandler.toggle_rect
JEditBasedTextArea
JEditTextArea
KeywordMap
PopupHelpItem
SyntaxDocument
SyntaxStyle
SyntaxUtilities
TextAreaDefaults
TextAreaPainter
TextUtilities
mars.venus.editors.jeditsyntax
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
Package mars.venus.editors.jeditsyntax
Interface Summary
InputHandler.MacroRecorder Macro recorder.
InputHandler.NonRecordable If an action implements this interface, it should not be recorded
by the macro recorder.
InputHandler.NonRepeatable If an action implements this interface, it should not be repeated.
InputHandler.Wrapper For use by EditAction.Wrapper only.
TextAreaPainter.Highlight Highlight interface.
Class Summary
DefaultInputHandler The default input handler.
InputHandler An input handler converts the user’s key strokes into concrete actions.
InputHandler.backspace
InputHandler.backspace_word
InputHandler.clip_copy
InputHandler.clip_cut
InputHandler.clip_paste
InputHandler.delete
InputHandler.delete_word
InputHandler.document_end
InputHandler.document_home
InputHandler.end
InputHandler.home
InputHandler.insert_break
InputHandler.insert_char
InputHandler.insert_tab
InputHandler.next_char
InputHandler.next_line
InputHandler.next_page
InputHandler.next_word
InputHandler.overwrite
InputHandler.prev_char
InputHandler.prev_line
InputHandler.prev_page
InputHandler.prev_word
InputHandler.repeat
InputHandler.select_all
InputHandler.toggle_rect
JEditBasedTextArea Adaptor subclass for JEditTextArea
Provides those methods required by the MARSTextEditingArea interface
that are not defined by JEditTextArea.
JEditTextArea jEdit’s text area component.
KeywordMap A KeywordMap is similar to a hashtable in that it maps keys
to values.
PopupHelpItem Handly little class to contain help information for a popupMenu or
tool tip item.
SyntaxDocument A document implementation that can be tokenized by the syntax highlighting
system.
SyntaxStyle A simple text style class.
SyntaxUtilities Class with several utility functions used by jEdit’s syntax colorizing
subsystem.
TextAreaDefaults Encapsulates default settings for a text area.
TextAreaPainter The text area repaint manager.
TextUtilities Class with several utility functions used by the text area component.
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
mars.venus.editors.jeditsyntax Class Hierarchy
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Hierarchy For Package mars.venus.editors.jeditsyntax
Package Hierarchies:
All Packages
Class Hierarchy
java.lang.Object javax.swing.text.AbstractDocument (implements javax.swing.text.Document, java.io.Serializable)
javax.swing.text.PlainDocument mars.venus.editors.jeditsyntax.SyntaxDocument
java.awt.Component (implements java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable)
java.awt.Container javax.swing.JComponent (implements java.io.Serializable)
mars.venus.editors.jeditsyntax.JEditTextArea mars.venus.editors.jeditsyntax.JEditBasedTextArea (implements javax.swing.event.CaretListener, mars.venus.editors.MARSTextEditingArea)
mars.venus.editors.jeditsyntax.TextAreaPainter (implements javax.swing.text.TabExpander)
mars.venus.editors.jeditsyntax.InputHandler.backspace (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.backspace_word (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.clip_copy (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.clip_cut (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.clip_paste (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.delete (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.delete_word (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.document_end (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.document_home (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.end (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.home (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.insert_break (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.insert_char (implements java.awt.event.ActionListener, mars.venus.editors.jeditsyntax.InputHandler.NonRepeatable)
mars.venus.editors.jeditsyntax.InputHandler.insert_tab (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.next_char (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.next_line (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.next_page (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.next_word (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.overwrite (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.prev_char (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.prev_line (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.prev_page (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.prev_word (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.repeat (implements java.awt.event.ActionListener, mars.venus.editors.jeditsyntax.InputHandler.NonRecordable)
mars.venus.editors.jeditsyntax.InputHandler.select_all (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.toggle_rect (implements java.awt.event.ActionListener)
java.awt.event.KeyAdapter (implements java.awt.event.KeyListener)
mars.venus.editors.jeditsyntax.InputHandler mars.venus.editors.jeditsyntax.DefaultInputHandler
mars.venus.editors.jeditsyntax.KeywordMap
mars.venus.editors.jeditsyntax.PopupHelpItem
mars.venus.editors.jeditsyntax.SyntaxStyle
mars.venus.editors.jeditsyntax.SyntaxUtilities
mars.venus.editors.jeditsyntax.TextAreaDefaults
mars.venus.editors.jeditsyntax.TextUtilities
Interface Hierarchy
mars.venus.editors.jeditsyntax.InputHandler.MacroRecorder
mars.venus.editors.jeditsyntax.InputHandler.NonRecordable
mars.venus.editors.jeditsyntax.InputHandler.NonRepeatable
mars.venus.editors.jeditsyntax.InputHandler.Wrapper
mars.venus.editors.jeditsyntax.TextAreaPainter.Highlight
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
PopupHelpItem
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class PopupHelpItem
java.lang.Object
mars.venus.editors.jeditsyntax.PopupHelpItem
public class PopupHelpItem
extends Object
Handly little class to contain help information for a popupMenu or
tool tip item.
Constructor Summary
PopupHelpItem(String tokenText,
String example,
String description)
Create popup help item, where match is result of an exact-match search.
PopupHelpItem(String tokenText,
String example,
String description,
boolean exact)
Create popup help item.
Method Summary
String getDescription()
boolean getExact()
Determines whether match occurred in an exact-match or prefix-match search.
String getExample()
int getExampleLength()
String getExamplePaddedToLength(int length)
String getTokenText()
The document text that mached this item
static int maxExampleLength(ArrayList matches)
void setDescription(String description)
void setExample(String example)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
PopupHelpItem
public PopupHelpItem(String tokenText,
String example,
String description,
boolean exact)
Create popup help item. This is created as result of either an exact-match or
prefix-match search. Note that prefix-match search includes exact as well as partial matches.
Parameters:
tokenText – The document text that matched
example – An example instruction
description – A textual description of the instruction
exact – True if match occurred as result of exact-match search, false otherwise.
PopupHelpItem
public PopupHelpItem(String tokenText,
String example,
String description)
Create popup help item, where match is result of an exact-match search.
Parameters:
tokenText – The document text that matched
example – An example instruction
description – A textual description of the instruction
Method Detail
getTokenText
public String getTokenText()
The document text that mached this item
getExample
public String getExample()
getDescription
public String getDescription()
getExact
public boolean getExact()
Determines whether match occurred in an exact-match or prefix-match search.
Note this can return false even if the match is exact because prefix-match also
includes exact match results. E.g. prefix match on “lw” will match both “lwl” and “lw”.
Returns:
True if exact-match search, false otherwise.
getExampleLength
public int getExampleLength()
getExamplePaddedToLength
public String getExamplePaddedToLength(int length)
setExample
public void setExample(String example)
setDescription
public void setDescription(String description)
maxExampleLength
public static int maxExampleLength(ArrayList matches)
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyntaxDocument
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class SyntaxDocument
java.lang.Object
javax.swing.text.AbstractDocument
javax.swing.text.PlainDocument
mars.venus.editors.jeditsyntax.SyntaxDocument
All Implemented Interfaces:
Serializable, Document
public class SyntaxDocument
extends PlainDocument
A document implementation that can be tokenized by the syntax highlighting
system.
Author:
Slava Pestov
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement
Field Summary
protected TokenMarker tokenMarker
Fields inherited from class javax.swing.text.PlainDocument
lineLimitAttribute, tabSizeAttribute
Fields inherited from class javax.swing.text.AbstractDocument
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
Constructor Summary
SyntaxDocument()
Method Summary
void addUndoableEdit(UndoableEdit edit)
Adds an undoable edit to this document’s undo list.
void beginCompoundEdit()
Starts a compound edit that can be undone in one operation.
void endCompoundEdit()
Ends a compound edit that can be undone in one operation.
protected void fireInsertUpdate(DocumentEvent evt)
We overwrite this method to update the token marker
state immediately so that any event listeners get a
consistent token marker.
protected void fireRemoveUpdate(DocumentEvent evt)
We overwrite this method to update the token marker
state immediately so that any event listeners get a
consistent token marker.
TokenMarker getTokenMarker()
Returns the token marker that is to be used to split lines
of this document up into tokens.
void setTokenMarker(TokenMarker tm)
Sets the token marker that is to be used to split lines of
this document up into tokens.
void tokenizeLines()
Reparses the document, by passing all lines to the token
marker.
void tokenizeLines(int start,
int len)
Reparses the document, by passing the specified lines to the
token marker.
Methods inherited from class javax.swing.text.PlainDocument
createDefaultRoot, getDefaultRootElement, getParagraphElement, insertString, insertUpdate, removeUpdate
Methods inherited from class javax.swing.text.AbstractDocument
addDocumentListener, addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, remove, removeDocumentListener, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
tokenMarker
protected TokenMarker tokenMarker
Constructor Detail
SyntaxDocument
public SyntaxDocument()
Method Detail
getTokenMarker
public TokenMarker getTokenMarker()
Returns the token marker that is to be used to split lines
of this document up into tokens. May return null if this
document is not to be colorized.
setTokenMarker
public void setTokenMarker(TokenMarker tm)
Sets the token marker that is to be used to split lines of
this document up into tokens. May throw an exception if
this is not supported for this type of document.
Parameters:
tm – The new token marker
tokenizeLines
public void tokenizeLines()
Reparses the document, by passing all lines to the token
marker. This should be called after the document is first
loaded.
tokenizeLines
public void tokenizeLines(int start,
int len)
Reparses the document, by passing the specified lines to the
token marker. This should be called after a large quantity of
text is first inserted.
Parameters:
start – The first line to parse
len – The number of lines, after the first one to parse
beginCompoundEdit
public void beginCompoundEdit()
Starts a compound edit that can be undone in one operation.
Subclasses that implement undo should override this method;
this class has no undo functionality so this method is
empty.
endCompoundEdit
public void endCompoundEdit()
Ends a compound edit that can be undone in one operation.
Subclasses that implement undo should override this method;
this class has no undo functionality so this method is
empty.
addUndoableEdit
public void addUndoableEdit(UndoableEdit edit)
Adds an undoable edit to this document’s undo list. The edit
should be ignored if something is currently being undone.
Parameters:
edit – The undoable edit
Since:
jEdit 2.2pre1
fireInsertUpdate
protected void fireInsertUpdate(DocumentEvent evt)
We overwrite this method to update the token marker
state immediately so that any event listeners get a
consistent token marker.
Overrides:
fireInsertUpdate in class AbstractDocument
fireRemoveUpdate
protected void fireRemoveUpdate(DocumentEvent evt)
We overwrite this method to update the token marker
state immediately so that any event listeners get a
consistent token marker.
Overrides:
fireRemoveUpdate in class AbstractDocument
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyntaxStyle
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class SyntaxStyle
java.lang.Object
mars.venus.editors.jeditsyntax.SyntaxStyle
public class SyntaxStyle
extends Object
A simple text style class. It can specify the color, italic flag,
and bold flag of a run of text.
Author:
Slava Pestov
Constructor Summary
SyntaxStyle(Color color,
boolean italic,
boolean bold)
Creates a new SyntaxStyle.
Method Summary
Color getColor()
Returns the color specified in this style.
String getColorAsHexString()
Returns the color coded as Stringified 32-bit hex with
Red in bits 16-23, Green in bits 8-15, Blue in bits 0-7
e.g.
FontMetrics getFontMetrics(Font font)
Returns the font metrics for the styled font.
Font getStyledFont(Font font)
Returns the specified font, but with the style’s bold and
italic flags applied.
boolean isBold()
Returns true if boldface is enabled for this style.
boolean isItalic()
Returns true if italics is enabled for this style.
boolean isPlain()
Returns true if no font styles are enabled.
void setGraphicsFlags(Graphics gfx,
Font font)
Sets the foreground color and font of the specified graphics
context to that specified in this style.
String toString()
Returns a string representation of this object.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
SyntaxStyle
public SyntaxStyle(Color color,
boolean italic,
boolean bold)
Creates a new SyntaxStyle.
Parameters:
color – The text color
italic – True if the text should be italics
bold – True if the text should be bold
Method Detail
getColor
public Color getColor()
Returns the color specified in this style.
getColorAsHexString
public String getColorAsHexString()
Returns the color coded as Stringified 32-bit hex with
Red in bits 16-23, Green in bits 8-15, Blue in bits 0-7
e.g. “0x00FF3366” where Red is FF, Green is 33, Blue is 66.
This is used by Settings initialization to avoid direct
use of Color class. Long story. DPS 13-May-2010
Returns:
String containing hex-coded color value.
isPlain
public boolean isPlain()
Returns true if no font styles are enabled.
isItalic
public boolean isItalic()
Returns true if italics is enabled for this style.
isBold
public boolean isBold()
Returns true if boldface is enabled for this style.
getStyledFont
public Font getStyledFont(Font font)
Returns the specified font, but with the style’s bold and
italic flags applied.
getFontMetrics
public FontMetrics getFontMetrics(Font font)
Returns the font metrics for the styled font.
setGraphicsFlags
public void setGraphicsFlags(Graphics gfx,
Font font)
Sets the foreground color and font of the specified graphics
context to that specified in this style.
Parameters:
gfx – The graphics context
font – The font to add the styles to
toString
public String toString()
Returns a string representation of this object.
Overrides:
toString in class Object
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SyntaxUtilities
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class SyntaxUtilities
java.lang.Object
mars.venus.editors.jeditsyntax.SyntaxUtilities
public class SyntaxUtilities
extends Object
Class with several utility functions used by jEdit’s syntax colorizing
subsystem.
Author:
Slava Pestov
Field Summary
static Popup popup
static boolean popupShowing
Paints the specified line onto the graphics context.
Method Summary
static SyntaxStyle[] getCurrentSyntaxStyles()
Returns the CURRENT style table.
static SyntaxStyle[] getDefaultSyntaxStyles()
Returns the default style table.
static int paintSyntaxLine(Segment line,
Token tokens,
SyntaxStyle[] styles,
TabExpander expander,
Graphics gfx,
int x,
int y)
static boolean regionMatches(boolean ignoreCase,
Segment text,
int offset,
char[] match)
Checks if a subregion of a Segment is equal to a
character array.
static boolean regionMatches(boolean ignoreCase,
Segment text,
int offset,
String match)
Checks if a subregion of a Segment is equal to a
string.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
popupShowing
public static boolean popupShowing
Paints the specified line onto the graphics context. Note that this
method munges the offset and count values of the segment.
popup
public static Popup popup
Method Detail
regionMatches
public static boolean regionMatches(boolean ignoreCase,
Segment text,
int offset,
String match)
Checks if a subregion of a Segment is equal to a
string.
Parameters:
ignoreCase – True if case should be ignored, false otherwise
text – The segment
offset – The offset into the segment
match – The string to match
regionMatches
public static boolean regionMatches(boolean ignoreCase,
Segment text,
int offset,
char[] match)
Checks if a subregion of a Segment is equal to a
character array.
Parameters:
ignoreCase – True if case should be ignored, false otherwise
text – The segment
offset – The offset into the segment
match – The character array to match
getDefaultSyntaxStyles
public static SyntaxStyle[] getDefaultSyntaxStyles()
Returns the default style table. This can be passed to the
setStyles() method of SyntaxDocument
to use the default syntax styles.
getCurrentSyntaxStyles
public static SyntaxStyle[] getCurrentSyntaxStyles()
Returns the CURRENT style table. This can be passed to the
setStyles() method of SyntaxDocument
to use the current syntax styles. If changes have been made
via MARS Settings menu, the current settings will not be the
same as the default settings.
paintSyntaxLine
public static int paintSyntaxLine(Segment line,
Token tokens,
SyntaxStyle[] styles,
TabExpander expander,
Graphics gfx,
int x,
int y)
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
TextAreaDefaults
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class TextAreaDefaults
java.lang.Object
mars.venus.editors.jeditsyntax.TextAreaDefaults
public class TextAreaDefaults
extends Object
Encapsulates default settings for a text area. This can be passed
to the constructor once the necessary fields have been filled out.
The advantage of doing this over calling lots of set() methods after
creating the text area is that this method is faster.
Field Summary
boolean blockCaret
boolean bracketHighlight
Color bracketHighlightColor
int caretBlinkRate
boolean caretBlinks
Color caretColor
boolean caretVisible
int cols
SyntaxDocument document
boolean editable
int electricScroll
Color eolMarkerColor
boolean eolMarkers
InputHandler inputHandler
boolean lineHighlight
Color lineHighlightColor
boolean paintInvalid
JPopupMenu popup
int rows
Color selectionColor
SyntaxStyle[] styles
int tabSize
Constructor Summary
TextAreaDefaults()
Method Summary
static TextAreaDefaults getDefaults()
Returns a new TextAreaDefaults object with the default values filled
in.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
inputHandler
public InputHandler inputHandler
document
public SyntaxDocument document
editable
public boolean editable
caretVisible
public boolean caretVisible
caretBlinks
public boolean caretBlinks
blockCaret
public boolean blockCaret
caretBlinkRate
public int caretBlinkRate
electricScroll
public int electricScroll
tabSize
public int tabSize
cols
public int cols
rows
public int rows
styles
public SyntaxStyle[] styles
caretColor
public Color caretColor
selectionColor
public Color selectionColor
lineHighlightColor
public Color lineHighlightColor
lineHighlight
public boolean lineHighlight
bracketHighlightColor
public Color bracketHighlightColor
bracketHighlight
public boolean bracketHighlight
eolMarkerColor
public Color eolMarkerColor
eolMarkers
public boolean eolMarkers
paintInvalid
public boolean paintInvalid
popup
public JPopupMenu popup
Constructor Detail
TextAreaDefaults
public TextAreaDefaults()
Method Detail
getDefaults
public static TextAreaDefaults getDefaults()
Returns a new TextAreaDefaults object with the default values filled
in.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
TextAreaPainter.Highlight
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Interface TextAreaPainter.Highlight
Enclosing class:
TextAreaPainter
public static interface TextAreaPainter.Highlight
Highlight interface.
Method Summary
String getToolTipText(MouseEvent evt)
Returns the tool tip to display at the specified
location.
void init(JEditTextArea textArea,
TextAreaPainter.Highlight next)
Called after the highlight painter has been added.
void paintHighlight(Graphics gfx,
int line,
int y)
This should paint the highlight and delgate to the
next highlight painter.
Method Detail
init
void init(JEditTextArea textArea,
TextAreaPainter.Highlight next)
Called after the highlight painter has been added.
Parameters:
textArea – The text area
next – The painter this one should delegate to
paintHighlight
void paintHighlight(Graphics gfx,
int line,
int y)
This should paint the highlight and delgate to the
next highlight painter.
Parameters:
gfx – The graphics context
line – The line number
y – The y co-ordinate of the line
getToolTipText
String getToolTipText(MouseEvent evt)
Returns the tool tip to display at the specified
location. If this highlighter doesn’t know what to
display, it should delegate to the next highlight
painter.
Parameters:
evt – The mouse event
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
TextAreaPainter
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class TextAreaPainter
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
mars.venus.editors.jeditsyntax.TextAreaPainter
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, TabExpander
public class TextAreaPainter
extends JComponent
implements TabExpander
The text area repaint manager. It performs double buffering and paints
lines of text.
Author:
Slava Pestov
See Also:
Serialized Form
Nested Class Summary
static interface TextAreaPainter.Highlight
Highlight interface.
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
protected boolean blockCaret
protected boolean bracketHighlight
protected Color bracketHighlightColor
protected Color caretColor
protected int cols
protected Color eolMarkerColor
protected boolean eolMarkers
protected FontMetrics fm
protected TextAreaPainter.Highlight highlights
protected boolean lineHighlight
protected Color lineHighlightColor
protected boolean paintInvalid
protected int rows
protected Color selectionColor
protected SyntaxStyle[] styles
protected int tabSize
protected int tabSizeChars
protected JEditTextArea textArea
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
TextAreaPainter(JEditTextArea textArea,
TextAreaDefaults defaults)
Creates a new repaint manager.
Method Summary
void addCustomHighlight(TextAreaPainter.Highlight highlight)
Adds a custom highlight painter.
Color getBracketHighlightColor()
Returns the bracket highlight color.
Color getCaretColor()
Returns the caret color.
Color getEOLMarkerColor()
Returns the EOL marker color.
boolean getEOLMarkersPainted()
Returns true if EOL markers are drawn, false otherwise.
FontMetrics getFontMetrics()
Returns the font metrics used by this component.
boolean getInvalidLinesPainted()
Returns true if invalid lines are painted as red tildes (~),
false otherwise.
Color getLineHighlightColor()
Returns the line highlight color.
Dimension getMinimumSize()
Returns the painter’s minimum size.
Dimension getPreferredSize()
Returns the painter’s preferred size.
Color getSelectionColor()
Returns the selection color.
SyntaxStyle[] getStyles()
Returns the syntax styles used to paint colorized text.
int getTabSize()
Fetch the tab size in characters.
String getToolTipText(MouseEvent evt)
Returns the tool tip to display at the specified location.
void invalidateLine(int line)
Marks a line as needing a repaint.
void invalidateLineRange(int firstLine,
int lastLine)
Marks a range of lines as needing a repaint.
void invalidateSelectedLines()
Repaints the lines containing the selection.
boolean isBlockCaretEnabled()
Returns true if the caret should be drawn as a block, false otherwise.
boolean isBracketHighlightEnabled()
Returns true if bracket highlighting is enabled, false otherwise.
boolean isLineHighlightEnabled()
Returns true if line highlight is enabled, false otherwise.
boolean isManagingFocus()
Returns if this component can be traversed by pressing the
Tab key.
float nextTabStop(float x,
int tabOffset)
Implementation of TabExpander interface.
void paint(Graphics gfx)
Repaints the text.
protected void paintBracketHighlight(Graphics gfx,
int line,
int y)
protected void paintCaret(Graphics gfx,
int line,
int y)
protected void paintHighlight(Graphics gfx,
int line,
int y)
protected void paintLine(Graphics gfx,
TokenMarker tokenMarker,
int line,
int x)
protected void paintLineHighlight(Graphics gfx,
int line,
int y)
protected void paintPlainLine(Graphics gfx,
int line,
Font defaultFont,
Color defaultColor,
int x,
int y)
protected void paintSyntaxLine(Graphics gfx,
TokenMarker tokenMarker,
int line,
Font defaultFont,
Color defaultColor,
int x,
int y)
void setBlockCaretEnabled(boolean blockCaret)
Sets if the caret should be drawn as a block, false otherwise.
void setBracketHighlightColor(Color bracketHighlightColor)
Sets the bracket highlight color.
void setBracketHighlightEnabled(boolean bracketHighlight)
Enables or disables bracket highlighting.
void setCaretColor(Color caretColor)
Sets the caret color.
void setEOLMarkerColor(Color eolMarkerColor)
Sets the EOL marker color.
void setEOLMarkersPainted(boolean eolMarkers)
Sets if EOL markers are to be drawn.
void setFont(Font font)
Sets the font for this component.
void setInvalidLinesPainted(boolean paintInvalid)
Sets if invalid lines are to be painted as red tildes.
void setLineHighlightColor(Color lineHighlightColor)
Sets the line highlight color.
void setLineHighlightEnabled(boolean lineHighlight)
Enables or disables current line highlighting.
void setSelectionColor(Color selectionColor)
Sets the selection color.
void setStyles(SyntaxStyle[] styles)
Sets the syntax styles used to paint colorized text.
void setTabSize(int size)
Set the tab size in characters.
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
textArea
protected JEditTextArea textArea
styles
protected SyntaxStyle[] styles
caretColor
protected Color caretColor
selectionColor
protected Color selectionColor
lineHighlightColor
protected Color lineHighlightColor
bracketHighlightColor
protected Color bracketHighlightColor
eolMarkerColor
protected Color eolMarkerColor
blockCaret
protected boolean blockCaret
lineHighlight
protected boolean lineHighlight
bracketHighlight
protected boolean bracketHighlight
paintInvalid
protected boolean paintInvalid
eolMarkers
protected boolean eolMarkers
cols
protected int cols
rows
protected int rows
tabSize
protected int tabSize
tabSizeChars
protected int tabSizeChars
fm
protected FontMetrics fm
highlights
protected TextAreaPainter.Highlight highlights
Constructor Detail
TextAreaPainter
public TextAreaPainter(JEditTextArea textArea,
TextAreaDefaults defaults)
Creates a new repaint manager. This should be not be called
directly.
Method Detail
isManagingFocus
public final boolean isManagingFocus()
Returns if this component can be traversed by pressing the
Tab key. This returns false.
NOTE: as of Java 1.4 this method is deprecated and no longer
has the desired effect because the focus subsystem does not
call it. I’ve implemented a KeyEventDispatcher in JEditTextArea
to handle Tabs. DPS 12-May-2010
Overrides:
isManagingFocus in class JComponent
getTabSize
public int getTabSize()
Fetch the tab size in characters. DPS 12-May-2010.
Returns:
int tab size in characters
setTabSize
public void setTabSize(int size)
Set the tab size in characters. DPS 12-May-2010.
Originally it was fixed at PlainDocument property
value (8).
Parameters:
size – tab size in characters
getStyles
public final SyntaxStyle[] getStyles()
Returns the syntax styles used to paint colorized text. Entry n
will be used to paint tokens with id = n.
See Also:
org.syntax.jedit.Token
setStyles
public final void setStyles(SyntaxStyle[] styles)
Sets the syntax styles used to paint colorized text. Entry n
will be used to paint tokens with id = n.
Parameters:
styles – The syntax styles
See Also:
org.syntax.jedit.Token
getCaretColor
public final Color getCaretColor()
Returns the caret color.
setCaretColor
public final void setCaretColor(Color caretColor)
Sets the caret color.
Parameters:
caretColor – The caret color
getSelectionColor
public final Color getSelectionColor()
Returns the selection color.
setSelectionColor
public final void setSelectionColor(Color selectionColor)
Sets the selection color.
Parameters:
selectionColor – The selection color
getLineHighlightColor
public final Color getLineHighlightColor()
Returns the line highlight color.
setLineHighlightColor
public final void setLineHighlightColor(Color lineHighlightColor)
Sets the line highlight color.
Parameters:
lineHighlightColor – The line highlight color
isLineHighlightEnabled
public final boolean isLineHighlightEnabled()
Returns true if line highlight is enabled, false otherwise.
setLineHighlightEnabled
public final void setLineHighlightEnabled(boolean lineHighlight)
Enables or disables current line highlighting.
Parameters:
lineHighlight – True if current line highlight should be enabled,
false otherwise
getBracketHighlightColor
public final Color getBracketHighlightColor()
Returns the bracket highlight color.
setBracketHighlightColor
public final void setBracketHighlightColor(Color bracketHighlightColor)
Sets the bracket highlight color.
Parameters:
bracketHighlightColor – The bracket highlight color
isBracketHighlightEnabled
public final boolean isBracketHighlightEnabled()
Returns true if bracket highlighting is enabled, false otherwise.
When bracket highlighting is enabled, the bracket matching the
one before the caret (if any) is highlighted.
setBracketHighlightEnabled
public final void setBracketHighlightEnabled(boolean bracketHighlight)
Enables or disables bracket highlighting.
When bracket highlighting is enabled, the bracket matching the
one before the caret (if any) is highlighted.
Parameters:
bracketHighlight – True if bracket highlighting should be
enabled, false otherwise
isBlockCaretEnabled
public final boolean isBlockCaretEnabled()
Returns true if the caret should be drawn as a block, false otherwise.
setBlockCaretEnabled
public final void setBlockCaretEnabled(boolean blockCaret)
Sets if the caret should be drawn as a block, false otherwise.
Parameters:
blockCaret – True if the caret should be drawn as a block,
false otherwise.
getEOLMarkerColor
public final Color getEOLMarkerColor()
Returns the EOL marker color.
setEOLMarkerColor
public final void setEOLMarkerColor(Color eolMarkerColor)
Sets the EOL marker color.
Parameters:
eolMarkerColor – The EOL marker color
getEOLMarkersPainted
public final boolean getEOLMarkersPainted()
Returns true if EOL markers are drawn, false otherwise.
setEOLMarkersPainted
public final void setEOLMarkersPainted(boolean eolMarkers)
Sets if EOL markers are to be drawn.
Parameters:
eolMarkers – True if EOL markers should be drawn, false otherwise
getInvalidLinesPainted
public boolean getInvalidLinesPainted()
Returns true if invalid lines are painted as red tildes (~),
false otherwise.
setInvalidLinesPainted
public void setInvalidLinesPainted(boolean paintInvalid)
Sets if invalid lines are to be painted as red tildes.
Parameters:
paintInvalid – True if invalid lines should be drawn, false otherwise
addCustomHighlight
public void addCustomHighlight(TextAreaPainter.Highlight highlight)
Adds a custom highlight painter.
Parameters:
highlight – The highlight
getToolTipText
public String getToolTipText(MouseEvent evt)
Returns the tool tip to display at the specified location.
Overrides:
getToolTipText in class JComponent
Parameters:
evt – The mouse event
getFontMetrics
public FontMetrics getFontMetrics()
Returns the font metrics used by this component.
setFont
public void setFont(Font font)
Sets the font for this component. This is overridden to update the
cached font metrics and to recalculate which lines are visible.
Overrides:
setFont in class JComponent
Parameters:
font – The font
paint
public void paint(Graphics gfx)
Repaints the text.
Overrides:
paint in class JComponent
Parameters:
gfx – The graphics context
invalidateLine
public final void invalidateLine(int line)
Marks a line as needing a repaint.
Parameters:
line – The line to invalidate
invalidateLineRange
public final void invalidateLineRange(int firstLine,
int lastLine)
Marks a range of lines as needing a repaint.
Parameters:
firstLine – The first line to invalidate
lastLine – The last line to invalidate
invalidateSelectedLines
public final void invalidateSelectedLines()
Repaints the lines containing the selection.
nextTabStop
public float nextTabStop(float x,
int tabOffset)
Implementation of TabExpander interface. Returns next tab stop after
a specified point.
Specified by:
nextTabStop in interface TabExpander
Parameters:
x – The x co-ordinate
tabOffset – Ignored
Returns:
The next tab stop after x
getPreferredSize
public Dimension getPreferredSize()
Returns the painter’s preferred size.
Overrides:
getPreferredSize in class JComponent
getMinimumSize
public Dimension getMinimumSize()
Returns the painter’s minimum size.
Overrides:
getMinimumSize in class JComponent
paintLine
protected void paintLine(Graphics gfx,
TokenMarker tokenMarker,
int line,
int x)
paintPlainLine
protected void paintPlainLine(Graphics gfx,
int line,
Font defaultFont,
Color defaultColor,
int x,
int y)
paintSyntaxLine
protected void paintSyntaxLine(Graphics gfx,
TokenMarker tokenMarker,
int line,
Font defaultFont,
Color defaultColor,
int x,
int y)
paintHighlight
protected void paintHighlight(Graphics gfx,
int line,
int y)
paintLineHighlight
protected void paintLineHighlight(Graphics gfx,
int line,
int y)
paintBracketHighlight
protected void paintBracketHighlight(Graphics gfx,
int line,
int y)
paintCaret
protected void paintCaret(Graphics gfx,
int line,
int y)
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
TextUtilities
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax
Class TextUtilities
java.lang.Object
mars.venus.editors.jeditsyntax.TextUtilities
public class TextUtilities
extends Object
Class with several utility functions used by the text area component.
Author:
Slava Pestov
Constructor Summary
TextUtilities()
Method Summary
static int findMatchingBracket(Document doc,
int offset)
Returns the offset of the bracket matching the one at the
specified offset of the document, or -1 if the bracket is
unmatched (or if the character is not a bracket).
static int findWordEnd(String line,
int pos,
String noWordSep)
Locates the end of the word at the specified position.
static int findWordStart(String line,
int pos,
String noWordSep)
Locates the start of the word at the specified position.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
TextUtilities
public TextUtilities()
Method Detail
findMatchingBracket
public static int findMatchingBracket(Document doc,
int offset)
throws BadLocationException
Returns the offset of the bracket matching the one at the
specified offset of the document, or -1 if the bracket is
unmatched (or if the character is not a bracket).
Parameters:
doc – The document
offset – The offset
Throws:
BadLocationException – If an out-of-bounds access
was attempted on the document text
findWordStart
public static int findWordStart(String line,
int pos,
String noWordSep)
Locates the start of the word at the specified position.
Parameters:
line – The text
pos – The position
findWordEnd
public static int findWordEnd(String line,
int pos,
String noWordSep)
Locates the end of the word at the specified position.
Parameters:
line – The text
pos – The position
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
MIPSTokenMarker
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax.tokenmarker
Class MIPSTokenMarker
java.lang.Object
mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
mars.venus.editors.jeditsyntax.tokenmarker.MIPSTokenMarker
public class MIPSTokenMarker
extends TokenMarker
MIPS token marker.
Author:
Pete Sanderson (2010) and Slava Pestov (1999)
Nested Class Summary
Nested classes/interfaces inherited from class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
TokenMarker.LineInfo
Field Summary
Fields inherited from class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
firstToken, lastLine, lastToken, length, lineInfo, nextLineRequested
Constructor Summary
MIPSTokenMarker()
MIPSTokenMarker(KeywordMap keywords)
Method Summary
static KeywordMap getKeywords()
Get KeywordMap containing all MIPS key words.
static String[] getMIPSTokenExamples()
static String[] getMIPSTokenLabels()
ArrayList getTokenExactMatchHelp(Token token,
String tokenText)
Construct and return any appropriate help information for
the given token.
ArrayList getTokenPrefixMatchHelp(String line,
Token tokenList,
Token token,
String tokenText)
Construct and return any appropriate help information for
prefix match based on current line’s token list.
byte markTokensImpl(byte token,
Segment line,
int lineIndex)
An abstract method that splits a line up into tokens.
Methods inherited from class mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
addToken, deleteLines, ensureCapacity, getLineCount, insertLines, isNextLineRequested, markTokens, supportsMultilineTokens
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
MIPSTokenMarker
public MIPSTokenMarker()
MIPSTokenMarker
public MIPSTokenMarker(KeywordMap keywords)
Method Detail
getMIPSTokenLabels
public static String[] getMIPSTokenLabels()
getMIPSTokenExamples
public static String[] getMIPSTokenExamples()
markTokensImpl
public byte markTokensImpl(byte token,
Segment line,
int lineIndex)
Description copied from class: TokenMarker
An abstract method that splits a line up into tokens. It
should parse the line, and call addToken() to
add syntax tokens to the token list. Then, it should return
the initial token type for the next line.
For example if the current line contains the start of a
multiline comment that doesn’t end on that line, this method
should return the comment token type so that it continues on
the next line.
Specified by:
markTokensImpl in class TokenMarker
Parameters:
token – The initial token type for this line
line – The line to be tokenized
lineIndex – The index of the line in the document, starting at 0
Returns:
The initial token type for the next line
getTokenExactMatchHelp
public ArrayList getTokenExactMatchHelp(Token token,
String tokenText)
Construct and return any appropriate help information for
the given token.
Overrides:
getTokenExactMatchHelp in class TokenMarker
Parameters:
token – the pertinent Token object
tokenText – the source String that matched to the token
Returns:
ArrayList of PopupHelpItem objects, one per match.
getTokenPrefixMatchHelp
public ArrayList getTokenPrefixMatchHelp(String line,
Token tokenList,
Token token,
String tokenText)
Construct and return any appropriate help information for
prefix match based on current line’s token list.
Overrides:
getTokenPrefixMatchHelp in class TokenMarker
Parameters:
line – String containing current line
tokenList – first Token on current line (head of linked list)
token – the pertinent Token object
tokenText – the source String that matched to the token in previous parameter
Returns:
ArrayList of PopupHelpItem objects, one per match.
getKeywords
public static KeywordMap getKeywords()
Get KeywordMap containing all MIPS key words. This includes all instruction mnemonics,
assembler directives, and register names.
Returns:
KeywordMap where key is the keyword and associated value is the token type (e.g. Token.KEYWORD1).
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax.tokenmarker
mars.venus.editors.jeditsyntax.tokenmarker
Classes
MIPSTokenMarker
Token
TokenMarker
mars.venus.editors.jeditsyntax.tokenmarker
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
Package mars.venus.editors.jeditsyntax.tokenmarker
Class Summary
MIPSTokenMarker MIPS token marker.
Token A linked list of tokens.
TokenMarker A token marker that splits lines of text into tokens.
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
mars.venus.editors.jeditsyntax.tokenmarker Class Hierarchy
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Hierarchy For Package mars.venus.editors.jeditsyntax.tokenmarker
Package Hierarchies:
All Packages
Class Hierarchy
java.lang.Object mars.venus.editors.jeditsyntax.tokenmarker.Token
mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker mars.venus.editors.jeditsyntax.tokenmarker.MIPSTokenMarker
mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker.LineInfo
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Token
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax.tokenmarker
Class Token
java.lang.Object
mars.venus.editors.jeditsyntax.tokenmarker.Token
public class Token
extends Object
A linked list of tokens. Each token has three fields – a token
identifier, which is a byte value that can be looked up in the
array returned by SyntaxDocument.getColors()
to get a color value, a length value which is the length of the
token in the text, and a pointer to the next token in the list.
Author:
Slava Pestov
Field Summary
static byte COMMENT1
Comment 1 token id.
static byte COMMENT2
Comment 2 token id.
static byte END
The token type, that along with a length of 0
marks the end of the token list.
byte id
The id of this token.
static byte ID_COUNT
The total number of defined token ids.
static byte INTERNAL_FIRST
The first id that can be used for internal state
in a token marker.
static byte INTERNAL_LAST
The last id that can be used for internal state
in a token marker.
static byte INVALID
Invalid token id.
static byte KEYWORD1
Keyword 1 token id.
static byte KEYWORD2
Keyword 2 token id.
static byte KEYWORD3
Keyword 3 token id.
static byte LABEL
Label token id.
int length
The length of this token.
static byte LITERAL1
Literal 1 token id.
static byte LITERAL2
Literal 2 token id.
static byte MACRO_ARG
Macro parameter token.
Token next
The next token in the linked list.
static byte NULL
Normal text token id.
static byte OPERATOR
Operator token id.
Constructor Summary
Token(int length,
byte id)
Creates a new token.
Method Summary
String toString()
Returns a string representation of this token.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
NULL
public static final byte NULL
Normal text token id. This should be used to mark
normal text.
See Also:
Constant Field Values
COMMENT1
public static final byte COMMENT1
Comment 1 token id. This can be used to mark a comment.
See Also:
Constant Field Values
COMMENT2
public static final byte COMMENT2
Comment 2 token id. This can be used to mark a comment.
See Also:
Constant Field Values
LITERAL1
public static final byte LITERAL1
Literal 1 token id. This can be used to mark a string
literal (eg, C mode uses this to mark “…” literals)
See Also:
Constant Field Values
LITERAL2
public static final byte LITERAL2
Literal 2 token id. This can be used to mark an object
literal (eg, Java mode uses this to mark true, false, etc)
See Also:
Constant Field Values
LABEL
public static final byte LABEL
Label token id. This can be used to mark labels
(eg, C mode uses this to mark …: sequences)
See Also:
Constant Field Values
KEYWORD1
public static final byte KEYWORD1
Keyword 1 token id. This can be used to mark a
keyword. This should be used for general language
constructs.
See Also:
Constant Field Values
KEYWORD2
public static final byte KEYWORD2
Keyword 2 token id. This can be used to mark a
keyword. This should be used for preprocessor
commands, or variables.
See Also:
Constant Field Values
KEYWORD3
public static final byte KEYWORD3
Keyword 3 token id. This can be used to mark a
keyword. This should be used for data types.
See Also:
Constant Field Values
OPERATOR
public static final byte OPERATOR
Operator token id. This can be used to mark an
operator. (eg, SQL mode marks +, -, etc with this
token type)
See Also:
Constant Field Values
INVALID
public static final byte INVALID
Invalid token id. This can be used to mark invalid
or incomplete tokens, so the user can easily spot
syntax errors.
See Also:
Constant Field Values
MACRO_ARG
public static final byte MACRO_ARG
Macro parameter token. Added for MARS 4.3.
See Also:
Constant Field Values
ID_COUNT
public static final byte ID_COUNT
The total number of defined token ids.
See Also:
Constant Field Values
INTERNAL_FIRST
public static final byte INTERNAL_FIRST
The first id that can be used for internal state
in a token marker.
See Also:
Constant Field Values
INTERNAL_LAST
public static final byte INTERNAL_LAST
The last id that can be used for internal state
in a token marker.
See Also:
Constant Field Values
END
public static final byte END
The token type, that along with a length of 0
marks the end of the token list.
See Also:
Constant Field Values
length
public int length
The length of this token.
id
public byte id
The id of this token.
next
public Token next
The next token in the linked list.
Constructor Detail
Token
public Token(int length,
byte id)
Creates a new token.
Parameters:
length – The length of the token
id – The id of the token
Method Detail
toString
public String toString()
Returns a string representation of this token.
Overrides:
toString in class Object
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
TokenMarker
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax.tokenmarker
Class TokenMarker
java.lang.Object
mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker
Direct Known Subclasses:
MIPSTokenMarker
public abstract class TokenMarker
extends Object
A token marker that splits lines of text into tokens. Each token carries
a length field and an indentification tag that can be mapped to a color
for painting that token.
For performance reasons, the linked list of tokens is reused after each
line is tokenized. Therefore, the return value of markTokens
should only be used for immediate painting. Notably, it cannot be
cached.
Author:
Slava Pestov
See Also:
org.syntax.jedit.Token
Nested Class Summary
class TokenMarker.LineInfo
Inner class for storing information about tokenized lines.
Field Summary
protected Token firstToken
The first token in the list.
protected int lastLine
The last tokenized line.
protected Token lastToken
The last token in the list.
protected int length
The number of lines in the model being tokenized.
protected TokenMarker.LineInfo[] lineInfo
An array for storing information about lines.
protected boolean nextLineRequested
True if the next line should be painted.
Constructor Summary
protected TokenMarker()
Creates a new TokenMarker.
Method Summary
protected void addToken(int length,
byte id)
Adds a token to the token list.
void deleteLines(int index,
int lines)
Informs the token marker that line have been deleted from
the document.
protected void ensureCapacity(int index)
Ensures that the lineInfo array can contain the
specified index.
int getLineCount()
Returns the number of lines in this token marker.
ArrayList getTokenExactMatchHelp(Token token,
String tokenText)
Construct and return any appropriate help information for
the given token.
ArrayList getTokenPrefixMatchHelp(String line,
Token tokenList,
Token tokenAtOffset,
String tokenText)
Construct and return any appropriate help information for
the given token or “token prefix”.
void insertLines(int index,
int lines)
Informs the token marker that lines have been inserted into
the document.
boolean isNextLineRequested()
Returns true if the next line should be repainted.
Token markTokens(Segment line,
int lineIndex)
A wrapper for the lower-level markTokensImpl method
that is called to split a line up into tokens.
protected abstract byte markTokensImpl(byte token,
Segment line,
int lineIndex)
An abstract method that splits a line up into tokens.
boolean supportsMultilineTokens()
Returns if the token marker supports tokens that span multiple
lines.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
firstToken
protected Token firstToken
The first token in the list. This should be used as the return
value from markTokens().
lastToken
protected Token lastToken
The last token in the list. New tokens are added here.
This should be set to null before a new line is to be tokenized.
lineInfo
protected TokenMarker.LineInfo[] lineInfo
An array for storing information about lines. It is enlarged and
shrunk automatically by the insertLines() and
deleteLines() methods.
length
protected int length
The number of lines in the model being tokenized. This can be
less than the length of the lineInfo array.
lastLine
protected int lastLine
The last tokenized line.
nextLineRequested
protected boolean nextLineRequested
True if the next line should be painted.
Constructor Detail
TokenMarker
protected TokenMarker()
Creates a new TokenMarker. This DOES NOT create
a lineInfo array; an initial call to insertLines()
does that.
Method Detail
markTokens
public Token markTokens(Segment line,
int lineIndex)
A wrapper for the lower-level markTokensImpl method
that is called to split a line up into tokens.
Parameters:
line – The line
lineIndex – The line number
markTokensImpl
protected abstract byte markTokensImpl(byte token,
Segment line,
int lineIndex)
An abstract method that splits a line up into tokens. It
should parse the line, and call addToken() to
add syntax tokens to the token list. Then, it should return
the initial token type for the next line.
For example if the current line contains the start of a
multiline comment that doesn’t end on that line, this method
should return the comment token type so that it continues on
the next line.
Parameters:
token – The initial token type for this line
line – The line to be tokenized
lineIndex – The index of the line in the document, starting at 0
Returns:
The initial token type for the next line
supportsMultilineTokens
public boolean supportsMultilineTokens()
Returns if the token marker supports tokens that span multiple
lines. If this is true, the object using this token marker is
required to pass all lines in the document to the
markTokens() method (in turn).
The default implementation returns true; it should be overridden
to return false on simpler token markers for increased speed.
insertLines
public void insertLines(int index,
int lines)
Informs the token marker that lines have been inserted into
the document. This inserts a gap in the lineInfo
array.
Parameters:
index – The first line number
lines – The number of lines
deleteLines
public void deleteLines(int index,
int lines)
Informs the token marker that line have been deleted from
the document. This removes the lines in question from the
lineInfo array.
Parameters:
index – The first line number
lines – The number of lines
getLineCount
public int getLineCount()
Returns the number of lines in this token marker.
isNextLineRequested
public boolean isNextLineRequested()
Returns true if the next line should be repainted. This
will return true after a line has been tokenized that starts
a multiline token that continues onto the next line.
getTokenExactMatchHelp
public ArrayList getTokenExactMatchHelp(Token token,
String tokenText)
Construct and return any appropriate help information for
the given token. This default definition returns null;
override it in language-specific subclasses.
Parameters:
token – the pertinent Token object
tokenText – the source String that matched to the token
Returns:
ArrayList containing PopupHelpItem objects, one per match.
getTokenPrefixMatchHelp
public ArrayList getTokenPrefixMatchHelp(String line,
Token tokenList,
Token tokenAtOffset,
String tokenText)
Construct and return any appropriate help information for
the given token or “token prefix”. Will match instruction prefixes, e.g. “s” matches “sw”.
This default definition returns null;
override it in language-specific subclasses.
Parameters:
line – String containing current line
tokenList – first Token on the current line
token – the pertinent Token object
tokenText – the source String that matched to the token
Returns:
ArrayList containing PopupHelpItem objects, one per match.
ensureCapacity
protected void ensureCapacity(int index)
Ensures that the lineInfo array can contain the
specified index. This enlarges it if necessary. No action is
taken if the array is large enough already.
It should be unnecessary to call this under normal
circumstances; insertLine() should take care of
enlarging the line info array automatically.
Parameters:
index – The array index
addToken
protected void addToken(int length,
byte id)
Adds a token to the token list.
Parameters:
length – The length of the token
id – The id of the token
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
TokenMarker.LineInfo
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors.jeditsyntax.tokenmarker
Class TokenMarker.LineInfo
java.lang.Object
mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker.LineInfo
Enclosing class:
TokenMarker
public class TokenMarker.LineInfo
extends Object
Inner class for storing information about tokenized lines.
Field Summary
Object obj
This is for use by the token marker implementations
themselves.
byte token
The id of the last token of the line.
Constructor Summary
TokenMarker.LineInfo()
Creates a new LineInfo object with token = Token.NULL
and obj = null.
TokenMarker.LineInfo(byte token,
Object obj)
Creates a new LineInfo object with the specified
parameters.
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
token
public byte token
The id of the last token of the line.
obj
public Object obj
This is for use by the token marker implementations
themselves. It can be used to store anything that
is an object and that needs to exist on a per-line
basis.
Constructor Detail
TokenMarker.LineInfo
public TokenMarker.LineInfo()
Creates a new LineInfo object with token = Token.NULL
and obj = null.
TokenMarker.LineInfo
public TokenMarker.LineInfo(byte token,
Object obj)
Creates a new LineInfo object with the specified
parameters.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
MARSTextEditingArea
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors
Interface MARSTextEditingArea
All Known Implementing Classes:
GenericTextArea, JEditBasedTextArea
public interface MARSTextEditingArea
Specifies capabilities that any test editor used in MARS must have.
Field Summary
static int TEXT_FOUND
static int TEXT_NOT_FOUND
static int TEXT_REPLACED_FOUND_NEXT
static int TEXT_REPLACED_NOT_FOUND_NEXT
Method Summary
void copy()
void cut()
void discardAllUndoableEdits()
int doFindText(String find,
boolean caseSensitive)
int doReplace(String find,
String replace,
boolean caseSensitive)
int doReplaceAll(String find,
String replace,
boolean caseSensitive)
int getCaretPosition()
Document getDocument()
Font getFont()
FontMetrics getFontMetrics(Font f)
Component getOuterComponent()
String getSelectedText()
int getSelectionEnd()
int getSelectionStart()
String getText()
UndoManager getUndoManager()
void grabFocus()
void paste()
void redo()
void replaceSelection(String str)
boolean requestFocusInWindow()
void revalidate()
void select(int selectionStart,
int selectionEnd)
void selectAll()
void setBackground(Color c)
void setCaretBlinkRate(int rate)
void setCaretPosition(int position)
void setCaretVisible(boolean vis)
void setEditable(boolean editable)
void setEnabled(boolean enabled)
void setFont(Font f)
void setLineHighlightEnabled(boolean highlight)
void setSelectionEnd(int pos)
void setSelectionStart(int pos)
void setSelectionVisible(boolean vis)
void setSourceCode(String code,
boolean editable)
void setTabSize(int chars)
void setText(String text)
void undo()
void updateSyntaxStyles()
Field Detail
TEXT_NOT_FOUND
static final int TEXT_NOT_FOUND
See Also:
Constant Field Values
TEXT_FOUND
static final int TEXT_FOUND
See Also:
Constant Field Values
TEXT_REPLACED_FOUND_NEXT
static final int TEXT_REPLACED_FOUND_NEXT
See Also:
Constant Field Values
TEXT_REPLACED_NOT_FOUND_NEXT
static final int TEXT_REPLACED_NOT_FOUND_NEXT
See Also:
Constant Field Values
Method Detail
copy
void copy()
cut
void cut()
doFindText
int doFindText(String find,
boolean caseSensitive)
doReplace
int doReplace(String find,
String replace,
boolean caseSensitive)
doReplaceAll
int doReplaceAll(String find,
String replace,
boolean caseSensitive)
getCaretPosition
int getCaretPosition()
getDocument
Document getDocument()
getSelectedText
String getSelectedText()
getSelectionEnd
int getSelectionEnd()
getSelectionStart
int getSelectionStart()
select
void select(int selectionStart,
int selectionEnd)
selectAll
void selectAll()
getText
String getText()
getUndoManager
UndoManager getUndoManager()
paste
void paste()
replaceSelection
void replaceSelection(String str)
setCaretPosition
void setCaretPosition(int position)
setEditable
void setEditable(boolean editable)
setSelectionEnd
void setSelectionEnd(int pos)
setSelectionStart
void setSelectionStart(int pos)
setText
void setText(String text)
setFont
void setFont(Font f)
getFont
Font getFont()
requestFocusInWindow
boolean requestFocusInWindow()
getFontMetrics
FontMetrics getFontMetrics(Font f)
setBackground
void setBackground(Color c)
setEnabled
void setEnabled(boolean enabled)
grabFocus
void grabFocus()
redo
void redo()
revalidate
void revalidate()
setSourceCode
void setSourceCode(String code,
boolean editable)
setCaretVisible
void setCaretVisible(boolean vis)
setSelectionVisible
void setSelectionVisible(boolean vis)
undo
void undo()
discardAllUndoableEdits
void discardAllUndoableEdits()
setLineHighlightEnabled
void setLineHighlightEnabled(boolean highlight)
setCaretBlinkRate
void setCaretBlinkRate(int rate)
setTabSize
void setTabSize(int chars)
updateSyntaxStyles
void updateSyntaxStyles()
getOuterComponent
Component getOuterComponent()
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus.editors
mars.venus.editors
Interfaces
MARSTextEditingArea
mars.venus.editors
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
Package mars.venus.editors
Interface Summary
MARSTextEditingArea Specifies capabilities that any test editor used in MARS must have.
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
mars.venus.editors Class Hierarchy
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Hierarchy For Package mars.venus.editors
Package Hierarchies:
All Packages
Interface Hierarchy
mars.venus.editors.MARSTextEditingArea
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
EditPane
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class EditPane
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
mars.venus.EditPane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Observer, Accessible
public class EditPane
extends JPanel
implements Observer
Represents one file opened for editing. Maintains required internal structures.
Before Mars 4.0, there was only one editor pane, a tab, and only one file could
be open at a time. With 4.0 came the multifile (pane, tab) editor, and existing
duties were split between EditPane and the new EditTabbedPane class.
Author:
Sanderson and Bumgarner
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
EditPane(VenusUI appFrame)
Constructor for the EditPane class.
Method Summary
int convertLineColumnToStreamPosition(int line,
int column)
Given line and column (position in the line) numbers, calculate
its byte stream position in text being edited.
Point convertStreamPositionToLineColumn(int position)
void copyText()
copy currently-selected text into clipboard
void cutText()
cut currently-selected text into clipboard
void discardAllUndoableEdits()
Get rid of any accumulated undoable edits.
void displayCaretPosition(int pos)
Update the caret position label on the editor’s border to
display the current line and column.
void displayCaretPosition(Point p)
Display cursor coordinates
int doFindText(String find,
boolean caseSensitive)
Finds next occurrence of text in a forward search of a string.
int doReplace(String find,
String replace,
boolean caseSensitive)
Finds and replaces next occurrence of text in a string in a forward search.
int doReplaceAll(String find,
String replace,
boolean caseSensitive)
Finds and replaces ALL occurrences of text in a string in a forward search.
String getFilename()
Delegates to corresponding FileStatus method
int getFileStatus()
Get the editing status for this EditPane’s associated document.
String getLineNumbersList(Document doc)
String getPathname()
Delegates to corresponding FileStatus method
String getSource()
Get source code text
int getSourceLineCount()
Calculate and return number of lines in source code text.
UndoManager getUndoManager()
get the manager in charge of Undo and Redo operations
boolean hasUnsavedEdits()
Delegates to corresponding FileStatus method
boolean isNew()
Delegates to corresponding FileStatus method
void pasteText()
paste clipboard contents at cursor position
void redo()
Redo previous edit
void selectAllText()
select all text
void selectLine(int line)
Select the specified editor text line.
void selectLine(int line,
int column)
Select the specified editor text line.
void setFileStatus(int fileStatus)
Set the editing status for this EditPane’s associated document.
void setPathname(String pathname)
Delegates to corresponding FileStatus method
void setShowLineNumbersEnabled(boolean enabled)
enable or disable checkbox that controls display of line numbers
void setSourceCode(String s,
boolean editable)
For initalizing the source code when opening an ASM file
boolean showingLineNumbers()
get editor’s line number display status
void tellEditingComponentToRequestFocusInWindow()
Delegates to text area’s requestFocusInWindow method.
void undo()
Undo previous edit
void update(Observable fontChanger,
Object arg)
Update, if source code is visible, when Font setting changes.
void updateRedoState()
Update state of Edit menu’s Redo menu item.
void updateStaticFileStatus()
Delegates to corresponding FileStatus method
void updateUndoState()
Update state of Edit menu’s Undo menu item.
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
EditPane
public EditPane(VenusUI appFrame)
Constructor for the EditPane class.
Method Detail
setSourceCode
public void setSourceCode(String s,
boolean editable)
For initalizing the source code when opening an ASM file
Parameters:
s – String containing text
editable – set true if code is editable else false
discardAllUndoableEdits
public void discardAllUndoableEdits()
Get rid of any accumulated undoable edits. It is useful to call
this method after opening a file into the text area. The
act of setting its text content upon reading the file will generate
an undoable edit. Normally you don’t want a freshly-opened file
to appear with its Undo action enabled. But it will unless you
call this after setting the text.
getLineNumbersList
public String getLineNumbersList(Document doc)
getSourceLineCount
public int getSourceLineCount()
Calculate and return number of lines in source code text.
Do this by counting newline characters then adding one if last line does
not end with newline character.
getSource
public String getSource()
Get source code text
Returns:
Sting containing source code
setFileStatus
public void setFileStatus(int fileStatus)
Set the editing status for this EditPane’s associated document.
For the argument, use one of the constants from class FileStatus.
Parameters:
FileStatus – the status constant from class FileStatus
getFileStatus
public int getFileStatus()
Get the editing status for this EditPane’s associated document.
This will be one of the constants from class FileStatus.
getFilename
public String getFilename()
Delegates to corresponding FileStatus method
getPathname
public String getPathname()
Delegates to corresponding FileStatus method
setPathname
public void setPathname(String pathname)
Delegates to corresponding FileStatus method
hasUnsavedEdits
public boolean hasUnsavedEdits()
Delegates to corresponding FileStatus method
isNew
public boolean isNew()
Delegates to corresponding FileStatus method
tellEditingComponentToRequestFocusInWindow
public void tellEditingComponentToRequestFocusInWindow()
Delegates to text area’s requestFocusInWindow method.
updateStaticFileStatus
public void updateStaticFileStatus()
Delegates to corresponding FileStatus method
getUndoManager
public UndoManager getUndoManager()
get the manager in charge of Undo and Redo operations
Returns:
the UnDo manager
copyText
public void copyText()
copy currently-selected text into clipboard
cutText
public void cutText()
cut currently-selected text into clipboard
pasteText
public void pasteText()
paste clipboard contents at cursor position
selectAllText
public void selectAllText()
select all text
undo
public void undo()
Undo previous edit
redo
public void redo()
Redo previous edit
updateUndoState
public void updateUndoState()
Update state of Edit menu’s Undo menu item.
updateRedoState
public void updateRedoState()
Update state of Edit menu’s Redo menu item.
showingLineNumbers
public boolean showingLineNumbers()
get editor’s line number display status
Returns:
true if editor is current displaying line numbers, false otherwise.
setShowLineNumbersEnabled
public void setShowLineNumbersEnabled(boolean enabled)
enable or disable checkbox that controls display of line numbers
Parameters:
enable – True to enable box, false to disable.
displayCaretPosition
public void displayCaretPosition(int pos)
Update the caret position label on the editor’s border to
display the current line and column. The position is given
as text stream offset and will be converted into line and column.
Parameters:
pos – Offset into the text stream of caret.
displayCaretPosition
public void displayCaretPosition(Point p)
Display cursor coordinates
Parameters:
p – Point object with x-y (column, line number) coordinates of cursor
convertStreamPositionToLineColumn
public Point convertStreamPositionToLineColumn(int position)
convertLineColumnToStreamPosition
public int convertLineColumnToStreamPosition(int line,
int column)
Given line and column (position in the line) numbers, calculate
its byte stream position in text being edited.
Parameters:
line – Line number in file (starts with 1)
column – Position within that line (starts with 1)
Returns:
corresponding stream position. Returns -1 if there is no corresponding position.
selectLine
public void selectLine(int line)
Select the specified editor text line. Lines are numbered starting with 1, consistent
with line numbers displayed by the editor.
Parameters:
line – The desired line number of this TextPane’s text. Numbering starts at 1, and
nothing will happen if the parameter value is less than 1
selectLine
public void selectLine(int line,
int column)
Select the specified editor text line. Lines are numbered starting with 1, consistent
with line numbers displayed by the editor.
Parameters:
line – The desired line number of this TextPane’s text. Numbering starts at 1, and
nothing will happen if the parameter value is less than 1
column – Desired column at which to place the cursor.
doFindText
public int doFindText(String find,
boolean caseSensitive)
Finds next occurrence of text in a forward search of a string. Search begins
at the current cursor location, and wraps around when the end of the string
is reached.
Parameters:
find – the text to locate in the string
caseSensitive – true if search is to be case-sensitive, false otherwise
Returns:
TEXT_FOUND or TEXT_NOT_FOUND, depending on the result.
doReplace
public int doReplace(String find,
String replace,
boolean caseSensitive)
Finds and replaces next occurrence of text in a string in a forward search.
If cursor is initially at end
of matching selection, will immediately replace then find and select the
next occurrence if any. Otherwise it performs a find operation. The replace
can be undone with one undo operation.
Parameters:
find – the text to locate in the string
replace – the text to replace the find text with – if the find text exists
caseSensitive – true for case sensitive. false to ignore case
Returns:
Returns TEXT_FOUND if not initially at end of selected match and matching
occurrence is found. Returns TEXT_NOT_FOUND if the text is not matched.
Returns TEXT_REPLACED_NOT_FOUND_NEXT if replacement is successful but there are
no additional matches. Returns TEXT_REPLACED_FOUND_NEXT if reaplacement is
successful and there is at least one additional match.
doReplaceAll
public int doReplaceAll(String find,
String replace,
boolean caseSensitive)
Finds and replaces ALL occurrences of text in a string in a forward search.
All replacements are bundled into one CompoundEdit, so one Undo operation will
undo all of them.
Parameters:
find – the text to locate in the string
replace – the text to replace the find text with – if the find text exists
caseSensitive – true for case sensitive. false to ignore case
Returns:
the number of occurrences that were matched and replaced.
update
public void update(Observable fontChanger,
Object arg)
Update, if source code is visible, when Font setting changes.
This method is specified by the Observer interface.
Specified by:
update in interface Observer
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
EditPasteAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class EditPasteAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.EditPasteAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class EditPasteAction
extends GuiAction
Action for the Edit -> Paste menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
EditPasteAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
EditPasteAction
public EditPasteAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
EditRedoAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class EditRedoAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.EditRedoAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class EditRedoAction
extends GuiAction
Action for the Edit -> Redo menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
EditRedoAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
Adapted from TextComponentDemo.java in the
Java Tutorial “Text Component Features”
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
EditRedoAction
public EditRedoAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Adapted from TextComponentDemo.java in the
Java Tutorial “Text Component Features”
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
EditSelectAllAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class EditSelectAllAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.EditSelectAllAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class EditSelectAllAction
extends GuiAction
Action for the Edit -> Copy menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
EditSelectAllAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
EditSelectAllAction
public EditSelectAllAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
EditTabbedPane
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class EditTabbedPane
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTabbedPane
mars.venus.EditTabbedPane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants
public class EditTabbedPane
extends JTabbedPane
Tabbed pane for the editor. Each of its tabs represents an open file.
Author:
Sanderson
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JTabbedPane
JTabbedPane.AccessibleJTabbedPane, JTabbedPane.ModelListener
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class javax.swing.JTabbedPane
changeEvent, changeListener, model, SCROLL_TAB_LAYOUT, tabPlacement, WRAP_TAB_LAYOUT
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
EditTabbedPane(VenusUI appFrame,
Editor editor,
MainPane mainPane)
Constructor for the EditTabbedPane class.
Method Summary
boolean closeAllFiles()
Carries out all necessary operations to implement
the Close All operation from the File menu.
boolean closeCurrentFile()
Carries out all necessary operations to implement
the Close operation from the File menu.
boolean editsSavedOrAbandoned()
Check whether file has unsaved edits and, if so, check with user about saving them.
EditPane getCurrentEditTab()
The current EditPane representing a file.
EditPane getCurrentEditTabForFile(File file)
If the given file is open in the tabbed pane, make it the
current tab.
EditPane getEditPaneForFile(String pathname)
If there is an EditPane for the given file pathname, return it else return null.
void newFile()
Carries out all necessary operations to implement
the New operation from the File menu.
boolean openFile()
Carries out all necessary operations to implement
the Open operation from the File menu.
boolean openFile(File file)
Carries out all necessary operations to open the
specified file in the editor.
void remove(EditPane editPane)
Remove the pane and update menu status
boolean saveAllFiles()
Saves all files currently open in the editor.
boolean saveAsCurrentFile()
Pops up a dialog box to do “Save As” operation.
boolean saveCurrentFile()
Saves file under existing name.
void setCurrentEditTab(EditPane editPane)
Select the specified EditPane to be the current tab.
Methods inherited from class javax.swing.JTabbedPane
add, add, add, add, add, addChangeListener, addTab, addTab, addTab, createChangeListener, fireStateChanged, getAccessibleContext, getBackgroundAt, getBoundsAt, getChangeListeners, getComponentAt, getDisabledIconAt, getDisplayedMnemonicIndexAt, getForegroundAt, getIconAt, getMnemonicAt, getModel, getSelectedComponent, getSelectedIndex, getTabComponentAt, getTabCount, getTabLayoutPolicy, getTabPlacement, getTabRunCount, getTitleAt, getToolTipText, getToolTipTextAt, getUI, getUIClassID, indexAtLocation, indexOfComponent, indexOfTab, indexOfTab, indexOfTabComponent, insertTab, isEnabledAt, paramString, remove, remove, removeAll, removeChangeListener, removeTabAt, setBackgroundAt, setComponentAt, setDisabledIconAt, setDisplayedMnemonicIndexAt, setEnabledAt, setForegroundAt, setIconAt, setMnemonicAt, setModel, setSelectedComponent, setSelectedIndex, setTabComponentAt, setTabLayoutPolicy, setTabPlacement, setTitleAt, setToolTipTextAt, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
EditTabbedPane
public EditTabbedPane(VenusUI appFrame,
Editor editor,
MainPane mainPane)
Constructor for the EditTabbedPane class.
Method Detail
getCurrentEditTab
public EditPane getCurrentEditTab()
The current EditPane representing a file. Returns null if
no files open.
Returns:
the current editor pane
setCurrentEditTab
public void setCurrentEditTab(EditPane editPane)
Select the specified EditPane to be the current tab.
Parameters:
editPane – The EditPane tab to become current.
getCurrentEditTabForFile
public EditPane getCurrentEditTabForFile(File file)
If the given file is open in the tabbed pane, make it the
current tab. If not opened, open it in a new tab and make
it the current tab. If file is unable to be opened,
leave current tab as is.
Parameters:
file – File object for the desired file.
Returns:
EditPane for the specified file, or null if file is unable to be opened in an EditPane
newFile
public void newFile()
Carries out all necessary operations to implement
the New operation from the File menu.
openFile
public boolean openFile()
Carries out all necessary operations to implement
the Open operation from the File menu. This
begins with an Open File dialog.
Returns:
true if file was opened, false otherwise.
openFile
public boolean openFile(File file)
Carries out all necessary operations to open the
specified file in the editor.
Returns:
true if file was opened, false otherwise.
closeCurrentFile
public boolean closeCurrentFile()
Carries out all necessary operations to implement
the Close operation from the File menu. May return
false, for instance when file has unsaved changes
and user selects Cancel from the warning dialog.
Returns:
true if file was closed, false otherwise.
closeAllFiles
public boolean closeAllFiles()
Carries out all necessary operations to implement
the Close All operation from the File menu.
Returns:
true if files closed, false otherwise.
saveCurrentFile
public boolean saveCurrentFile()
Saves file under existing name. If no name, will invoke Save As.
Returns:
true if the file was actually saved.
saveAsCurrentFile
public boolean saveAsCurrentFile()
Pops up a dialog box to do “Save As” operation. If necessary
an additional overwrite dialog is performed.
Returns:
true if the file was actually saved.
saveAllFiles
public boolean saveAllFiles()
Saves all files currently open in the editor.
Returns:
true if operation succeeded otherwise false.
remove
public void remove(EditPane editPane)
Remove the pane and update menu status
getEditPaneForFile
public EditPane getEditPaneForFile(String pathname)
If there is an EditPane for the given file pathname, return it else return null.
Parameters:
pathname – Pathname for desired file
Returns:
the EditPane for this file if it is open in the editor, or null if not.
editsSavedOrAbandoned
public boolean editsSavedOrAbandoned()
Check whether file has unsaved edits and, if so, check with user about saving them.
Returns:
true if no unsaved edits or if user chooses to save them or not; false
if there are unsaved edits and user cancels the operation.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
EditUndoAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class EditUndoAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.EditUndoAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class EditUndoAction
extends GuiAction
Action for the Edit -> Undo menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
EditUndoAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
Adapted from TextComponentDemo.java in the
Java Tutorial “Text Component Features”
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
EditUndoAction
public EditUndoAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Adapted from TextComponentDemo.java in the
Java Tutorial “Text Component Features”
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
ExecutePane
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class ExecutePane
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLayeredPane
javax.swing.JDesktopPane
mars.venus.ExecutePane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
public class ExecutePane
extends JDesktopPane
Container for the execution-related windows. Currently displayed as a tabbed pane.
Author:
Sanderson and Team JSpim
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JDesktopPane
JDesktopPane.AccessibleJDesktopPane
Nested classes/interfaces inherited from class javax.swing.JLayeredPane
JLayeredPane.AccessibleJLayeredPane
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class javax.swing.JDesktopPane
LIVE_DRAG_MODE, OUTLINE_DRAG_MODE
Fields inherited from class javax.swing.JLayeredPane
DEFAULT_LAYER, DRAG_LAYER, FRAME_CONTENT_LAYER, LAYER_PROPERTY, MODAL_LAYER, PALETTE_LAYER, POPUP_LAYER
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
ExecutePane(VenusUI mainUI,
RegistersWindow regs,
Coprocessor1Window cop1Regs,
Coprocessor0Window cop0Regs)
initialize the Execute pane with major components
Method Summary
void clearPane()
Clears out all components of the Execute tab: text segment
display, data segment display, label display and register display.
int getAddressDisplayBase()
Retrieve the number system base for displaying memory addresses
NumberDisplayBaseChooser getAddressDisplayBaseChooser()
Retrieve component used to set numerical base (10 or 16) of address display.
Coprocessor0Window getCoprocessor0Window()
Access the coprocessor0 values window.
Coprocessor1Window getCoprocessor1Window()
Access the coprocessor1 values window.
DataSegmentWindow getDataSegmentWindow()
Access the data segment window.
LabelsWindow getLabelsWindow()
Access the label values window.
RegistersWindow getRegistersWindow()
Access the register values window.
TextSegmentWindow getTextSegmentWindow()
Access the text segment window.
int getValueDisplayBase()
Retrieve the number system base for displaying values (mem/register contents)
NumberDisplayBaseChooser getValueDisplayBaseChooser()
Retrieve component used to set numerical base (10 or 16) of data value display.
void numberDisplayBaseChanged(NumberDisplayBaseChooser chooser)
Update display of columns based on state of given chooser.
void setLabelWindowVisibility(boolean visibility)
Show or hide the label window (symbol table).
void setWindowBounds()
This method will set the bounds of this JDesktopPane’s internal windows
relative to the current size of this JDesktopPane.
Methods inherited from class javax.swing.JDesktopPane
addImpl, getAccessibleContext, getAllFrames, getAllFramesInLayer, getDesktopManager, getDragMode, getSelectedFrame, getUI, getUIClassID, paramString, remove, removeAll, selectFrame, setComponentZOrder, setDesktopManager, setDragMode, setSelectedFrame, setUI, updateUI
Methods inherited from class javax.swing.JLayeredPane
getComponentCountInLayer, getComponentsInLayer, getComponentToLayer, getIndexOf, getLayer, getLayer, getLayeredPaneAbove, getObjectForLayer, getPosition, highestLayer, insertIndexForLayer, isOptimizedDrawingEnabled, lowestLayer, moveToBack, moveToFront, paint, putLayer, setLayer, setLayer, setPosition
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeContainerListener, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
ExecutePane
public ExecutePane(VenusUI mainUI,
RegistersWindow regs,
Coprocessor1Window cop1Regs,
Coprocessor0Window cop0Regs)
initialize the Execute pane with major components
Parameters:
mainUI – the parent GUI
regs – window containing integer register set
cop1Regs – window containing Coprocessor 1 register set
cop0Regs – window containing Coprocessor 0 register set
Method Detail
setWindowBounds
public void setWindowBounds()
This method will set the bounds of this JDesktopPane’s internal windows
relative to the current size of this JDesktopPane. Such an operation
cannot be adequately done at constructor time because the actual
size of the desktop pane window is not yet established. Layout manager
is not a good option here because JDesktopPane does not work well with
them (the whole idea of using JDesktopPane with internal frames is to
have mini-frames that you can resize, move around, minimize, etc). This
method should be invoked only once: the first time the Execute tab is
selected (a change listener invokes it). We do not want it invoked
on subsequent tab selections; otherwise, user manipulations of the
internal frames would be lost the next time execute tab is selected.
setLabelWindowVisibility
public void setLabelWindowVisibility(boolean visibility)
Show or hide the label window (symbol table). If visible, it is displayed
to the right of the text segment and the latter is shrunk accordingly.
Parameters:
visibility – set to true or false
clearPane
public void clearPane()
Clears out all components of the Execute tab: text segment
display, data segment display, label display and register display.
This will typically be done upon File->Close, Open, New.
getTextSegmentWindow
public TextSegmentWindow getTextSegmentWindow()
Access the text segment window.
getDataSegmentWindow
public DataSegmentWindow getDataSegmentWindow()
Access the data segment window.
getRegistersWindow
public RegistersWindow getRegistersWindow()
Access the register values window.
getCoprocessor1Window
public Coprocessor1Window getCoprocessor1Window()
Access the coprocessor1 values window.
getCoprocessor0Window
public Coprocessor0Window getCoprocessor0Window()
Access the coprocessor0 values window.
getLabelsWindow
public LabelsWindow getLabelsWindow()
Access the label values window.
getValueDisplayBase
public int getValueDisplayBase()
Retrieve the number system base for displaying values (mem/register contents)
getAddressDisplayBase
public int getAddressDisplayBase()
Retrieve the number system base for displaying memory addresses
getValueDisplayBaseChooser
public NumberDisplayBaseChooser getValueDisplayBaseChooser()
Retrieve component used to set numerical base (10 or 16) of data value display.
Returns:
the chooser
getAddressDisplayBaseChooser
public NumberDisplayBaseChooser getAddressDisplayBaseChooser()
Retrieve component used to set numerical base (10 or 16) of address display.
Returns:
the chooser
numberDisplayBaseChanged
public void numberDisplayBaseChanged(NumberDisplayBaseChooser chooser)
Update display of columns based on state of given chooser. Normally
called only by the chooser’s ItemListener.
Parameters:
chooser – the GUI object manipulated by the user to change number base
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
FileCloseAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class FileCloseAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.FileCloseAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class FileCloseAction
extends GuiAction
Action for the File -> Close menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
FileCloseAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
FileCloseAction
public FileCloseAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
FileCloseAllAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class FileCloseAllAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.FileCloseAllAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class FileCloseAllAction
extends GuiAction
Action for the File -> Close All menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
FileCloseAllAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
FileCloseAllAction
public FileCloseAllAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
FileDumpMemoryAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class FileDumpMemoryAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.FileDumpMemoryAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class FileDumpMemoryAction
extends GuiAction
Action for the File -> Save For Dump Memory menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
FileDumpMemoryAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
FileDumpMemoryAction
public FileDumpMemoryAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
FileExitAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class FileExitAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.FileExitAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class FileExitAction
extends GuiAction
Action for the File -> Exit menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
FileExitAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
Exit MARS, unless one or more files have unsaved edits and user cancels.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
FileExitAction
public FileExitAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Exit MARS, unless one or more files have unsaved edits and user cancels.
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
FileNewAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class FileNewAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.FileNewAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class FileNewAction
extends GuiAction
Action for the File -> New menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
FileNewAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
Code to create a new document.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
FileNewAction
public FileNewAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Code to create a new document. It clears the source code window.
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Parameters:
e – component triggering this call
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
FileOpenAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class FileOpenAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.FileOpenAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class FileOpenAction
extends GuiAction
Action for the File -> Open menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
FileOpenAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
Launch a file chooser for name of file to open
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
FileOpenAction
public FileOpenAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Launch a file chooser for name of file to open
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Parameters:
e – component triggering this call
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
FilePrintAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class FilePrintAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.FilePrintAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class FilePrintAction
extends GuiAction
Action for the File -> Print menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
FilePrintAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
Uses the HardcopyWriter class developed by David Flanagan for the book
“Java Examples in a Nutshell”.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
FilePrintAction
public FilePrintAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Uses the HardcopyWriter class developed by David Flanagan for the book
“Java Examples in a Nutshell”. It will do basic printing of multipage
text documents. It displays a print dialog but does not act on any
changes the user may have specified there, such as number of copies.
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Parameters:
e – component triggering this call
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
FileSaveAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class FileSaveAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.FileSaveAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class FileSaveAction
extends GuiAction
Action for the File -> Save menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
FileSaveAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
saves the file, if not alredy saved it will do a saveAs
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
FileSaveAction
public FileSaveAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
saves the file, if not alredy saved it will do a saveAs
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
FileSaveAllAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class FileSaveAllAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.FileSaveAllAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class FileSaveAllAction
extends GuiAction
Action for the File -> Close All menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
FileSaveAllAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
FileSaveAllAction
public FileSaveAllAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
FileSaveAsAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class FileSaveAsAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.FileSaveAsAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class FileSaveAsAction
extends GuiAction
Action for the File -> Save As menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
FileSaveAsAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
FileSaveAsAction
public FileSaveAsAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
FileStatus
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class FileStatus
java.lang.Object
mars.venus.FileStatus
public class FileStatus
extends Object
Used to store and return information on the status of the current ASM file that
is being edited in the program.
Author:
Team JSpim
Field Summary
static int EDITED
open/saved edit window with unsaved edits
static int NEW_EDITED
New edit window with unsaved edits
static int NEW_NOT_EDITED
New edit window with no edits
static int NO_FILE
initial state or after close
static int NOT_EDITED
open/saved edit window with no edits
static int OPENING
file is being opened.
static int RUNNABLE
successful assembly
static int RUNNING
execution is under way
static int TERMINATED
execution terminated
Constructor Summary
FileStatus()
Create a FileStatus object with FileStatis.NO_FILE for status and null for file getters.
FileStatus(int status,
String pathname)
Create a FileStatus object with given status and file pathname.
Method Summary
static int get()
Get file status
static File getFile()
Returns the ASM file.
String getFilename()
Get file name with no path information.
int getFileStatus()
Get editing status of this file.
static String getName()
Returns the name of the file.
String getParent()
Get file parent pathname.
String getPathname()
Get full file pathname.
boolean hasUnsavedEdits()
Determine if file has been modified since last save or, if not yet saved, since
being created using New or Open.
static boolean isAssembled()
Tells whether the file has been assembled.
static boolean isEdited()
Tells whether the file has been edited since it has been saved.
boolean isNew()
Determine if file is “new”, which means created using New but not yet saved.
static boolean isSaved()
Tells whether the file has been saved.
static void reset()
Resets all the values in FileStatus
static void set(int newStatus)
Set file status.
static void setAssembled(boolean b)
Changes the value of assenbked to the parameter given.
static void setEdited(boolean b)
Changes the value of edited to the parameter given.
static void setFile(File f)
Sets the file to the ASM file passed.
void setFileStatus(int newStatus)
Set editing status of this file.
static void setName(String s)
Changes the value of name to the parameter given.
void setPathname(String newPath)
Set full file pathname.
void setPathname(String parent,
String name)
Set full file pathname.
static void setSaved(boolean b)
Changes the value of saved to the parameter given.
void updateStaticFileStatus()
Update static FileStatus fields with values from this FileStatus object
To support legacy code that depends on the static.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
NO_FILE
public static final int NO_FILE
initial state or after close
See Also:
Constant Field Values
NEW_NOT_EDITED
public static final int NEW_NOT_EDITED
New edit window with no edits
See Also:
Constant Field Values
NEW_EDITED
public static final int NEW_EDITED
New edit window with unsaved edits
See Also:
Constant Field Values
NOT_EDITED
public static final int NOT_EDITED
open/saved edit window with no edits
See Also:
Constant Field Values
EDITED
public static final int EDITED
open/saved edit window with unsaved edits
See Also:
Constant Field Values
RUNNABLE
public static final int RUNNABLE
successful assembly
See Also:
Constant Field Values
RUNNING
public static final int RUNNING
execution is under way
See Also:
Constant Field Values
TERMINATED
public static final int TERMINATED
execution terminated
See Also:
Constant Field Values
OPENING
public static final int OPENING
file is being opened. DPS 9-Aug-2011
See Also:
Constant Field Values
Constructor Detail
FileStatus
public FileStatus()
Create a FileStatus object with FileStatis.NO_FILE for status and null for file getters.
FileStatus
public FileStatus(int status,
String pathname)
Create a FileStatus object with given status and file pathname.
Parameters:
status – Initial file status. See FileStatus static constants.
pathname – Full file pathname. See setPathname(String newPath) below.
Method Detail
set
public static void set(int newStatus)
Set file status. Also updates menu state accordingly.
Parameters:
newStatus – New status: EDITED, RUNNABLE, etc, see list above.
get
public static int get()
Get file status
Returns:
file status EDITED, RUNNABLE, etc, see list above
setAssembled
public static void setAssembled(boolean b)
Changes the value of assenbked to the parameter given.
Parameters:
b – boolean variable that tells what to set assembled to.
setSaved
public static void setSaved(boolean b)
Changes the value of saved to the parameter given.
Parameters:
b – boolean variable that tells what to set saved to .
setEdited
public static void setEdited(boolean b)
Changes the value of edited to the parameter given.
Parameters:
b – boolean variable that tells what to set edited to.
setName
public static void setName(String s)
Changes the value of name to the parameter given.
Parameters:
s – string variable tells what to set the name of the file to .
setFile
public static void setFile(File f)
Sets the file to the ASM file passed.
Parameters:
f – file object variable that stores the ASM file.
getFile
public static File getFile()
Returns the ASM file.
Returns:
The ASM file.
getName
public static String getName()
Returns the name of the file.
Returns:
The name of the ASM file.
isAssembled
public static boolean isAssembled()
Tells whether the file has been assembled.
Returns:
Boolean value that is true if the ASM file has been assembled.
isSaved
public static boolean isSaved()
Tells whether the file has been saved.
Returns:
Boolean variable that is true if the ASM file has been saved
isEdited
public static boolean isEdited()
Tells whether the file has been edited since it has been saved.
Returns:
Boolean value that returns true if the ASM file has been edited.
reset
public static void reset()
Resets all the values in FileStatus
setFileStatus
public void setFileStatus(int newStatus)
Set editing status of this file. See FileStatus static constants.
Parameters:
newStatus – the new status
getFileStatus
public int getFileStatus()
Get editing status of this file.
Returns:
current editing status. See FileStatus static constants.
isNew
public boolean isNew()
Determine if file is “new”, which means created using New but not yet saved.
If created using Open, it is not new.
Returns:
true if file was created using New and has not yet been saved, false otherwise.
hasUnsavedEdits
public boolean hasUnsavedEdits()
Determine if file has been modified since last save or, if not yet saved, since
being created using New or Open.
Returns:
true if file has been modified since save or creation, false otherwise.
setPathname
public void setPathname(String newPath)
Set full file pathname. See java.io.File(String pathname) for parameter specs.
Parameters:
newPath – the new pathname. If no directory path, getParent() will return null.
setPathname
public void setPathname(String parent,
String name)
Set full file pathname. See java.io.File(String parent, String child) for parameter specs.
Parameters:
parent – the parent directory of the file. If null, getParent() will return null.
name – the name of the file (no directory path)
getPathname
public String getPathname()
Get full file pathname. See java.io.File.getPath()
Returns:
full pathname as a String. Null if
getFilename
public String getFilename()
Get file name with no path information. See java.io.File.getName()
Returns:
filename as a String
getParent
public String getParent()
Get file parent pathname. See java.io.File.getParent()
Returns:
parent full pathname as a String
updateStaticFileStatus
public void updateStaticFileStatus()
Update static FileStatus fields with values from this FileStatus object
To support legacy code that depends on the static.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class GuiAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
Direct Known Subclasses:
EditCopyAction, EditCutAction, EditFindReplaceAction, EditPasteAction, EditRedoAction, EditSelectAllAction, EditUndoAction, FileCloseAction, FileCloseAllAction, FileDumpMemoryAction, FileExitAction, FileNewAction, FileOpenAction, FilePrintAction, FileSaveAction, FileSaveAllAction, FileSaveAsAction, HelpAboutAction, HelpHelpAction, RunAssembleAction, RunBackstepAction, RunClearBreakpointsAction, RunGoAction, RunPauseAction, RunResetAction, RunStepAction, RunStopAction, RunToggleBreakpointsAction, SettingsAddressDisplayBaseAction, SettingsAssembleAllAction, SettingsAssembleOnOpenAction, SettingsDelayedBranchingAction, SettingsEditorAction, SettingsExceptionHandlerAction, SettingsExtendedAction, SettingsHighlightingAction, SettingsLabelAction, SettingsMemoryConfigurationAction, SettingsPopupInputAction, SettingsProgramArgumentsAction, SettingsSelfModifyingCodeAction, SettingsStartAtMainAction, SettingsValueDisplayBaseAction, SettingsWarningsAreErrorsAction
public class GuiAction
extends AbstractAction
parent class for Action subclasses to be defined for every menu/toolbar
option.
See Also:
Serialized Form
Field Summary
protected VenusUI mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
protected GuiAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
mainUI
protected VenusUI mainUI
Constructor Detail
GuiAction
protected GuiAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
does nothing by default. Should be over-ridden by subclass
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
HardcopyWriter
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class HardcopyWriter
java.lang.Object
java.io.Writer
mars.venus.HardcopyWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable
public class HardcopyWriter
extends Writer
Nested Class Summary
static class HardcopyWriter.PrintCanceledException
This is the exception class that the HardcopyWriter constructor
throws when the user clicks “Cancel” in the print dialog box.
Field Summary
protected int charnum
protected int chars_per_line
protected int chars_per_tab
protected int charwidth
protected Font font
protected int fontsize
protected Font headerfont
protected FontMetrics headermetrics
protected int headery
protected int height
protected PrintJob job
protected String jobname
protected int lineascent
protected int lineheight
protected int linenum
protected int lines_per_page
protected FontMetrics metrics
protected Graphics page
protected int pagedpi
protected int pagenum
protected Dimension pagesize
protected static Properties printprops
protected String time
protected int width
protected int x0
protected int y0
Fields inherited from class java.io.Writer
lock
Constructor Summary
HardcopyWriter(Frame frame,
String jobname,
int fontsize,
double leftmargin,
double rightmargin,
double topmargin,
double bottommargin)
The constructor for this class has a bunch of arguments:
The frame argument is required for all printing in Java.
Method Summary
void close()
This is the close( ) method that all Writer subclasses must implement.
void flush()
This is the flush( ) method that all Writer subclasses must implement.
int getCharactersPerLine()
Return the number of columns of characters that fit on the page
int getLinesPerPage()
Return the number of lines that fit on a page
static void main(String[] args)
A program that prints the specified file using HardcopyWriter
protected void newline()
This internal method begins a new line
protected void newpage()
This internal method begins a new page and prints the header.
void pageBreak()
End the current page.
void setFontStyle(int style)
Set the font style.
void write(char[] buffer,
int index,
int len)
This is the write( ) method of the stream.
Methods inherited from class java.io.Writer
append, append, append, write, write, write, write
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
job
protected PrintJob job
page
protected Graphics page
jobname
protected String jobname
fontsize
protected int fontsize
time
protected String time
pagesize
protected Dimension pagesize
pagedpi
protected int pagedpi
font
protected Font font
headerfont
protected Font headerfont
metrics
protected FontMetrics metrics
headermetrics
protected FontMetrics headermetrics
x0
protected int x0
y0
protected int y0
width
protected int width
height
protected int height
headery
protected int headery
charwidth
protected int charwidth
lineheight
protected int lineheight
lineascent
protected int lineascent
chars_per_line
protected int chars_per_line
lines_per_page
protected int lines_per_page
chars_per_tab
protected int chars_per_tab
charnum
protected int charnum
linenum
protected int linenum
pagenum
protected int pagenum
printprops
protected static Properties printprops
Constructor Detail
HardcopyWriter
public HardcopyWriter(Frame frame,
String jobname,
int fontsize,
double leftmargin,
double rightmargin,
double topmargin,
double bottommargin)
throws HardcopyWriter.PrintCanceledException
The constructor for this class has a bunch of arguments:
The frame argument is required for all printing in Java.
The jobname appears left justified at the top of each printed page.
The font size is specified in points, as on-screen font sizes are.
The margins are specified in inches (or fractions of inches).
Throws:
HardcopyWriter.PrintCanceledException
Method Detail
write
public void write(char[] buffer,
int index,
int len)
This is the write( ) method of the stream. All Writer subclasses
implement this. All other versions of write( ) are variants of this one
Specified by:
write in class Writer
flush
public void flush()
This is the flush( ) method that all Writer subclasses must implement.
There is no way to flush a PrintJob without prematurely printing the
page, so we don’t do anything.
Specified by:
flush in interface Flushable
Specified by:
flush in class Writer
close
public void close()
This is the close( ) method that all Writer subclasses must implement.
Print the pending page (if any) and terminate the PrintJob.
Specified by:
close in interface Closeable
Specified by:
close in class Writer
setFontStyle
public void setFontStyle(int style)
Set the font style. The argument should be one of the font style
constants defined by the java.awt.Font class. All subsequent output
will be in that style. This method relies on all styles of the
Monospaced font having the same metrics.
pageBreak
public void pageBreak()
End the current page. Subsequent output will be on a new page.
getCharactersPerLine
public int getCharactersPerLine()
Return the number of columns of characters that fit on the page
getLinesPerPage
public int getLinesPerPage()
Return the number of lines that fit on a page
newline
protected void newline()
This internal method begins a new line
newpage
protected void newpage()
This internal method begins a new page and prints the header.
main
public static void main(String[] args)
A program that prints the specified file using HardcopyWriter
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
HardcopyWriter.PrintCanceledException
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class HardcopyWriter.PrintCanceledException
java.lang.Object
java.lang.Throwable
java.lang.Exception
mars.venus.HardcopyWriter.PrintCanceledException
All Implemented Interfaces:
Serializable
Enclosing class:
HardcopyWriter
public static class HardcopyWriter.PrintCanceledException
extends Exception
This is the exception class that the HardcopyWriter constructor
throws when the user clicks “Cancel” in the print dialog box.
See Also:
Serialized Form
Constructor Summary
HardcopyWriter.PrintCanceledException(String msg)
Method Summary
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
HardcopyWriter.PrintCanceledException
public HardcopyWriter.PrintCanceledException(String msg)
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
HelpAboutAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class HelpAboutAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.HelpAboutAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class HelpAboutAction
extends GuiAction
Action for the Help -> About menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
HelpAboutAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
HelpAboutAction
public HelpAboutAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
HelpHelpAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class HelpHelpAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.HelpHelpAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class HelpHelpAction
extends GuiAction
Action for the Help -> Help menu item
See Also:
Serialized Form
Field Summary
static String descriptionDetailSeparator
Separates Instruction name descriptor from detailed (operation) description
in help string.
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
HelpHelpAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
Displays tabs with categories of information
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
descriptionDetailSeparator
public static final String descriptionDetailSeparator
Separates Instruction name descriptor from detailed (operation) description
in help string.
See Also:
Constant Field Values
Constructor Detail
HelpHelpAction
public HelpHelpAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Displays tabs with categories of information
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
LabelsWindow
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class LabelsWindow
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JInternalFrame
mars.venus.LabelsWindow
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants
public class LabelsWindow
extends JInternalFrame
Represents the Labels window, which is a type of JInternalFrame. Venus user
can view MIPS program labels.
Author:
Sanderson and Team JSpim
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JInternalFrame
JInternalFrame.AccessibleJInternalFrame, JInternalFrame.JDesktopIcon
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class javax.swing.JInternalFrame
closable, CONTENT_PANE_PROPERTY, desktopIcon, FRAME_ICON_PROPERTY, frameIcon, GLASS_PANE_PROPERTY, iconable, IS_CLOSED_PROPERTY, IS_ICON_PROPERTY, IS_MAXIMUM_PROPERTY, IS_SELECTED_PROPERTY, isClosed, isIcon, isMaximum, isSelected, LAYERED_PANE_PROPERTY, maximizable, MENU_BAR_PROPERTY, resizable, ROOT_PANE_PROPERTY, rootPane, rootPaneCheckingEnabled, title, TITLE_PROPERTY
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
LabelsWindow()
Constructor for the Labels (symbol table) window.
Method Summary
void clearWindow()
Clear the window
void setupTable()
Initialize table of labels (symbol table)
void updateLabelAddresses()
Method to update display of label addresses.
Methods inherited from class javax.swing.JInternalFrame
addImpl, addInternalFrameListener, createRootPane, dispose, doDefaultCloseAction, fireInternalFrameEvent, getAccessibleContext, getContentPane, getDefaultCloseOperation, getDesktopIcon, getDesktopPane, getFocusCycleRootAncestor, getFocusOwner, getFrameIcon, getGlassPane, getInternalFrameListeners, getJMenuBar, getLastCursor, getLayer, getLayeredPane, getMenuBar, getMostRecentFocusOwner, getNormalBounds, getRootPane, getTitle, getUI, getUIClassID, getWarningString, hide, isClosable, isClosed, isFocusCycleRoot, isIcon, isIconifiable, isMaximizable, isMaximum, isResizable, isRootPaneCheckingEnabled, isSelected, moveToBack, moveToFront, pack, paintComponent, paramString, remove, removeInternalFrameListener, reshape, restoreSubcomponentFocus, setClosable, setClosed, setContentPane, setCursor, setDefaultCloseOperation, setDesktopIcon, setFocusCycleRoot, setFrameIcon, setGlassPane, setIcon, setIconifiable, setJMenuBar, setLayer, setLayer, setLayeredPane, setLayout, setMaximizable, setMaximum, setMenuBar, setNormalBounds, setResizable, setRootPane, setRootPaneCheckingEnabled, setSelected, setTitle, setUI, show, toBack, toFront, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
LabelsWindow
public LabelsWindow()
Constructor for the Labels (symbol table) window.
Method Detail
setupTable
public void setupTable()
Initialize table of labels (symbol table)
clearWindow
public void clearWindow()
Clear the window
updateLabelAddresses
public void updateLabelAddresses()
Method to update display of label addresses. Since label information doesn’t change,
this should only be done when address base is changed.
(e.g. between base 16 hex and base 10 dec).
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
MainPane
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class MainPane
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTabbedPane
mars.venus.MainPane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants
public class MainPane
extends JTabbedPane
Creates the tabbed areas in the UI and also created the internal windows that
exist in them.
Author:
Sanderson and Bumgarner
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JTabbedPane
JTabbedPane.AccessibleJTabbedPane, JTabbedPane.ModelListener
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class javax.swing.JTabbedPane
changeEvent, changeListener, model, SCROLL_TAB_LAYOUT, tabPlacement, WRAP_TAB_LAYOUT
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
MainPane(VenusUI appFrame,
Editor editor,
RegistersWindow regs,
Coprocessor1Window cop1Regs,
Coprocessor0Window cop0Regs)
Constructor for the MainPane class.
Method Summary
EditPane getEditPane()
Returns current edit pane.
JComponent getEditTabbedPane()
Returns component containing editor display
ExecutePane getExecutePane()
returns component containing execution-time display
ExecutePane getExecuteTab()
returns component containing execution-time display.
Methods inherited from class javax.swing.JTabbedPane
add, add, add, add, add, addChangeListener, addTab, addTab, addTab, createChangeListener, fireStateChanged, getAccessibleContext, getBackgroundAt, getBoundsAt, getChangeListeners, getComponentAt, getDisabledIconAt, getDisplayedMnemonicIndexAt, getForegroundAt, getIconAt, getMnemonicAt, getModel, getSelectedComponent, getSelectedIndex, getTabComponentAt, getTabCount, getTabLayoutPolicy, getTabPlacement, getTabRunCount, getTitleAt, getToolTipText, getToolTipTextAt, getUI, getUIClassID, indexAtLocation, indexOfComponent, indexOfTab, indexOfTab, indexOfTabComponent, insertTab, isEnabledAt, paramString, remove, remove, removeAll, removeChangeListener, removeTabAt, setBackgroundAt, setComponentAt, setDisabledIconAt, setDisplayedMnemonicIndexAt, setEnabledAt, setForegroundAt, setIconAt, setMnemonicAt, setModel, setSelectedComponent, setSelectedIndex, setTabComponentAt, setTabLayoutPolicy, setTabPlacement, setTitleAt, setToolTipTextAt, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
MainPane
public MainPane(VenusUI appFrame,
Editor editor,
RegistersWindow regs,
Coprocessor1Window cop1Regs,
Coprocessor0Window cop0Regs)
Constructor for the MainPane class.
Method Detail
getEditPane
public EditPane getEditPane()
Returns current edit pane. Implementation changed for MARS 4.0 support
for multiple panes, but specification is same.
Returns:
the editor pane
getEditTabbedPane
public JComponent getEditTabbedPane()
Returns component containing editor display
Returns:
the editor tabbed pane
getExecutePane
public ExecutePane getExecutePane()
returns component containing execution-time display
Returns:
the execute pane
getExecuteTab
public ExecutePane getExecuteTab()
returns component containing execution-time display.
Same as getExecutePane().
Returns:
the execute pane
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
MessagesPane
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class MessagesPane
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTabbedPane
mars.venus.MessagesPane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants
public class MessagesPane
extends JTabbedPane
Creates the message window at the bottom of the UI.
Author:
Team JSpim
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JTabbedPane
JTabbedPane.AccessibleJTabbedPane, JTabbedPane.ModelListener
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
static int MAXIMUM_SCROLLED_CHARACTERS
static int NUMBER_OF_CHARACTERS_TO_CUT
Fields inherited from class javax.swing.JTabbedPane
changeEvent, changeListener, model, SCROLL_TAB_LAYOUT, tabPlacement, WRAP_TAB_LAYOUT
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
MessagesPane()
Constructor for the class, sets up two fresh tabbed text areas for program feedback.
Method Summary
JTextArea getAssembleTextArea()
Returns component used to display assembler messages
String getInputString(int maxLen)
Method used by the SystemIO class to get interactive user input
requested by a running MIPS program (e.g.
String getInputString(String prompt)
Method used by the SystemIO class to get interactive user input
requested by a running MIPS program (e.g.
JTextArea getRunTextArea()
Returns component used to display runtime messages
void postMarsMessage(String message)
Post a message to the assembler display
void postRunMessage(String message)
Post a message to the runtime display
void selectEditorTextLine(String fileName,
int line,
int column)
Will select the specified line in an editor tab.
void selectErrorMessage(String fileName,
int line,
int column)
Will select the Mars Messages tab error message that matches the given
specifications, if it is found.
void selectMarsMessageTab()
Make the assembler message tab current (up front)
void selectRunMessageTab()
Make the runtime message tab current (up front)
Methods inherited from class javax.swing.JTabbedPane
add, add, add, add, add, addChangeListener, addTab, addTab, addTab, createChangeListener, fireStateChanged, getAccessibleContext, getBackgroundAt, getBoundsAt, getChangeListeners, getComponentAt, getDisabledIconAt, getDisplayedMnemonicIndexAt, getForegroundAt, getIconAt, getMnemonicAt, getModel, getSelectedComponent, getSelectedIndex, getTabComponentAt, getTabCount, getTabLayoutPolicy, getTabPlacement, getTabRunCount, getTitleAt, getToolTipText, getToolTipTextAt, getUI, getUIClassID, indexAtLocation, indexOfComponent, indexOfTab, indexOfTab, indexOfTabComponent, insertTab, isEnabledAt, paramString, remove, remove, removeAll, removeChangeListener, removeTabAt, setBackgroundAt, setComponentAt, setDisabledIconAt, setDisplayedMnemonicIndexAt, setEnabledAt, setForegroundAt, setIconAt, setMnemonicAt, setModel, setSelectedComponent, setSelectedIndex, setTabComponentAt, setTabLayoutPolicy, setTabPlacement, setTitleAt, setToolTipTextAt, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
MAXIMUM_SCROLLED_CHARACTERS
public static final int MAXIMUM_SCROLLED_CHARACTERS
NUMBER_OF_CHARACTERS_TO_CUT
public static final int NUMBER_OF_CHARACTERS_TO_CUT
Constructor Detail
MessagesPane
public MessagesPane()
Constructor for the class, sets up two fresh tabbed text areas for program feedback.
Method Detail
selectErrorMessage
public void selectErrorMessage(String fileName,
int line,
int column)
Will select the Mars Messages tab error message that matches the given
specifications, if it is found. Matching is done by constructing
a string using the parameter values and searching the text area for the last
occurrance of that string.
Parameters:
fileName – A String containing the file path name.
line – Line number for error message
column – Column number for error message
selectEditorTextLine
public void selectEditorTextLine(String fileName,
int line,
int column)
Will select the specified line in an editor tab. If the file is open
but not current, its tab will be made current. If the file is not open,
it will be opened in a new tab and made current, however the line will
not be selected (apparent apparent problem with JEditTextArea).
Parameters:
fileName – A String containing the file path name.
line – Line number for error message
column – Column number for error message
getAssembleTextArea
public JTextArea getAssembleTextArea()
Returns component used to display assembler messages
Returns:
assembler message text component
getRunTextArea
public JTextArea getRunTextArea()
Returns component used to display runtime messages
Returns:
runtime message text component
postMarsMessage
public void postMarsMessage(String message)
Post a message to the assembler display
Parameters:
message – String to append to assembler display text
postRunMessage
public void postRunMessage(String message)
Post a message to the runtime display
Parameters:
message – String to append to runtime display text
selectMarsMessageTab
public void selectMarsMessageTab()
Make the assembler message tab current (up front)
selectRunMessageTab
public void selectRunMessageTab()
Make the runtime message tab current (up front)
getInputString
public String getInputString(String prompt)
Method used by the SystemIO class to get interactive user input
requested by a running MIPS program (e.g. syscall #5 to read an
integer). SystemIO knows whether simulator is being run at
command line by the user, or by the GUI. If run at command line,
it gets input from System.in rather than here.
This is an overloaded method. This version, with the String parameter,
is used to get input from a popup dialog.
Parameters:
prompt – Prompt to display to the user.
Returns:
User input.
getInputString
public String getInputString(int maxLen)
Method used by the SystemIO class to get interactive user input
requested by a running MIPS program (e.g. syscall #5 to read an
integer). SystemIO knows whether simulator is being run at
command line by the user, or by the GUI. If run at command line,
it gets input from System.in rather than here.
This is an overloaded method. This version, with the int parameter,
is used to get input from the MARS Run I/O window.
Parameters:
maxLen: – maximum length of input. This method returns when maxLen characters have been read. Use -1 for no length restrictions.
Returns:
User input.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
NumberDisplayBaseChooser
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class NumberDisplayBaseChooser
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.AbstractButton
javax.swing.JToggleButton
javax.swing.JCheckBox
mars.venus.NumberDisplayBaseChooser
All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, SwingConstants
public class NumberDisplayBaseChooser
extends JCheckBox
Use to select base for displaying numbers. Initially the
choices are only 10 (decimal) and 16 (hex), so I’m using
a check box where checked means hex. If base 8 (octal)
is added later, the Component will need to change.
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JCheckBox
JCheckBox.AccessibleJCheckBox
Nested classes/interfaces inherited from class javax.swing.JToggleButton
JToggleButton.AccessibleJToggleButton, JToggleButton.ToggleButtonModel
Nested classes/interfaces inherited from class javax.swing.AbstractButton
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
static int ASCII
static int DECIMAL
static int HEXADECIMAL
Fields inherited from class javax.swing.JCheckBox
BORDER_PAINTED_FLAT_CHANGED_PROPERTY
Fields inherited from class javax.swing.AbstractButton
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
NumberDisplayBaseChooser(String text,
boolean displayInHex)
constructor.
Method Summary
static String formatDoubleNumber(long value,
int base)
Produces a string form of a double given a long containing
the 64 bit pattern and the numerical base to use (10 or 16).
static String formatFloatNumber(int value,
int base)
Produces a string form of a float given an integer containing
the 32 bit pattern and the numerical base to use (10 or 16).
static String formatNumber(double value,
int base)
Produces a string form of a double given the value and the
numerical base to convert it to.
static String formatNumber(float value,
int base)
Produces a string form of a float given the value and the
numerical base to convert it to.
String formatNumber(int value)
Produces a string form of a number given the value.
static String formatNumber(int value,
int base)
Produces a string form of an integer given the value and the
numerical base to convert it to.
String formatUnsignedInteger(int value)
Produces a string form of an unsigned integer given the value.
static String formatUnsignedInteger(int value,
int base)
Produces a string form of an unsigned given the value and the
numerical base to convert it to.
int getBase()
Retrieve the current number base.
static int getBase(boolean setting)
Return the number base corresponding to the specified setting.
void setBase(int newBase)
Set the current number base.
void setSettingsMenuItem(JCheckBoxMenuItem setter)
Set the menu item from Settings menu that corresponds to this chooser.
Methods inherited from class javax.swing.JCheckBox
getAccessibleContext, getUIClassID, isBorderPaintedFlat, paramString, setBorderPaintedFlat, updateUI
Methods inherited from class javax.swing.AbstractButton
actionPropertyChanged, addActionListener, addChangeListener, addImpl, addItemListener, checkHorizontalKey, checkVerticalKey, configurePropertiesFromAction, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHideActionText, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, init, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, isSelected, paintBorder, removeActionListener, removeChangeListener, removeItemListener, removeNotify, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setEnabled, setFocusPainted, setHideActionText, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
DECIMAL
public static final int DECIMAL
See Also:
Constant Field Values
HEXADECIMAL
public static final int HEXADECIMAL
See Also:
Constant Field Values
ASCII
public static final int ASCII
See Also:
Constant Field Values
Constructor Detail
NumberDisplayBaseChooser
public NumberDisplayBaseChooser(String text,
boolean displayInHex)
constructor. It assumes the text will be worded
so that a checked box means hexadecimal!
Parameters:
text – Text to accompany the check box.
defaultBase – Currently either DECIMAL or HEXADECIMAL
Method Detail
getBase
public int getBase()
Retrieve the current number base.
Returns:
current number base, currently DECIMAL or HEXADECIMAL
setBase
public void setBase(int newBase)
Set the current number base.
Parameters:
newBase – The new number base. Currently, if it is
neither DECIMAL nor HEXADECIMAL, the base will not be changed.
formatUnsignedInteger
public static String formatUnsignedInteger(int value,
int base)
Produces a string form of an unsigned given the value and the
numerical base to convert it to. This class
method can be used by anyone anytime. If base is 16, result
is same as for formatNumber(). If base is 10, will produce
string version of unsigned value. E.g. 0xffffffff will produce
“4294967295” instead of “-1”.
Parameters:
value – the number to be converted
base – the numerical base to use (currently 10 or 16)
Returns:
a String equivalent of the value rendered appropriately.
formatNumber
public static String formatNumber(int value,
int base)
Produces a string form of an integer given the value and the
numerical base to convert it to. There is an instance
method that uses the internally stored base. This class
method can be used by anyone anytime.
Parameters:
value – the number to be converted
base – the numerical base to use (currently 10 or 16)
Returns:
a String equivalent of the value rendered appropriately.
formatNumber
public static String formatNumber(float value,
int base)
Produces a string form of a float given the value and the
numerical base to convert it to. There is an instance
method that uses the internally stored base. This class
method can be used by anyone anytime.
Parameters:
value – the number to be converted
base – the numerical base to use (currently 10 or 16)
Returns:
a String equivalent of the value rendered appropriately.
formatNumber
public static String formatNumber(double value,
int base)
Produces a string form of a double given the value and the
numerical base to convert it to. There is an instance
method that uses the internally stored base. This class
method can be used by anyone anytime.
Parameters:
value – the number to be converted
base – the numerical base to use (currently 10 or 16)
Returns:
a String equivalent of the value rendered appropriately.
formatNumber
public String formatNumber(int value)
Produces a string form of a number given the value. There
is also an class (static method) that uses a specified
base.
Parameters:
value – the number to be converted
Returns:
a String equivalent of the value rendered appropriately.
formatUnsignedInteger
public String formatUnsignedInteger(int value)
Produces a string form of an unsigned integer given the value. There
is also an class (static method) that uses a specified base.
If the current base is 16, this produces the same result as formatNumber().
Parameters:
value – the number to be converted
Returns:
a String equivalent of the value rendered appropriately.
formatFloatNumber
public static String formatFloatNumber(int value,
int base)
Produces a string form of a float given an integer containing
the 32 bit pattern and the numerical base to use (10 or 16). If the
base is 16, the string will be built from the 32 bits. If the
base is 10, the int bits will be converted to float and the
string constructed from that. Seems an odd distinction to make,
except that contents of floating point registers are stored
internally as int bits. If the int bits represent a NaN value
(of which there are many!), converting them to float then calling
formatNumber(float, int) above, causes the float value to become
the canonical NaN value 0x7fc00000. It does not preserve the bit
pattern! Then converting it to hex string yields the canonical NaN.
Not an issue if display base is 10 since result string will be NaN
no matter what the internal NaN value is.
Parameters:
value – the int bits to be converted to string of corresponding float.
base – the numerical base to use (currently 10 or 16)
Returns:
a String equivalent of the value rendered appropriately.
formatDoubleNumber
public static String formatDoubleNumber(long value,
int base)
Produces a string form of a double given a long containing
the 64 bit pattern and the numerical base to use (10 or 16). If the
base is 16, the string will be built from the 64 bits. If the
base is 10, the long bits will be converted to double and the
string constructed from that. Seems an odd distinction to make,
except that contents of floating point registers are stored
internally as int bits. If the int bits represent a NaN value
(of which there are many!), converting them to double then calling
formatNumber(double, int) above, causes the double value to become
the canonical NaN value. It does not preserve the bit
pattern! Then converting it to hex string yields the canonical NaN.
Not an issue if display base is 10 since result string will be NaN
no matter what the internal NaN value is.
Parameters:
value – the long bits to be converted to string of corresponding double.
base – the numerical base to use (currently 10 or 16)
Returns:
a String equivalent of the value rendered appropriately.
setSettingsMenuItem
public void setSettingsMenuItem(JCheckBoxMenuItem setter)
Set the menu item from Settings menu that corresponds to this chooser.
It is the responsibility of that item to register here, because this
one is created first (before the menu item). They need to communicate
with each other so that whenever one changes, so does the other. They
cannot be the same object (one is JCheckBox, the other is JCheckBoxMenuItem).
getBase
public static int getBase(boolean setting)
Return the number base corresponding to the specified setting.
Returns:
HEXADECIMAL if setting is true, DECIMAL otherwise.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
mars.venus
Classes
AbstractFontSettingDialog
Coprocessor0Window
Coprocessor1Window
DataSegmentWindow
EditCopyAction
EditCutAction
EditFindReplaceAction
Editor
EditPane
EditPasteAction
EditRedoAction
EditSelectAllAction
EditTabbedPane
EditUndoAction
ExecutePane
FileCloseAction
FileCloseAllAction
FileDumpMemoryAction
FileExitAction
FileNewAction
FileOpenAction
FilePrintAction
FileSaveAction
FileSaveAllAction
FileSaveAsAction
FileStatus
GuiAction
HardcopyWriter
HelpAboutAction
HelpHelpAction
LabelsWindow
MainPane
MessagesPane
NumberDisplayBaseChooser
PopupListener
RegistersPane
RegistersWindow
RepeatButton
RunAssembleAction
RunBackstepAction
RunClearBreakpointsAction
RunGoAction
RunPauseAction
RunResetAction
RunSpeedPanel
RunStepAction
RunStopAction
RunToggleBreakpointsAction
SettingsAddressDisplayBaseAction
SettingsAssembleAllAction
SettingsAssembleOnOpenAction
SettingsDelayedBranchingAction
SettingsEditorAction
SettingsExceptionHandlerAction
SettingsExtendedAction
SettingsHighlightingAction
SettingsLabelAction
SettingsMemoryConfigurationAction
SettingsPopupInputAction
SettingsProgramArgumentsAction
SettingsSelfModifyingCodeAction
SettingsStartAtMainAction
SettingsValueDisplayBaseAction
SettingsWarningsAreErrorsAction
TextSegmentWindow
ToolAction
ToolLoader
VenusUI
Exceptions
HardcopyWriter.PrintCanceledException
mars.venus
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
Package mars.venus
Class Summary
AbstractFontSettingDialog Abstract class for a font selection dialog.
Coprocessor0Window Sets up a window to display registers in the UI.
Coprocessor1Window Sets up a window to display Coprocessor 1 registers in the Registers pane of the UI.
DataSegmentWindow Represents the Data Segment window, which is a type of JInternalFrame.
EditCopyAction Action for the Edit -> Copy menu item
EditCutAction Action for the Edit -> Cut menu item
EditFindReplaceAction Action for the Edit -> Find/Replace menu item
Editor Manage the file being edited.
EditPane Represents one file opened for editing.
EditPasteAction Action for the Edit -> Paste menu item
EditRedoAction Action for the Edit -> Redo menu item
EditSelectAllAction Action for the Edit -> Copy menu item
EditTabbedPane Tabbed pane for the editor.
EditUndoAction Action for the Edit -> Undo menu item
ExecutePane Container for the execution-related windows.
FileCloseAction Action for the File -> Close menu item
FileCloseAllAction Action for the File -> Close All menu item
FileDumpMemoryAction Action for the File -> Save For Dump Memory menu item
FileExitAction Action for the File -> Exit menu item
FileNewAction Action for the File -> New menu item
FileOpenAction Action for the File -> Open menu item
FilePrintAction Action for the File -> Print menu item
FileSaveAction Action for the File -> Save menu item
FileSaveAllAction Action for the File -> Close All menu item
FileSaveAsAction Action for the File -> Save As menu item
FileStatus Used to store and return information on the status of the current ASM file that
is being edited in the program.
GuiAction parent class for Action subclasses to be defined for every menu/toolbar
option.
HardcopyWriter
HelpAboutAction Action for the Help -> About menu item
HelpHelpAction Action for the Help -> Help menu item
LabelsWindow Represents the Labels window, which is a type of JInternalFrame.
MainPane Creates the tabbed areas in the UI and also created the internal windows that
exist in them.
MessagesPane Creates the message window at the bottom of the UI.
NumberDisplayBaseChooser Use to select base for displaying numbers.
PopupListener
RegistersPane Contains tabbed areas in the UI to display register contents
RegistersWindow Sets up a window to display registers in the UI.
RepeatButton RepeatButton is a JButton which contains a timer
for firing events while the button is held down.
RunAssembleAction Action class for the Run -> Assemble menu item (and toolbar icon)
RunBackstepAction Action for the Run -> Backstep menu item
RunClearBreakpointsAction Action class for the Run menu item to clear execution breakpoints that have been set.
RunGoAction Action class for the Run -> Go menu item (and toolbar icon)
RunPauseAction Action class for the Run -> Pause menu item (and toolbar icon)
RunResetAction Action for the Run -> Reset menu item
RunSpeedPanel Class for the Run speed slider control.
RunStepAction Action for the Run -> Step menu item
RunStopAction Action class for the Run -> Stop menu item (and toolbar icon)
RunToggleBreakpointsAction Action class for the Run menu item to clear execution breakpoints that have been set.
SettingsAddressDisplayBaseAction Action class for the Settings menu item to control number base (10 or 16) of memory addresses.
SettingsAssembleAllAction Action class for the Settings menu item to determine whether assemble operation applies
only to current file or to all files in its directory.
SettingsAssembleOnOpenAction Action class for the Settings menu item to control automatic assemble of file upon opening.
SettingsDelayedBranchingAction Action class for the Settings menu item to control delayed branching.
SettingsEditorAction Action class for the Settings menu item for text editor settings.
SettingsExceptionHandlerAction Action class for the Settings menu item for optionally loading a MIPS exception handler.
SettingsExtendedAction Action class for the Settings menu item to control use of extended (pseudo) instructions or formats.
SettingsHighlightingAction Action class for the Settings menu item for text editor settings.
SettingsLabelAction Action class for the Settings menu item to control display of Labels window (symbol table).
SettingsMemoryConfigurationAction Action class for the Settings menu item for text editor settings.
SettingsPopupInputAction Action class for the Settings menu item to control use of popup dialog for input syscalls.
SettingsProgramArgumentsAction Action class for the Settings menu item to control whether or not
program arguments can be entered and used.
SettingsSelfModifyingCodeAction Action class for the Settings menu item to control whether
the running MIPS program can write to the text segment or
branch to the data segment.
SettingsStartAtMainAction Action class for the Settings menu item to control whether or not
assembler warnings are considered errors.
SettingsValueDisplayBaseAction Action class for the Settings menu item to control number base (10 or 16) of memory/register contents.
SettingsWarningsAreErrorsAction Action class for the Settings menu item to control whether or not
assembler warnings are considered errors.
TextSegmentWindow Creates the Text Segment window in the Execute tab of the UI
ToolAction Connects a MarsTool class (class that implements MarsTool interface) to
the Mars menu system by supplying the response to that tool’s menu item
selection.
ToolLoader This class provides functionality to bring external Mars tools into the Mars
system by adding them to its Tools menu.
VenusUI Top level container for Venus GUI.
Exception Summary
HardcopyWriter.PrintCanceledException This is the exception class that the HardcopyWriter constructor
throws when the user clicks “Cancel” in the print dialog box.
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
mars.venus Class Hierarchy
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Hierarchy For Package mars.venus
Package Hierarchies:
All Packages
Class Hierarchy
java.lang.Object javax.swing.AbstractAction (implements javax.swing.Action, java.lang.Cloneable, java.io.Serializable)
mars.venus.GuiAction mars.venus.EditCopyAction
mars.venus.EditCutAction
mars.venus.EditFindReplaceAction
mars.venus.EditPasteAction
mars.venus.EditRedoAction
mars.venus.EditSelectAllAction
mars.venus.EditUndoAction
mars.venus.FileCloseAction
mars.venus.FileCloseAllAction
mars.venus.FileDumpMemoryAction
mars.venus.FileExitAction
mars.venus.FileNewAction
mars.venus.FileOpenAction
mars.venus.FilePrintAction
mars.venus.FileSaveAction
mars.venus.FileSaveAllAction
mars.venus.FileSaveAsAction
mars.venus.HelpAboutAction
mars.venus.HelpHelpAction
mars.venus.RunAssembleAction
mars.venus.RunBackstepAction
mars.venus.RunClearBreakpointsAction (implements javax.swing.event.TableModelListener)
mars.venus.RunGoAction
mars.venus.RunPauseAction
mars.venus.RunResetAction
mars.venus.RunStepAction
mars.venus.RunStopAction
mars.venus.RunToggleBreakpointsAction
mars.venus.SettingsAddressDisplayBaseAction
mars.venus.SettingsAssembleAllAction
mars.venus.SettingsAssembleOnOpenAction
mars.venus.SettingsDelayedBranchingAction
mars.venus.SettingsEditorAction
mars.venus.SettingsExceptionHandlerAction
mars.venus.SettingsExtendedAction
mars.venus.SettingsHighlightingAction
mars.venus.SettingsLabelAction
mars.venus.SettingsMemoryConfigurationAction
mars.venus.SettingsPopupInputAction
mars.venus.SettingsProgramArgumentsAction
mars.venus.SettingsSelfModifyingCodeAction
mars.venus.SettingsStartAtMainAction
mars.venus.SettingsValueDisplayBaseAction
mars.venus.SettingsWarningsAreErrorsAction
mars.venus.ToolAction
java.awt.Component (implements java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable)
java.awt.Container javax.swing.JComponent (implements java.io.Serializable)
javax.swing.AbstractButton (implements java.awt.ItemSelectable, javax.swing.SwingConstants)
javax.swing.JButton (implements javax.accessibility.Accessible)
mars.venus.RepeatButton (implements java.awt.event.ActionListener, java.awt.event.MouseListener)
javax.swing.JToggleButton (implements javax.accessibility.Accessible)
javax.swing.JCheckBox (implements javax.accessibility.Accessible)
mars.venus.NumberDisplayBaseChooser
javax.swing.JInternalFrame (implements javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants)
mars.venus.DataSegmentWindow (implements java.util.Observer)
mars.venus.LabelsWindow
mars.venus.TextSegmentWindow (implements java.util.Observer)
javax.swing.JLayeredPane (implements javax.accessibility.Accessible)
javax.swing.JDesktopPane (implements javax.accessibility.Accessible)
mars.venus.ExecutePane
javax.swing.JPanel (implements javax.accessibility.Accessible)
mars.venus.Coprocessor0Window (implements java.util.Observer)
mars.venus.Coprocessor1Window (implements java.awt.event.ActionListener, java.util.Observer)
mars.venus.EditPane (implements java.util.Observer)
mars.venus.RegistersWindow (implements java.util.Observer)
mars.venus.RunSpeedPanel
javax.swing.JTabbedPane (implements javax.accessibility.Accessible, java.io.Serializable, javax.swing.SwingConstants)
mars.venus.EditTabbedPane
mars.venus.MainPane
mars.venus.MessagesPane
mars.venus.RegistersPane
java.awt.Window (implements javax.accessibility.Accessible)
java.awt.Dialog javax.swing.JDialog (implements javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants)
mars.venus.AbstractFontSettingDialog
java.awt.Frame (implements java.awt.MenuContainer)
javax.swing.JFrame (implements javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants)
mars.venus.VenusUI
mars.venus.Editor
mars.venus.FileStatus
java.awt.event.MouseAdapter (implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener)
mars.venus.PopupListener
java.lang.Throwable (implements java.io.Serializable)
java.lang.Exception mars.venus.HardcopyWriter.PrintCanceledException
mars.venus.ToolLoader
java.io.Writer (implements java.lang.Appendable, java.io.Closeable, java.io.Flushable)
mars.venus.HardcopyWriter
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
PopupListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class PopupListener
java.lang.Object
java.awt.event.MouseAdapter
mars.venus.PopupListener
All Implemented Interfaces:
MouseListener, MouseMotionListener, MouseWheelListener, EventListener
public class PopupListener
extends MouseAdapter
Constructor Summary
PopupListener(JPopupMenu p)
Method Summary
void mousePressed(MouseEvent e)
void mouseReleased(MouseEvent e)
Methods inherited from class java.awt.event.MouseAdapter
mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseWheelMoved
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
PopupListener
public PopupListener(JPopupMenu p)
Method Detail
mousePressed
public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener
Overrides:
mousePressed in class MouseAdapter
mouseReleased
public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener
Overrides:
mouseReleased in class MouseAdapter
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
RegistersPane
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class RegistersPane
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTabbedPane
mars.venus.RegistersPane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants
public class RegistersPane
extends JTabbedPane
Contains tabbed areas in the UI to display register contents
Author:
Sanderson
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JTabbedPane
JTabbedPane.AccessibleJTabbedPane, JTabbedPane.ModelListener
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class javax.swing.JTabbedPane
changeEvent, changeListener, model, SCROLL_TAB_LAYOUT, tabPlacement, WRAP_TAB_LAYOUT
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
RegistersPane(VenusUI appFrame,
RegistersWindow regs,
Coprocessor1Window cop1,
Coprocessor0Window cop0)
Constructor for the RegistersPane class.
Method Summary
Coprocessor0Window getCoprocessor0Window()
Return component containing coprocessor 0 (exceptions) register set.
Coprocessor1Window getCoprocessor1Window()
Return component containing coprocessor 1 (floating point) register set.
RegistersWindow getRegistersWindow()
Return component containing integer register set.
Methods inherited from class javax.swing.JTabbedPane
add, add, add, add, add, addChangeListener, addTab, addTab, addTab, createChangeListener, fireStateChanged, getAccessibleContext, getBackgroundAt, getBoundsAt, getChangeListeners, getComponentAt, getDisabledIconAt, getDisplayedMnemonicIndexAt, getForegroundAt, getIconAt, getMnemonicAt, getModel, getSelectedComponent, getSelectedIndex, getTabComponentAt, getTabCount, getTabLayoutPolicy, getTabPlacement, getTabRunCount, getTitleAt, getToolTipText, getToolTipTextAt, getUI, getUIClassID, indexAtLocation, indexOfComponent, indexOfTab, indexOfTab, indexOfTabComponent, insertTab, isEnabledAt, paramString, remove, remove, removeAll, removeChangeListener, removeTabAt, setBackgroundAt, setComponentAt, setDisabledIconAt, setDisplayedMnemonicIndexAt, setEnabledAt, setForegroundAt, setIconAt, setMnemonicAt, setModel, setSelectedComponent, setSelectedIndex, setTabComponentAt, setTabLayoutPolicy, setTabPlacement, setTitleAt, setToolTipTextAt, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
RegistersPane
public RegistersPane(VenusUI appFrame,
RegistersWindow regs,
Coprocessor1Window cop1,
Coprocessor0Window cop0)
Constructor for the RegistersPane class.
Method Detail
getRegistersWindow
public RegistersWindow getRegistersWindow()
Return component containing integer register set.
Returns:
integer register window
getCoprocessor1Window
public Coprocessor1Window getCoprocessor1Window()
Return component containing coprocessor 1 (floating point) register set.
Returns:
floating point register window
getCoprocessor0Window
public Coprocessor0Window getCoprocessor0Window()
Return component containing coprocessor 0 (exceptions) register set.
Returns:
exceptions register window
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
RegistersWindow
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class RegistersWindow
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
mars.venus.RegistersWindow
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Observer, Accessible
public class RegistersWindow
extends JPanel
implements Observer
Sets up a window to display registers in the UI.
Author:
Sanderson, Bumgarner
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
RegistersWindow()
Constructor which sets up a fresh window with a table that contains the register values.
Method Summary
void clearHighlighting()
Clear highlight background color from any cell currently highlighted.
void clearWindow()
clear and redisplay registers
void refresh()
Refresh the table, triggering re-rendering.
Object[][] setupWindow()
Sets up the data for the window.
void update(Observable observable,
Object obj)
Required by Observer interface.
void updateRegisters()
update register display using current number base (10 or 16)
void updateRegisters(int base)
update register display using specified number base (10 or 16)
void updateRegisterValue(int number,
int val,
int base)
This method handles the updating of the GUI.
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
RegistersWindow
public RegistersWindow()
Constructor which sets up a fresh window with a table that contains the register values.
Method Detail
setupWindow
public Object[][] setupWindow()
Sets up the data for the window.
Returns:
The array object with the data for the window.
clearWindow
public void clearWindow()
clear and redisplay registers
clearHighlighting
public void clearHighlighting()
Clear highlight background color from any cell currently highlighted.
refresh
public void refresh()
Refresh the table, triggering re-rendering.
updateRegisters
public void updateRegisters()
update register display using current number base (10 or 16)
updateRegisters
public void updateRegisters(int base)
update register display using specified number base (10 or 16)
Parameters:
base – desired number base
updateRegisterValue
public void updateRegisterValue(int number,
int val,
int base)
This method handles the updating of the GUI.
Parameters:
number – The number of the register to update.
val – New value.
update
public void update(Observable observable,
Object obj)
Required by Observer interface. Called when notified by an Observable that we are registered with.
Observables include:
The Simulator object, which lets us know when it starts and stops running
A register object, which lets us know of register operations
The Simulator keeps us informed of when simulated MIPS execution is active.
This is the only time we care about register operations.
Specified by:
update in interface Observer
Parameters:
observable – The Observable object who is notifying us
obj – Auxiliary object with additional information.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
RepeatButton
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class RepeatButton
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.AbstractButton
javax.swing.JButton
mars.venus.RepeatButton
All Implemented Interfaces:
ActionListener, MouseListener, ImageObserver, ItemSelectable, MenuContainer, Serializable, EventListener, Accessible, SwingConstants
public class RepeatButton
extends JButton
implements ActionListener, MouseListener
RepeatButton is a JButton which contains a timer
for firing events while the button is held down. There is a default
initial delay of 300ms before the first event is fired and a 60ms delay
between subsequent events. When the user holds the button down and moves
the mouse out from over the button, the timer stops, but if the user moves
the mouse back over the button without having released the mouse button,
the timer starts up again at the same delay rate. If the enabled state is
changed while the timer is active, it will be stopped.
NOTE: The normal button behavior is that the action event is fired after
the button is released. It may be important to konw then that this is
still the case. So in effect, listeners will get 1 more event then what
the internal timer fires. It’s not a “bug”, per se, just something to be
aware of. There seems to be no way to suppress the final event from
firing anyway, except to process all ActionListeners internally. But
realistically, it probably doesn’t matter.
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JButton
JButton.AccessibleJButton
Nested classes/interfaces inherited from class javax.swing.AbstractButton
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class javax.swing.AbstractButton
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
RepeatButton()
Creates a button with no set text or icon.
RepeatButton(Action a)
Creates a button where properties are taken from the Action supplied.
RepeatButton(Icon icon)
Creates a button with an icon.
RepeatButton(String text)
Creates a button with text.
RepeatButton(String text,
Icon icon)
Creates a button with initial text and an icon.
Method Summary
void actionPerformed(ActionEvent ae)
Handle action events.
int getDelay()
Gets the delay for the timer of this button.
int getInitialDelay()
Gets the initial delay for the timer of this button.
boolean isRepeatEnabled()
Checks if the button should fire events when held.
static void main(String[] args)
Main method, for testing.
void mouseClicked(MouseEvent me)
Handle mouse clicked events.
void mouseEntered(MouseEvent me)
Handle mouse entered events.
void mouseExited(MouseEvent me)
Handle mouse exited events.
void mousePressed(MouseEvent me)
Handle mouse pressed events.
void mouseReleased(MouseEvent me)
Handle mouse released events.
void setDelay(int d)
Set the delay for the timer of this button.
void setEnabled(boolean en)
Sets the enabled state of this button.
void setInitialDelay(int d)
Sets the initial delay for the timer of this button.
void setRepeatEnabled(boolean en)
Sets if the button should fire events when held.
Methods inherited from class javax.swing.JButton
getAccessibleContext, getUIClassID, isDefaultButton, isDefaultCapable, paramString, removeNotify, setDefaultCapable, updateUI
Methods inherited from class javax.swing.AbstractButton
actionPropertyChanged, addActionListener, addChangeListener, addImpl, addItemListener, checkHorizontalKey, checkVerticalKey, configurePropertiesFromAction, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHideActionText, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, init, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, isSelected, paintBorder, removeActionListener, removeChangeListener, removeItemListener, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setFocusPainted, setHideActionText, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
RepeatButton
public RepeatButton()
Creates a button with no set text or icon.
RepeatButton
public RepeatButton(Action a)
Creates a button where properties are taken from the Action supplied.
Parameters:
a – the button action
RepeatButton
public RepeatButton(Icon icon)
Creates a button with an icon.
Parameters:
icon – the button icon
RepeatButton
public RepeatButton(String text)
Creates a button with text.
Parameters:
text – the button text
RepeatButton
public RepeatButton(String text,
Icon icon)
Creates a button with initial text and an icon.
Parameters:
text – the button text
icon – the button icon
Method Detail
getDelay
public int getDelay()
Gets the delay for the timer of this button.
Returns:
the delay
setDelay
public void setDelay(int d)
Set the delay for the timer of this button.
Parameters:
d – the delay
getInitialDelay
public int getInitialDelay()
Gets the initial delay for the timer of this button.
Returns:
the initial delay
setInitialDelay
public void setInitialDelay(int d)
Sets the initial delay for the timer of this button.
Parameters:
d – the initial delay
isRepeatEnabled
public boolean isRepeatEnabled()
Checks if the button should fire events when held. If false, the
button is effectively a plain old JButton, but there may be times
when this feature might wish to be disabled.
Returns:
if true, the button should fire events when held
setRepeatEnabled
public void setRepeatEnabled(boolean en)
Sets if the button should fire events when held. If false, the
button is effectively a plain old JButton, but there may be times
when this feature might wish to be disabled. If false, it will
also stop the timer if it’s running.
Parameters:
en – if true, the button should fire events when held
setEnabled
public void setEnabled(boolean en)
Sets the enabled state of this button. Overridden to stop the timer
if it’s running.
Overrides:
setEnabled in class AbstractButton
Parameters:
en – if true, enables the button
actionPerformed
public void actionPerformed(ActionEvent ae)
Handle action events. OVERRIDE THIS IN SUBCLASS!
Specified by:
actionPerformed in interface ActionListener
Parameters:
ae – the action event
mouseClicked
public void mouseClicked(MouseEvent me)
Handle mouse clicked events.
Specified by:
mouseClicked in interface MouseListener
Parameters:
me – the mouse event
mousePressed
public void mousePressed(MouseEvent me)
Handle mouse pressed events.
Specified by:
mousePressed in interface MouseListener
Parameters:
me – the mouse event
mouseReleased
public void mouseReleased(MouseEvent me)
Handle mouse released events.
Specified by:
mouseReleased in interface MouseListener
Parameters:
me – the mouse event
mouseEntered
public void mouseEntered(MouseEvent me)
Handle mouse entered events.
Specified by:
mouseEntered in interface MouseListener
Parameters:
me – the mouse event
mouseExited
public void mouseExited(MouseEvent me)
Handle mouse exited events.
Specified by:
mouseExited in interface MouseListener
Parameters:
me – the mouse event
main
public static void main(String[] args)
Main method, for testing. Creates a frame with both styles of menu.
Parameters:
args – the command-line arguments
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
RunAssembleAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class RunAssembleAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.RunAssembleAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class RunAssembleAction
extends GuiAction
Action class for the Run -> Assemble menu item (and toolbar icon)
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
RunAssembleAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
RunAssembleAction
public RunAssembleAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
RunBackstepAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class RunBackstepAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.RunBackstepAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class RunBackstepAction
extends GuiAction
Action for the Run -> Backstep menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
RunBackstepAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
perform next simulated instruction step.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
RunBackstepAction
public RunBackstepAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
perform next simulated instruction step.
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
RunClearBreakpointsAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class RunClearBreakpointsAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.RunClearBreakpointsAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action, TableModelListener
public class RunClearBreakpointsAction
extends GuiAction
implements TableModelListener
Action class for the Run menu item to clear execution breakpoints that have been set.
It is a listener and is notified whenever a breakpoint is added or removed, thus will
set its enabled status true or false depending on whether breakpoints remain after that action.
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
RunClearBreakpointsAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Create the object and register with text segment window as a listener on its table model.
Method Summary
void actionPerformed(ActionEvent e)
When this option is selected, tell text segment window to clear breakpoints in its table model.
void tableChanged(TableModelEvent e)
Required TableModelListener method.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
RunClearBreakpointsAction
public RunClearBreakpointsAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Create the object and register with text segment window as a listener on its table model.
The table model has not been created yet, so text segment window will hang onto this
registration info and transfer it to the table model upon creation (which happens with
each successful assembly).
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
When this option is selected, tell text segment window to clear breakpoints in its table model.
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
tableChanged
public void tableChanged(TableModelEvent e)
Required TableModelListener method. This is response upon editing of text segment table
model. The only editable column is breakpoints so this method is called only when user
adds or removes a breakpoint. Gets new breakpoint count and sets enabled status
accordingly.
Specified by:
tableChanged in interface TableModelListener
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
RunGoAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class RunGoAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.RunGoAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class RunGoAction
extends GuiAction
Action class for the Run -> Go menu item (and toolbar icon)
See Also:
Serialized Form
Field Summary
static int defaultMaxSteps
static int maxSteps
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
RunGoAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
Action to take when GO is selected — run the MIPS program!
void paused(boolean done,
int pauseReason,
ProcessingException pe)
Method to be called when Pause is selected through menu/toolbar/shortcut.
static void resetMaxSteps()
Reset max steps limit to default value at termination of a simulated execution.
void stopped(ProcessingException pe,
int reason)
Method to be called when Stop is selected through menu/toolbar/shortcut.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
defaultMaxSteps
public static int defaultMaxSteps
maxSteps
public static int maxSteps
Constructor Detail
RunGoAction
public RunGoAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Action to take when GO is selected — run the MIPS program!
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
paused
public void paused(boolean done,
int pauseReason,
ProcessingException pe)
Method to be called when Pause is selected through menu/toolbar/shortcut. This should only
happen when MIPS program is running (FileStatus.RUNNING). See VenusUI.java for enabled
status of menu items based on FileStatus. Set GUI as if at breakpoint or executing
step by step.
stopped
public void stopped(ProcessingException pe,
int reason)
Method to be called when Stop is selected through menu/toolbar/shortcut. This should only
happen when MIPS program is running (FileStatus.RUNNING). See VenusUI.java for enabled
status of menu items based on FileStatus. Display finalized values as if execution
terminated due to completion or exception.
resetMaxSteps
public static void resetMaxSteps()
Reset max steps limit to default value at termination of a simulated execution.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
RunPauseAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class RunPauseAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.RunPauseAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class RunPauseAction
extends GuiAction
Action class for the Run -> Pause menu item (and toolbar icon)
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
RunPauseAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
RunPauseAction
public RunPauseAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
RunResetAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class RunResetAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.RunResetAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class RunResetAction
extends GuiAction
Action for the Run -> Reset menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
RunResetAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
reset GUI components and MIPS resources
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
RunResetAction
public RunResetAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
reset GUI components and MIPS resources
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
RunSpeedPanel
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class RunSpeedPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
mars.venus.RunSpeedPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
public class RunSpeedPanel
extends JPanel
Class for the Run speed slider control. One is created and can be obtained using
getInstance().
Author:
Pete Sanderson
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
static double UNLIMITED_SPEED
Constant that represents unlimited run speed.
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Method Summary
static RunSpeedPanel getInstance()
Retrieve the run speed panel object
double getRunSpeed()
returns current run speed setting, in instructions/second.
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
UNLIMITED_SPEED
public static final double UNLIMITED_SPEED
Constant that represents unlimited run speed. Compare with return value of
getRunSpeed() to determine if set to unlimited. At the unlimited setting, the GUI
will not attempt to update register and memory contents as each instruction
is executed. This is the only possible value for command-line use of Mars.
See Also:
Constant Field Values
Method Detail
getInstance
public static RunSpeedPanel getInstance()
Retrieve the run speed panel object
Returns:
the run speed panel
getRunSpeed
public double getRunSpeed()
returns current run speed setting, in instructions/second. Unlimited speed
setting is equal to RunSpeedPanel.UNLIMITED_SPEED
Returns:
run speed setting in instructions/second.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
RunStepAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class RunStepAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.RunStepAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class RunStepAction
extends GuiAction
Action for the Run -> Step menu item
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
RunStepAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
perform next simulated instruction step.
void stepped(boolean done,
int reason,
ProcessingException pe)
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
RunStepAction
public RunStepAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
perform next simulated instruction step.
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
stepped
public void stepped(boolean done,
int reason,
ProcessingException pe)
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
RunStopAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class RunStopAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.RunStopAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class RunStopAction
extends GuiAction
Action class for the Run -> Stop menu item (and toolbar icon)
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
RunStopAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
RunStopAction
public RunStopAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
RunToggleBreakpointsAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class RunToggleBreakpointsAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.RunToggleBreakpointsAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class RunToggleBreakpointsAction
extends GuiAction
Action class for the Run menu item to clear execution breakpoints that have been set.
It is a listener and is notified whenever a breakpoint is added or removed, thus will
set its enabled status true or false depending on whether breakpoints remain after that action.
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
RunToggleBreakpointsAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Create the object and register with text segment window as a listener on its table model.
Method Summary
void actionPerformed(ActionEvent e)
When this option is selected, tell text segment window to clear breakpoints in its table model.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
RunToggleBreakpointsAction
public RunToggleBreakpointsAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Create the object and register with text segment window as a listener on its table model.
The table model has not been created yet, so text segment window will hang onto this
registration info and transfer it to the table model upon creation (which happens with
each successful assembly).
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
When this option is selected, tell text segment window to clear breakpoints in its table model.
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SettingsAddressDisplayBaseAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class SettingsAddressDisplayBaseAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.SettingsAddressDisplayBaseAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class SettingsAddressDisplayBaseAction
extends GuiAction
Action class for the Settings menu item to control number base (10 or 16) of memory addresses.
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
SettingsAddressDisplayBaseAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SettingsAddressDisplayBaseAction
public SettingsAddressDisplayBaseAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SettingsAssembleAllAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class SettingsAssembleAllAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.SettingsAssembleAllAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class SettingsAssembleAllAction
extends GuiAction
Action class for the Settings menu item to determine whether assemble operation applies
only to current file or to all files in its directory.
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
SettingsAssembleAllAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SettingsAssembleAllAction
public SettingsAssembleAllAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SettingsAssembleOnOpenAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class SettingsAssembleOnOpenAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.SettingsAssembleOnOpenAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class SettingsAssembleOnOpenAction
extends GuiAction
Action class for the Settings menu item to control automatic assemble of file upon opening.
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
SettingsAssembleOnOpenAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SettingsAssembleOnOpenAction
public SettingsAssembleOnOpenAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SettingsDelayedBranchingAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class SettingsDelayedBranchingAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.SettingsDelayedBranchingAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class SettingsDelayedBranchingAction
extends GuiAction
Action class for the Settings menu item to control delayed branching.
Note: Changing this setting while the current program is runnable
(assembled, or stepped execution) or terminated triggers a re-assembly.
This is necessary to maintain consistency because the machine
code assembled for branch instructions differs depending on
this setting — would branch to incorrect address if setting
were changed between assembly and execution.
Note: This action is disabled while the MIPS program is running.
The user need only pause or stop execution to re-enable it.
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
SettingsDelayedBranchingAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SettingsDelayedBranchingAction
public SettingsDelayedBranchingAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SettingsEditorAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class SettingsEditorAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.SettingsEditorAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class SettingsEditorAction
extends GuiAction
Action class for the Settings menu item for text editor settings.
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
SettingsEditorAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Create a new SettingsEditorAction.
Method Summary
void actionPerformed(ActionEvent e)
When this action is triggered, launch a dialog to view and modify
editor settings.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SettingsEditorAction
public SettingsEditorAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Create a new SettingsEditorAction. Has all the GuiAction parameters.
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
When this action is triggered, launch a dialog to view and modify
editor settings.
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SettingsExceptionHandlerAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class SettingsExceptionHandlerAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.SettingsExceptionHandlerAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class SettingsExceptionHandlerAction
extends GuiAction
Action class for the Settings menu item for optionally loading a MIPS exception handler.
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
SettingsExceptionHandlerAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SettingsExceptionHandlerAction
public SettingsExceptionHandlerAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SettingsExtendedAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class SettingsExtendedAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.SettingsExtendedAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class SettingsExtendedAction
extends GuiAction
Action class for the Settings menu item to control use of extended (pseudo) instructions or formats.
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
SettingsExtendedAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SettingsExtendedAction
public SettingsExtendedAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SettingsHighlightingAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class SettingsHighlightingAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.SettingsHighlightingAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class SettingsHighlightingAction
extends GuiAction
Action class for the Settings menu item for text editor settings.
See Also:
Serialized Form
Field Summary
static String APPLY_TOOL_TIP_TEXT
static String CANCEL_TOOL_TIP_TEXT
static String CLOSE_TOOL_TIP_TEXT
static String RESET_TOOL_TIP_TEXT
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
SettingsHighlightingAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Create a new SettingsEditorAction.
Method Summary
void actionPerformed(ActionEvent e)
When this action is triggered, launch a dialog to view and modify
editor settings.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
CLOSE_TOOL_TIP_TEXT
public static final String CLOSE_TOOL_TIP_TEXT
See Also:
Constant Field Values
APPLY_TOOL_TIP_TEXT
public static final String APPLY_TOOL_TIP_TEXT
See Also:
Constant Field Values
RESET_TOOL_TIP_TEXT
public static final String RESET_TOOL_TIP_TEXT
See Also:
Constant Field Values
CANCEL_TOOL_TIP_TEXT
public static final String CANCEL_TOOL_TIP_TEXT
See Also:
Constant Field Values
Constructor Detail
SettingsHighlightingAction
public SettingsHighlightingAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Create a new SettingsEditorAction. Has all the GuiAction parameters.
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
When this action is triggered, launch a dialog to view and modify
editor settings.
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SettingsLabelAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class SettingsLabelAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.SettingsLabelAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class SettingsLabelAction
extends GuiAction
Action class for the Settings menu item to control display of Labels window (symbol table).
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
SettingsLabelAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SettingsLabelAction
public SettingsLabelAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SettingsMemoryConfigurationAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class SettingsMemoryConfigurationAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.SettingsMemoryConfigurationAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class SettingsMemoryConfigurationAction
extends GuiAction
Action class for the Settings menu item for text editor settings.
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
SettingsMemoryConfigurationAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Create a new SettingsEditorAction.
Method Summary
void actionPerformed(ActionEvent e)
When this action is triggered, launch a dialog to view and modify
editor settings.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SettingsMemoryConfigurationAction
public SettingsMemoryConfigurationAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Create a new SettingsEditorAction. Has all the GuiAction parameters.
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
When this action is triggered, launch a dialog to view and modify
editor settings.
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SettingsPopupInputAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class SettingsPopupInputAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.SettingsPopupInputAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class SettingsPopupInputAction
extends GuiAction
Action class for the Settings menu item to control use of popup dialog for input syscalls.
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
SettingsPopupInputAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SettingsPopupInputAction
public SettingsPopupInputAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SettingsProgramArgumentsAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class SettingsProgramArgumentsAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.SettingsProgramArgumentsAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class SettingsProgramArgumentsAction
extends GuiAction
Action class for the Settings menu item to control whether or not
program arguments can be entered and used. If so, a text field
will be displayed where they can be interactively entered.
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
SettingsProgramArgumentsAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SettingsProgramArgumentsAction
public SettingsProgramArgumentsAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SettingsSelfModifyingCodeAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class SettingsSelfModifyingCodeAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.SettingsSelfModifyingCodeAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class SettingsSelfModifyingCodeAction
extends GuiAction
Action class for the Settings menu item to control whether
the running MIPS program can write to the text segment or
branch to the data segment. This actions permit the program
to generate and execute binary code at runtime. In other
words, modify itself.
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
SettingsSelfModifyingCodeAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SettingsSelfModifyingCodeAction
public SettingsSelfModifyingCodeAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SettingsStartAtMainAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class SettingsStartAtMainAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.SettingsStartAtMainAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class SettingsStartAtMainAction
extends GuiAction
Action class for the Settings menu item to control whether or not
assembler warnings are considered errors. If so, a program generating
warnings but not errors will not assemble.
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
SettingsStartAtMainAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SettingsStartAtMainAction
public SettingsStartAtMainAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SettingsValueDisplayBaseAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class SettingsValueDisplayBaseAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.SettingsValueDisplayBaseAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class SettingsValueDisplayBaseAction
extends GuiAction
Action class for the Settings menu item to control number base (10 or 16) of memory/register contents.
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
SettingsValueDisplayBaseAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SettingsValueDisplayBaseAction
public SettingsValueDisplayBaseAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
SettingsWarningsAreErrorsAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class SettingsWarningsAreErrorsAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.GuiAction
mars.venus.SettingsWarningsAreErrorsAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class SettingsWarningsAreErrorsAction
extends GuiAction
Action class for the Settings menu item to control whether or not
assembler warnings are considered errors. If so, a program generating
warnings but not errors will not assemble.
See Also:
Serialized Form
Field Summary
Fields inherited from class mars.venus.GuiAction
mainUI
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
SettingsWarningsAreErrorsAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Summary
void actionPerformed(ActionEvent e)
does nothing by default.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SettingsWarningsAreErrorsAction
public SettingsWarningsAreErrorsAction(String name,
Icon icon,
String descrip,
Integer mnemonic,
KeyStroke accel,
VenusUI gui)
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Description copied from class: GuiAction
does nothing by default. Should be over-ridden by subclass
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class GuiAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
TextSegmentWindow
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class TextSegmentWindow
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JInternalFrame
mars.venus.TextSegmentWindow
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Observer, Accessible, RootPaneContainer, WindowConstants
public class TextSegmentWindow
extends JInternalFrame
implements Observer
Creates the Text Segment window in the Execute tab of the UI
Author:
Team JSpim
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JInternalFrame
JInternalFrame.AccessibleJInternalFrame, JInternalFrame.JDesktopIcon
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class javax.swing.JInternalFrame
closable, CONTENT_PANE_PROPERTY, desktopIcon, FRAME_ICON_PROPERTY, frameIcon, GLASS_PANE_PROPERTY, iconable, IS_CLOSED_PROPERTY, IS_ICON_PROPERTY, IS_MAXIMUM_PROPERTY, IS_SELECTED_PROPERTY, isClosed, isIcon, isMaximum, isSelected, LAYERED_PANE_PROPERTY, maximizable, MENU_BAR_PROPERTY, resizable, ROOT_PANE_PROPERTY, rootPane, rootPaneCheckingEnabled, title, TITLE_PROPERTY
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
TextSegmentWindow()
Constructor, sets up a new JInternalFrame.
Method Summary
void addProgramArgumentsPanel()
void clearAllBreakpoints()
Clears all breakpoints that have been set since last assemble, and
updates the display of the breakpoint column.
void clearWindow()
remove all components
int getBreakpointCount()
Returns number of breakpoints currently set.
boolean getCodeHighlighting()
Get code highlighting status.
String getProgramArguments()
Get program arguments from text field in south border of text segment window.
int[] getSortedBreakPointsArray()
Returns array of current breakpoints, each represented by a MIPS program counter address.
void highlightStepAtAddress(int address)
Highlights the source code line whose address matches the given
text segment address.
void highlightStepAtAddress(int address,
boolean inDelaySlot)
Highlights the source code line whose address matches the given
text segment address.
void highlightStepAtPC()
Highlights the source code line whose address matches the current
program counter value.
void highlightStepAtPC(boolean inDelaySlot)
Highlights the source code line whose address matches the current
program counter value.
void registerTableModelListener(TableModelListener tml)
Assign listener to Table model.
void removeProgramArgumentsPanel()
void setCodeHighlighting(boolean highlightSetting)
Used to enable or disable source code highlighting.
void setupTable()
Method to be called once the user compiles the program.
void toggleBreakpoints()
Enable or disable all items in the Breakpoints column.
void unhighlightAllSteps()
If any steps are highlighted, this erases the highlighting.
void update(Observable observable,
Object obj)
Required by Observer interface.
void updateBasicStatements()
Redisplay the basic statements.
void updateCodeAddresses()
Redisplay the addresses.
Methods inherited from class javax.swing.JInternalFrame
addImpl, addInternalFrameListener, createRootPane, dispose, doDefaultCloseAction, fireInternalFrameEvent, getAccessibleContext, getContentPane, getDefaultCloseOperation, getDesktopIcon, getDesktopPane, getFocusCycleRootAncestor, getFocusOwner, getFrameIcon, getGlassPane, getInternalFrameListeners, getJMenuBar, getLastCursor, getLayer, getLayeredPane, getMenuBar, getMostRecentFocusOwner, getNormalBounds, getRootPane, getTitle, getUI, getUIClassID, getWarningString, hide, isClosable, isClosed, isFocusCycleRoot, isIcon, isIconifiable, isMaximizable, isMaximum, isResizable, isRootPaneCheckingEnabled, isSelected, moveToBack, moveToFront, pack, paintComponent, paramString, remove, removeInternalFrameListener, reshape, restoreSubcomponentFocus, setClosable, setClosed, setContentPane, setCursor, setDefaultCloseOperation, setDesktopIcon, setFocusCycleRoot, setFrameIcon, setGlassPane, setIcon, setIconifiable, setJMenuBar, setLayer, setLayer, setLayeredPane, setLayout, setMaximizable, setMaximum, setMenuBar, setNormalBounds, setResizable, setRootPane, setRootPaneCheckingEnabled, setSelected, setTitle, setUI, show, toBack, toFront, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
TextSegmentWindow
public TextSegmentWindow()
Constructor, sets up a new JInternalFrame.
Method Detail
setupTable
public void setupTable()
Method to be called once the user compiles the program.
Should convert the lines of code over to the table rows and columns.
getProgramArguments
public String getProgramArguments()
Get program arguments from text field in south border of text segment window.
Returns:
String containing program arguments
addProgramArgumentsPanel
public void addProgramArgumentsPanel()
removeProgramArgumentsPanel
public void removeProgramArgumentsPanel()
clearWindow
public void clearWindow()
remove all components
registerTableModelListener
public void registerTableModelListener(TableModelListener tml)
Assign listener to Table model. Used for breakpoints, since that is the only editable
column in the table. Since table model objects are transient (get a new one with each
successful assemble), this method will simply keep the identity of the listener then
add it as a listener each time a new table model object is created. Limit 1 listener.
updateCodeAddresses
public void updateCodeAddresses()
Redisplay the addresses. This should only be done when address display base is
modified (e.g. between base 16 hex and base 10 dec).
updateBasicStatements
public void updateBasicStatements()
Redisplay the basic statements. This should only be done when address or value display base is
modified (e.g. between base 16 hex and base 10 dec).
update
public void update(Observable observable,
Object obj)
Required by Observer interface. Called when notified by an Observable that we are registered with.
The Observable here is a delegate of the Memory object, which lets us know of memory operations.
More precisely, memory operations only in the text segment, since that is the only range of
addresses we’re registered for. And we’re only interested in write operations.
Specified by:
update in interface Observer
Parameters:
observable – The Observable object who is notifying us
obj – Auxiliary object with additional information.
getBreakpointCount
public int getBreakpointCount()
Returns number of breakpoints currently set.
Returns:
number of current breakpoints
getSortedBreakPointsArray
public int[] getSortedBreakPointsArray()
Returns array of current breakpoints, each represented by a MIPS program counter address.
These are stored in the BREAK_COLUMN of the table model.
Returns:
int array of breakpoints, sorted by PC address, or null if there are none.
clearAllBreakpoints
public void clearAllBreakpoints()
Clears all breakpoints that have been set since last assemble, and
updates the display of the breakpoint column.
highlightStepAtPC
public void highlightStepAtPC()
Highlights the source code line whose address matches the current
program counter value. This is used for stepping through code
execution and when reaching breakpoints.
highlightStepAtPC
public void highlightStepAtPC(boolean inDelaySlot)
Highlights the source code line whose address matches the current
program counter value. This is used for stepping through code
execution and when reaching breakpoints.
Parameters:
inDelaySlot – Set true if delayed branching is enabled and the
instruction at this address is executing in the delay slot, false
otherwise.
highlightStepAtAddress
public void highlightStepAtAddress(int address)
Highlights the source code line whose address matches the given
text segment address.
Parameters:
address – text segment address of instruction to be highlighted.
highlightStepAtAddress
public void highlightStepAtAddress(int address,
boolean inDelaySlot)
Highlights the source code line whose address matches the given
text segment address.
Parameters:
address – Text segment address of instruction to be highlighted.
inDelaySlot – Set true if delayed branching is enabled and the
instruction at this address is executing in the delay slot, false
otherwise.
setCodeHighlighting
public void setCodeHighlighting(boolean highlightSetting)
Used to enable or disable source code highlighting. If true (normally while
stepping through execution) then MIPS statement at current program counter
is highlighted. The code column’s cell renderer tests this variable.
Parameters:
highlightSetting – true to enable highlighting, false to disable.
getCodeHighlighting
public boolean getCodeHighlighting()
Get code highlighting status.
Returns:
true if code highlighting currently enabled, false otherwise.
unhighlightAllSteps
public void unhighlightAllSteps()
If any steps are highlighted, this erases the highlighting.
toggleBreakpoints
public void toggleBreakpoints()
Enable or disable all items in the Breakpoints column.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
ToolAction
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class ToolAction
java.lang.Object
javax.swing.AbstractAction
mars.venus.ToolAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
public class ToolAction
extends AbstractAction
Connects a MarsTool class (class that implements MarsTool interface) to
the Mars menu system by supplying the response to that tool’s menu item
selection.
Author:
Pete Sanderson
See Also:
Serialized Form
Field Summary
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor Summary
ToolAction(Class toolClass,
String toolName)
Simple constructor.
Method Summary
void actionPerformed(ActionEvent e)
Response when tool’s item selected from menu.
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
ToolAction
public ToolAction(Class toolClass,
String toolName)
Simple constructor.
Parameters:
toolClass – Class object for the associated MarsTool subclass
toolName – Name of this tool, for the menu.
Method Detail
actionPerformed
public void actionPerformed(ActionEvent e)
Response when tool’s item selected from menu. Invokes tool’s action() method.
Parameters:
e – the ActionEvent that triggered this call
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
ToolLoader
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class ToolLoader
java.lang.Object
mars.venus.ToolLoader
public class ToolLoader
extends Object
This class provides functionality to bring external Mars tools into the Mars
system by adding them to its Tools menu. This permits anyone with knowledge
of the Mars public interfaces, in particular of the Memory and Register
classes, to write applications which can interact with a MIPS program
executing under Mars. The execution is of course simulated. The
private method for loading tool classes is adapted from Bret Barker’s
GameServer class from the book “Developing Games In Java”.
Author:
Pete Sanderson with help from Bret Barker
Constructor Summary
ToolLoader()
Method Summary
JMenu buildToolsMenu()
Called in VenusUI to build its Tools menu.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
ToolLoader
public ToolLoader()
Method Detail
buildToolsMenu
public JMenu buildToolsMenu()
Called in VenusUI to build its Tools menu. If there are no qualifying tools
or any problems accessing those tools, it returns null. A qualifying tool
must be a class in the Tools package that implements MarsTool, must be compiled
into a .class file, and its .class file must be in the same Tools folder as
MarsTool.class.
Returns:
a Tools JMenu if qualifying tool classes are found, otherwise null
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
VenusUI
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
mars.venus
Class VenusUI
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
mars.venus.VenusUI
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants
public class VenusUI
extends JFrame
Top level container for Venus GUI.
Author:
Sanderson and Team JSpim
See Also:
Serialized Form
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
JMenuBar menu
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor Summary
VenusUI(String s)
Constructor for the Class.
Method Summary
void dispatchEventToMenu(KeyEvent evt)
Send keyboard event to menu for possible processing.
JCheckBoxMenuItem getAddressDisplayBaseMenuItem()
Get reference to settings menu item for display base of memory/register values.
Editor getEditor()
Get reference to Editor object associated with this GUI.
MainPane getMainPane()
Get reference to messages pane associated with this GUI.
static int getMenuState()
Get current menu state.
MessagesPane getMessagesPane()
Get reference to messages pane associated with this GUI.
RegistersPane getRegistersPane()
Get reference to registers pane associated with this GUI.
static boolean getReset()
To find out whether the register values are reset.
Action getRunAssembleAction()
Return reference tothe Run->Assemble item’s action.
static boolean getStarted()
To find out whether MIPS program is currently executing.
JCheckBoxMenuItem getValueDisplayBaseMenuItem()
Get reference to settings menu item for display base of memory/register values.
void haveMenuRequestFocus()
Have the menu request keyboard focus.
static void setReset(boolean b)
To set whether the register values are reset.
static void setStarted(boolean b)
To set whether MIPS program execution has started.
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
Field Detail
menu
public JMenuBar menu
Constructor Detail
VenusUI
public VenusUI(String s)
Constructor for the Class. Sets up a window object for the UI
Parameters:
s – Name of the window to be created.
Method Detail
getMenuState
public static int getMenuState()
Get current menu state. State values are constants in FileStatus class. DPS 23 July 2008
Returns:
current menu state.
setReset
public static void setReset(boolean b)
To set whether the register values are reset.
Parameters:
b – Boolean true if the register values have been reset.
setStarted
public static void setStarted(boolean b)
To set whether MIPS program execution has started.
Parameters:
b – true if the MIPS program execution has started.
getReset
public static boolean getReset()
To find out whether the register values are reset.
Returns:
Boolean true if the register values have been reset.
getStarted
public static boolean getStarted()
To find out whether MIPS program is currently executing.
Returns:
true if MIPS program is currently executing.
getEditor
public Editor getEditor()
Get reference to Editor object associated with this GUI.
Returns:
Editor for the GUI.
getMainPane
public MainPane getMainPane()
Get reference to messages pane associated with this GUI.
Returns:
MessagesPane object associated with the GUI.
getMessagesPane
public MessagesPane getMessagesPane()
Get reference to messages pane associated with this GUI.
Returns:
MessagesPane object associated with the GUI.
getRegistersPane
public RegistersPane getRegistersPane()
Get reference to registers pane associated with this GUI.
Returns:
RegistersPane object associated with the GUI.
getValueDisplayBaseMenuItem
public JCheckBoxMenuItem getValueDisplayBaseMenuItem()
Get reference to settings menu item for display base of memory/register values.
Returns:
the menu item
getAddressDisplayBaseMenuItem
public JCheckBoxMenuItem getAddressDisplayBaseMenuItem()
Get reference to settings menu item for display base of memory/register values.
Returns:
the menu item
getRunAssembleAction
public Action getRunAssembleAction()
Return reference tothe Run->Assemble item’s action. Needed by File->Open in case
assemble-upon-open flag is set.
Returns:
the Action object for the Run->Assemble operation.
haveMenuRequestFocus
public void haveMenuRequestFocus()
Have the menu request keyboard focus. DPS 5-4-10
dispatchEventToMenu
public void dispatchEventToMenu(KeyEvent evt)
Send keyboard event to menu for possible processing. DPS 5-4-10
Parameters:
evt – KeyEvent for menu component to consider for processing.
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Mars
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Class Mars
java.lang.Object
Mars
public class Mars
extends Object
Portal to Mars
Author:
Pete Sanderson
Constructor Summary
Mars()
Method Summary
static void main(String[] args)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
Mars
public Mars()
Method Detail
main
public static void main(String[] args)
Overview Package Class Tree Deprecated Index Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Overview List
All Classes
Packages
mars
mars.assembler
mars.mips.dump
mars.mips.hardware
mars.mips.instructions
mars.mips.instructions.syscalls
mars.simulator
mars.tools
mars.util
mars.venus
mars.venus.editors
mars.venus.editors.generic
mars.venus.editors.jeditsyntax
mars.venus.editors.jeditsyntax.tokenmarker
Overview
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Packages
mars
mars.assembler
mars.mips.dump
mars.mips.hardware
mars.mips.instructions
mars.mips.instructions.syscalls
mars.simulator
mars.tools
mars.util
mars.venus
mars.venus.editors
mars.venus.editors.generic
mars.venus.editors.jeditsyntax
mars.venus.editors.jeditsyntax.tokenmarker
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Class Hierarchy
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Hierarchy For All Packages
Package Hierarchies:
mars, mars.assembler, mars.mips.dump, mars.mips.hardware, mars.mips.instructions, mars.mips.instructions.syscalls, mars.simulator, mars.tools, mars.util, mars.venus, mars.venus.editors, mars.venus.editors.generic, mars.venus.editors.jeditsyntax, mars.venus.editors.jeditsyntax.tokenmarker
Class Hierarchy
java.lang.Object javax.swing.AbstractAction (implements javax.swing.Action, java.lang.Cloneable, java.io.Serializable)
mars.venus.GuiAction mars.venus.EditCopyAction
mars.venus.EditCutAction
mars.venus.EditFindReplaceAction
mars.venus.EditPasteAction
mars.venus.EditRedoAction
mars.venus.EditSelectAllAction
mars.venus.EditUndoAction
mars.venus.FileCloseAction
mars.venus.FileCloseAllAction
mars.venus.FileDumpMemoryAction
mars.venus.FileExitAction
mars.venus.FileNewAction
mars.venus.FileOpenAction
mars.venus.FilePrintAction
mars.venus.FileSaveAction
mars.venus.FileSaveAllAction
mars.venus.FileSaveAsAction
mars.venus.HelpAboutAction
mars.venus.HelpHelpAction
mars.venus.RunAssembleAction
mars.venus.RunBackstepAction
mars.venus.RunClearBreakpointsAction (implements javax.swing.event.TableModelListener)
mars.venus.RunGoAction
mars.venus.RunPauseAction
mars.venus.RunResetAction
mars.venus.RunStepAction
mars.venus.RunStopAction
mars.venus.RunToggleBreakpointsAction
mars.venus.SettingsAddressDisplayBaseAction
mars.venus.SettingsAssembleAllAction
mars.venus.SettingsAssembleOnOpenAction
mars.venus.SettingsDelayedBranchingAction
mars.venus.SettingsEditorAction
mars.venus.SettingsExceptionHandlerAction
mars.venus.SettingsExtendedAction
mars.venus.SettingsHighlightingAction
mars.venus.SettingsLabelAction
mars.venus.SettingsMemoryConfigurationAction
mars.venus.SettingsPopupInputAction
mars.venus.SettingsProgramArgumentsAction
mars.venus.SettingsSelfModifyingCodeAction
mars.venus.SettingsStartAtMainAction
mars.venus.SettingsValueDisplayBaseAction
mars.venus.SettingsWarningsAreErrorsAction
mars.venus.ToolAction
javax.swing.text.AbstractDocument (implements javax.swing.text.Document, java.io.Serializable)
javax.swing.text.PlainDocument mars.venus.editors.jeditsyntax.SyntaxDocument
mars.mips.dump.AbstractDumpFormat (implements mars.mips.dump.DumpFormat)
mars.mips.dump.AsciiTextDumpFormat
mars.mips.dump.BinaryDumpFormat
mars.mips.dump.BinaryTextDumpFormat
mars.mips.dump.HexTextDumpFormat
mars.mips.dump.IntelHexDumpFormat
mars.mips.dump.SegmentWindowDumpFormat
mars.mips.instructions.syscalls.AbstractSyscall (implements mars.mips.instructions.syscalls.Syscall)
mars.mips.instructions.syscalls.SyscallClose
mars.mips.instructions.syscalls.SyscallConfirmDialog
mars.mips.instructions.syscalls.SyscallExit
mars.mips.instructions.syscalls.SyscallExit2
mars.mips.instructions.syscalls.SyscallInputDialogDouble
mars.mips.instructions.syscalls.SyscallInputDialogFloat
mars.mips.instructions.syscalls.SyscallInputDialogInt
mars.mips.instructions.syscalls.SyscallInputDialogString
mars.mips.instructions.syscalls.SyscallMessageDialog
mars.mips.instructions.syscalls.SyscallMessageDialogDouble
mars.mips.instructions.syscalls.SyscallMessageDialogFloat
mars.mips.instructions.syscalls.SyscallMessageDialogInt
mars.mips.instructions.syscalls.SyscallMessageDialogString
mars.mips.instructions.syscalls.SyscallMidiOut
mars.mips.instructions.syscalls.SyscallMidiOutSync
mars.mips.instructions.syscalls.SyscallOpen
mars.mips.instructions.syscalls.SyscallPrintChar
mars.mips.instructions.syscalls.SyscallPrintDouble
mars.mips.instructions.syscalls.SyscallPrintFloat
mars.mips.instructions.syscalls.SyscallPrintInt
mars.mips.instructions.syscalls.SyscallPrintIntBinary
mars.mips.instructions.syscalls.SyscallPrintIntHex
mars.mips.instructions.syscalls.SyscallPrintIntUnsigned
mars.mips.instructions.syscalls.SyscallPrintString
mars.mips.instructions.syscalls.SyscallRandDouble
mars.mips.instructions.syscalls.SyscallRandFloat
mars.mips.instructions.syscalls.SyscallRandInt
mars.mips.instructions.syscalls.SyscallRandIntRange
mars.mips.instructions.syscalls.SyscallRandSeed
mars.mips.instructions.syscalls.SyscallRead
mars.mips.instructions.syscalls.SyscallReadChar
mars.mips.instructions.syscalls.SyscallReadDouble
mars.mips.instructions.syscalls.SyscallReadFloat
mars.mips.instructions.syscalls.SyscallReadInt
mars.mips.instructions.syscalls.SyscallReadString
mars.mips.instructions.syscalls.SyscallSbrk
mars.mips.instructions.syscalls.SyscallSleep
mars.mips.instructions.syscalls.SyscallTime
mars.mips.instructions.syscalls.SyscallWrite
javax.swing.table.AbstractTableModel (implements java.io.Serializable, javax.swing.table.TableModel)
mars.tools.BHTableModel
mars.mips.hardware.AccessNotice mars.mips.hardware.MemoryAccessNotice
mars.mips.hardware.RegisterAccessNotice
mars.assembler.Assembler
mars.simulator.BackStepper
mars.mips.instructions.BasicInstructionFormat
mars.tools.BHTEntry
mars.util.Binary
java.awt.Component (implements java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable)
java.awt.Container javax.swing.JComponent (implements java.io.Serializable)
javax.swing.AbstractButton (implements java.awt.ItemSelectable, javax.swing.SwingConstants)
javax.swing.JButton (implements javax.accessibility.Accessible)
mars.tools.AbstractMarsToolAndApplication.ConnectButton
mars.venus.RepeatButton (implements java.awt.event.ActionListener, java.awt.event.MouseListener)
javax.swing.JToggleButton (implements javax.accessibility.Accessible)
javax.swing.JCheckBox (implements javax.accessibility.Accessible)
mars.venus.NumberDisplayBaseChooser
mars.tools.DigitalLabSim.SevenSegmentDisplay
mars.venus.editors.jeditsyntax.JEditTextArea mars.venus.editors.jeditsyntax.JEditBasedTextArea (implements javax.swing.event.CaretListener, mars.venus.editors.MARSTextEditingArea)
javax.swing.JInternalFrame (implements javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants)
mars.venus.DataSegmentWindow (implements java.util.Observer)
mars.venus.LabelsWindow
mars.venus.TextSegmentWindow (implements java.util.Observer)
javax.swing.JLayeredPane (implements javax.accessibility.Accessible)
javax.swing.JDesktopPane (implements javax.accessibility.Accessible)
mars.venus.ExecutePane
javax.swing.JPanel (implements javax.accessibility.Accessible)
mars.tools.BHTSimGUI
mars.venus.Coprocessor0Window (implements java.util.Observer)
mars.venus.Coprocessor1Window (implements java.awt.event.ActionListener, java.util.Observer)
mars.tools.DigitalLabSim.HexaKeyboard
mars.tools.DigitalLabSim.SevenSegmentPanel
mars.venus.EditPane (implements java.util.Observer)
mars.venus.RegistersWindow (implements java.util.Observer)
mars.venus.RunSpeedPanel
javax.swing.JTabbedPane (implements javax.accessibility.Accessible, java.io.Serializable, javax.swing.SwingConstants)
mars.venus.EditTabbedPane
mars.venus.MainPane
mars.venus.MessagesPane
mars.venus.RegistersPane
javax.swing.text.JTextComponent (implements javax.accessibility.Accessible, javax.swing.Scrollable)
javax.swing.JTextArea mars.venus.editors.generic.GenericTextArea (implements mars.venus.editors.MARSTextEditingArea)
mars.venus.editors.jeditsyntax.TextAreaPainter (implements javax.swing.text.TabExpander)
java.awt.Window (implements javax.accessibility.Accessible)
java.awt.Dialog javax.swing.JDialog (implements javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants)
mars.venus.AbstractFontSettingDialog
java.awt.Frame (implements java.awt.MenuContainer)
javax.swing.JFrame (implements javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants)
mars.tools.AbstractMarsToolAndApplication (implements mars.tools.MarsTool, java.util.Observer)
mars.tools.BHTSimulator (implements java.awt.event.ActionListener)
mars.tools.BitmapDisplay
mars.tools.CacheSimulator
mars.tools.DigitalLabSim
mars.tools.FloatRepresentation
mars.tools.InstructionCounter
mars.tools.InstructionStatistics
mars.tools.IntroToTools
mars.tools.KeyboardAndDisplaySimulator
mars.tools.MemoryReferenceVisualization
mars.venus.VenusUI
javax.swing.JWindow (implements javax.accessibility.Accessible, javax.swing.RootPaneContainer)
mars.MarsSplashScreen
mars.mips.hardware.Coprocessor0
mars.mips.hardware.Coprocessor1
mars.assembler.DataTypes
mars.simulator.DelayedBranch
mars.tools.DigitalLabSim.HexaKeyboard.EcouteurClick (implements java.awt.event.MouseListener)
mars.tools.DigitalLabSim.OneSecondCounter
mars.assembler.Directives
mars.mips.dump.DumpFormatLoader
mars.venus.Editor
mars.util.EditorFont
mars.ErrorList
mars.ErrorMessage
mars.simulator.Exceptions
mars.util.FilenameFinder
mars.venus.FileStatus
mars.Globals
mars.venus.editors.jeditsyntax.InputHandler.backspace (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.backspace_word (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.clip_copy (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.clip_cut (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.clip_paste (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.delete (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.delete_word (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.document_end (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.document_home (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.end (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.home (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.insert_break (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.insert_char (implements java.awt.event.ActionListener, mars.venus.editors.jeditsyntax.InputHandler.NonRepeatable)
mars.venus.editors.jeditsyntax.InputHandler.insert_tab (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.next_char (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.next_line (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.next_page (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.next_word (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.overwrite (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.prev_char (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.prev_line (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.prev_page (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.prev_word (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.repeat (implements java.awt.event.ActionListener, mars.venus.editors.jeditsyntax.InputHandler.NonRecordable)
mars.venus.editors.jeditsyntax.InputHandler.select_all (implements java.awt.event.ActionListener)
mars.venus.editors.jeditsyntax.InputHandler.toggle_rect (implements java.awt.event.ActionListener)
mars.mips.instructions.Instruction mars.mips.instructions.BasicInstruction
mars.mips.instructions.ExtendedInstruction
mars.mips.instructions.InstructionSet
java.awt.event.KeyAdapter (implements java.awt.event.KeyListener)
mars.tools.AbstractMarsToolAndApplication.EnterKeyListener
mars.venus.editors.jeditsyntax.InputHandler mars.venus.editors.jeditsyntax.DefaultInputHandler
mars.venus.editors.jeditsyntax.KeywordMap
mars.assembler.Macro
mars.assembler.MacroPool
Mars
mars.tools.MarsBot (implements mars.tools.MarsTool, java.util.Observer)
mars.MarsLaunch
mars.mips.hardware.MemoryConfiguration
mars.mips.hardware.MemoryConfigurations
mars.util.MemoryDump
mars.mips.dump.MIFDumpFormat
mars.MIPSprogram
java.awt.event.MouseAdapter (implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener)
mars.venus.PopupListener
java.util.Observable mars.mips.hardware.Memory
mars.mips.hardware.Register
mars.Settings
mars.simulator.Simulator
mars.assembler.OperandFormat
mars.venus.editors.jeditsyntax.PopupHelpItem
mars.simulator.ProgramArgumentList
mars.ProgramStatement
mars.util.PropertiesFile
mars.mips.instructions.syscalls.RandomStreams
mars.mips.hardware.RegisterFile
mars.tools.ScavengerHunt (implements mars.tools.MarsTool, java.util.Observer)
mars.tools.ScreenMagnifier (implements mars.tools.MarsTool)
mars.simulator.SimulatorNotice
mars.assembler.SourceLine
mars.simulator.SwingWorker
mars.assembler.Symbol
mars.assembler.SymbolTable
mars.venus.editors.jeditsyntax.SyntaxStyle
mars.venus.editors.jeditsyntax.SyntaxUtilities
mars.mips.instructions.syscalls.SyscallNumberOverride
mars.util.SystemIO
mars.venus.editors.jeditsyntax.TextAreaDefaults
mars.venus.editors.jeditsyntax.TextUtilities
java.lang.Throwable (implements java.io.Serializable)
java.lang.Exception mars.mips.hardware.AddressErrorException
mars.venus.HardcopyWriter.PrintCanceledException
mars.mips.hardware.InvalidRegisterAccessException
mars.ProcessingException
mars.venus.editors.jeditsyntax.tokenmarker.Token
mars.assembler.Token
mars.assembler.Tokenizer
mars.assembler.TokenList (implements java.lang.Cloneable)
mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker mars.venus.editors.jeditsyntax.tokenmarker.MIPSTokenMarker
mars.venus.editors.jeditsyntax.tokenmarker.TokenMarker.LineInfo
mars.assembler.TokenTypes
mars.venus.ToolLoader
java.io.Writer (implements java.lang.Appendable, java.io.Closeable, java.io.Flushable)
mars.venus.HardcopyWriter
Interface Hierarchy
mars.mips.dump.DumpFormat
mars.venus.editors.jeditsyntax.InputHandler.MacroRecorder
mars.venus.editors.jeditsyntax.InputHandler.NonRecordable
mars.venus.editors.jeditsyntax.InputHandler.NonRepeatable
mars.venus.editors.jeditsyntax.InputHandler.Wrapper
mars.venus.editors.MARSTextEditingArea
mars.tools.MarsTool
mars.mips.instructions.SimulationCode
mars.simulator.Simulator.StopListener
mars.mips.instructions.syscalls.Syscall
mars.venus.editors.jeditsyntax.TextAreaPainter.Highlight
mars.assembler.TranslationCode
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Classes
Mars
mars
mars.assembler
mars.mips.dump
mars.mips.hardware
mars.mips.instructions
mars.mips.instructions.syscalls
mars.simulator
mars.tools
mars.util
mars.venus
mars.venus.editors
mars.venus.editors.generic
mars.venus.editors.jeditsyntax
mars.venus.editors.jeditsyntax.tokenmarker
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
Package
Class Summary
Mars Portal to Mars
Overview Package Class Tree Deprecated Index Help
PREV PACKAGE
NEXT PACKAGE
FRAMES
NO FRAMES
All Classes
Class Hierarchy
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Hierarchy For Package
Package Hierarchies:
All Packages
Class Hierarchy
java.lang.Object Mars
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Serialized Form
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Serialized Form
Package mars
Class mars.MarsSplashScreen extends JWindow implements Serializable
Serialized Fields
duration
int duration
Class mars.ProcessingException extends Exception implements Serializable
Serialized Fields
errs
ErrorList errs
Package mars.mips.hardware
Class mars.mips.hardware.AddressErrorException extends Exception implements Serializable
Serialized Fields
address
int address
type
int type
Class mars.mips.hardware.InvalidRegisterAccessException extends Exception implements Serializable
Serialized Fields
errs
ErrorList errs
Package mars.tools
Class mars.tools.AbstractMarsToolAndApplication extends JFrame implements Serializable
Serialized Fields
isBeingUsedAsAMarsTool
boolean isBeingUsedAsAMarsTool
thisMarsApp
AbstractMarsToolAndApplication thisMarsApp
dialog
JDialog dialog
theWindow
Window theWindow
headingLabel
JLabel headingLabel
title
String title
heading
String heading
emptyBorder
EmptyBorder emptyBorder
backgroundColor
Color backgroundColor
lowMemoryAddress
int lowMemoryAddress
highMemoryAddress
int highMemoryAddress
observing
boolean observing
mostRecentlyOpenedFile
File mostRecentlyOpenedFile
interactiveGUIUpdater
Runnable interactiveGUIUpdater
operationStatusMessages
mars.tools.AbstractMarsToolAndApplication.MessageField operationStatusMessages
openFileButton
JButton openFileButton
assembleRunButton
JButton assembleRunButton
stopButton
JButton stopButton
multiFileAssemble
boolean multiFileAssemble
connectButton
AbstractMarsToolAndApplication.ConnectButton connectButton
Class mars.tools.AbstractMarsToolAndApplication.ConnectButton extends JButton implements Serializable
Class mars.tools.BHTableModel extends AbstractTableModel implements Serializable
Serialized Fields
m_entries
Vector
vector holding the entries of the BHT
m_entryCnt
int m_entryCnt
number of entries in the BHT
m_historySize
int m_historySize
number of past branch events to remember
m_columnNames
String[] m_columnNames
name of the table columns
m_columnClasses
Class
type of the table columns
Class mars.tools.BHTSimGUI extends JPanel implements Serializable
Serialized Fields
m_tfInstruction
JTextField m_tfInstruction
text field presenting the most recent branch instruction
m_tfAddress
JTextField m_tfAddress
text field representing the address of the most recent branch instruction
m_tfIndex
JTextField m_tfIndex
text field representing the resulting BHT index of the branch instruction
m_cbBHTentries
JComboBox m_cbBHTentries
combo box for selecting the number of BHT entries
m_cbBHThistory
JComboBox m_cbBHThistory
combo box for selecting the history size
m_cbBHTinitVal
JComboBox m_cbBHTinitVal
combo box for selecting the initial value
m_tabBHT
JTable m_tabBHT
the table representing the BHT
m_taLog
JTextArea m_taLog
text field for log output
Class mars.tools.BHTSimulator extends AbstractMarsToolAndApplication implements Serializable
Serialized Fields
m_gui
BHTSimGUI m_gui
the GUI of the BHT simulator
m_bhtModel
BHTableModel m_bhtModel
the model of the BHT
m_pendingBranchInstAddress
int m_pendingBranchInstAddress
state variable that indicates that the last instruction was a branch instruction (if address != 0) or not (address == 0)
m_lastBranchTaken
boolean m_lastBranchTaken
state variable that signals if the last branch was taken
Class mars.tools.BitmapDisplay extends AbstractMarsToolAndApplication implements Serializable
Serialized Fields
visualizationUnitPixelWidthSelector
JComboBox visualizationUnitPixelWidthSelector
visualizationUnitPixelHeightSelector
JComboBox visualizationUnitPixelHeightSelector
visualizationPixelWidthSelector
JComboBox visualizationPixelWidthSelector
visualizationPixelHeightSelector
JComboBox visualizationPixelHeightSelector
displayBaseAddressSelector
JComboBox displayBaseAddressSelector
drawingArea
Graphics drawingArea
canvas
JPanel canvas
results
JPanel results
emptyBorder
EmptyBorder emptyBorder
countFonts
Font countFonts
backgroundColor
Color backgroundColor
visualizationUnitPixelWidthChoices
String[] visualizationUnitPixelWidthChoices
defaultVisualizationUnitPixelWidthIndex
int defaultVisualizationUnitPixelWidthIndex
visualizationUnitPixelHeightChoices
String[] visualizationUnitPixelHeightChoices
defaultVisualizationUnitPixelHeightIndex
int defaultVisualizationUnitPixelHeightIndex
displayAreaPixelWidthChoices
String[] displayAreaPixelWidthChoices
defaultDisplayWidthIndex
int defaultDisplayWidthIndex
displayAreaPixelHeightChoices
String[] displayAreaPixelHeightChoices
defaultDisplayHeightIndex
int defaultDisplayHeightIndex
unitPixelWidth
int unitPixelWidth
unitPixelHeight
int unitPixelHeight
displayAreaWidthInPixels
int displayAreaWidthInPixels
displayAreaHeightInPixels
int displayAreaHeightInPixels
displayBaseAddressChoices
String[] displayBaseAddressChoices
displayBaseAddresses
int[] displayBaseAddresses
defaultBaseAddressIndex
int defaultBaseAddressIndex
baseAddress
int baseAddress
theGrid
mars.tools.BitmapDisplay.Grid theGrid
Class mars.tools.CacheSimulator extends AbstractMarsToolAndApplication implements Serializable
Serialized Fields
cacheBlockSizeSelector
JComboBox cacheBlockSizeSelector
cacheBlockCountSelector
JComboBox cacheBlockCountSelector
cachePlacementSelector
JComboBox cachePlacementSelector
cacheReplacementSelector
JComboBox cacheReplacementSelector
cacheSetSizeSelector
JComboBox cacheSetSizeSelector
memoryAccessCountDisplay
JTextField memoryAccessCountDisplay
cacheHitCountDisplay
JTextField cacheHitCountDisplay
cacheMissCountDisplay
JTextField cacheMissCountDisplay
replacementPolicyDisplay
JTextField replacementPolicyDisplay
cachableAddressesDisplay
JTextField cachableAddressesDisplay
cacheSizeDisplay
JTextField cacheSizeDisplay
cacheHitRateDisplay
JProgressBar cacheHitRateDisplay
animations
mars.tools.CacheSimulator.Animation animations
logPanel
JPanel logPanel
logScroll
JScrollPane logScroll
logText
JTextArea logText
logShow
JCheckBox logShow
emptyBorder
EmptyBorder emptyBorder
countFonts
Font countFonts
backgroundColor
Color backgroundColor
cacheBlockSizeChoicesInt
int[] cacheBlockSizeChoicesInt
cacheBlockCountChoicesInt
int[] cacheBlockCountChoicesInt
cacheBlockSizeChoices
String[] cacheBlockSizeChoices
cacheBlockCountChoices
String[] cacheBlockCountChoices
placementPolicyChoices
String[] placementPolicyChoices
DIRECT
int DIRECT
FULL
int FULL
SET
int SET
replacementPolicyChoices
String[] replacementPolicyChoices
LRU
int LRU
RANDOM
int RANDOM
cacheSetSizeChoices
String[] cacheSetSizeChoices
defaultCacheBlockSizeIndex
int defaultCacheBlockSizeIndex
defaultCacheBlockCountIndex
int defaultCacheBlockCountIndex
defaultPlacementPolicyIndex
int defaultPlacementPolicyIndex
defaultReplacementPolicyIndex
int defaultReplacementPolicyIndex
defaultCacheSetSizeIndex
int defaultCacheSetSizeIndex
theCache
mars.tools.CacheSimulator.AbstractCache theCache
memoryAccessCount
int memoryAccessCount
cacheHitCount
int cacheHitCount
cacheMissCount
int cacheMissCount
cacheHitRate
double cacheHitRate
randu
Random randu
Class mars.tools.DigitalLabSim extends AbstractMarsToolAndApplication implements Serializable
Serialized Fields
sevenSegPanel
DigitalLabSim.SevenSegmentPanel sevenSegPanel
hexaKeyPanel
DigitalLabSim.HexaKeyboard hexaKeyPanel
Class mars.tools.DigitalLabSim.HexaKeyboard extends JPanel implements Serializable
Serialized Fields
button
JButton[] button
Class mars.tools.DigitalLabSim.SevenSegmentDisplay extends JComponent implements Serializable
Serialized Fields
aff
char aff
Class mars.tools.DigitalLabSim.SevenSegmentPanel extends JPanel implements Serializable
Serialized Fields
display
DigitalLabSim.SevenSegmentDisplay[] display
Class mars.tools.FloatRepresentation extends AbstractMarsToolAndApplication implements Serializable
Serialized Fields
attachedRegister
Register attachedRegister
fpRegisters
Register[] fpRegisters
thisFloatTool
FloatRepresentation thisFloatTool
binarySignDecoratedDisplay
JPanel binarySignDecoratedDisplay
binaryExponentDecoratedDisplay
JPanel binaryExponentDecoratedDisplay
binaryFractionDecoratedDisplay
JPanel binaryFractionDecoratedDisplay
hexDisplay
JTextField hexDisplay
decimalDisplay
JTextField decimalDisplay
binarySignDisplay
JTextField binarySignDisplay
binaryExponentDisplay
JTextField binaryExponentDisplay
binaryFractionDisplay
JTextField binaryFractionDisplay
expansionDisplay
JLabel expansionDisplay
significandLabel
JLabel significandLabel
binaryToDecimalFormulaGraphic
mars.tools.FloatRepresentation.BinaryToDecimalFormulaGraphic binaryToDecimalFormulaGraphic
instructions
mars.tools.FloatRepresentation.InstructionsPane instructions
defaultInstructions
String defaultInstructions
Class mars.tools.InstructionCounter extends AbstractMarsToolAndApplication implements Serializable
Serialized Fields
counter
int counter
Number of instructions executed until now.
counterField
JTextField counterField
counterR
int counterR
Number of instructions of type R.
counterRField
JTextField counterRField
progressbarR
JProgressBar progressbarR
counterI
int counterI
Number of instructions of type I.
counterIField
JTextField counterIField
progressbarI
JProgressBar progressbarI
counterJ
int counterJ
Number of instructions of type J.
counterJField
JTextField counterJField
progressbarJ
JProgressBar progressbarJ
lastAddress
int lastAddress
The last address we saw. We ignore it because the only way for a
program to execute twice the same instruction is to enter an infinite
loop, which is not insteresting in the POV of counting instructions.
Class mars.tools.InstructionStatistics extends AbstractMarsToolAndApplication implements Serializable
Serialized Fields
m_tfTotalCounter
JTextField m_tfTotalCounter
text field for visualizing the total number of instructions processed
m_tfCounters
JTextField[] m_tfCounters
array of text field – one for each instruction category
m_pbCounters
JProgressBar[] m_pbCounters
array of progress pars – one for each instruction category
m_totalCounter
int m_totalCounter
counter for the total number of instructions processed
m_counters
int[] m_counters
array of counter variables – one for each instruction category
m_categoryLabels
String[] m_categoryLabels
names of the instruction categories as array
lastAddress
int lastAddress
The last address we saw. We ignore it because the only way for a
program to execute twice the same instruction is to enter an infinite
loop, which is not insteresting in the POV of counting instructions.
Class mars.tools.IntroToTools extends AbstractMarsToolAndApplication implements Serializable
Class mars.tools.KeyboardAndDisplaySimulator extends AbstractMarsToolAndApplication implements Serializable
Serialized Fields
delayTechniques
mars.tools.KeyboardAndDisplaySimulator.TransmitterDelayTechnique[] delayTechniques
countingInstructions
boolean countingInstructions
instructionCount
int instructionCount
transmitDelayInstructionCountLimit
int transmitDelayInstructionCountLimit
currentDelayInstructionLimit
int currentDelayInstructionLimit
characterToDisplay
char characterToDisplay
displayAfterDelay
boolean displayAfterDelay
keyboardAndDisplay
JPanel keyboardAndDisplay
displayScrollPane
JScrollPane displayScrollPane
display
JTextArea display
displayPanel
JPanel displayPanel
displayOptions
JPanel displayOptions
delayTechniqueChooser
JComboBox delayTechniqueChooser
delayLengthPanel
mars.tools.KeyboardAndDisplaySimulator.DelayLengthPanel delayLengthPanel
delayLengthSlider
JSlider delayLengthSlider
displayAfterDelayCheckBox
JCheckBox displayAfterDelayCheckBox
keyboardPanel
JPanel keyboardPanel
keyAccepterScrollPane
JScrollPane keyAccepterScrollPane
keyEventAccepter
JTextArea keyEventAccepter
fontButton
JButton fontButton
defaultFont
Font defaultFont
Class mars.tools.MemoryReferenceVisualization extends AbstractMarsToolAndApplication implements Serializable
Serialized Fields
wordsPerUnitSelector
JComboBox wordsPerUnitSelector
visualizationUnitPixelWidthSelector
JComboBox visualizationUnitPixelWidthSelector
visualizationUnitPixelHeightSelector
JComboBox visualizationUnitPixelHeightSelector
visualizationPixelWidthSelector
JComboBox visualizationPixelWidthSelector
visualizationPixelHeightSelector
JComboBox visualizationPixelHeightSelector
displayBaseAddressSelector
JComboBox displayBaseAddressSelector
drawHashMarksSelector
JCheckBox drawHashMarksSelector
drawingArea
Graphics drawingArea
canvas
JPanel canvas
results
JPanel results
emptyBorder
EmptyBorder emptyBorder
countFonts
Font countFonts
backgroundColor
Color backgroundColor
wordsPerUnitChoices
String[] wordsPerUnitChoices
defaultWordsPerUnitIndex
int defaultWordsPerUnitIndex
visualizationUnitPixelWidthChoices
String[] visualizationUnitPixelWidthChoices
defaultVisualizationUnitPixelWidthIndex
int defaultVisualizationUnitPixelWidthIndex
visualizationUnitPixelHeightChoices
String[] visualizationUnitPixelHeightChoices
defaultVisualizationUnitPixelHeightIndex
int defaultVisualizationUnitPixelHeightIndex
displayAreaPixelWidthChoices
String[] displayAreaPixelWidthChoices
defaultDisplayWidthIndex
int defaultDisplayWidthIndex
displayAreaPixelHeightChoices
String[] displayAreaPixelHeightChoices
defaultDisplayHeightIndex
int defaultDisplayHeightIndex
defaultDrawHashMarks
boolean defaultDrawHashMarks
unitPixelWidth
int unitPixelWidth
unitPixelHeight
int unitPixelHeight
wordsPerUnit
int wordsPerUnit
visualizationAreaWidthInPixels
int visualizationAreaWidthInPixels
visualizationAreaHeightInPixels
int visualizationAreaHeightInPixels
defaultCounterColors
mars.tools.MemoryReferenceVisualization.CounterColor[] defaultCounterColors
countTable
int[] countTable
COUNT_INDEX_INIT
int COUNT_INDEX_INIT
displayBaseAddressChoices
String[] displayBaseAddressChoices
displayBaseAddresses
int[] displayBaseAddresses
defaultBaseAddressIndex
int defaultBaseAddressIndex
baseAddress
int baseAddress
theGrid
mars.tools.MemoryReferenceVisualization.Grid theGrid
counterColorScale
mars.tools.MemoryReferenceVisualization.CounterColorScale counterColorScale
Package mars.venus
Class mars.venus.AbstractFontSettingDialog extends JDialog implements Serializable
Serialized Fields
editorDialog
JDialog editorDialog
fontFamilySelector
JComboBox fontFamilySelector
fontStyleSelector
JComboBox fontStyleSelector
fontSizeSelector
JSlider fontSizeSelector
fontSizeSpinSelector
JSpinner fontSizeSpinSelector
fontSample
JLabel fontSample
currentFont
Font currentFont
initialFontFamily
String initialFontFamily
initialFontStyle
String initialFontStyle
initialFontSize
String initialFontSize
Class mars.venus.Coprocessor0Window extends JPanel implements Serializable
Serialized Fields
tableData
Object[][] tableData
highlighting
boolean highlighting
highlightRow
int highlightRow
executePane
ExecutePane executePane
rowGivenRegNumber
int[] rowGivenRegNumber
Class mars.venus.Coprocessor1Window extends JPanel implements Serializable
Serialized Fields
tableData
Object[][] tableData
highlighting
boolean highlighting
highlightRow
int highlightRow
executePane
ExecutePane executePane
conditionFlagCheckBox
JCheckBox[] conditionFlagCheckBox
Class mars.venus.DataSegmentWindow extends JInternalFrame implements Serializable
Serialized Fields
dataTableScroller
JScrollPane dataTableScroller
contentPane
Container contentPane
tablePanel
JPanel tablePanel
dataButton
JButton dataButton
nextButton
JButton nextButton
prevButton
JButton prevButton
stakButton
JButton stakButton
globButton
JButton globButton
heapButton
JButton heapButton
kernButton
JButton kernButton
extnButton
JButton extnButton
mmioButton
JButton mmioButton
textButton
JButton textButton
asciiDisplayCheckBox
JCheckBox asciiDisplayCheckBox
addressHighlighting
boolean addressHighlighting
asciiDisplay
boolean asciiDisplay
addressRow
int addressRow
addressColumn
int addressColumn
addressRowFirstAddress
int addressRowFirstAddress
settings
Settings settings
firstAddress
int firstAddress
homeAddress
int homeAddress
userOrKernelMode
boolean userOrKernelMode
baseAddressSelector
JComboBox baseAddressSelector
displayBaseAddressChoices
String[] displayBaseAddressChoices
displayBaseAddresses
int[] displayBaseAddresses
defaultBaseAddressIndex
int defaultBaseAddressIndex
baseAddressButtons
JButton[] baseAddressButtons
displayBaseAddressArray
int[] displayBaseAddressArray
descriptions
String[] descriptions
Class mars.venus.EditCopyAction extends GuiAction implements Serializable
Class mars.venus.EditCutAction extends GuiAction implements Serializable
Class mars.venus.EditFindReplaceAction extends GuiAction implements Serializable
Serialized Fields
findReplaceDialog
JDialog findReplaceDialog
Class mars.venus.EditPane extends JPanel implements Serializable
Serialized Fields
sourceCode
MARSTextEditingArea sourceCode
mainUI
VenusUI mainUI
currentDirectoryPath
String currentDirectoryPath
caretPositionLabel
JLabel caretPositionLabel
showLineNumbers
JCheckBox showLineNumbers
lineNumbers
JLabel lineNumbers
isCompoundEdit
boolean isCompoundEdit
compoundEdit
CompoundEdit compoundEdit
fileStatus
FileStatus fileStatus
Class mars.venus.EditPasteAction extends GuiAction implements Serializable
Class mars.venus.EditRedoAction extends GuiAction implements Serializable
Class mars.venus.EditSelectAllAction extends GuiAction implements Serializable
Class mars.venus.EditTabbedPane extends JTabbedPane implements Serializable
Serialized Fields
editTab
EditPane editTab
mainPane
MainPane mainPane
mainUI
VenusUI mainUI
editor
Editor editor
fileOpener
mars.venus.EditTabbedPane.FileOpener fileOpener
Class mars.venus.EditUndoAction extends GuiAction implements Serializable
Class mars.venus.ExecutePane extends JDesktopPane implements Serializable
Serialized Fields
registerValues
RegistersWindow registerValues
coprocessor1Values
Coprocessor1Window coprocessor1Values
coprocessor0Values
Coprocessor0Window coprocessor0Values
dataSegment
DataSegmentWindow dataSegment
textSegment
TextSegmentWindow textSegment
labelValues
LabelsWindow labelValues
mainUI
VenusUI mainUI
valueDisplayBase
NumberDisplayBaseChooser valueDisplayBase
addressDisplayBase
NumberDisplayBaseChooser addressDisplayBase
labelWindowVisible
boolean labelWindowVisible
Class mars.venus.FileCloseAction extends GuiAction implements Serializable
Class mars.venus.FileCloseAllAction extends GuiAction implements Serializable
Class mars.venus.FileDumpMemoryAction extends GuiAction implements Serializable
Serialized Fields
dumpDialog
JDialog dumpDialog
segmentArray
String[] segmentArray
baseAddressArray
int[] baseAddressArray
limitAddressArray
int[] limitAddressArray
highAddressArray
int[] highAddressArray
segmentListArray
String[] segmentListArray
segmentListBaseArray
int[] segmentListBaseArray
segmentListHighArray
int[] segmentListHighArray
segmentListSelector
JComboBox segmentListSelector
formatListSelector
JComboBox formatListSelector
Class mars.venus.FileExitAction extends GuiAction implements Serializable
Class mars.venus.FileNewAction extends GuiAction implements Serializable
Class mars.venus.FileOpenAction extends GuiAction implements Serializable
Serialized Fields
mostRecentlyOpenedFile
File mostRecentlyOpenedFile
fileChooser
JFileChooser fileChooser
fileFilterCount
int fileFilterCount
fileFilterList
ArrayList
listenForUserAddedFileFilter
PropertyChangeListener listenForUserAddedFileFilter
Class mars.venus.FilePrintAction extends GuiAction implements Serializable
Class mars.venus.FileSaveAction extends GuiAction implements Serializable
Class mars.venus.FileSaveAllAction extends GuiAction implements Serializable
Class mars.venus.FileSaveAsAction extends GuiAction implements Serializable
Class mars.venus.GuiAction extends AbstractAction implements Serializable
Serialized Fields
mainUI
VenusUI mainUI
Class mars.venus.HardcopyWriter.PrintCanceledException extends Exception implements Serializable
Class mars.venus.HelpAboutAction extends GuiAction implements Serializable
Class mars.venus.HelpHelpAction extends GuiAction implements Serializable
Class mars.venus.LabelsWindow extends JInternalFrame implements Serializable
Serialized Fields
contentPane
Container contentPane
labelPanel
JPanel labelPanel
dataLabels
JCheckBox dataLabels
textLabels
JCheckBox textLabels
listOfLabelsForSymbolTable
ArrayList
labelsWindow
LabelsWindow labelsWindow
tableSortComparator
Comparator
tableSortingComparators
Comparator
sortState
int sortState
Class mars.venus.MainPane extends JTabbedPane implements Serializable
Serialized Fields
editTab
EditPane editTab
executeTab
ExecutePane executeTab
editTabbedPane
EditTabbedPane editTabbedPane
mainUI
VenusUI mainUI
Class mars.venus.MessagesPane extends JTabbedPane implements Serializable
Serialized Fields
assemble
JTextArea assemble
run
JTextArea run
assembleTab
JPanel assembleTab
runTab
JPanel runTab
Class mars.venus.NumberDisplayBaseChooser extends JCheckBox implements Serializable
Serialized Fields
base
int base
settingMenuItem
JCheckBoxMenuItem settingMenuItem
Class mars.venus.RegistersPane extends JTabbedPane implements Serializable
Serialized Fields
regsTab
RegistersWindow regsTab
cop1Tab
Coprocessor1Window cop1Tab
cop0Tab
Coprocessor0Window cop0Tab
mainUI
VenusUI mainUI
Class mars.venus.RegistersWindow extends JPanel implements Serializable
Serialized Fields
tableData
Object[][] tableData
highlighting
boolean highlighting
highlightRow
int highlightRow
executePane
ExecutePane executePane
Class mars.venus.RepeatButton extends JButton implements Serializable
Serialized Fields
pressed
boolean pressed
The pressed state for this button.
repeatEnabled
boolean repeatEnabled
Flag to indicate that the button should fire events when held.
If false, the button is effectively a plain old JButton, but
there may be times when this feature might wish to be disabled.
timer
Timer timer
The hold-down timer for this button.
initialDelay
int initialDelay
The initial delay for this button. Hold-down time before first
timer firing. In milliseconds.
delay
int delay
The delay between timer firings for this button once the delay
period is past. In milliseconds.
modifiers
int modifiers
Holder of the modifiers used when the mouse pressed the button.
This is used for subsequently fired action events. This may change
after mouse pressed if the user moves the mouse out, releases a key
and then moves the mouse back in.
Class mars.venus.RunAssembleAction extends GuiAction implements Serializable
Class mars.venus.RunBackstepAction extends GuiAction implements Serializable
Serialized Fields
name
String name
executePane
ExecutePane executePane
Class mars.venus.RunClearBreakpointsAction extends GuiAction implements Serializable
Class mars.venus.RunGoAction extends GuiAction implements Serializable
Serialized Fields
name
String name
executePane
ExecutePane executePane
Class mars.venus.RunPauseAction extends GuiAction implements Serializable
Class mars.venus.RunResetAction extends GuiAction implements Serializable
Class mars.venus.RunSpeedPanel extends JPanel implements Serializable
Serialized Fields
speedTable
double[] speedTable
sliderLabel
JLabel sliderLabel
runSpeedSlider
JSlider runSpeedSlider
runSpeedIndex
int runSpeedIndex
Class mars.venus.RunStepAction extends GuiAction implements Serializable
Serialized Fields
name
String name
executePane
ExecutePane executePane
Class mars.venus.RunStopAction extends GuiAction implements Serializable
Class mars.venus.RunToggleBreakpointsAction extends GuiAction implements Serializable
Class mars.venus.SettingsAddressDisplayBaseAction extends GuiAction implements Serializable
Class mars.venus.SettingsAssembleAllAction extends GuiAction implements Serializable
Class mars.venus.SettingsAssembleOnOpenAction extends GuiAction implements Serializable
Class mars.venus.SettingsDelayedBranchingAction extends GuiAction implements Serializable
Class mars.venus.SettingsEditorAction extends GuiAction implements Serializable
Serialized Fields
editorDialog
JDialog editorDialog
fontFamilySelector
JComboBox fontFamilySelector
fontStyleSelector
JComboBox fontStyleSelector
tabSizeSelector
JSlider tabSizeSelector
fontSizeDisplay
JTextField fontSizeDisplay
initialFontFamily
String initialFontFamily
initialFontStyle
String initialFontStyle
initialFontSize
String initialFontSize
Class mars.venus.SettingsExceptionHandlerAction extends GuiAction implements Serializable
Serialized Fields
exceptionHandlerDialog
JDialog exceptionHandlerDialog
exceptionHandlerSetting
JCheckBox exceptionHandlerSetting
exceptionHandlerSelectionButton
JButton exceptionHandlerSelectionButton
exceptionHandlerDisplay
JTextField exceptionHandlerDisplay
initialSelected
boolean initialSelected
initialPathname
String initialPathname
Class mars.venus.SettingsExtendedAction extends GuiAction implements Serializable
Class mars.venus.SettingsHighlightingAction extends GuiAction implements Serializable
Serialized Fields
highlightDialog
JDialog highlightDialog
backgroundButtons
JButton[] backgroundButtons
foregroundButtons
JButton[] foregroundButtons
fontButtons
JButton[] fontButtons
defaultCheckBoxes
JCheckBox[] defaultCheckBoxes
samples
JLabel[] samples
currentNondefaultBackground
Color[] currentNondefaultBackground
currentNondefaultForeground
Color[] currentNondefaultForeground
initialSettingsBackground
Color[] initialSettingsBackground
initialSettingsForeground
Color[] initialSettingsForeground
initialFont
Font[] initialFont
currentFont
Font[] currentFont
currentNondefaultFont
Font[] currentNondefaultFont
dataHighlightButton
JButton dataHighlightButton
registerHighlightButton
JButton registerHighlightButton
currentDataHighlightSetting
boolean currentDataHighlightSetting
initialDataHighlightSetting
boolean initialDataHighlightSetting
currentRegisterHighlightSetting
boolean currentRegisterHighlightSetting
initialRegisterHighlightSetting
boolean initialRegisterHighlightSetting
Class mars.venus.SettingsLabelAction extends GuiAction implements Serializable
Class mars.venus.SettingsMemoryConfigurationAction extends GuiAction implements Serializable
Serialized Fields
configDialog
JDialog configDialog
fontFamilySelector
JComboBox fontFamilySelector
fontStyleSelector
JComboBox fontStyleSelector
fontSizeSelector
JSlider fontSizeSelector
fontSizeDisplay
JTextField fontSizeDisplay
thisAction
SettingsMemoryConfigurationAction thisAction
initialFontFamily
String initialFontFamily
initialFontStyle
String initialFontStyle
initialFontSize
String initialFontSize
Class mars.venus.SettingsPopupInputAction extends GuiAction implements Serializable
Class mars.venus.SettingsProgramArgumentsAction extends GuiAction implements Serializable
Class mars.venus.SettingsSelfModifyingCodeAction extends GuiAction implements Serializable
Class mars.venus.SettingsStartAtMainAction extends GuiAction implements Serializable
Class mars.venus.SettingsValueDisplayBaseAction extends GuiAction implements Serializable
Class mars.venus.SettingsWarningsAreErrorsAction extends GuiAction implements Serializable
Class mars.venus.TextSegmentWindow extends JInternalFrame implements Serializable
Serialized Fields
programArgumentsPanel
JPanel programArgumentsPanel
programArgumentsTextField
JTextField programArgumentsTextField
table
JTable table
tableScroller
JScrollPane tableScroller
data
Object[][] data
intAddresses
int[] intAddresses
addressRows
Hashtable
executeMods
Hashtable
contentPane
Container contentPane
tableModel
mars.venus.TextSegmentWindow.TextTableModel tableModel
tableCellFont
Font tableCellFont
codeHighlighting
boolean codeHighlighting
breakpointsEnabled
boolean breakpointsEnabled
highlightAddress
int highlightAddress
tableModelListener
TableModelListener tableModelListener
inDelaySlot
boolean inDelaySlot
Class mars.venus.ToolAction extends AbstractAction implements Serializable
Serialized Fields
toolClass
Class
Class mars.venus.VenusUI extends JFrame implements Serializable
Serialized Fields
mainUI
VenusUI mainUI
menu
JMenuBar menu
toolbar
JToolBar toolbar
mainPane
MainPane mainPane
registersPane
RegistersPane registersPane
registersTab
RegistersWindow registersTab
coprocessor1Tab
Coprocessor1Window coprocessor1Tab
coprocessor0Tab
Coprocessor0Window coprocessor0Tab
messagesPane
MessagesPane messagesPane
splitter
JSplitPane splitter
horizonSplitter
JSplitPane horizonSplitter
north
JPanel north
frameState
int frameState
editor
Editor editor
file
JMenu file
run
JMenu run
window
JMenu window
help
JMenu help
edit
JMenu edit
settings
JMenu settings
fileNew
JMenuItem fileNew
fileOpen
JMenuItem fileOpen
fileClose
JMenuItem fileClose
fileCloseAll
JMenuItem fileCloseAll
fileSave
JMenuItem fileSave
fileSaveAs
JMenuItem fileSaveAs
fileSaveAll
JMenuItem fileSaveAll
fileDumpMemory
JMenuItem fileDumpMemory
filePrint
JMenuItem filePrint
fileExit
JMenuItem fileExit
editUndo
JMenuItem editUndo
editRedo
JMenuItem editRedo
editCut
JMenuItem editCut
editCopy
JMenuItem editCopy
editPaste
JMenuItem editPaste
editFindReplace
JMenuItem editFindReplace
editSelectAll
JMenuItem editSelectAll
runGo
JMenuItem runGo
runStep
JMenuItem runStep
runBackstep
JMenuItem runBackstep
runReset
JMenuItem runReset
runAssemble
JMenuItem runAssemble
runStop
JMenuItem runStop
runPause
JMenuItem runPause
runClearBreakpoints
JMenuItem runClearBreakpoints
runToggleBreakpoints
JMenuItem runToggleBreakpoints
settingsLabel
JCheckBoxMenuItem settingsLabel
settingsPopupInput
JCheckBoxMenuItem settingsPopupInput
settingsValueDisplayBase
JCheckBoxMenuItem settingsValueDisplayBase
settingsAddressDisplayBase
JCheckBoxMenuItem settingsAddressDisplayBase
settingsExtended
JCheckBoxMenuItem settingsExtended
settingsAssembleOnOpen
JCheckBoxMenuItem settingsAssembleOnOpen
settingsAssembleAll
JCheckBoxMenuItem settingsAssembleAll
settingsWarningsAreErrors
JCheckBoxMenuItem settingsWarningsAreErrors
settingsStartAtMain
JCheckBoxMenuItem settingsStartAtMain
settingsDelayedBranching
JCheckBoxMenuItem settingsDelayedBranching
settingsProgramArguments
JCheckBoxMenuItem settingsProgramArguments
settingsSelfModifyingCode
JCheckBoxMenuItem settingsSelfModifyingCode
settingsExceptionHandler
JMenuItem settingsExceptionHandler
settingsEditor
JMenuItem settingsEditor
settingsHighlighting
JMenuItem settingsHighlighting
settingsMemoryConfiguration
JMenuItem settingsMemoryConfiguration
helpHelp
JMenuItem helpHelp
helpAbout
JMenuItem helpAbout
Undo
JButton Undo
Redo
JButton Redo
Cut
JButton Cut
Copy
JButton Copy
Paste
JButton Paste
FindReplace
JButton FindReplace
SelectAll
JButton SelectAll
New
JButton New
Open
JButton Open
Save
JButton Save
SaveAs
JButton SaveAs
SaveAll
JButton SaveAll
DumpMemory
JButton DumpMemory
JButton Print
Run
JButton Run
Assemble
JButton Assemble
Reset
JButton Reset
Step
JButton Step
Backstep
JButton Backstep
Stop
JButton Stop
Pause
JButton Pause
Help
JButton Help
fileNewAction
Action fileNewAction
fileOpenAction
Action fileOpenAction
fileCloseAction
Action fileCloseAction
fileCloseAllAction
Action fileCloseAllAction
fileSaveAction
Action fileSaveAction
fileSaveAsAction
Action fileSaveAsAction
fileSaveAllAction
Action fileSaveAllAction
fileDumpMemoryAction
Action fileDumpMemoryAction
filePrintAction
Action filePrintAction
fileExitAction
Action fileExitAction
editUndoAction
EditUndoAction editUndoAction
editRedoAction
EditRedoAction editRedoAction
editCutAction
Action editCutAction
editCopyAction
Action editCopyAction
editPasteAction
Action editPasteAction
editFindReplaceAction
Action editFindReplaceAction
editSelectAllAction
Action editSelectAllAction
runAssembleAction
Action runAssembleAction
runGoAction
Action runGoAction
runStepAction
Action runStepAction
runBackstepAction
Action runBackstepAction
runResetAction
Action runResetAction
runStopAction
Action runStopAction
runPauseAction
Action runPauseAction
runClearBreakpointsAction
Action runClearBreakpointsAction
runToggleBreakpointsAction
Action runToggleBreakpointsAction
settingsLabelAction
Action settingsLabelAction
settingsPopupInputAction
Action settingsPopupInputAction
settingsValueDisplayBaseAction
Action settingsValueDisplayBaseAction
settingsAddressDisplayBaseAction
Action settingsAddressDisplayBaseAction
settingsExtendedAction
Action settingsExtendedAction
settingsAssembleOnOpenAction
Action settingsAssembleOnOpenAction
settingsAssembleAllAction
Action settingsAssembleAllAction
settingsWarningsAreErrorsAction
Action settingsWarningsAreErrorsAction
settingsStartAtMainAction
Action settingsStartAtMainAction
settingsProgramArgumentsAction
Action settingsProgramArgumentsAction
settingsDelayedBranchingAction
Action settingsDelayedBranchingAction
settingsExceptionHandlerAction
Action settingsExceptionHandlerAction
settingsEditorAction
Action settingsEditorAction
settingsHighlightingAction
Action settingsHighlightingAction
settingsMemoryConfigurationAction
Action settingsMemoryConfigurationAction
settingsSelfModifyingCodeAction
Action settingsSelfModifyingCodeAction
helpHelpAction
Action helpHelpAction
helpAboutAction
Action helpAboutAction
Package mars.venus.editors.generic
Class mars.venus.editors.generic.GenericTextArea extends JTextArea implements Serializable
Serialized Fields
editPane
EditPane editPane
undoManager
UndoManager undoManager
undoableEditListener
UndoableEditListener undoableEditListener
sourceCode
JTextArea sourceCode
editAreaScrollPane
JScrollPane editAreaScrollPane
isCompoundEdit
boolean isCompoundEdit
compoundEdit
CompoundEdit compoundEdit
Package mars.venus.editors.jeditsyntax
Class mars.venus.editors.jeditsyntax.JEditBasedTextArea extends JEditTextArea implements Serializable
Serialized Fields
editPane
EditPane editPane
undoManager
UndoManager undoManager
undoableEditListener
UndoableEditListener undoableEditListener
isCompoundEdit
boolean isCompoundEdit
compoundEdit
CompoundEdit compoundEdit
sourceCode
JEditBasedTextArea sourceCode
Class mars.venus.editors.jeditsyntax.JEditTextArea extends JComponent implements Serializable
Serialized Fields
lineNumbersVertical
JScrollBar lineNumbersVertical
Creates a new JEditTextArea with the specified settings.
popupMenu
JPopupMenu popupMenu
painter
TextAreaPainter painter
popup
JPopupMenu popup
listenerList
EventListenerList listenerList
caretEvent
mars.venus.editors.jeditsyntax.JEditTextArea.MutableCaretEvent caretEvent
caretBlinks
boolean caretBlinks
caretVisible
boolean caretVisible
blink
boolean blink
editable
boolean editable
caretBlinkRate
int caretBlinkRate
firstLine
int firstLine
visibleLines
int visibleLines
electricScroll
int electricScroll
horizontalOffset
int horizontalOffset
vertical
JScrollBar vertical
horizontal
JScrollBar horizontal
scrollBarsInitialized
boolean scrollBarsInitialized
inputHandler
InputHandler inputHandler
document
SyntaxDocument document
documentHandler
mars.venus.editors.jeditsyntax.JEditTextArea.DocumentHandler documentHandler
lineSegment
Segment lineSegment
selectionStart
int selectionStart
selectionStartLine
int selectionStartLine
selectionEnd
int selectionEnd
selectionEndLine
int selectionEndLine
biasLeft
boolean biasLeft
bracketPosition
int bracketPosition
bracketLine
int bracketLine
magicCaret
int magicCaret
overwrite
boolean overwrite
rectSelect
boolean rectSelect
unredoing
boolean unredoing
Class mars.venus.editors.jeditsyntax.SyntaxDocument extends PlainDocument implements Serializable
Serialized Fields
tokenMarker
TokenMarker tokenMarker
Class mars.venus.editors.jeditsyntax.TextAreaPainter extends JComponent implements Serializable
Serialized Fields
currentLineIndex
int currentLineIndex
currentLineTokens
Token currentLineTokens
currentLine
Segment currentLine
textArea
JEditTextArea textArea
styles
SyntaxStyle[] styles
caretColor
Color caretColor
selectionColor
Color selectionColor
lineHighlightColor
Color lineHighlightColor
bracketHighlightColor
Color bracketHighlightColor
eolMarkerColor
Color eolMarkerColor
blockCaret
boolean blockCaret
lineHighlight
boolean lineHighlight
bracketHighlight
boolean bracketHighlight
paintInvalid
boolean paintInvalid
eolMarkers
boolean eolMarkers
cols
int cols
rows
int rows
tabSize
int tabSize
tabSizeChars
int tabSizeChars
fm
FontMetrics fm
highlights
TextAreaPainter.Highlight highlights
Overview Package Class Tree Deprecated Index Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
/* Javadoc style sheet */
/* Define colors, fonts and other style attributes here to override the defaults */
/* Page background color */
body { background-color: #FFFFFF; color:#000000 }
/* Headings */
h1 { font-size: 145% }
/* Table colors */
.TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */
.TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */
.TableRowColor { background: #FFFFFF; color:#000000 } /* White */
/* Font used in left-hand frame lists */
.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
.FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
/* Navigation bar fonts and colors */
.NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */
.NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */
.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;}
.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;}
.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}
.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}
MARS Acknowledgements
MARS Acknowledgements
Updated 18 August 2014
Pete and Ken would like to acknowledge the many helpful contributors to MARS.
It has succeeded beyond our wildest expectations and for this we are most grateful.
Its success would not be possible without your feedback, suggestions and assistance!
We are pleased to recognize these contributions to release 4.5:
Torsten Mahne, Umberto Villano and others who took care of the
bug with certain European keyboards that require an Alt key combo to form
essential MIPS assembly characters like $ and #. I had no means of testing it.
Eric Wang at Washington State University, who suggested adding
cursor positioning to the Keyboard and Display MMIO Simulator tool.
Marcio Roberto and everyone else involved in the development of MIPS X-Ray tool, which has been
around for several years but only now added to the release. Sorry for the delay.
We also appreciate the contributions others have made to previous releases:
Carl Burch of Hendrix College, who developed the mechanism for
simulating the execution of straight binary code. Previously, execution was based on
ProgramStatement objects generated by the assembler. This, combined with the added capabilities
to write to the text segment and
branch/jump into the data segment at runtime, permits one to produce self-modifying
programs, simulate buffer overflow attacks, and the like.
Tom Bradford, Slava Pestov and others, who developed the jEdit Syntax Package (syntax.jedit.org)
at the heart of the syntax-aware color highlighting editor. It was old but the licensing was right and it was
written for embedding into Java applications.
Mohammad Sekhavat from Sharif University in Tehran, who developed the
macro capability.
Greg Gibeling of UC Berkeley, who introduced capabilities into his customized version
of MARS that have subsequently been expanded and integrated into our release.
These include the ability to dump MIPS memory contents to file and parser improvements
to distinguish signed from unsigned hexadecimal constants.
Eric Shade of Missouri State University, who suggested several improvements to
pseudo-instruction expansions such as elimination of internal branches
and improvements to the sign-extended loading of 16-bit immediate operands.
Saul Spatz of the University of Missouri Kansas City, who noticed and provided a solution
for a flaw in the calculation of byte-oriented addresses in the simulated MIPS memory stack segment.
He has also suggested several improvements that we have implemented.
Zachary Kurmas of Grand Valley State University, who suggested several bug fixes and
who encorporated MARS into his own successful JLSCircuitTester digital logic simulator software.
Felipe Lessa, who contributed the Instruction Counter tool and suggested a solution
for the problem of MARS inability to launch when stored in a directory whose name
contained non-ASCII characters.
Carl Hauser of Washington State University, who pointed out and provided a solution to
a flaw in the Keyboard and Display Simulator Tool in how it used the Exception Level bit in the
Coprocessor1 Status register. Also thanks to Michael Clancy of UC Berkeley for pointing out a flaw in the
tool’s mechanism for resetting the Transmit Ready bit when operating in kernel memory.
Dave Poplawski of Michigan Technological University, for his assistance in working through
some issues with signed/unsigned constants and with output redirection.
Ingo Kofler of Klagenfurt University in Austria, who contributed two Tools: a tool
to collect Instruction Statistics, and a tool to simulate branch prediction
with a Branch History Table.
Brad Richards and Steven Canfield from the University of Puget Sound, for providing
a technique that improved file loading performance.
Jan Schejbal and Jan-Peter Kleinhans of Darmstadt technical university in Germany, for
suggesting and providing a patch to display Run I/O text in a constant-width font.
Max Hailperin of Gustavus Adolphus College, who made several
improvements to the MIDI syscalls.
David Patterson of UC Berkeley, for making time in his busy schedule for Ken’s demo of MARS.
Denise Penrose and Nate McFadden of Morgan Kaufmann Publishers, for their
assistance as editors of
Computer Organization and Design.
Ricardo Pascual of University of Murcia in Spain, who contributed the code to permit input syscall
keystrokes to be typed directly into the Run I/O window instead of through a popup dialog.
Didier Teifreto of Université de Franche-Comté in France, who contributed the Digital Lab Sim tool.
Facundo Agriel of the University of Illinois at Chicago, who added font selection to the Keyboard and
Display Simulator tool.
Patrik Lundin for contributing the code to add scrolling to the keyboard and display simulator.
Otterbein students Robert Anderson, Jonathan Barnes, Sean Pomeroy and Melissa Tress
for contributing the new command-mode options for specifying MARS exit codes when
assembly or simulation errors occur. This was sparked by a comment from
Zheming Jim of the University of South Carolina.
The unknown audience member at our SIGCSE 2006 conference presentation,
who suggested that MARS would also be useful running in the background
in support of an external application. This led directly to our development of the Tools
framework and API that truly distinguishes MARS from all other MIPS simulators.
We would also like to recognize many others who have contacted us to point out bugs, suggest improvements, or engaged us in
interesting correspondence. The bugs have been addressed and the
improvements either implemented or added to our wish list. Correspondents include:
William Bai,
Miguel Barao,
James Baltimore,
Jared Barneck,
Bruce Barton,
Rudolf Biczok,
Battista Biggio,
Carl Burch,
Ram Busani,
Gene Chase,
Lucien Chaubert,
David Chilson,
Sangyeun Cho,
Donald Cooley,
Bernardo Cunha,
John Donaldson,
Abhik Ghosh,
Michael Grant,
Thomas Hain,
John Ham,
Kurtis Hardy,
Justin Harlow,
David Harris,
Bill Hsu,
Pierre von Kaenel,
Amos Kittelson,
klondike,
Geoffrey Knauth,
Sudheer Kumar,
Yi-Yu Liu,
Jeremie Lumbroso,
Paul Lynch,
Richard McKenna,
William McQuain,
Adam Megacz,
Alessandro Montano,
Judy Mullins,
William Obermeyer,
Ivor Page,
Gustavo Patino,
Christoph von Praun,
Klaus Ramelow,
David Reimann,
Patricia Renault,
André Rodrigues,
Robert Roos,
Joseph Roth,
Marco Salinas,
Peter Schulthess,
Ofer Shaham,
Scott Sigman,
Sasha Solganik,
Timothy Stanley,
Gene Stark,
Josh Steinhurst,
Michelle Strout,
Didier Teifreto,
Mitchell Theys,
Massimo Tivoli,
Dwayne Towell,
Duy Truong,
Judah Veichselfish,
Vineeth,
Daniel Walker,
Janyce Weibe,
Ben West,
and
Armin Zundel.
The Mars.jar file contains all source code and, starting with Release 3.6,
the files necessary to generate a new jar file should you wish to make changes to
the source and repackage it for your own use. Let us know if you do this, so we
can consider your changes for the general release.
Thanks to everyone who uses MARS. Keep those cards and letters coming!
Bug Reporting help contents
Bug Reporting and General Comments
The MARS web page is maintained at
http://www.cs.missouristate.edu/MARS/
and will contain updated releases, bug lists, etc.
For bug reporting and general comments, please send email to
Dr. Pete Sanderson at
PSanderson@otterbein.edu
with “MARS” in the
subject line. Please include sufficient information to recreate
the problem, and assembly programs if appropriate.
Writing and Using MIPS exception handlers in MARS
Writing and Using MIPS exception handlers in MARS
Introduction
Exception handlers, also known as trap handlers or
interrupt handlers, can easily be incorporated into a MIPS program.
This guide is not intended to be comprehensive but provides the essential
information for writing and using exception handlers.
Although the same mechanism services all three, exceptions, traps
and interrupts are all distinct from each other.
Exceptions are caused by exceptional conditions that occur at runtime
such as invalid memory address references. Traps are caused by instructions
constructed especially for this purpose, listed below. Interrupts are
caused by external devices.
MARS partially but not completely implements the exception and interrupt
mechanism of SPIM.
Essential Facts
Some essential facts about writing and using exception handlers include:
MARS simulates basic elements of the MIPS32 exception mechanism.
The MIPS instruction set includes a number of instructions that
conditionally trigger a trap exception based on the relative values of two
registers or of a constant and a register:
teq, teqi (trap if equal),
tne, tnei (trap if not equal),
tge, tgeu,
tgei, tgeiu (trap if greater than or equal),
tlt, tltu,
tlti, tltiu (trap if less than)
When an exception occurs,
Coprocessor 0 register $12 (status) bit 1 is set
Coprocessor 0 register $13 (cause) bits 2-6 are set to the exception type (codes below)
Coprocessor 0 register $14 (epc) is set to the
address of the instruction that triggered the exception
If the exception was caused by an invalid memory address,
Coprocessor 0 register $8 (vaddr) is set to the invalid address.
Execution flow jumps to the MIPS
instruction at memory location 0x800000180. This address
in the kernel text segment (.ktext directive) is the
standard MIPS32 exception handler location. The only way to change
it in MARS is to change the MIPS memory configuration through
the Settings menu item Memory Configuration.
There are three ways to include an exception handler in a MIPS program
Write the exception handler in the same file as the regular
program. An example of this is presented below.
Write the exception handler in a separate file, store that file
in the same directory as the regular program, and select
the Settings menu item “Assemble all files in directory”
Write the exception handler in a separate file, store that file
in any directory, then open the “Exception Handler…” dialog
in the Settings menu, check the check box and browse to
that file.
If there is no instruction at location 0x800000180,
MARS will terminate the MIPS program with an appropriate error message.
The exception handler can return control to the program using
the eret instruction. This will place the EPC register $14 value into the
Program Counter, so be sure to increment $14 by 4 before returning
to skip over the instruction that caused the exception. The mfc0
and mtc0 instructions are used to read from and write to Coprocessor 0
registers.
Bits 8-15 of the Cause register $13 can also be used to indicate
pending interrupts. Currently this is used only by the Keyboard and
Display Simulator Tool, where bit 8 represents a keyboard interrupt
and bit 9 represents a display interrupt. For more details, see the
Help panel for that Tool.
Exception types declared in mars.simulator.Exceptions, but
not necessarily implemented, are ADDRESS_EXCEPTION_LOAD (4), ADDRESS_EXCEPTION_STORE (5),
SYSCALL_EXCEPTION (8),
BREAKPOINT_EXCEPTION (9),
RESERVED_INSTRUCTION_EXCEPTION (10),
ARITHMETIC_OVERFLOW_EXCEPTION (12),
TRAP_EXCEPTION(13),
DIVIDE_BY_ZERO_EXCEPTION (15),
FLOATING_POINT_OVERFLOW (16), and
FLOATING_POINT_UNDERFLOW (17).
When writing a non-trivial exception handler, your handler must first save
general purpose register contents, then restore them before returning.
Example of Trap Handler
The sample MIPS program below will immediately generate a trap exception because
the trap condition evaluates true, control jumps to the exception handler,
the exception handler returns control to the instruction following
the one that triggered the exception, then the program terminates normally.
.text
main:
teqi $t0,0 # immediately trap because $t0 contains 0
li $v0, 10 # After return from exception handler, specify exit service
syscall # terminate normally
# Trap handler in the standard MIPS32 kernel text segment
.ktext 0x80000180
move $k0,$v0 # Save $v0 value
move $k1,$a0 # Save $a0 value
la $a0, msg # address of string to print
li $v0, 4 # Print String service
syscall
move $v0,$k0 # Restore $v0
move $a0,$k1 # Restore $a0
mfc0 $k0,$14 # Coprocessor 0 register $14 has address of trapping instruction
addi $k0,$k0,4 # Add 4 to point to next instruction
mtc0 $k0,$14 # Store new address back into $14
eret # Error return; set PC to value in $14
.kdata
msg:
.asciiz “Trap generated”
Widely Used Exception Handler
The exception handler exceptions.s provided with
the SPIM simulator will assemble and run under MARS. The MARS
assembler will generate warnings because this program
contains directives that it does not
recognize, but as long as the setting “Assembler warnings are
considered errors” is not set this will not cause any
problems.
Intro
Settings
Syscalls
IDE
Debugging
Command
Tools
History
Limitations
Exception Handlers
Macros
Acknowledgements
MARS home
Macros in MARS
Writing and Using Macros
.macro, .end_macro,.eqv and .include directives are new in MARS 4.3
Introduction to macros
Patterson and Hennessy define a macro as a pattern-matching and replacement facility
that provides a simple mechanism to name a frequently used sequence of instructions [1].
This permits the programmer to specify the instruction sequence by invoking the macro. This requires
only one line of code for each use instead of repeatedly typing
in the instruction sequence each time. It follows the axiom “define once, use many times,” which
not only reduces the chance for error but also facilitates program maintenance.
Macros are like procedures (subroutines) in this sense but operate differently than procedures.
Procedures in MIPS assembly language follow particular protocols for procedure definition, call and return.
Macros operate by substituting the macro body for each use at the time of assembly. This substitution
is called macro expansion.. They do not require the protocols and execution overhead of procedures.
As a simple example, you may want to terminate your program from a number of locations. If you are running
from the MARS IDE, you will use system call 10, exit. The instruction sequence is pretty easy
li $v0,10
syscall
but still tedious. You can define a macro, let’s call it done, to represent this sequence
.macro done
li $v0,10
syscall
.end_macro
then invoke it whenever you wish with the statement
done
At assembly time, the assembler will replace each occurrence of the statement done with the two-statement
sequence
li $v0,10
syscall
This is the macro expansion. The runtime simulator is unaware of macros or macro expansion.
If running MARS from the command line, perhaps you want to return a termination value. This can be done
with syscall 17, exit2, which takes the termination value as an argument. An equivalent macro,
let’s call it terminate would be
.macro terminate (%termination_value)
li $a0, %termination_value
li $v0, 17
syscall
.end_macro
This macro defines a formal parameter to represent the termination value. You would invoke it
with the statement
terminate (1)
to terminate with value 1. Upon assembly,
the statement terminate (1) would be replaced by the three-statement sequence
li $a0, 1
li $v0, 17
syscall
The argument value, 1, is substituted wherever the formal parameter %termination_value appears
in the macro body.
This is a textual substitution. Note that in this example the argument value must be an integer, not a
register name or a label, because the parameter is used as the second operand in the Load Immediate operation.
In MARS, a macro is similar to an extended (pseudo) instruction. They are distinguished in that the expansion of
extended instructions is supported by an internally-defined specification language and mechanism which can manipulate argument values.
The macro facility can only substitute argument values as given, and it uses a separate mechanism from extended instructions.
Additional examples and details follow.
How to define macros
The first line begins with a .macro directive followed by an optional list of formal parameters.
Placing commas between parameters and parentheses around the list is optional.
Each formal parameter is an identifier that begins with a % character. For compatibility with
the SPIM preprocessor APP, it may alternatively begin with $.
The lines that follow define the body of the macro. Use the formal parameters as appropriate. The body
may contain data segments as well as text segments.
The macro definition finishes with a .end_macro directive.
See the Notes below for additional information.
How to use macros
To invoke a macro, form a statement consisting of the macro name and then one token for each argument
to be substituted for its corresponding formal parameter by the assembler.
The argument list may optionally be surrounded by parentheses.
Arguments may be separated either by spaces or commas.
Macro expansion is a pre-processing task for assemblers.
Notes
A macro definition must appear before its use. No forward references.
All macro definitions are local in each file and they cannot be global.
Nested macro definitions are not supported. No .macro directive should appear inside body of a macro definition.
A macro definition can contain a call to a previously-defined macro. Only backward references are allowed.
Labels placed in the body of a macro definition will not have same name after macro expansion.
During expansion, their name will be followed by “_M#” where # will be a unique number for each macro expansion.
Two macros with the same name but different number of parameters are considered different and both can be used.
A macro defined with the same name and same number of parameters as another macro defined before it will be ignored.
Each argument in a macro call can only be a single language element (token). For instance “4($t0)” cannot be an argument.
Macros are a part of the assembler, not the ISA. So the syntax might be different with other assemblers.
For compatibility with the SPIM simulator, SPIM-style macros are also supported in MARS. SPIM-style macros are same as MARS but formal parameters begin with “$” instead of “%”.
Examples
Printing an integer (argument may be either an immediate value or register name):
.macro print_int (%x)
li $v0, 1
add $a0, $zero, %x
syscall
.end_macro
print_int ($s0)
print_int (10)
Printing a string (macro will first assign a label to its parameter in data segment then print it):
.macro print_str (%str)
.data
myLabel: .asciiz %str
.text
li $v0, 4
la $a0, myLabel
syscall
.end_macro
print_str (“test1″) #”test1” will be labeled with name “myLabel_M0”
print_str (“test2″) #”test2” will be labeled with name “myLabel_M1”
Implementing a simple for-loop:
# generic looping mechanism
.macro for (%regIterator, %from, %to, %bodyMacroName)
add %regIterator, $zero, %from
Loop:
%bodyMacroName ()
add %regIterator, %regIterator, 1
ble %regIterator, %to, Loop
.end_macro
#print an integer
.macro body()
print_int $t0
print_str “\n”
.end_macro
#printing 1 to 10:
for ($t0, 1, 10, body)
The for macro has 4 parameters. %regIterator should be the name of a register which iterates from %from to %to and in each iteration %bodyMacroName will be expanded and run.
Arguments for
%from and %to can be either a register name or an immediate value, and %bodyMacroName should be name of a macro that has no parameters.
Macro source line numbers
For purpose of error messaging and Text Segment display, MARS attempts to display line numbers for both the definition and use of the pertinent
macro statement. If an error message shows the line number in the form “X->Y” (e.g. “20->4”), then X is the line number in the expansion
(use) where the error was detected and Y is the line number in the macro definition. In the Text Segment display
of source code, the macro definition
line number will be displayed within brackets, e.g. “<4>“, at the point of expansion. Line numbers should correspond to the
numbers you would see in the text editor.
The .eqv directive
The .eqv directive (short for “equivalence”) is also new in MARS 4.3. It is similar to #define in C or C++. It
is used to substitute an arbitrary string for an identifier. It is useful but much less powerful than macros.
It was developed independently of the macro facility.
Using .eqv, you can specify simple substitutions that provide “define once, use many times” capability at assembly
pre-processing time. For example, once you define
.eqv LIMIT 20
.eqv CTR $t2
.eqv CLEAR_CTR add CTR, $zero, 0
then you can refer to them in subsequent code:
li $v0,1
CLEAR_CTR
loop: move $a0, CTR
syscall
add CTR, CTR, 1
blt CTR, LIMIT, loop
CLEAR_CTR
During assembly pre-processing, the .eqv substitutions will be applied. The resulting code is
li $v0,1
add $t2, $zero, 0
loop: move $a0, $t2
syscall
add $t2, $t2, 1
blt $t2, 20, loop
add $t2, $zero, 0
which when run will display the values 0 through 19 on one line with no intervening spaces.
Note that the substitution string is not limited to a single token. Like .macro, .eqv is local to the file
in which it is defined, and must be defined prior to use. Macro bodies can contain references to .eqv directives.
The .include directive
The .include directive is also new in MARS 4.3. It has one operand, a quoted filename. When the
directive is carried out, the contents of the specified file are substituted for the directive. This occurs
during assembly preprocessing. It is like #include in C or C++.
.include is designed to make macro and equivalence (.eqv directive) use
more convenient. Both macro definitions and equivalence definitions are local, which means they can be used only
in the same file where defined. Without .include, you would have to repeat their definitions in every
file where you want to use them. Besides being tedious, this is poor programming practice; remember
“define once, use many times.” Now you can define macros and equivalences in a separate file, then include it
in any file where you want to use them.
The .include preprocessor will detect and flag any circular includes (file that includes itself, directly or
indirectly).
The use of .include presents some challenges for error messaging and for source code numbering in the Text
Segment display. If a file being included has any assembly errors, the filename and line number in the error
message should refer to the file being included, not the file it was substituted into. Similarly, the line number
given in the Text Segment source code display refers to the line in the file being included. Thus the displayed line numbers do not
monotonically increase – this is also the case when using the “assemble all” setting. Line numbers should correspond to the numbers
you would see in the text editor.
As a simple example, you could define the done macro (and others) in a separate file
then include it wherever you need it. Suppose “macros.asm” contains the following:
.macro done
li $v0,10
syscall
.end_macro
You could then include it in a different source file something like this:
.include “macros.asm”
.data
value: .word 13
.text
li $v0, 1
lw $a0, value
syscall
done
During assembly preprocessing, this would be expanded to
.macro done
li $v0,10
syscall
.end_macro
.data
value: .word 13
.text
li $v0, 1
lw $a0, value
syscall
done
The assembler will then perform the appropriate macro expansion.
Acknowledgements
The MARS macro facility was developed in 2012 by Mohammad Hossein Sekhavat, sekhavat17@gmail.com, while an engineering student at
Sharif University in Tehran. MARS creators Pete and Ken are incredibly grateful for his contribution! Pete developed .eqv
and .include at about the same time.
References
[1] Computer Organization and Design: The Hardware/Software Interface, Fourth Edition, Patterson and Hennessy,
Morgan Kauffman Publishers, 2009.
MARS 4.5 help contents
MARS – Mips Assembly and Runtime Simulator
Release 4.5
August 2014
Using MARS from a command line.
MARS can be run from a command interpreter to assemble and execute a MIPS program in
a batch fashion.
The format for running MARS from a command line is:
java -jar mars.jar [options] program.asm [more files…] [ pa arg1 [more args…]]
Items in [ ] are optional. Valid options (not case sensitive, separated by spaces) are:
Option Description Since
a assemble only, do not simulate 1.0
aen terminate MARS with integer exit code n if assembly error occurs 4.1
ascii display memory or register contents interpreted as ASCII codes. (alternatives are dec and hex) 4.1
b brief – do not display register/memory address along with contents 2.2
d display MARS debugging statements (of interest mainly to MARS developer) 1.0
db MIPS delayed branching is enabled. 3.3
dec display memory or register contents in decimal. (alternatives are ascii and hex) 2.2
dump dump memory contents to file.
Option has 3 arguments, e.g. dump
and .data. Also supports an address range (see m-n below). Current supported dump formats are Binary, HexText, BinaryText, AsciiText. See examples below. 3.4
hex display memory or register contents in hexadecimal – this is the default. (alternatives are ascii and dec) 2.2
h display this help. Use this option by itself and with no filename. 1.0
ic display instruction count; the number of MIPS basic instructions ‘executed’ 4.3
mc set memory configuration.
Option has 1 argument, e.g. mc
possible values are Default for the default 32-bit address space, CompactDataAtZero for
a 32KB address space with data segment at address 0, or CompactTextAtZero
for a 32KB address space with text segment at address 0. 3.7
me display MARS messages to standard err instead of standard out. Allows you to separate MARS messages from MIPS program output using redirection. 4.3
nc copyright notice will not be displayed. Useful if redirecting or piping program output. 3.5
np pseudo-instructions or extended instruction formats are not permitted. 3.0
p project option – will assemble the specified file and all other assembly files (*.asm; *.s) in its directory. 3.1
sen terminate MARS with exit code n if simulate (run) error occurs 4.1
sm start execution at statement having global label ‘main’ if defined 3.8
smc Self Modifying Code – Program can write and execute in either text or data segment 4.4
we assembler warnings will be considered errors. 3.5
n where n is an integer maximum count of execution steps to simulate.
If 0, negative or not specified, there is no maximum. 1.0
$reg where reg is number or name (e.g. 5, t3, f10) of register whose
content to display at end of run. Even-numbered float register displays both float and double. Option may be repeated.
NOTE: Depending on your command shell, you may need to escape the $, e.g. \$t3 2.2
reg_name where reg_name is the name (e.g. t3, f10) of register whose
content to display at end of run. Even-numbered float register displays both float and double. Option may be repeated. $ not required. 2.2
m-n memory address range from m to n whose contents to
display at end of run. m and n may be decimal or hexadecimal (starts with 0x),
m <= n, both must be on word boundary. Option may be repeated. 2.2
pa program arguments - all remaining space-separated items are argument values provided to the MIPS
program via $a0 (argc - argument count) and $a1 (argv - address of array containing pointers to null-terminated argument
strings). The count is also at the top of the runtime stack ($sp), followed by the array.This option and its arguments must be the last items in the command! 3.5
Example: java -jar mars.jar h
Displays command options and explanations.
Example: java -jar mars.jar $s0 $s1 0x10010000-0x10010010 fibonacci.asm
Assemble and run fibonacci.asm. At the end of the run, display the contents of registers $s0 and
$s1, and the contents of memory locations 0x10010000 through 0x10010010. The contents are displayed in
hexadecimal format.
Example: java -jar mars.jar a fibonacci.asm
Assemble fibonacci.asm. Does not attempt to run the program, and the assembled code is not saved.
Example: java -jar mars.jar 100000 infinite.asm
Assemble and run infinite.asm for a maximum of 100,000 execution steps.
Example: java -jar mars.jar p major.asm
Assemble major.asm and all other files in the same directory, link the assembled code, and run starting with the first instruction in major.asm.
Example: java -jar mars.jar major.asm minor.asm sub.asm
Assemble and link major.asm, minor.asm and sub.asm. If successful, execution
will begin with the first instruction in major.asm.
Example: java -jar mars.jar a dump .text HexText hexcode.txt fibonacci.asm
Assemble fibonacci.asm without simulating (note use of 'a' option). At end of assembly, dump the text segment (machine code) to
file hexcode.txt in hexadecimal text format with one instruction per line.
Example: java -jar mars.jar dump 0x10010000-0x10010020 HexText hexcode.txt fibonacci.asm
Assemble and simulate fibonacci.asm. At end of simulation, dump the contents of addresses 0x1001000 to
0x10010020 to file hexdata.txt in hexadecimal text format with one word per line.
Example: java -jar mars.jar t0 process.asm pa counter 10
Assemble and run process.asm with two program argument values, "counter" and "10". It may retrieve the
argument count (2) from $a0, and the address of an array containing pointers to the strings "count" and "10",
from $a1. At the
end of the run, display the contents of register $t0.
The ability to run MARS from the command line is useful if you want to develop
scripts (macros) to exercise a given MIPS program under multiple scenarios
or if you want to run a number of different MIPS programs
such as for grading purposes.
This document is available for printing on the MARS home page
http://www.cs.missouristate.edu/MARS/.
MARS 4.5 help contents
MARS - Mips Assembly and Runtime Simulator
Release 4.5
August 2014
Interactive Debugging Features
MARS provides many features for interactive debugging through its Execute pane.
Features include:
In Step mode, the next instruction to be simulated is highlighted and
memory content displays are updated at each step.
Select the Go option if you want to simulate continually.
It can also be used to continue simulation
from a paused (step, breakpoint, pause) state.
Breakpoints are easily set and reset using the check boxes next to each instruction displayed
in the Text Segment window. New in Release 3.8: You can temporarily suspend breakpoints
using Toggle Breakpoints in the Run menu or by clicking the "Bkpt" column header in the Text Segment
window. Repeat, to re-activate.
When running in the Go mode, you can select the simulation
speed using the Run Speed slider. Available speeds range
from .05 instructions per second (20 seconds between steps) up to 30
instructions per second, then above this offers an "unlimited" speed.
When using "unlimited" speed, code highlighting and memory display updating
are turned off while simulating (but it executes really fast!).
When a breakpoint is reached, highlighting and updating occur.
Run speed can be adjusted while the program is running.
When running in the Go mode, you can pause or stop
simulation at any time using the Pause or Stop features.
The former will pause execution and update the display, as if you
were stepping or at a breakpoint. The latter will terminate execution
and display final memory and register values. If running at "unlimited"
speed, the system may not respond immediately but it will respond.
You have the ability to interactively step "backward" through program execution
one instruction at a time to "undo" execution steps. It will buffer up to 2000 of the most
recent execution steps (this limit is stored in a properties file and can be changed).
It will undo changes made to MIPS memory, registers or condition flags,
but not console or file I/O. This should be a great debugging aid.
It is available anytime execution is paused and at termination (even if terminated due to
exception).
When program execution is paused or terminated, select Reset
to reset all memory cells and registers to their initial post-assembly values.
In fact, Reset is implemented by re-assembling the program.
Memory addresses and values, and register values, can be viewed in either decimal
or hexadecimal format. All data are stored in little-endian byte order (each
word consists of byte 3 followed by byte 2 then 1 then 0). Note that each word
can hold 4 characters of a string and those 4 characters will appear in the
reverse order from that of the string literal.
Data segment contents are displayed 512 bytes
at a time (with scrolling) starting with the data segment base address (0x10010000).
Navigation buttons are provided to change the display to the next
section of memory, the previous, or back to the initial (home) range. A combo box is
also provided to view memory contents in the vicinity of the stack pointer
(contents of MIPS $sp register), global pointer (contents of MIPS $gp register),
the heap base address (0x10040000), .extern globals (0x10000000),
the kernel data segment (0x90000000), or memory-mapped IO (MMIO, 0xFFFF0000).
Starting with Mars 4.4, raw text segment contents can also be displayed.
Contents of any data segment memory word and almost any MIPS register can be modified by
editing its displayed table cell. Double-click on a cell to edit it and press the Enter key
when finished typing the new value. If you
enter an invalid 32-bit integer, the word INVALID appears in the cell
and memory/register contents are not affected. Values can be entered
in either decimal or hexadecimal (leading "0x"). Negative hexadecimal
values can be entered in either two's complement or signed format. Note
that three of the integer registers (zero, program counter, return address)
cannot be edited.
New in 4.4 If the setting for Self-Modifying Code is enabled
(disabled by default, look in the Settings menu), text segment binary
code can be modified using the same technique described above. It can also
be modified by double-clicking on a cell in the Text Segment display's Code
column.
Contents of cells representing floating point registers can be edited
as described above and will accept valid hexadecimal or decimal floating point
values. Since each double-precision register overlays two single-precision
registers, any changes to a double-precision register will affect one or both
of the displayed contents of its corresponding single-precision registers.
Changes to a single-precision register will affect the display of its
corresponding double-precision register. Values entered in hexadecimal
need to conform to IEEE-754 format. Values entered in decimal are entered
using decimal points and E-notation (e.g. 12.5e3 is 12.5 times 10 cubed).
Cell contents can be edited during program execution and once accepted
will apply starting with the next instruction to be executed.
Clicking on a Labels window entry will cause the location associated with
that label to be centered and highlighted in the Text Segment or Data Segment
window as appropriate. Note the Labels window is not displayed by default but
can be by selecting it from the Settings menu.
This document is available for printing on the MARS home page
http://www.cs.missouristate.edu/MARS/.
MARS Release History and Notes
MARS - Mips Assembly and Runtime Simulator
Release 4.5
August 2014
MARS Release History
Mars 4.5 was released in August 2014. Enhancements and bug fixes include:
The Keyboard and Display MMIO Simulator tool has been enhanced at the suggestion of Eric Wang at
Washington State University. Until now, all characters written to the display via the Data Transmitter
location (low order byte of memory word 0xFFFF000C) were simply streamed to the tools' display window.
Mr. Wang requested the ability to treat the display window as a virtual text-based terminal by
being able to programmatically clear the window or set the (x,y) position of a text cursor. Controlled
placement of the text cursor (which is not displayed) allows you to, among other things, develop
2D text-mode games.
To clear the window, place ASCII/Unicode 12 decimal in the Data Transmitter byte. This is the non-printing
Form Feed character.
To set the text cursor to a specified (x,y) position, where x is the column and y is the row,
place ASCII/Unicode 7 in the Data Transmitter byte, and place the (x,y) position in the unused
upper 24 bits of the Data Transmitter word. Place the X-position in bits 20-31 and the Y-position in bits 8-19.
Position (0,0) is the upper-left corner of the display.
You can resize the display window to desired dimensions prior to running your MIPS program.
Dimensions are dynamically displayed in the upper border. Note that the tool now contains a splitter between
the display window and the keyboard window. Once the program is running, changes to the display size
does not affect cursor positioning.
The Help window for this tool is no longer modal, so you can view it while working in other windows.
The Help window contains a lot of information so you
will find it useful to be able to refer to it while working on your program.
Installed the MIPS X-ray Tool developed by Marcio Roberto and colleagues at the Federal Center of
Technological Education of Minas Gerais in Brazil. This tool animates a display of the MIPS datapath.
The animation occurs while stepping through program execution. Search the Internet for "MIPS X-ray"
to find relevant publications and other information.
Context-sensitive help in the editor should now be easier to read. It was implemented as a menu of
disabled items, which caused their text to be dimmed. The items are now enabled for greater visibility
but clicking them will only make the list disappear.
Bug Fix: Fixed an editor problem that affects certain European keyboards. The syntax-highlighting editor
ignored the Alt key, which some European keyboards require to produce the # or $ characters in particular.
I had no means of testing this, but Torsten Maehne in France send me a solution and Umberto
Villano in Italy affirmed that it worked for him as well.
Bug Fix: Source code references to Coprocessor 1 floating point registers (e.g. $f12)
within macro definitions were erroneously flagged as syntax errors. MARS permits SPIM-style
macro parameters (which start with $ instead of %) and did not correctly distinguish them
from floating point register names. This has been fixed. Thanks to Rudolf Biczok in Germany for alerting
me to the bug.
Bug Fix: Corrected a bug that caused the Data Segment window to sometimes display incorrect values
at the upper boundary of simulated memory segments. Thanks to Yi-Yu (James) Liu from Taiwan for alerting
me to the bug, which was introduced in Mars 4.4.
Mars 4.4 was released in August 2013. Enhancements and bug fixes include:
A feature to support self-modifying code has been developed by Carl Burch
(Hendrix College) and Pete Sanderson. It is disabled by default
and can be enabled through a Settings menu option. A program can write to the
text segment and can also branch/jump to any user address in the data segments
within the limits of the simulated address space. Text segment contents
can also be edited interactively using the Data Segment window, and text
segment contents within the address range of existing code can be edited
interactively using the Text Segment window. In command mode, the smc option
permits a program to write and execute in both text and data segments.
Bug fix: An assembly error occurred when a line within a macro contained both
a macro parameter and an identifier defined to have an .eqv substitution.
Bug fix: If a macro name was used as a macro parameter, an assembly error occurred in some situations
when a macro being used as an argument was defined following the macro that
defined the parameter. The "for" macro described in the Macro help tab is
an example.
Mars 4.3 was released in January 2013. Enhancements and bug fixes include:
A macro facility has been developed by Mr. Mohammad Sekhavat. It is documented
in the MIPS help tab Macros.
A text substitution facility similar to #define has been developed using
the new .eqv directive. It is also documented in the MIPS help
tab Macros.
A text insertion facility similar to #include has been developed
using the new .include directive. It is also documented in the
MIPS help tab Macros. It permits a macro to be defined in one file and
included wherever needed.
Two new command mode options are now available: ic (Instruction Count) to
display a count of statements executed upon program termination, and me
(Messages to Error) to send MARS messages to System.err instead of System.out.
Allows you to separate MARS messages from MIPS output using redirection,
if desired. Redirect a stream in DOS with "1>” or “2>” for out and err,
respectively. To redirect both, use “> filename 2>&1”
Changed the default font family settings from Courier New to Monospaced.
This was in response to reports of Macs displaying left parentheses and vertical
bars incorrectly.
Changed the way operands for .byte and .half directives are range-checked.
It will now work like SPIM, which accepts any operand value but truncates high-end bits as
needed to fit the 1 (byte) or 2 (half) byte field. We’ll still issue a warning
but not an error.
For file reads, syscall 14, file descriptor 0 is always open for standard input. For file
writes, syscall 15, file descriptors 1 and 2 are always open for standard output and
standard error, respectively. This permits you to write I/O code that will
work either with files or standard I/O. When using the IDE, standard input and output
are performed in the Run I/O tab. File descriptors for regular files are
allocated starting with file descriptor 3.
Mars 4.2 was released in August 2011. Enhancements and bug fixes include:
Performing a Save operation on a new file will now use the file’s tab
label as the the default filename in the Save As dialog (e.g. mips1.asm).
Previously, it did not provide a default name.
When the “assemble all files in directory” setting is enabled (useful
for multi-file projects), you can now switch focus from one editor tab to another
without invalidating the current assemble operation. You can similarly open
additional project files. Previously, the open or tab selection would
invalidate the assemble operation and any paused execution state or
breakpoints would be lost.
The Read String syscall (syscall 8) has been fortified to prevent Java exceptions from occurring
when invalid values are placed in $a1.
Will now perform runtime test for unaligned doubleword address in
‘ldc1’ and ‘sdc1’ instructions and trap if not aligned.
Basic statements in the Text Segment display now renders immediates using
eight hex digits when displaying in hex. Previously it rendered only
four digits to conserve space. This led to confusing
results. For instance, -1 and 0xFFFF would both be displayed as 0xFFFF
but -1 expands to 0xFFFFFFFF and 0xFFFF expands to 0x0000FFFF.
Mars 4.1 was released in January 2011. Enhancements and bug fixes include:
The ability to view Data Segment contents interpreted as ASCII
characters has been added. You’ll find it on the bottom border of
the Data Segment Window as the checkbox “ASCII”. This overrides the
hexadecimal/decimal setting but only for the Data Segment display.
It does not persist across sessions. Cells cannot be edited in
ASCII format.
The Dump Memory feature in the File menu now provides an ASCII dump
format. Memory contents are interpreted as ASCII codes.
A command-mode option “ascii” has been added to display memory or
register contents interpreted as ASCII codes. It joins the existing
“dec” and “hex” options for displaying in decimal or hexadecimal,
respectively. Only one of the three may be specified.
The actual characters to display for all the ASCII display options
(data segment window, dump memory, command-mode option) are
specified in the config.properties file. This includes a “placeholder”
character to be displayed for all codes specified as non-printing.
ASCII codes 1-7, 14-31, and 127-255 are specified as
non-printing, but this can be changed in the properties file.
A new Help tab called Exceptions has been added. It explains the basics
of MIPS exceptions and interrupts as implemented in MARS. It also includes
tips for writing and using exception handlers.
A new Tool called Bitmap Display has been added. You can use it
to simulate a simple bitmap display. Each word of the specified address
space represents a 24 bit RGB color (red in bits 16-23, green in bits
8-15, blue in bits 0-7) and a word’s value will be displayed on the Tool’s
display area when the word is written to by the MIPS program. The base
address corresponds to the upper left corner of the display, and words are
displayed in row-major order. Version 1.0 is pretty basic, constructed
from the Memory Reference Visualization Tool code.
Additional operand formats
were added for the multiplication pseudo-instructions ‘mul’ and ‘mulu’.
The editor’s context-sensitive pop-up help will now appear below
the current line whenever possible. Originally it appeared either above,
centered to the side,
or below, depending on the current line’s vertical position in the editing
window. Displaying the pop-up above the current line tended to visually block
important information, since frequently a line of code uses the same operand
(especially registers) as the one immediately above it.
The editor will now auto-indent each new line when the Enter
key is pressed. Indentation of the new line will match that of the
line that precedes it. This feature can be disabled in the Editor settings dialog.
Two new command-mode options have been added. The “aeN” option, where
N is an integer, will terminate MARS with exit value N when an assemble error
occurs. The “seN” option will similarly terminate MARS with exit value
N when a simulation (MIPS runtime) error occurs. These options can be useful
when writing scripts for grading. Thanks to my Software
Engineering students Robert Anderson, Jonathan Barnes, Sean Pomeroy, and Melissa Tress
for designing and implementing these options.
An editor bug that affected Macintosh users has been fixed.
Command shortcuts, e.g. Command-s for save, did not
function and also inserted the character into the text.
A bug in Syscall 54 (InputDialogString) has been fixed. This syscall is
the GUI equivalent of Syscall 8 (ReadString), which follows the semantics
of UNIX ‘fgets’. Syscall 54 has been modified to also follow the ‘fgets’
semantics.
A bug in the Cache Simulator Tool has been fixed. The animator that
paints visualized blocks green or red (to show cache hit or miss) sometimes
paints the wrong block when set-associated caching is used. The underlying
caching algorithm is correct so the numeric results such as hit ratios
have always been correct. The animator has been corrected.
Thanks to Andreas Schafer and his student Carsten Demel for bringing this
to my attention.
Mars 4.0.1 was released in October 2010. It is a bug fix release to address three bugs.
The Edit and Execute tabs of the IDE, which were relocated in 4.0 from the top to the left edge and oriented vertically, have been
moved back to the top edge because Macintosh running Java 1.6 does not correctly render vertically-oriented tabs.
An exception may be thrown in multi-file assembles when the last file of the assembly is not the longest. This occurs
only when using the IDE, and has been corrected.
If an assemble operation fails due to a non-existing exception handler file (specified through the IDE Settings menu), unchecking
the exception handler setting does not prevent the same error from occuring on the next assemble. This has been corrected.
Mars 4.0 was released in August 2010. Enhancements and bug fixes include:
New Text Editor: Mars features an entirely new integrated text editor. It creates a new tab for each file
as it is opened. The editor now features language-aware
color highlighting of many MIPS assembly language elements with customizable
colors and styles. It also features automatic context-sensitive popup instruction
guides. There are two levels: one with help and autocompletion of instruction names
and a second with help information for operands. These and other new editor
features can be customized or disabled through
the expanded Editor Settings dialog. You can even revert to the previous
notepad-style editor if you wish (multi-file capability is retained).
The language-aware editor is based on
the open source jEdit Syntax Package (syntax.jedit.org). It is separate from
the assembler, so any syntax highlighting quirks will not affect assembly.
Improved Instruction Help: All the instruction examples in the help tabs (and new popup instruction guides)
now use realistic register names, e.g. $t1, $t2, instead of $1, $2. The instruction format
key displayed above the MIPS help tabs has been expanded to include explanations of the
various addressing modes for load and store instructions and pseudo-instructions.
Descriptions have been added to every example instruction and pseudo-instruction.
Improved Assembly Error Capability: If the assemble operation results in errors, the first error message
in the Mars Messages text area will be highighted and the corresponding erroneous instruction will be selected in the
text editor. In addition, you can click on any error message in the Mars Messages text area to select the corresponding
erroneous instruction in the text editor. The first feature does not select in every situation (such as when
assemble-on-open is set) but in the situations where it doesn’t work no harm is done plus
the second feature, clicking on error messages, can still be used.
Console input syscalls (5, 6, 7, 8, 12) executed in the IDE now receive input keystrokes directly in the Run I/O text
area instead of through a popup input dialog. Thanks to Ricardo Pascual for providing this feature!
If you prefer the popup dialogs, there is a setting to restore them.
The floor, ceil, trunc and round operations now all produce the MIPS default result 2^31-1 if the value is
infinity, NaN or out of 32-bit range. For consistency, the sqrt operations now produce the result NaN if the operand is negative
(instead of raising an exception). These cases are all consistent with FCSR (FPU Control and Status Register)
Invalid Operation flag being off. The ideal solution would be to simulate the FCSR register itself so all
MIPS specs for floating point instructions can be implemented, but that hasn’t happened yet.
The Basic column in the Text Segment Window now displays data and addresses in either decimal or
hexadecimal, depending on the current settings. Note that the “address” in branch instructions
is actually an offset relative to the PC, so is treated as data not address. Since data operands in
basic instructions are no more than 16 bits long, their hexadecimal display includes only 4 digits.
The Source column in the Text Segment Window now preserves tab spacing for a cleaner appearance (tab characters were previously not rendered).
Instruction mnemonics can now be used as labels, e.g. “b:”.
New syscall 36 will display an integer as an unsigned decimal.
A new tool, Digital Lab Sim, contributed by Didier Teifreto (dteifreto@lifc.univ-fcomte.fr). This tool
features two seven-segment displays, a hexadecimal keypad, and a counter. It uses MMIO to explore
interrupt-driven I/O in an engaging setting. More information is available from its Help feature. Many thanks!
MARS 4.0 requires Java 1.5 (5.0) instead of 1.4. If this is an issue for you, let me know.
Mars 3.8 was released in January 2010. Enhancements and bug fixes include:
A new feature to temporarily suspend breakpoints you have previously set. Use it
when you feel confident enough to run your program without the breakpoints but not
confident enough to clear them! Use the Toggle Breakpoints item in the Run menu, or
simply click on the “Bkpt” column header in the Text Segment window. Repeat, to re-activate.
Two new Tools contributed by Ingo Kofler of Klagenfurt University in Austria.
One generates instruction statistics and the other simulates branch prediction using
a Branch History Table.
Two new print syscalls. Syscall 34 prints an integer in hexadecimal format.
Syscall 35 prints an integer in binary format. Suggested by Bernardo Cunha of Portugal.
A new Setting to control whether or not the MIPS program counter will be
initialized to the statement with global label ‘main’ if such a statement exists. If
the setting is unchecked or if checked and there is no ‘main’, the program counter
will be initialized to the default starting address. Release 3.7 was programmed
to automatically initialize it to the statement labeled ‘main’. This led to
problems with programs that use the standard SPIM exception handler exceptions.s
because it includes a short statement sequence at the default starting address
to do some initialization then branch to ‘main’. Under 3.7 the initialization
sequence was being bypassed. By default this setting is unchecked. This
option can be specified in command mode using the ‘sm’ (Start at Main) option.
Mars Tools that exist outside of Mars can now be included in the Tools
menu by placing them in a JAR and including it in a command that launches
the Mars IDE. For example: java -cp plugin.jar;Mars.jar Mars
Thanks to Ingo Kofler for thinking of this technique and providing the
patch to implement it.
Corrections and general improvements to the MIDI syscalls. Thanks to Max Hailperin
of Gustavus Adolphus College for supplying them.
Correction to an assembler bug that flagged misidentified invalid MIPS instructions
as directives.
Mars 3.7 was released in August 2009. Enhancements and bug fixes include:
A new feature for changing the address space configuration of the
simulated MIPS machine. The 32-bit address space configuration used by
all previous releases remains the default. We have defined two
alternative configurations for a compact 32KB address space. One starts the
text segment at address 0 and the other starts the data segment at address 0.
A 32KB address space permits commonly-used load/store pseudo-instructions
using labels, such as lw $t0,increment, to expand to a single basic
instruction since the label’s full address will fit into the 16-bit address
offset field without sign-extending to a negative value. This was done in response to
several requests over the years for smaller addresses and simplified expansions
to make assembly programs easier to comprehend. This release does not
include the ability to define your own customized configuration, although we
anticipate adding it in the future. It is available both through the command
mode (option mc) and the IDE.
See Memory Configuration… at the bottom of the Settings menu.
Related to the previous item: load and store pseudo-instructions of the form
lw $t0,label and lw $t0,label($t1) will expand to a single
instruction (addi for these examples) if the current memory configuration assures the
label’s full address will fit into the low-order 15 bits. Instructions
for which this was implemented are: la, lw, lh, lb, lhu, lbu, lwl, lwr, ll,
lwc1, ldc1, l.s, l.d, sw, sh, sb, swl, swr, sc, swc1, sdc1,
s.s, and s.d.
If a file contains a global statement label “main” (without quotes, case-sensitive), then execution will
begin at that statement regardless of its address. Previously, program execution
always started at the base address of the text segment. This will be handy for
multi-file projects because you no longer need to have the “main file” opened in
the editor in order to run the project. Note that main has to be declared global
using the .globl directive.
We have added a Find/Replace feature to the editor. This has been another
frequent request. Access it through the Edit menu or Ctrl-F. Look for major
enhancements to the editor in 2010!
The syscalls for Open File (13), Read from File (14), and Write to File (15)
all now place their return value into register $v0 instead of $a0. The table
in Computer Organization and Design’s Appendix B on SPIM specifies
$a0 but SPIM itself consistently uses $v0 for the return values.
Pseudo-instructions for div, divu, mulo, mulou, rem, remu, seq, sne, sge,
sgeu, sgt, sgtu, sle, sleu now accept a 16- or 32-bit immediate as their third operand.
Previously the third operand had to be a register.
Existing Tools were tested using reconfigured memory address space (see first item). Made some
adaptations to the Keyboard and Display Simulator Tool that allow it to be used for
Memory Mapped I/O (MMIO) even under the compact memory model, where the MMIO base address
is 0x00007f00 instead of 0xffff0000. Highlighting is not perfect in this scenario.
Bug Fix: The syscall for Open File (13) reversed the meanings of the
terms mode and flag. Flags are used to indicate the intended
use of the file (read/write). Mode is used to set file permissions in specific situations.
MARS implements selected flags as supported by Java file streams,
and ignores the mode if specified. For more details, see the Syscalls
tab under Help. The file example in that tab has been corrected.
Bug Fix: The assembler incorrectly generated an
error on Jump instructions located in the kernel text segment.
Bug Fix: The project (p) option in the command interface worked incorrectly
when MARS was invoked within the directory containing the files to be assembled.
Acknowledgement: The development of Release 3.7 was supported by a SIGCSE
Special Projects Grant.
Mars 3.6 was released in January 2009. Enhancements and bug fixes include:
We’ve finally implemented the most requested new feature: memory and register cells will
be highlighted when written to during timed or stepped simulation! The
highlighted memory/register cell thus represents the result of the instruction just completed.
During timed or stepped execution, this is NOT the highlighted instruction. During back-stepping,
this IS the highlighted instruction. The highlighted instruction is the next one
to be executed in the normal (forward) execution sequence.
In conjunction with cell highlighting, we’ve added the ability to customize the highlighting
color scheme and font. Select Highlighting in the Settings menu. In the resulting dialog,
you can select highlight background color, text color, and font for the different runtime tables (Text segment,
Data segment, Registers). You can also select them for normal, not just
highlighted, display by even- and odd-numbered row but not by table.
Cool new Labels Window feature: the table can be sorted in either ascending or descending
order based on either the Label (alphanumeric) or the Address (numeric) column. Just click on
the column heading to select and toggle between ascending (upright triangle) or descending
(inverted triangle). Addresses are sorted based on unsigned 32 bit values.
The setting persists across sessions.
The Messages panel, which includes the Mars Messages and Run I/O tabs, now displays using
a mono-spaced (fixed character width) font. This facilitates text-based graphics when running
from the IDE.
The Mars.jar distribution file now contains all files needed to produce
a new jar file. This will make it easier for you to expand the jar, modify source files,
recompile and produce a new jar for local use. CreatMarsJar.bat contains the jar instruction.
The Help window now includes a tab for Acknowledgements. This recognizes MARS contributors
and correspondents.
We’ve added a new system call (syscall) for generating MIDI tones synchronously, syscall 33.
The original MIDI call returns immediately when the tone is generated. The new one will not return
until the tone output is complete regardless of its duration.
The Data Segment display now scrolls 8 rows (half a table) rather than 16 when the
arrow buttons are clicked. This makes it easier to view a sequence of related cells that
happen to cross a table boundary. Note you can hold down either button for rapid scrolling.
The combo box with various data address boundaries also works better now.
Bug Fix: Two corrections to the Keyboard and Display Simulator Tool. Transmitter Ready bit was
not being reset based on instruction count
when running in the kernel text segment, and the Status register’s Exception Level bit was not
tested before enabling the interrupt service routine (could lead to looping if interrupts occur
w/i the interrupt service routine). Thanks to Michael Clancy and Carl Hauser for bringing these
to my attention and suggesting solutions.
Bug Fix: Stack segment byte addresses not on word boundaries were not being processed
correctly. This applies to little-endian byte order (big-endian is not enabled or tested in MARS).
Thanks to Saul Spatz for recognizing the problem and providing a patch.
Minor Bug Fixes include: Correcting a fault leading to failure when launching MARS in command
mode, clarifying assembler error message for too-few or too-many operands error, and correcting the
description of lhu and lbu instructions from “unaligned” to “unsigned”.
Mars 3.5 was released in August 2008. Major enhancements and bug fixes include:
A new Tool, the Keyboard and Display MMIO Simulator, that supports polled and interrupt-driven
input and output operations through Memory-Mapped I/O (MMIO) memory. The MIPS program writes to
memory locations which serve as registers for simulated devices. Supports keyboard input and a
simulated character-oriented display. Click the tool’s Help button for more details.
A new Tool, the Instruction Counter, contributed by MARS user Felipe Lessa. It will count the
number of MIPS instructions executed along with percentages for R-format, I-format, and J-format
instructions. Thanks, Felipe!
Program arguments can now be provided to the MIPS program at runtime, through either an IDE setting or
command mode. See the command mode “pa” option for more details on command mode operation. The argument
count (argc) is placed in $a0 and the address of an array of null-terminated strings containing the
arguments (argv) is placed in $a1. They are also available on the runtime stack ($sp).
Two related changes permit MARS to assemble source code produced by certain compilers such as gcc.
One change is to issue warnings rather than errors for unrecognized directives. MARS implements a
limited number of directives. Ignore these warnings at your risk, but the assembly can continue.
The second change is to allow statement labels to contain, and specifically begin with, ‘$’.
In command mode, final register values are displayed by giving the register name as an option.
Register names begin with ‘$’, which is intercepted by certain OS command shells. The
convention for escaping it is not uniform across shells. We have enhanced the options so now you can
give the register name without the ‘$’. For instance, you can use t0 instead of $t0 as the option.
You cannot refer to registers by number in this manner, since an integer option is interpreted by
the command parser as an instruction execution limit. Thanks to Lucien Chaubert for reporting
this problem.
Minor enhancements: The command mode dump feature has been extended to permit memory address ranges as well
as segment names. If you enter a new file extension into the Open dialog, the extension will remain available throughout
the interactive session. The data segment value repetition operator ‘:’ now
works for all numeric directives (.word, .half, .byte, .float, .double).
This allows you to initialize multiple consecutive memory locations to the same value. For
example:
ones: .half 1 : 8 # Store the value 1 in 8 consecutive halfwords
Major change: Hexadecimal constants containing less than 8 digits will be interpreted as though the
leading digits are 0’s. For instance, 0xFFFF will be interpreted as 0x0000FFFF, not 0xFFFFFFFF as before.
This was causing problems with immediate operands in the range 32768 through 65535, which were
misinterpreted by the logical operations as signed 32 bit values rather than unsigned 16 bit values.
Signed and unsigned 16 bit values are now distinguished by the tokenizer based on the prototype
symbols -100 for signed and 100 for unsigned (mainly logical operations).
Many thanks to Eric Shade of Missouri State University and Greg Gibeling of UC Berkeley for
their extended efforts in helping me address this situation.
Minor Bug Fixes: round.w.s and round.w.d have been modified to correctly perform IEEE
rounding by default. Thanks to Eric Shade for pointing this out.
Syscall 12 (read character) has been changed to leave the character in $v0 rather then $a0. The
original was based on a misprint in Appendix A of Computer Organization and Design.
MARS would not execute from the executable Mars.jar file if it was stored in a directory
path those directory names contain any non-ASCII characters. This has been corrected. Thanks to
Felipe Lessa for pointing this out and offering a solution.
MARS will now correctly detect the EOF condition when reading from a file using syscall 14.
Thanks to David Reimann for bringing this to our attention.
Mars 3.4.1 was released on 23 January 2008. It is a bug fix release to address two bugs.
One bug shows up in pseudo-instructions in which the expansion includes branch instructions. The fixed branch
offsets were no longer correct due to changes in the calculation of branch offsets in Release 3.4.
At the same time, we addressed the issue of expanding such pseudo-instructions when
delayed branching is enabled. Such expansions will now include a nop instruction following the
branch.
We also addressed an off-by-one error that occurred in generating the lui instruction in the
expansion of conditional branch pseudo-instructions whose second operand is a 32 bit immediate.
The expansions for a number of pseudo-instructions were modified to eliminate internal branches.
These and other expansions were also optimized for sign-extended loading of 16-bit immediate operands
by replacing the lui/ori or lui/sra sequence with addi. Pseudo-instructions affected by one
or both of these modifications include: abs, bleu, bgtu, beq, bne, seq, sge, sgeu, sle, sleu, sne,
li, sub and subi. These modifications were suggested by Eric Shade of Missouri State University.
Mars 3.4 was released in January 2008. Major enhancements are:
A new syscall (32) to support pauses of specified length in milliseconds (sleep) during simulated execution.
Five new syscalls (40-44) to support the use of pseudo-random number generators. An unlimited number of these generators are available,
each identified by an integer value, and for each you have the ability to: set the seed value, generate a 32 bit integer value from the Java
int range, generate a 32 bit integer value between 0 (inclusive) and a specified upper bound (exclusive), generate a 32-bit float value between 0 (inclusive) and 1 (exclusive),
and generate a 64-bit double value between 0 (inclusive) and 1 (exclusive). All are based on the java.util.Random class.
Ten new syscalls (50-59) to support message dialog windows and data input dialog windows. The latter are distinguished from
the standard data input syscalls in that a prompting message is specified as a syscall argument and displayed in the input dialog.
All are based on the javax.swing.JOptionPane class.
The capability to dump .text or .data memory contents to file in various formats. The dump can be performed
before or after program execution from either the IDE (File menu and toolbar) or from command mode. It can also be performed
during an execution pause from the IDE. Look for the “Dump Memory” menu item in the File menu, or the “dump” option in command
mode. A .text dump will include only locations containing an instruction. A .data dump will include a multiple
of 4KB “pages” starting at the segment base address and ending with the last 4KB “page” to be referenced by the
program. Current dump formats include pure binary (java.io.PrintStream.write() method), hexadecimal text with one word (32 bits)
per line, and binary text with one word per line. An interface, abstract class, and format loader have been developed to facilitate
development and deployment of additional dump formats. This capability was prototyped by Greg Gibeling of UC Berkeley.
Changed the calculation of branch offsets when Delayed Branching setting is disabled.
Branch instruction target addresses are represented by
the relative number of words to branch. With Release 3.4, this value reflects delayed branching,
regardless of whether the Delayed Branching setting is enabled or not.
The generated binary code for branches will now match that of examples in the Computer Organization
and Design textbook. This is a change from the past, and was made after extensive discussions
with several MARS adopters. Previously, the branch offset was 1 lower if the Delayed Branching setting
was enabled — the instruction label: beq $0,$0,label would generate 0x1000FFFF if
Delayed Branching was enabled and 0x10000000 if it was disabled. Now it will generate 0x1000FFFF in
either case. The simulator will always branch to the correct location; MARS does not allow assembly under one
setting and simulation under the other.
Bug fix: The mars.jar executable JAR file can now be run from a different working directory. Fix was
suggested by Zachary Kurmas of Grand Valley State University.
Bug fix: The problem of MARS hanging while assembling a pseudo-instruction with a label operand that
contains the substring “lab”, has been fixed.
Bug fix: No Swing-related code will be executed when MARS is run in command mode. This fixes a problem that
occurred when MARS was run on a “headless” system (no monitor). Swing is the Java library to support
programming Graphical User Interfaces. Fix was provided by Greg Gibeling of UC Berkeley.
The ‘\0’ character is now recognized when it appears in string literals.
MARS 3.3 was released in July 2007. Major enhancements are:
Support for MIPS delayed branching. All MIPS computers implement this but it can be confusing for
programmers, so it is disabled by default. Under delayed branching, the next instruction after a branch
or jump instruction will always be executed, even if the branch or jump is taken! Many
programmers and assemblers deal with this by inserting a do-nothing “nop” instruction after every branch or jump.
The MARS assembler does not insert a “nop”. Certain pseudo-instructions expand to
a sequence that includes a branch; such instructions will not work correctly under delayed
branching.
Delayed branching is available in command mode with the “db” option.
A new tool of interest mainly to instructors. The Screen Magnifier tool, when selected from
the Tools menu, can be used to produce an enlarged static image of the pixels that lie beneath it.
The image can be annotated by dragging the mouse over it to produce a scribble line. It enlarges
up to 4 times original size.
You now have the ability to set and modify the text editor font family, style and size. Select
“Editor…” from the Settings menu to get the dialog. Click the Apply button to see the new
settings while the dialog is still open. Font settings are retained from one session to the next.
The font family list begins with 6 fonts commonly used across platforms (selected from lists
found at www.codestyle.org), followed by a complete list.
Two of the six are monospaced fonts, two are proportional serif, and two are proportional sans serif.
The Labels window on the Execute pane, which displays symbol table information, has been
enhanced. When you click on a label name or its address, the contents of that address are
centered and highlighted in the Text Segment window or Data Segment window as appropriate. This makes
it easier to set breakpoints based on text labels, or to find the value stored at a label’s address.
If you re-order the columns in the Text Segment window by dragging a column header,
the new ordering will be remembered and applied from that time forward, even from one MARS session to the next. The Text Segment
window is where source code, basic code, binary code, code addresses, and breakpoints are displayed.
If a MIPS program terminates by “running off the bottom” of the program, MARS terminates, as
before, without an exception, but now will display a more descriptive termination message in the
Messages window. Previously, the termination message was the same as that generated after executing an Exit syscall.
A new system call (syscall) to obtain the system time is now available. It is service
30 and is not available in SPIM. Its value is obtained from the java.util.Date.getTime() method.
See the Syscall tab in MIPS help for further information.
A new system call (syscall) to produce simulated MIDI sound through your sound card is now available.
It is service 31 and is not available in SPIM. Its implementation is based on the
javax.sound.midi package. It has been tested only under Windows.
See the Syscall tab in MIPS help for further information.
MARS 3.2.1 was released in January 2007. It is a bug fix release that addresses the
following bug in 3.2: a NullPointerException occurs when MIPS program execution terminates
by “dropping off the bottom” of the program rather than by using one of the Exit system
calls.
MARS 3.2 was released in December 2006. Major enhancements are:
It fixes several minor bugs, including one that
could cause incorrect file sequencing in the Project feature.
It includes the
AbstractMarsToolAndApplication abstract class to serve as a framework for easily
constructing “tools” and equivalent free-standing applications that use the MARS assembler
and simulator engines (kudos to the SIGCSE 2006 audience member who suggested this capability!).
A subclass of this abstract class can be used both ways (tool or application).
The floating
point and data cache tools were elaborated in this release and a new tool for animating and
visualizing memory references was developed. All are AbstractMarsToolAndApplication
subclasses.
This release includes support for exception handlers: the kernel data and text
segments (.kdata and .ktext directives), the MIPS trap-related instructions, and the ability
to automatically include a selected exception (trap) handler with each assemble operation.
Items in the Settings menu became persistent with this release.
Added default assembly file extensions “asm” and “s” to the Config.properties file and used
those not only to filter files for the File Open dialog but also to filter them for the “assemble all”
setting.
Implemented a limit to the amount of text scrollable in the Mars Messages and Run I/O message
tabs – default 1 MB is set in the Config.properties file.
For programmer convenience, labels can now be referenced in the operand field of integer
data directives (.word, .half, .byte). The assembler will substitute the label’s address (low order
half for .half, low order byte for .byte).
For programmer convenience, character literals (e.g. ‘b’, ‘\n’, ‘\377’) can be used anywhere that integer literals are
permitted. The assembler converts them directly to their equivalent 8 bit integer value. Unicode is not supported and
octal values must be exactly 3 digits ranging from ‘\000’ to ‘\377’.
Replaced buttons for selecting Data Segment display base addresses with a combo box and added more
base addresses: MMIO (0xFFFF0000), .kdata (0x90000000), .extern (0x10000000).
MARS 3.1 was released in October 2006. The major issues and features are listed here:
It addressed several minor limits (Tools menu items
could not be run from the JAR file, non-standard shortcuts for Mac users, inflexible and
sometimes inappropriate sizing of
GUI components).
It changed the way SYSCALLs are implemented, to allow anyone to define
new customized syscall services without modifying MARS.
It added a primitive
Project capability through the “Assemble operation applies to all files in current directory.”
setting (also available as “p” option in command mode). The command mode also allows you
to list several file names not necessarily in the same directory to be assembled and linked.
Multi-file assembly also required implementing the “.globl” and “.extern” directives.
And although “Mars tools” are not officially part of MARS releases, MARS 3.1 includes the
initial versions of two tools: one for learning about floating point representation and another
for simulating data caching capability.
MARS 3.0 was released in August 2006, with one bug fix and two major additions.
The bug fix was corrected instruction format for the slti and sltiu instructions.
One major addition is a greatly expanded MIPS-32 instruction
set (trap instructions are the only significant ones to remain unimplemented). This includes, via
pseudo-instructions, all reasonable memory addressing modes for the load/store instructions.
The
second major addition is ability to interactively step “backward” through program execution
one instruction at a time to “undo” execution steps. It will buffer up to 2000 of the most
recent execution steps (this limit is stored in a properties file and can be changed).
It will undo changes made to MIPS memory, registers or condition flags,
but not console or file I/O. This should be a great debugging aid.
It is available anytime execution is paused and at termination (even if terminated due to
exception).
A number of IDE settings, described
above, are now available through the Settings menu.
MARS 2.2 was released in March 2006 with additional bug fixes and implemented command
line options (run MARS from command line with h option for command line help). This also coincides with our
SIGCSE 2006 paper “MARS: An Education-Oriented MIPS Assembly Language Simulator”.
MARS 2.1 was released in October 2005 with some bug fixes.
MARS 2.0 was released in September 2005. It incorporated significant
modifications to both the GUI and the assembler, floating point registers and instructions
most notably.
MARS 1.0 was released in January 2005 and
publicized during a poster presentation at SIGCSE 2005.
Dr. Ken Vollmar initiated MARS development in 2002 at Missouri State University. In
2003, Dr. Pete Sanderson of Otterbein College and his student Jason Bumgarner continued
implementation. Sanderson implemented the assembler and simulator that summer, and
the basic GUI the following summer, 2004.
The development of Releases 3.1 and 3.2 in 2006 and 4.0 in 2010 were supported by the Otterbein College
sabbatical leave program. The development of Release 3.7 during summer 2009 was supported by
a SIGCSE Special Projects Grant.
This document is available for printing on the MARS home page
http://www.cs.missouristate.edu/MARS/.
MARS 4.5 help contents
MARS – Mips Assembly and Runtime Simulator
Release 4.5
August 2014
Using MARS through its Integrated Development Environment (IDE)
The IDE is invoked when MARS is run with no command arguments, e.g. java -jar mars.jar.
It may also be launched from a graphical interface by double-clicking the mars.jar icon
that represents this executable JAR file.
The IDE provides basic editing, assembling and execution capabilities. Hopefully it
is intuitive to use. Here are comments on some features.
Menus and Toolbar: Most menu items have equivalent toolbar icons.
If the function of a toolbar icon is not obvious, just hover the mouse over it and
a tool tip will soon appear. Nearly all menu items also have keyboard shortcuts.
Any menu item not appropriate in a given situation is disabled.
Editor: MARS includes two integrated text editors. The default editor, new
in Release 4.0, features syntax-aware color highlighting of most MIPS language elements
and popup instruction guides. The original, generic, text editor without these features
is still available and can be selected in the Editor Settings dialog. It supports a single
font which can be modified in the Editor Settings dialog.
The bottom border of either editor includes the cursor line
and column position and there is a checkbox to display line numbers.
They are displayed outside the editing area. If you use an external editor, MARS provides
a convenience setting that will automatically assemble a file as soon as it is opened. See
the Settings menu.
Message Areas: There are two tabbed message areas at the
bottom of the screen. The Run I/O tab is used at runtime for
displaying console output and entering console input as program execution progresses.
You have the option of entering console input into a pop-up dialog then echoes to the message area.
The MARS Messages tab is used for other messages such as assembly or
runtime errors and informational messages. You can click on assembly error messages to
select the corresponding line of code in the editor.
MIPS Registers: MIPS registers are displayed at all times, even
when you are editing and not running a program. While writing your program,
this serves as a useful reference for register names and their conventional
uses (hover mouse over the register name to see tool tips). There are three
register tabs: the Register File (integer registers $0 through $31 plus LO,
HI and the Program Counter), selected Coprocesor 0 registers (exceptions and
interrupts), and Coprocessor 1 floating point registers.
Assembly: Select Assemble from the Run menu or the
corresponding toolbar icon to assemble the file currently in the Edit tab.
Prior to Release 3.1, only one file could be assembled and run at a time.
Releases 3.1 and later provide a primitive Project capability. To use it, go to the
Settings menu and check Assemble operation applies to all
files in current directory. Subsequently, the assembler will assemble
the current file as the “main” program and also assemble all other assembly
files (*.asm; *.s)
in the same directory. The results are linked and if all these
operations were successful the program can be executed. Labels that are
declared global with the “.globl” directive may be referenced in any of the
other files in the project. There is also a setting that permits
automatic loading and assembly of a selected exception handler file. MARS uses
the MIPS32 starting address for exception handlers: 0x80000180.
Execution: Once a MIPS program successfully assembles, the
registers are initialized and three windows
in the Execute tab are filled: Text Segment, Data Segment,
and Program Labels. The major execution-time features are described below.
Labels Window: Display of the Labels window (symbol table) is
controlled through the Settings menu. When displayed, you can click on any label
or its associated address to center and highlight the contents of that address
in the Text Segment window or Data Segment window as appropriate.
The assembler and simulator are invoked from the IDE
when you select the Assemble, Go,
or Step operations from the Run menu or their corresponding
toolbar icons or keyboard shortcuts. MARS messages are displayed on the
MARS Messages tab of the message area at the bottom of the screen.
Runtime console input and output is handled in the Run I/O tab.
This document is available for printing on the MARS home page
http://www.cs.missouristate.edu/MARS/.
MARS 4.5 help contents
MARS – Mips Assembly and Runtime Simulator
Release 4.5
August 2014
Introduction
MARS, the Mips Assembly and Runtime Simulator,
will assemble and simulate the execution of MIPS assembly language programs.
It can be used either from a command line or through its
integrated development environment (IDE). MARS is written in Java and
requires at least Release 1.5 of the J2SE Java Runtime Environment (JRE) to work.
It is distributed as an executable JAR file.
The MARS home page
is
http://www.cs.missouristate.edu/MARS/. This document is available for printing there.
As of Release 4.0, MARS assembles and simulates 155 basic instructions of the MIPS-32
instruction set, approximately 370 pseudo-instructions or instruction variations, the 17 syscall functions
mainly for console and file I/O defined by SPIM, and an additional 22 syscalls for other uses such as MIDI
output, random number generation and more. These are listed in separate help tabs. It supports seven
different memory addressing modes for load and store instructions: label, immed,
label+immed, ($reg), label($reg), immed($reg), and label+immed($reg), where immed
is an integer up to 32 bits. A setting is available to disallow use of pseudo-instructions
and extended instruction formats and memory addressing modes.
Our guiding reference in implementing the instruction set has been
Computer Organization and Design, Fourth Edition by Patterson and Hennessy,
Elsevier – Morgan Kaufmann, 2009. It summarizes the MIPS-32 instruction set
and pseudo-instructions in Figures 3.24 and 3.25 on pages 279-281, with details
provided in the text and in Appendix B. MARS Releases 3.2 and above implement all the instructions
in Appendix B and those figures except the delay branches from the left column of Figure 3.25.
It also implements all the system services (syscalls) and assembler directives
documented in Appendix B.
The MARS IDE provides program editing and assembling but its real
strength is its support for interactive debugging. The programmer can easily set and
remove execution breakpoints or step through execution forward or backward (undo) while
viewing and directly editing register and memory contents.
Questions and Comments
Send MARS questions and comments to
Dr. Pete Sanderson at PSanderson@otterbein.edu or
Dr. Ken Vollmar at KenVollmar@missouristate.edu.
We will respond as quickly as we can but as teaching professors do not have as much time to work on
this project as we would like during the school year. We presented papers
on MARS at the 2005 CCSC:MW conference and the 2006 SIGCSE Technical Symposium. We presented
a tutorial session on MARS at the 2007 CCSC:CP conference and the Tutorial handout is available
from the MARS homepage.
This document is available for printing on the MARS home page
http://www.cs.missouristate.edu/MARS/.
MARS 4.5 help contents
MARS – Mips Assembly and Runtime Simulator
Release 4.5
August 2014
Operating Requirements
MARS is written in Java and
requires at least Release 1.5 of the J2SE Java Runtime Environment (JRE) to work.
The graphical IDE is implemented using Swing. It has been
tested on Windows XP, Vista and 7; Mac OS X; and is also being used under Linux.
Some MARS Assembler and Simulator Limitations
Releases 3.0 and later assemble and simulate nearly all the MIPS32 instructions documented in the
textbook Computer Organization and Design, Fourth Edition by Patterson and Hennessy,
Elsevier – Morgan Kaufmann, 2009. All basic and pseudo instructions, directives,
and system services described in Appendix B are implemented.
Limitations of MARS as of Release 4.5 include:
Memory segments (text, data, stack, kernel text, kernel data) are limited to 4MB each starting at their
respective base addresses.
There is no pipelined mode (but delayed branching is supported).
If you open a file which is a link or shortcut to another file, MARS will not
open the target file. The file open dialog is implemented using Java Swing’s JFileChooser,
which does not support links.
Very few configuration changes, besides those in the Settings menu, are saved from one session to the next.
The editor settings, which include font settings and display of line numbers, are saved.
The IDE will work only with the MARS assembler. It cannot be used
with any other compiler, assembler, or simulator. The MARS assembler and simulator
can be used either through the IDE or from a command prompt.
Bug:The error message highlighter does not automatically select the code for the first assembly
error if the file containing the error is not open at the time of assembly (assemble-on-open, assemble-all).
Bug: The Screen Magnifier screen capture feature does not appear to work properly under Windows Vista.
Bug: There appears to be a memory leak in the Editor. Several different people have independently
reported the same behavior: severe slowdown in editor response during an extended interactive session.
If MARS is exited and restarted, this behavior disappears and the editor responds instantly to actions.
Not a bug, but documented here anyway: MIPS Branch instruction target addresses are represented by
the relative number of words to branch. With Release 3.4, this value reflects delayed branching,
regardless of whether the Delayed Branching setting is enabled or not.
The generated binary code for branches will now match that of examples in the Computer Organization
and Design textbook. This is a change from the past, and was made after extensive discussions
with several faculty adopters of MARS. Previously, the branch offset was 1 lower if the Delayed Branching setting
was enabled — the instruction label: beq $0,$0,label would generate 0x1000FFFF if
Delayed Branching was enabled and 0x10000000 if it was disabled. Now it will generate 0x1000FFFF in
either case. The simulator will always branch to the correct location; MARS does not allow assembly under one
setting and simulation under the other to occur.
This document is available for printing on the MARS home page
http://www.cs.missouristate.edu/MARS/.
MARS 4.5 help contents
MARS – Mips Assembly and Runtime Simulator
Release 4.5
August 2014
Configuration Settings
Releases 3.0 and later include a Settings menu. The Editor and Exception Handler items launch a dialog but the rest are each
controlled by a checkbox for selecting or deselecting it (checked means true, unchecked means false). Settings and their default
values are:
Display the Labels window in the Execute tab. Default value is false. If selected, the Labels window,
which shows the name and associated address for each label defined in the program, will be
displayed to the right of the Text Segment.
Provide program arguments to the MIPS program. Default value is false. New in Release 3.5.
If selected, a text field will appear at the top of the Text Segment Display. Any argument values in this
text field at the time of program execution will be stored in MIPS memory prior to execution. The argument
count (argc) will be placed in register $a0, and the address of an array of null-terminated strings containing
the arguments (argv) will be placed in register $a1. These values are also available on the runtime stack ($sp).
Popup Dialog for input syscalls (5,6,7,8,12). New in Release 4.0. Default value is false. If selected, runtime console
input will be entered using popup dialogs (this was the only option prior to Release 4.0). Otherwise, input is entered
directly into the Run I/O tab at the bottom of the screen.
Display memory addresses in hexadecimal. Default value is true. If deselected, addresses will be displayed in decimal.
This setting can also be toggled in a checkbox on the lower border of the Data Segment Window.
Display memory and register contents in hexadecimal. Default value is true. If deselected, vlaues will be displayed in decimal.
This setting can also be toggled in a checkbox on the lower border of the Data Segment Window.
Assemble a file automatically as soon as it is opened, and initialize the File Open dialog with the most-recently opened file.
Default value is false. This is convenient if you use an external editor for composing your programs.
Assemble applies to all files in directory. Default value is false.
If selected, the file currently open in the
editor will become the “main” program in a multi-file assemble-and-link operation involving all
assembly files (*.asm; *.s) in its directory. If successful, execution will begin with the currently open file.
Assembler warnings are considered errors. Default value is false. New in Release 3.5.
If selected, the assemble operation will fail if any warnings are produced. At this time, all assembler warnings
relate to unrecognized or ignored directives. MARS may be able to assemble code produced by compilers for other MIPS
assemblers if this setting is deselected.
Initialize Program Counter to global ‘main’ if defined. Default value is false. New in Release 3.8.
If selected, the Program Counter will be initialized to the address of the text segment statement with the global label ‘main’ if it
exists. If it does not exist or if the setting is not selected, the Program Counter will be initialized to the default text segment
starting address.
Permit programs to use extended (pseudo) instructions and formats. Default value is true. This includes all memory addressing
modes other than the MIPS native mode (16 bit constant offset added to register content).
Assemble and execute programs using delayed branching. Default value is false. MIPS processors use delayed branches
as part of the pipelined design, but it can be confusing to programmers. With delayed branching, the instruction
following a branch or jump instruction will always be executed even if the branch condition is true! Assemblers
and, failing that, programmers, often deal with this by following branches and jumps with a “nop” instruction. The MARS
assembler does not insert a nop. When delayed branching was introduced in Release 3.3, the machine code generated
for a branch instruction depended on this setting since
its target value is relative to the Program Counter (PC-relative addressing). Although technically correct, this led to
confusion in the MARS community because the generated code did not match textbook examples. Starting with Release 3.4, the relative branching
offset is always calculated as if delayed branching is enabled even when it is not. The runtime simulation adjusts accordingly.
Self-modifying code. Default value is false. New in Release 4.4.
If selected, a running MIPS program can write to a user text segment address and can branch/jump to a user data segment address.
These capabilities permit a program to dynamically generate and/or modify its binary code. Also permits interactive modification of
text segment contents through either the Data Segment or Text Segment windows.
The Editor dialog. Use it to view and modify editor font settings. New with Release 3.3.
The Highlighting dialog. Use it to modify color and font settings for the highlighting of table items in the
Text Segment window, Data Segment window, Registers window, Coprocessor0 window and Coprocessor1 window.
Highlighting occurs during timed, stepped, and backstepped simulation. Color and font for normal (non-highlighted)
display can also be set separately for even-numbered and odd-numbered display rows but not individually by windows.
New with Release 3.6.
The Exception Handler dialog. It has the setting: Include this
exception handler in all assemble operations. Default value is false. If selected, a button to browse to the desired
file is enabled. New with Release 3.2
The Memory Configuration dialog. Use it to select from among available MIPS address space configurations.
The default configuration is derived from SPIM; it was only one available from MARS 1.0 through MARS 3.6.
New with Release 3.7.
Beginning with Release 3.2, settings are retained from one interactive session to the next. Settings are stored in a system-dependent
way as specified by java.util.prefs.Preferences. Windows systems use the Registry.
These settings are independent of command options given when using MARS from a command line;
neither affects the other. We anticipate future releases will include additional settings and preferences.
This document is available for printing on the MARS home page
http://www.cs.missouristate.edu/MARS/.
MARS 4.5 help contents
MARS – Mips Assembly and Runtime Simulator
Release 4.5
August 2014
Cool Capability: Plug-in Tools
Beginning with Release 2.0, MARS is capable of running externally-developed
software that interacts with an executing MIPS program and MIPS system
resources.
The requirements for such a program are:
It implements the mars.tools.MarsTool interface.
It is part of the mars.tools package.
It compiles cleanly into a “.class” file, stored in the mars/tools directory.
MARS will detect all qualifying tools upon startup and include them in
its Tools menu.
When a tool’s menu item is selected, an instance of it will be created using its no-argument
constructor and its action() method will be invoked.
If no qualifying tools are found at MARS startup, the Tools menu will not
appear.
To use such a tool, load and assemble a MIPS program of interest then select the desired tool
from the Tools menu. The tool’s window will open and depending on how it is written it will either
need to be “connected” to the MIPS program by clicking a button or will already be connected. Run
the MIPS program as you normally would, to initiate tool interaction with the executing program.
Beginning with Release 3.2, the abstract class mars.tools.AbstractMarsToolAndApplication
is included in the MARS distribution to provide
a substantial framework for implementing your own MARS Tool. A subclass that extends it by
implementing at least its two abstract methods can be run not only from the Tools menu but also
as a free-standing application that uses the MARS assembler and simulator in the background.
Several Tools developed by subclassing AbstractMarsToolAndApplication are included
with MARS: an Introduction to Tools, a Data Cache Simulator, a Memory Reference Visualizer, and
a Floating Point tool. The last one is quite useful even when not connected to a MIPS program
because it displays binary, hexadecimal and decimal representations for a 32 bit floating point
value; when any of them is modified the other two are updated as well.
Release 3.5 includes new tools, most notably a keyboard and display simulator that allows you
to perform memory-mapped I/O (MMIO) using polled and interrupt-driven techniques as described
in various references. Click its Help button for more details.
If you wish to develop your own MARS Tool, you will first need to extract the MARS distribution
from its JAR file if you have not already done so. All MARS tools must
be stored in the mars/tools directory.
Follow the Tutorial Materials link on the MARS homepage to find a tutorial
that covers development of MARS Tools.
Cool Capability: Extending the syscall set or reassigning syscall numbers
Beginning with Release 3.1, system calls (syscall instruction) are implemented using
a technique similar to that for tools. This permits anyone to add a new syscall by defining
a new class that meets these requirements:
It implements the mars.mips.instructions.syscalls.Syscall interface, or
extends the mars.mips.instructions.syscalls.AbstractSyscall class (which
provides default implementations of everything except the simulate() method).
It is part of the mars.mips.instructions.syscalls package.
It compiles cleanly into a “.class” file, stored in the
mars/mips/instructions/syscalls directory.
MARS will detect all qualifying syscall classes upon startup and the runtime simulator
will invoke them when the syscall instruction is simulated and register $v0
contains the corresponding integer service number.
Syscalls and syscall number assignments in MARs match those of SPIM for syscalls 1 through 17.
However if you wish to change syscall number assignments, you may do so by editing the
Syscall.properties file included in the release (this requires extraction from the JAR
file).
Follow the Tutorial Materials link on the MARS homepage to find a tutorial
that covers development of system calls.
Cool Capability: Extending the instruction set
You can add customized pseudo-instructions to the MIPS instruction set by editing
the PseudoOps.txt file included in the MARS distribution. Instruction
specification formats are explained in the file itself.
The specification of a pseudo-instruction is one line long. It consists of
an example of the instruction, constructed using
available instruction specification symbols, followed by a tab-separated
list of the basic MIPS instructions it will expand to. Each is an instruction template
constructed using
instruction specification symbols combined with special template
specification symbols. The latter permit substitution at program
assembly time of operands from the user’s program into the expanded
pseudo-instruction.
PseudoOps.txt is read and processed at MARS startup, and error messages will
be produced if a specification is not correctly formatted. Note that if you wish to
edit it you first have to extract it from the JAR file.
Follow the Tutorial Materials link on the MARS homepage to find a tutorial
that covers modification of the pseudo-instruction set.
This document is available for printing on the MARS home page
http://www.cs.missouristate.edu/MARS/.
The MIPS Instruction Set
The MIPS Instruction Set
Written by Walter Chang
Used by permission of the author. Copyright notice below.
Correct pronunciation is critical to get the cadence and beat to line
up; see the Pronunciation
Guide at the end of this document for how you should pronounce the various
assembler instructions.
To the tune of: The Major-General’s Song, from
Pirates of Penzance
Inspired by Tom Lehrer’s The Elements
There’s div and nor and mult and or and sllv sra
There’s xor and swl and beq and sll and bgezal jumps today
And multu, srav, and j combined with lhu and lui
And also slt and bne and instruction mthi
There’s sh and sb and lbu and blez and jal and then sltu
And of course there’s and and add and srl and sub and things to do
With the MIPS instructions I am very nimble on my feet
And though I sing assembler but I am really not a geek
There’s addu, ori, slti, swr, and bgez and jalr too
And loads of other fun instructions that were put in just for you
The MIPS instruction set is very simple to be memorized
Which will come in handy when you have your code to optimize!
There’s addi, divu, lh, rfe, and syscall, jr, mfcz
And mfc1, nop, and break, and bltzal with bczt
And srlv, xori, bltz, and lb, lwl, and addiu
andi, subu, lwr, and lwcz, mtcz, sltiu
There’s bczf, bgtz to branch if it’s greater than
And mflo and sw, these instructions are not any also-rans
There’s mtlo and swcz too, although I don’t know what they’re for
And lw – that’s obviously load word from mem bytes there are four
And now my song is through and I know all of my words by the heart
Which will come in handy when we have our projects multi-part
I live and breathe the MIPS instruction set on every night and day
Because the MIPS assembler will always try and work my way!
Pronunciation Guide
note: assembler is 4 syllables: ass-em-bell-er
The pronunciations suitable for this song are as follows:
div: div
nor: nor
mult: mult
or: or
sllv: s-l-l-v
sra: s-r-a
xor: zor
swl: swill
beq: beck
sll: sill
bgezal: beh-geezal
multu: mult-you
srav: srav (one syllable)
j: jay
lhu: l-h-u
lui: l-u-i
slt: slit
bne: b-n-e
mthi: m-t-high
sh: shih
sb: sib
lbu: l-b-u
blez: blez
jal: jal
sltu: slit-u
and: and
add: add
srl: srill
sub: sub
addu: add-u
ori: or-i
slti: slitty
swr: swir
bgez: beh-gez
jalr: jal-er
addi: addy
divu: div-u
lh: l-h
rfe: reef
syscall: sis-call
jr: junior
mfcz: miff-c-z
mfc1: m-f-c-one
nop: nopp
break: break
bltzal: blitz-al
bczt: b-c-z-t
srlv: s-r-l-v
xori: zorri
bltz: blitz
lb: l-b
lwl: lwill
addiu: addy-you
andi: andy
subu: sub-u
lwr: lwer
lwcz: lwiscz
mtcz: m-t-c-z
sltiu: slitty-u
bzcf: b-z-c-f
bgtz: b-g-t-z
mflo: em-flow
sw: swee
mtlo: m-t-low
swcz: swizzy
lw: lwee
http://www.cs.utexas.edu/users/walter/cs-songbook/instruction_set.html
Copyright Walter Chang. Permission granted for noncommercial use
as long as attribution is maintained. walter@cs.utexas.edu
MIPS/SPIM Reference Card
CORE INSTRUCTION SET (INCLUDING PSEUDO INSTRUCTIONS)
MNE- FOR- OPCODE/
MON- MAT FUNCT
NAME IC OPERATION (in Verilog) (Hex)
Add add R R[rd]=R[rs]+R[rt] (1) 0/20
Add Immediate addi I R[rt]=R[rs]+SignExtImm (1)(2) 8
Add Imm. Unsigned addiu I R[rt]=R[rs]+SignExtImm (2) 9
Add Unsigned addu R R[rd]=R[rs]+R[rt] (2) 0/21
Subtract sub R R[rd]=R[rs]-R[rt] (1) 0/22
Subtract Unsigned subu R R[rd]=R[rs]-R[rt] 0/23
And and R R[rd]=R[rs]&R[rt] 0/24
And Immediate andi I R[rt]=R[rs]&ZeroExtImm (3) c
Nor nor R R[rd]=∼(R[rs]|R[rt]) 0/27
Or or R R[rd]=R[rs]|R[rt] 0/25
Or Immediate ori I R[rt]=R[rs]|ZeroExtImm (3) d
Xor xor R R[rd]=R[rs]ˆR[rt] 0/26
Xor Immediate xori I R[rt]=R[rs]ˆZeroExtImm e
Shift Left Logical sll R R[rd]=R[rs]�shamt 0/00
Shift Right Logical srl R R[rd]=R[rs]�shamt 0/02
Shift Right Arithmetic sra R R[rd]=R[rs]�>shamt 0/03
Shift Left Logical Var. sllv R R[rd]=R[rs]�R[rt] 0/04
Shift Right Logical Var. srlv R R[rd]=R[rs]�R[rt] 0/06
Shift Right Arithmetic Var. srav R R[rd]=R[rs]�>R[rt] 0/07
Set Less Than slt R R[rd]=(R[rs]
Branch Less Than Or Equal ble P if(R[rs]<=R[rt]) PC=PC+4+BranchAddr
Branch Greater Than Or Equal bge P if(R[rs]>=R[rt]) PC=PC+4+BranchAddr
Jump j J PC=JumpAddr (5) 2
Jump And Link jal J R[31]=PC+4; (5) 2
PC=JumpAddr
Jump Register jr R PC=R[rs] 0/08
Jump And Link Register jalr R R[31]=PC+4; 0/09
PC=R[rs]
Move move P R[rd]=R[rs]
Load Byte lb I R[rt]={24’b0, M[R[rs]+ZeroExtImm](7:0)} (3) 20
Load Byte Unsigned lbu I R[rt]={24’b0, M[R[rs]+SignExtImm](7:0)} (2) 24
Load Halfword lh I R[rt]={16’b0, M[R[rs]+ZeroExtImm](15:0)} (3) 25
Load Halfword Unsigned lhu I R[rt]={16’b0, M[R[rs]+SignExtImm](15:0)} (2) 25
Load Upper Imm. lui I R[rt]={imm,16’b0} f
Load Word lw I R[rt]=M[R[rs]+SignExtImm] (2) 23
Load Immediate li P R[rd]=immediate
Load Address la P R[rd]=immediate
Store Byte sb I M[R[rs]+SignExtImm] (7:0)=R[rt](7:0) (2) 28
Store Halfword sh I M[R[rs]+SignExtImm] (15:0)=R[rt](15:0) (2) 29
Store Word sw I M[R[rs]+SignExtImm]=R[rt] (2) 2b
REGISTERS
NAME NMBR USE STORE?
$zero 0 The Constant Value 0 N.A.
$at 1 Assembler Temporary No
$v0-$v1 2-3 Values for Function Results and
Expression Evaluation
No
$a0-$a3 4-7 Arguments No
$t0-$t7 8-15 Temporaries No
$s0-$s7 16-23 Saved Temporaries Yes
$t8-$t9 24-25 Temporaries No
$k0-$k1 26-27 Reserved for OS Kernel No
$gp 28 Global Pointer Yes
$sp 29 Stack Pointer Yes
$fp 30 Frame Pointer Yes
$ra 31 Return Address Yes
$f0-$f31 0-31 Floating Point Registers Yes
(1) May cause overflow exception
(2) SignExtImm ={16{immediate[15]},immediate }
(3) ZeroExtImm ={16{1b’0},immediate }
(4) BranchAddr = {14{immediate[15]},immediate,2’b0 }
(4) JumpAddr = {PC[31:28], address, 2’b0 }
(6) Operands considered unsigned numbers (vs. 2 s comp.)
BASIC INSTRUCTION FORMATS,
FLOATING POINT INSTRUCTION FORMATS
R 31 opcode 2625 rs 2120 rt 1615 rd 1110 shamt 65 funct 0
I 31 opcode 2625 rs 2120 rt 1615 immediate 0
J 31 opcode 2625 immediate 0
FR 31 opcode 2625 fmt 2120 ft 1615 fs 1110 fd 65 funct 0
FI 31 opcode 2625 fmt 2120 rt 1615 immediate 0
Copyright c© 2007 Jan Wätzig, Staatliche Studienakademie Dresden (www.ba-dresden.de/∼jan)
This reference card may be used for educational purposes only.
http://www.ba-dresden.de/~jan
ARITHMETIC CORE INSTRUCTION SET
MNE- FOR- OPCODE/
MON- MAT FMT/FT/
NAME IC OPERATION (in Verilog) FUNCT
Divide div R Lo=R[rs]/R[rt]; 0/–/–/1a
Hi=R[rs]%R[rt]
Divide Unsigned divu R Lo=R[rs]/R[rt]; (6) 0/–/–/1b
Hi=R[rs]%R[rt]
Multiply mult R {Hi,Lo}=R[rs]∗R[rt] 0/–/–/18
Multiply Unsigned multu R {Hi,Lo}=R[rs]∗R[rt] (6) 0/–/–/19
Branch On FP True bc1t FI if(FPCond) PC=PC+4+BranchAddr (4) 11/8/1/–
Branch On FP False bc1f FR if(!FPCond) PC=PC+4+BranchAddr (4) 11/8/0/–
FP Compare Single c.x.s∗ FR FPCond=(F[fs] op F[ft])?1:0 11/10/–/y
FP Compare Double c.x.d∗ FR FPCond=({F[fs],F[fs+1]} op {F[ft],F[ft+1]})?1:0 11/11/–/y
∗(x is eq, lt or le) (op is ==, < or <=) (y is 32, 3c or 3e)
FP Add Single add.s FR F[fd]=F[fs]+F[ft] 11/10/–/0
FP Divide Single div.s FR F[fd]=F[fs]/F[ft] 11/10/–/3
FP Multiply Single mul.s FR F[fd]=F[fs]∗F[ft] 11/10/–/2
FP Subtract Single sub.s FR F[fd]=F[fs]-F[ft] 11/10/–/1
FP Add Double add.d FR {F[fd],F[fd+1]}={F[fs],F[fs+1]}+{F[ft],F[ft+1]} 11/11/–/0
FP Divide Double div.d FR {F[fd],F[fd+1]}={F[fs],F[fs+1]}/{F[ft],F[ft+1]} 11/11/–/3
FP Multiply Double mul.d FR {F[fd],F[fd+1]}={F[fs],F[fs+1]}∗{F[ft],F[ft+1]} 11/11/–/2
FP Subtract Double sub.d FR {F[fd],F[fd+1]}={F[fs],F[fs+1]}-{F[ft],F[ft+1]} 11/11/–/1
Move From Hi mfhi R R[rd]=Hi 0/–/–/10
Move From Lo mflo R R[rd]=Lo 0/–/–/12
Move From Control mfc0 R R[rd]=CR[rs] 16/0/–/0
Load FP Single lwc1 I F[rt]=M[R[rs]+SignExtImm] (2) 31/–/–/–
Load FP Double ldc1 I F[rt]=M[R[rs]+SignExtImm]; (2) 35/–/–/–
F[rt+1]=M[R[rs]+SignExtImm+4]
Store FP Single swc1 I M[R[rs]+SignExtImm]=F[rt] (2) 39/–/–/–
Store FP Double sdc1 I M[R[rs]+SignExtImm]=F[rt]; (2) 3d/–/–/–
M[R[rs]+SignExtImm+4]=F[rt+1]
ASSEMBLER DIRECTIVES
.data [addr]∗ Subsequent items are stored in the data segment
.kdata [addr]∗ Subsequent items are stored in the kernel data segment
.ktext [addr]∗ Subsequent items are stored in the kernel text segment
.text [addr]∗ Subsequent items are stored in the text
∗ starting at [addr] if specified
.ascii str Store string str in memory, but do not null-terminate it
.asciiz str Store string str in memory and null-terminate it
.byte b1, . . . , bn Store the n values in successive bytes of memory
.double d1, . . . , dn Store the n floating-point double precision numbers in successive memory locations
.float f1, . . . , f1 Store the n floating-point single precision numbers in successive memory locations
.half h1, . . . , hn Store the n 16-bit quantities in successive memory halfwords
.word w1, . . . , wn Store the n 32-bit quantities in successive memory words
.space n Allocate n bytes of space in the current segment
.extern symsize Declare that the datum stored at sym is size bytes large and is a global label
.globl sym Declare that label sym is global and can be referenced from other files
.align n Align the next datum on a 2n byte boundary, until the next .data or .kdata directive
.set at Tells SPIM to complain if subsequent instructions use $at
.set noat prevents SPIM from complaining if subsequent instructions use $at
SYSCALLS
SERVICE $v0 ARGS RESULT
print_int 1 integer $a0
print_float 2 float $f12
print_double 3 double $f12/$f13
print_string 4 string $a0
read_int 5 integer (in $v0)
read_float 6 float (in $f0)
read_double 7 double (in $f0)
read_string 8 buf $a0, buflen $a1
sbrk 9 amount $a address (in $v0)
exit 10
EXCEPTION CODES
Number Name Cause of Exception
0 Int Interrupt (hardware)
4 AdEL Address Error Exception (load or instruction
fetch)
5 AdES Address Error Exception (store)
6 IBE Bus Error on Instruction Fetch
7 DBE Bus Error on Load or Store
8 Sys Syscall Exception
9 Bp Breakpoint Exception
10 RI Reserved Instruction Exception
11 CpU Coprocessor Unimplemented
12 Ov Arithmetic Overflow Exception
13 Tr Trap
15 FPE Floating Point Exception
[1] Patterson, David A; Hennessy, John J.: Computer Organization and Design, 3rd Edition. Morgan Kaufmann Publishers. San Francisco, 2005.
Copyright c© 2007 Jan Wätzig, Staatliche Studienakademie Dresden (www.ba-dresden.de/∼jan)
This reference card may be used for educational purposes only.
http://www.ba-dresden.de/~jan
MIPS syscall functions available in MARS
SYSCALL functions available in MARS
Introduction
A number of system services, mainly for input and output, are available for use by
your MIPS program. They are described in the table below.
MIPS register contents are not affected by a system call, except for result registers
as specified in the table below.
How to use SYSCALL system services
Step 1. Load the service number in register $v0.
Step 2. Load argument values, if any, in $a0, $a1, $a2, or $f12 as specified.
Step 3. Issue the SYSCALL instruction.
Step 4. Retrieve return values, if any, from result registers as specified.
Example: display the value stored in $t0 on the console
li $v0, 1 # service 1 is print integer
add $a0, $t0, $zero # load desired value into argument register $a0, using pseudo-op
syscall
Table of Available Services
Service Code in $v0 Arguments Result
print integer 1 $a0 = integer to print
print float 2 $f12 = float to print
print double 3 $f12 = double to print
print string 4 $a0 = address of null-terminated string to print
read integer 5 $v0 contains integer read
read float 6 $f0 contains float read
read double 7 $f0 contains double read
read string 8 $a0 = address of input buffer
$a1 = maximum number of characters to read See note below table
sbrk (allocate heap memory) 9 $a0 = number of bytes to allocate $v0 contains address of allocated memory
exit (terminate execution) 10
print character 11 $a0 = character to print See note below table
read character 12 $v0 contains character read
open file 13 $a0 = address of null-terminated string containing filename
$a1 = flags
$a2 = mode $v0 contains file descriptor (negative if error). See note below table
read from file 14 $a0 = file descriptor
$a1 = address of input buffer
$a2 = maximum number of characters to read $v0 contains number of characters read (0 if end-of-file, negative if error). See note below table
write to file 15 $a0 = file descriptor
$a1 = address of output buffer
$a2 = number of characters to write $v0 contains number of characters written (negative if error). See note below table
close file 16 $a0 = file descriptor
exit2 (terminate with value) 17 $a0 = termination result See note below table
Services 1 through 17 are compatible with the SPIM simulator, other than Open File (13) as described in the Notes below the table.
Services 30 and higher are exclusive to MARS.
time (system time) 30 $a0 = low order 32 bits of system time
$a1 = high order 32 bits of system time. See note below table
MIDI out 31 $a0 = pitch (0-127)
$a1 = duration in milliseconds
$a2 = instrument (0-127)
$a3 = volume (0-127) Generate tone and return immediately. See note below table
sleep 32 $a0 = the length of time to sleep in milliseconds. Causes the MARS Java thread to sleep for (at least) the specified number of milliseconds. This timing will not be precise, as the Java implementation will add some overhead.
MIDI out synchronous 33 $a0 = pitch (0-127)
$a1 = duration in milliseconds
$a2 = instrument (0-127)
$a3 = volume (0-127) Generate tone and return upon tone completion. See note below table
print integer in hexadecimal 34 $a0 = integer to print Displayed value is 8 hexadecimal digits, left-padding with zeroes if necessary.
print integer in binary 35 $a0 = integer to print Displayed value is 32 bits, left-padding with zeroes if necessary.
print integer as unsigned 36 $a0 = integer to print Displayed as unsigned decimal value.
(not used) 37-39
set seed 40 $a0 = i.d. of pseudorandom number generator (any int).
$a1 = seed for corresponding pseudorandom number generator. No values are returned. Sets the seed of the corresponding underlying Java pseudorandom number generator (java.util.Random). See note below table
random int 41 $a0 = i.d. of pseudorandom number generator (any int). $a0 contains the next pseudorandom, uniformly distributed int value from this random number generator's sequence. See note below table
random int range 42 $a0 = i.d. of pseudorandom number generator (any int).
$a1 = upper bound of range of returned values. $a0 contains pseudorandom, uniformly distributed int value in the range 0 See note below table
random float 43 $a0 = i.d. of pseudorandom number generator (any int). $f0 contains the next pseudorandom, uniformly distributed float value in the range 0.0 See note below table
random double 44 $a0 = i.d. of pseudorandom number generator (any int). $f0 contains the next pseudorandom, uniformly distributed double value in the range 0.0 See note below table
(not used) 45-49
ConfirmDialog 50 $a0 = address of null-terminated string that is the message to user $a0 contains value of user-chosen option
0: Yes
1: No
2: Cancel
InputDialogInt 51 $a0 = address of null-terminated string that is the message to user $a0 contains int read
$a1 contains status value
0: OK status
-1: input data cannot be correctly parsed
-2: Cancel was chosen
-3: OK was chosen but no data had been input into field
InputDialogFloat 52 $a0 = address of null-terminated string that is the message to user $f0 contains float read
$a1 contains status value
0: OK status
-1: input data cannot be correctly parsed
-2: Cancel was chosen
-3: OK was chosen but no data had been input into field
InputDialogDouble 53 $a0 = address of null-terminated string that is the message to user $f0 contains double read
$a1 contains status value
0: OK status
-1: input data cannot be correctly parsed
-2: Cancel was chosen
-3: OK was chosen but no data had been input into field
InputDialogString 54 $a0 = address of null-terminated string that is the message to user
$a1 = address of input buffer
$a2 = maximum number of characters to read See Service 8 note below table
$a1 contains status value
0: OK status. Buffer contains the input string.
-2: Cancel was chosen. No change to buffer.
-3: OK was chosen but no data had been input into field. No change to buffer.
-4: length of the input string exceeded the specified maximum. Buffer contains the maximum allowable input string plus a terminating null.
MessageDialog 55 $a0 = address of null-terminated string that is the message to user
$a1 = the type of message to be displayed:
0: error message, indicated by Error icon
1: information message, indicated by Information icon
2: warning message, indicated by Warning icon
3: question message, indicated by Question icon
other: plain message (no icon displayed)
N/A
MessageDialogInt 56 $a0 = address of null-terminated string that is an information-type message to user
$a1 = int value to display in string form after the first string N/A
MessageDialogFloat 57 $a0 = address of null-terminated string that is an information-type message to user
$f12 = float value to display in string form after the first string N/A
MessageDialogDouble 58 $a0 = address of null-terminated string that is an information-type message to user
$f12 = double value to display in string form after the first string N/A
MessageDialogString 59 $a0 = address of null-terminated string that is an information-type message to user
$a1 = address of null-terminated string to display after the first string N/A
NOTES: Services numbered 30 and higher are not provided by SPIM
Service 8 - Follows semantics of UNIX 'fgets'. For specified length n, string can be no longer than n-1. If less than that, adds newline to end. In either case, then pads with null byte If n = 1, input is ignored and null byte placed at buffer address. If n < 1, input is ignored and nothing is written to the buffer.
Service 11 - Prints ASCII character corresponding to contents of low-order byte.
Service 13 - MARS implements three flag values: 0 for read-only, 1 for write-only with create, and 9 for write-only with create and append. It ignores mode. The returned file descriptor will be negative if the operation failed. The underlying file I/O
implementation uses java.io.FileInputStream.read() to read and java.io.FileOutputStream.write() to write. MARS maintains file descriptors internally and allocates them starting with 3. File descriptors 0, 1 and 2 are
always open for: reading from standard input, writing to standard output, and writing to standard error, respectively (new in release 4.3).
Services 13,14,15 - In MARS 3.7, the result register was changed to $v0 for SPIM compatability. It was previously $a0 as erroneously printed
in Appendix B of Computer Organization and Design,.
Service 17 - If the MIPS program is run under control of the MARS graphical interface (GUI), the exit code in $a0 is ignored.
Service 30 - System time comes from java.util.Date.getTime() as milliseconds since 1 January 1970.
Services 31,33 - Simulate MIDI output through sound card. Details below.
Services 40-44 use underlying Java pseudorandom number generators provided by the java.util.Random class. Each stream (identified
by $a0 contents) is modeled by a different Random object. There are no default seed values, so use the Set Seed service (40) if
replicated random sequences are desired.
Example of File I/O
The sample MIPS program below will open a new file for writing, write text to it from a memory buffer, then close it. The file will be created in the
directory in which MARS was run.
# Sample MIPS program that writes to a new file.
# by Kenneth Vollmar and Pete Sanderson
.data
fout: .asciiz "testout.txt" # filename for output
buffer: .asciiz "The quick brown fox jumps over the lazy dog."
.text
###############################################################
# Open (for writing) a file that does not exist
li $v0, 13 # system call for open file
la $a0, fout # output file name
li $a1, 1 # Open for writing (flags are 0: read, 1: write)
li $a2, 0 # mode is ignored
syscall # open a file (file descriptor returned in $v0)
move $s6, $v0 # save the file descriptor
###############################################################
# Write to file just opened
li $v0, 15 # system call for write to file
move $a0, $s6 # file descriptor
la $a1, buffer # address of buffer from which to write
li $a2, 44 # hardcoded buffer length
syscall # write to file
###############################################################
# Close the file
li $v0, 16 # system call for close file
move $a0, $s6 # file descriptor to close
syscall # close file
###############################################################
Using SYSCALL system services 31 and 33: MIDI output
These system services are unique to MARS, and provide a means of producing sound. MIDI output is
simulated by your system sound card, and the simulation is provided by the javax.sound.midi
package.
Service 31 will generate the tone then immediately return. Service 33 will generate the tone then
sleep for the tone's duration before returning. Thus it essentially combines services 31 and 32.
This service requires four parameters as follows:
pitch ($a0)
Accepts a positive byte value (0-127) that denotes a pitch as it would
be represented in MIDI
Each number is one semitone / half-step in the chromatic scale.
0 represents a very low C and 127 represents a very high G (a standard
88 key piano begins at 9-A and ends at 108-C).
If the parameter value is outside this range, it applies a default value 60 which is the same as middle C on a piano.
From middle C, all other pitches in the octave are as follows:
61 = C# or Db
62 = D
63 = D# or Eb
64 = E or Fb
65 = E# or F
66 = F# or Gb
67 = G
68 = G# or Ab
69 = A
70 = A# or Bb
71 = B or Cb
72 = B# or C
To produce these pitches in other octaves, add or subtract multiples
of 12.
duration in milliseconds ($a1)
Accepts a positive integer value that is the length of the tone in milliseconds.
If the parameter value is negative, it applies a default value of one second (1000 milliseconds).
instrument ($a2)
Accepts a positive byte value (0-127) that denotes the General MIDI
"patch" used to play the tone.
If the parameter is outside this range, it applies a default value 0 which is an Acoustic Grand Piano.
General MIDI standardizes the number associated with each possible instrument
(often referred to as program change numbers), however it does
not determine how the tone will sound. This is determined by the synthesizer
that is producing the sound. Thus a Tuba (patch 58) on one computer
may sound different than that same patch on another computer.
The 128 available patches are divided into instrument families of 8:
0-7 Piano 64-71 Reed
8-15 Chromatic Percussion 72-79 Pipe
16-23 Organ 80-87 Synth Lead
24-31 Guitar 88-95 Synth Pad
32-39 Bass 96-103 Synth Effects
40-47 Strings 104-111 Ethnic
48-55 Ensemble 112-119 Percussion
56-63 Brass 120-127 Sound Effects
Note that outside of Java, General MIDI usually refers to patches 1-128.
When referring to a list of General MIDI patches, 1 must be subtracted
to play the correct patch. For a full list of General MIDI instruments,
see
www.midi.org/about-midi/gm/gm1sound.shtml.
The General MIDI channel 10 percussion key map is not relevant to the
toneGenerator method because it always defaults to MIDI channel 1.
volume ($a3)
Accepts a positive byte value (0-127) where 127 is the loudest and 0
is silent. This value denotes MIDI velocity which refers to the initial
attack of the tone.
If the parameter value is outside this range, it applies a default value 100.
MIDI velocity measures how hard a note on (or note off)
message is played, perhaps on a MIDI controller like a keyboard. Most
MIDI synthesizers will translate this into volume on a logarithmic scale
in which the difference in amplitude decreases as the velocity value increases.
Note that velocity value on more sophisticated synthesizers can also
affect the timbre of the tone (as most instruments sound different when
they are played louder or softer).
System service 31 was developed and documented by Otterbein student Tony Brock in July 2007.
Assembler$1
package mars.assembler;
synchronized class Assembler$1 {
}
Assembler$DataSegmentForwardReferences$DataSegmentForwardReference
package mars.assembler;
synchronized class Assembler$DataSegmentForwardReferences$DataSegmentForwardReference {
int patchAddress;
int length;
Token token;
void Assembler$DataSegmentForwardReferences$DataSegmentForwardReference(Assembler$DataSegmentForwardReferences, int, int, Token);
}
Assembler$DataSegmentForwardReferences
package mars.assembler;
synchronized class Assembler$DataSegmentForwardReferences {
private java.util.ArrayList forwardReferenceList;
private void Assembler$DataSegmentForwardReferences(Assembler);
private int size();
private void add(int, int, Token);
private void add(Assembler$DataSegmentForwardReferences);
private void clear();
private int resolve(SymbolTable);
private void generateErrorMessages(mars.ErrorList);
}
Assembler$ProgramStatementComparator
package mars.assembler;
synchronized class Assembler$ProgramStatementComparator implements java.util.Comparator {
private void Assembler$ProgramStatementComparator(Assembler);
public int compare(Object, Object);
public boolean equals(Object);
}
Assembler$UserKernelAddressSpace
package mars.assembler;
synchronized class Assembler$UserKernelAddressSpace {
int[] address;
int currentAddressSpace;
private final int USER;
private final int KERNEL;
private void Assembler$UserKernelAddressSpace(Assembler, int, int);
private int get();
private void set(int);
private void increment(int);
private void setAddressSpace(int);
}
Assembler
package mars.assembler;
public synchronized class Assembler {
private java.util.ArrayList machineList;
private mars.ErrorList errors;
private boolean inDataSegment;
private boolean inMacroSegment;
private int externAddress;
private boolean autoAlign;
private Directives currentDirective;
private Directives dataDirective;
private mars.MIPSprogram fileCurrentlyBeingAssembled;
private TokenList globalDeclarationList;
private Assembler$UserKernelAddressSpace textAddress;
private Assembler$UserKernelAddressSpace dataAddress;
private Assembler$DataSegmentForwardReferences currentFileDataSegmentForwardReferences;
private Assembler$DataSegmentForwardReferences accumulatedDataSegmentForwardReferences;
public void Assembler();
public java.util.ArrayList assemble(mars.MIPSprogram, boolean) throws mars.ProcessingException;
public java.util.ArrayList assemble(mars.MIPSprogram, boolean, boolean) throws mars.ProcessingException;
public mars.ErrorList getErrorList();
public java.util.ArrayList assemble(java.util.ArrayList, boolean) throws mars.ProcessingException;
public java.util.ArrayList assemble(java.util.ArrayList, boolean, boolean) throws mars.ProcessingException;
private void catchDuplicateAddresses(java.util.ArrayList, mars.ErrorList);
private java.util.ArrayList parseLine(TokenList, String, int, boolean);
private void detectLabels(TokenList, Macro);
private boolean compactTranslationCanBeApplied(mars.ProgramStatement);
private TokenList stripComment(TokenList);
private void stripLabels(TokenList);
private boolean parseAndRecordLabel(TokenList);
private boolean tokenListBeginsWithLabel(TokenList);
private void executeDirective(TokenList);
private void transferGlobals();
private void executeDirectiveContinuation(TokenList);
private java.util.ArrayList matchInstruction(Token);
private void storeNumeric(TokenList, Directives, mars.ErrorList);
private void storeInteger(Token, Directives, mars.ErrorList);
private void storeRealNumber(Token, Directives, mars.ErrorList);
private void storeStrings(TokenList, Directives, mars.ErrorList);
private boolean passesDataSegmentCheck(Token);
private int writeToDataSegment(int, int, Token, mars.ErrorList);
private void writeDoubleToDataSegment(double, Token, mars.ErrorList);
private int alignToBoundary(int, int);
}
mars/assembler/Assembler.java
mars/assembler/Assembler.java package mars.assembler;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import mars.ErrorList;
import mars.ErrorMessage;
import mars.Globals;
import mars.MIPSprogram;
import mars.ProcessingException;
import mars.ProgramStatement;
import mars.mips.hardware.AddressErrorException;
import mars.mips.hardware.Memory;
import mars.mips.instructions.BasicInstruction;
import mars.mips.instructions.ExtendedInstruction;
import mars.mips.instructions.Instruction;
import mars.util.Binary;
import mars.util.SystemIO;
/*
Copyright (c) 2003-2012, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* An Assembler is capable of assembling a MIPS program. It has only one public
* method, assemble(), which implements a two-pass assembler. It
* translates MIPS source code into binary machine code.
*
* @author Pete Sanderson
* @version August 2003
**/
public class Assembler {
private ArrayList machineList;
private ErrorList errors;
private boolean inDataSegment; // status maintained by parser
private boolean inMacroSegment; // status maintained by parser, true if in
// macro definition segment
private int externAddress;
private boolean autoAlign;
private Directives currentDirective;
private Directives dataDirective;
private MIPSprogram fileCurrentlyBeingAssembled;
private TokenList globalDeclarationList;
private UserKernelAddressSpace textAddress;
private UserKernelAddressSpace dataAddress;
private DataSegmentForwardReferences currentFileDataSegmentForwardReferences,
accumulatedDataSegmentForwardReferences;
/**
* Parse and generate machine code for the given MIPS program. It must have
* already been tokenized. Warnings are not considered errors.
*
* @param p
* A MIPSprogram object representing the program source.
* @param extendedAssemblerEnabled
* A boolean value that if true permits use of extended (pseudo)
* instructions in the source code. If false, these are flagged
* as errors.
* @return An ArrayList representing the assembled program. Each member of
* the list is a ProgramStatement object containing the source,
* intermediate, and machine binary representations of a program
* statement.
*
* @see ProgramStatement
**/
public ArrayList assemble(MIPSprogram p, boolean extendedAssemblerEnabled)
throws ProcessingException {
return assemble(p, extendedAssemblerEnabled, false);
}
/**
* Parse and generate machine code for the given MIPS program. It must have
* already been tokenized.
*
* @param p
* A MIPSprogram object representing the program source.
* @param extendedAssemblerEnabled
* A boolean value that if true permits use of extended (pseudo)
* instructions in the source code. If false, these are flagged
* as errors.
* @param warningsAreErrors
* A boolean value – true means assembler warnings will be
* considered errors and terminate the assemble; false means the
* assembler will produce warning message but otherwise ignore
* warnings.
* @return An ArrayList representing the assembled program. Each member of
* the list is a ProgramStatement object containing the source,
* intermediate, and machine binary representations of a program
* statement.
*
* @see ProgramStatement
**/
public ArrayList assemble(MIPSprogram p, boolean extendedAssemblerEnabled,
boolean warningsAreErrors) throws ProcessingException {
ArrayList programFiles = new ArrayList();
programFiles.add(p);
return this.assemble(programFiles, extendedAssemblerEnabled, warningsAreErrors);
}
/**
* Get list of assembler errors and warnings
*
* @return ErrorList of any assembler errors and warnings.
*/
public ErrorList getErrorList() {
return errors;
}
/**
* Parse and generate machine code for the given MIPS program. All source
* files must have already been tokenized. Warnings will not be considered
* errors.
*
* @param tokenizedProgramFiles
* An ArrayList of MIPSprogram objects, each produced from a
* different source code file, representing the program source.
* @param extendedAssemblerEnabled
* A boolean value that if true permits use of extended (pseudo)
* instructions in the source code. If false, these are flagged
* as errors.
* @return An ArrayList representing the assembled program. Each member of
* the list is a ProgramStatement object containing the source,
* intermediate, and machine binary representations of a program
* statement. Returns null if incoming array list is null or empty.
*
* @see ProgramStatement
**/
public ArrayList assemble(ArrayList tokenizedProgramFiles, boolean extendedAssemblerEnabled)
throws ProcessingException {
return assemble(tokenizedProgramFiles, extendedAssemblerEnabled, false);
}
/**
* Parse and generate machine code for the given MIPS program. All source
* files must have already been tokenized.
*
* @param tokenizedProgramFiles
* An ArrayList of MIPSprogram objects, each produced from a
* different source code file, representing the program source.
* @param extendedAssemblerEnabled
* A boolean value that if true permits use of extended (pseudo)
* instructions in the source code. If false, these are flagged
* as errors.
* @param warningsAreErrors
* A boolean value – true means assembler warnings will be
* considered errors and terminate the assemble; false means the
* assembler will produce warning message but otherwise ignore
* warnings.
* @return An ArrayList representing the assembled program. Each member of
* the list is a ProgramStatement object containing the source,
* intermediate, and machine binary representations of a program
* statement. Returns null if incoming array list is null or empty.
*
* @see ProgramStatement
**/
public ArrayList assemble(ArrayList tokenizedProgramFiles, boolean extendedAssemblerEnabled,
boolean warningsAreErrors) throws ProcessingException {
if (tokenizedProgramFiles == null || tokenizedProgramFiles.size() == 0)
return null;
textAddress = new UserKernelAddressSpace(Memory.textBaseAddress,
Memory.kernelTextBaseAddress);
dataAddress = new UserKernelAddressSpace(Memory.dataBaseAddress,
Memory.kernelDataBaseAddress);
externAddress = Memory.externBaseAddress;
currentFileDataSegmentForwardReferences = new DataSegmentForwardReferences();
accumulatedDataSegmentForwardReferences = new DataSegmentForwardReferences();
Globals.symbolTable.clear();
Globals.memory.clear();
this.machineList = new ArrayList();
this.errors = new ErrorList();
if (Globals.debug)
System.out.println(“Assembler first pass begins:”);
// PROCESS THE FIRST ASSEMBLY PASS FOR ALL SOURCE FILES BEFORE PROCEEDING
// TO SECOND PASS. THIS ASSURES ALL SYMBOL TABLES ARE CORRECTLY BUILT.
// THERE IS ONE GLOBAL SYMBOL TABLE (for identifiers declared .globl) PLUS
// ONE LOCAL SYMBOL TABLE FOR EACH SOURCE FILE.
for (int fileIndex = 0; fileIndex < tokenizedProgramFiles.size(); fileIndex++) {
if (errors.errorLimitExceeded())
break;
this.fileCurrentlyBeingAssembled = (MIPSprogram) tokenizedProgramFiles.get(fileIndex);
// List of labels declared ".globl". new list for each file assembled
this.globalDeclarationList = new TokenList();
// Parser begins by default in text segment until directed otherwise.
this.inDataSegment = false;
// Macro segment will be started by .macro directive
this.inMacroSegment = false;
// Default is to align data from directives on appropriate boundary (word, half, byte)
// This can be turned off for remainder of current data segment with ".align 0"
this.autoAlign = true;
// Default data directive is .word for 4 byte data items
this.dataDirective = Directives.WORD;
// Clear out (initialize) symbol table related structures.
fileCurrentlyBeingAssembled.getLocalSymbolTable().clear();
currentFileDataSegmentForwardReferences.clear();
// sourceList is an ArrayList of String objects, one per source line.
// tokenList is an ArrayList of TokenList objects, one per source line;
// each ArrayList in tokenList consists of Token objects.
ArrayList
ArrayList tokenList = fileCurrentlyBeingAssembled.getTokenList();
ArrayList parsedList = fileCurrentlyBeingAssembled.createParsedList();
// each file keeps its own macro definitions
MacroPool macroPool = fileCurrentlyBeingAssembled.createMacroPool();
// FIRST PASS OF ASSEMBLER VERIFIES SYNTAX, GENERATES SYMBOL TABLE,
// INITIALIZES DATA SEGMENT
ArrayList
for (int i = 0; i < tokenList.size(); i++) {
if (errors.errorLimitExceeded())
break;
for (int z=0; z<((TokenList)tokenList.get(i)).size(); z++) {
Token t = ((TokenList) tokenList.get(i)).get(z);
// record this token's original source program and line #. Differs from final, if .include used
t.setOriginal(sourceLineList.get(i).getMIPSprogram(),sourceLineList.get(i).getLineNumber());
}
statements = this.parseLine((TokenList) tokenList.get(i),
sourceLineList.get(i).getSource(),
sourceLineList.get(i).getLineNumber(),
extendedAssemblerEnabled);
if (statements != null) {
parsedList.addAll(statements);
}
}
if (inMacroSegment) {
errors.add(new ErrorMessage(fileCurrentlyBeingAssembled,
fileCurrentlyBeingAssembled.getLocalMacroPool().getCurrent().getFromLine(),
0, "Macro started but not ended (no .end_macro directive)"));
}
// move ".globl" symbols from local symtab to global
this.transferGlobals();
// Attempt to resolve forward label references that were discovered in operand fields
// of data segment directives in current file. Those that are not resolved after this
// call are either references to global labels not seen yet, or are undefined.
// Cannot determine which until all files are parsed, so copy unresolved entries
// into accumulated list and clear out this one for re-use with the next source file.
currentFileDataSegmentForwardReferences.resolve(fileCurrentlyBeingAssembled
.getLocalSymbolTable());
accumulatedDataSegmentForwardReferences.add(currentFileDataSegmentForwardReferences);
currentFileDataSegmentForwardReferences.clear();
} // end of first-pass loop for each MIPSprogram
// Have processed all source files. Attempt to resolve any remaining forward label
// references from global symbol table. Those that remain unresolved are undefined
// and require error message.
accumulatedDataSegmentForwardReferences.resolve(Globals.symbolTable);
accumulatedDataSegmentForwardReferences.generateErrorMessages(errors);
// Throw collection of errors accumulated through the first pass.
if (errors.errorsOccurred()) {
throw new ProcessingException(errors);
}
if (Globals.debug)
System.out.println("Assembler second pass begins");
// SECOND PASS OF ASSEMBLER GENERATES BASIC ASSEMBLER THEN MACHINE CODE.
// Generates basic assembler statements...
for (int fileIndex = 0; fileIndex < tokenizedProgramFiles.size(); fileIndex++) {
if (errors.errorLimitExceeded())
break;
this.fileCurrentlyBeingAssembled = (MIPSprogram) tokenizedProgramFiles.get(fileIndex);
ArrayList parsedList = fileCurrentlyBeingAssembled.getParsedList();
ProgramStatement statement;
for (int i = 0; i < parsedList.size(); i++) {
statement = (ProgramStatement) parsedList.get(i);
statement.buildBasicStatementFromBasicInstruction(errors);
if (errors.errorsOccurred()) {
throw new ProcessingException(errors);
}
if (statement.getInstruction() instanceof BasicInstruction) {
this.machineList.add(statement);
}
else {
// It is a pseudo-instruction:
// 1. Fetch its basic instruction template list
// 2. For each template in the list,
// 2a. substitute operands from source statement
// 2b. tokenize the statement generated by 2a.
// 2d. call parseLine() to generate basic instrction
// 2e. add returned programStatement to the list
// The templates, and the instructions generated by filling
// in the templates, are specified
// in basic format (e.g. mnemonic register reference $zero
// already translated to $0).
// So the values substituted into the templates need to be
// in this format. Since those
// values come from the original source statement, they need
// to be translated before
// substituting. The next method call will perform this
// translation on the original
// source statement. Despite the fact that the original
// statement is a pseudo
// instruction, this method performs the necessary
// translation correctly.
ExtendedInstruction inst = (ExtendedInstruction) statement.getInstruction();
String basicAssembly = statement.getBasicAssemblyStatement();
int sourceLine = statement.getSourceLine();
TokenList theTokenList = new Tokenizer().tokenizeLine(sourceLine,
basicAssembly, errors, false);
// ////////////////////////////////////////////////////////////////////////////
// If we are using compact memory config and there is a compact expansion, use it
ArrayList templateList;
if (compactTranslationCanBeApplied(statement)) {
templateList = inst.getCompactBasicIntructionTemplateList();
}
else {
templateList = inst.getBasicIntructionTemplateList();
}
// subsequent ProgramStatement constructor needs the correct text segment address.
textAddress.set(statement.getAddress());
// Will generate one basic instruction for each template in the list.
for (int instrNumber = 0; instrNumber < templateList.size(); instrNumber++) {
String instruction = ExtendedInstruction.makeTemplateSubstitutions(
this.fileCurrentlyBeingAssembled,
(String) templateList.get(instrNumber), theTokenList);
// 23 Jan 2008 by DPS. Template substitution may result in no instruction.
// If this is the case, skip remainder of loop iteration. This should only
// happen if template substitution was for "nop" instruction but delayed branching
// is disabled so the "nop" is not generated.
if (instruction == null || instruction == "") {
continue;
}
// All substitutions have been made so we have generated
// a valid basic instruction!
if (Globals.debug)
System.out.println("PSEUDO generated: " + instruction);
// For generated instruction: tokenize, build program
// statement, add to list.
TokenList newTokenList = new Tokenizer().tokenizeLine(sourceLine,
instruction, errors,false);
ArrayList instrMatches = this.matchInstruction(newTokenList.get(0));
Instruction instr = OperandFormat.bestOperandMatch(newTokenList,
instrMatches);
// Only first generated instruction is linked to original source
ProgramStatement ps = new ProgramStatement(
this.fileCurrentlyBeingAssembled,
(instrNumber == 0) ? statement.getSource() : "", newTokenList,
newTokenList, instr, textAddress.get(), statement.getSourceLine());
textAddress.increment(Instruction.INSTRUCTION_LENGTH);
ps.buildBasicStatementFromBasicInstruction(errors);
this.machineList.add(ps);
} // end of FOR loop, repeated for each template in list.
} // end of ELSE part for extended instruction.
} // end of assembler second pass.
}
if (Globals.debug)
System.out.println("Code generation begins");
///////////// THIRD MAJOR STEP IS PRODUCE MACHINE CODE FROM ASSEMBLY //////////
// Generates machine code statements from the list of basic assembler statements
// and writes the statement to memory.
ProgramStatement statement;
for (int i = 0; i < this.machineList.size(); i++) {
if (errors.errorLimitExceeded())
break;
statement = (ProgramStatement) this.machineList.get(i);
statement.buildMachineStatementFromBasicStatement(errors);
if (Globals.debug)
System.out.println(statement);
try {
Globals.memory.setStatement(statement.getAddress(), statement);
}
catch (AddressErrorException e) {
Token t = statement.getOriginalTokenList().get(0);
errors.add(new ErrorMessage(t.getSourceMIPSprogram(), t.getSourceLine(), t
.getStartPos(), "Invalid address for text segment: " + e.getAddress()));
}
}
// Aug. 24, 2005 Ken Vollmar
// Ensure that I/O "file descriptors" are initialized for a new program run
SystemIO.resetFiles();
// DPS 6 Dec 2006:
// We will now sort the ArrayList of ProgramStatements by getAddress() value.
// This is for display purposes, since they have already been stored to Memory.
// Use of .ktext and .text with address operands has two implications:
// (1) the addresses may not be ordered at this point. Requires unsigned int
// sort because kernel addresses are negative. See special Comparator.
// (2) It is possible for two instructions to be placed at the same address.
// Such occurances will be flagged as errors.
// Yes, I would not have to sort here if I used SortedSet rather than ArrayList
// but in case of duplicate I like having both statements handy for error message.
Collections.sort(this.machineList, new ProgramStatementComparator());
catchDuplicateAddresses(this.machineList, errors);
if (errors.errorsOccurred() || errors.warningsOccurred() && warningsAreErrors) {
throw new ProcessingException(errors);
}
return this.machineList;
} // assemble()
// //////////////////////////////////////////////////////////////////////
// Will check for duplicate text addresses, which can happen inadvertantly when using
// operand on .text directive. Will generate error message for each one that occurs.
private void catchDuplicateAddresses(ArrayList instructions, ErrorList errors) {
for (int i = 0; i < instructions.size() - 1; i++) {
ProgramStatement ps1 = (ProgramStatement) instructions.get(i);
ProgramStatement ps2 = (ProgramStatement) instructions.get(i + 1);
if (ps1.getAddress() == ps2.getAddress()) {
errors.add(new ErrorMessage(ps2.getSourceMIPSprogram(), ps2.getSourceLine(), 0,
"Duplicate text segment address: "
+ mars.venus.NumberDisplayBaseChooser.formatUnsignedInteger(ps2
.getAddress(), (Globals.getSettings()
.getDisplayAddressesInHex()) ? 16 : 10)
+ " already occupied by " + ps1.getSourceFile() + " line "
+ ps1.getSourceLine() + " (caused by use of "
+ ((Memory.inTextSegment(ps2.getAddress())) ? ".text" : ".ktext")
+ " operand)"));
}
}
}
/**
* This method parses one line of MIPS source code. It works with the list
* of tokens, but original source is also provided. It also carries out
* directives, which includes initializing the data segment. This method is
* invoked in the assembler first pass.
*
* @param tokenList
* @param source
* @param sourceLineNumber
* @param extendedAssemblerEnabled
* @return ArrayList of ProgramStatements because parsing a macro expansion
* request will return a list of ProgramStatements expanded
*/
private ArrayList
int sourceLineNumber, boolean extendedAssemblerEnabled) {
ArrayList
ProgramStatement programStatement;
TokenList tokens = this.stripComment(tokenList);
// Labels should not be processed in macro definition segment.
MacroPool macroPool = fileCurrentlyBeingAssembled.getLocalMacroPool();
if (inMacroSegment) {
detectLabels(tokens, macroPool.getCurrent());
}
else {
stripLabels(tokens);
}
if (tokens.isEmpty())
return null;
// Grab first (operator) token…
Token token = tokens.get(0);
TokenTypes tokenType = token.getType();
// Let’s handle the directives here…
if (tokenType == TokenTypes.DIRECTIVE) {
this.executeDirective(tokens);
return null;
}
// don’t parse if in macro segment
if (inMacroSegment)
return null;
// SPIM-style macro calling:
TokenList parenFreeTokens = tokens;
if (tokens.size() > 2 && tokens.get(1).getType() == TokenTypes.LEFT_PAREN
&& tokens.get(tokens.size() – 1).getType() == TokenTypes.RIGHT_PAREN) {
parenFreeTokens = (TokenList) tokens.clone();
parenFreeTokens.remove(tokens.size() – 1);
parenFreeTokens.remove(1);
}
Macro macro = macroPool.getMatchingMacro(parenFreeTokens, sourceLineNumber);//parenFreeTokens.get(0).getSourceLine());
// expand macro if this line is a macro expansion call
if (macro != null) {
tokens = parenFreeTokens;
// get unique id for this expansion
int counter = macroPool.getNextCounter();
if (macroPool.pushOnCallStack(token)) {
errors.add(new ErrorMessage(fileCurrentlyBeingAssembled, tokens.get(0)
.getSourceLine(), 0, “Detected a macro expansion loop (recursive reference). “));
}
else {
// for (int i = macro.getFromLine() + 1; i < macro.getToLine(); i++) {
// String substituted = macro.getSubstitutedLine(i, tokens, counter, errors);
// TokenList tokenList2 = fileCurrentlyBeingAssembled.getTokenizer().tokenizeLine(
// i, substituted, errors);
// // If token list getProcessedLine() is not empty, then .eqv was performed and it contains the modified source.
// // Put it into the line to be parsed, so it will be displayed properly in text segment display. DPS 23 Jan 2013
// if (tokenList2.getProcessedLine().length() > 0)
// substituted = tokenList2.getProcessedLine();
// // recursively parse lines of expanded macro
// ArrayList
// + substituted.trim(), sourceLineNumber, extendedAssemblerEnabled);
// if (statements != null)
// ret.addAll(statements);
// }
for (int i = macro.getFromLine() + 1; i < macro.getToLine(); i++) {
String substituted = macro.getSubstitutedLine(i, tokens, counter, errors);
TokenList tokenList2 = fileCurrentlyBeingAssembled.getTokenizer().tokenizeLine(
i, substituted, errors);
// If token list getProcessedLine() is not empty, then .eqv was performed and it contains the modified source.
// Put it into the line to be parsed, so it will be displayed properly in text segment display. DPS 23 Jan 2013
if (tokenList2.getProcessedLine().length() > 0)
substituted = tokenList2.getProcessedLine();
// recursively parse lines of expanded macro
ArrayList
+ substituted.trim(), sourceLineNumber, extendedAssemblerEnabled);
if (statements != null)
ret.addAll(statements);
}
macroPool.popFromCallStack();
}
return ret;
}
// DPS 14-July-2008
// Yet Another Hack: detect unrecognized directive. MARS recognizes the same directives
// as SPIM but other MIPS assemblers recognize additional directives. Compilers such
// as MIPS-directed GCC generate assembly code containing these directives. We’d like
// the opportunity to ignore them and continue. Tokenizer would categorize an unrecognized
// directive as an TokenTypes.IDENTIFIER because it would not be matched as a directive and
// MIPS labels can start with ‘.’ NOTE: this can also be handled by including the
// ignored directive in the Directives.java list. There is already a mechanism in place
// for generating a warning there. But I cannot anticipate the names of all directives
// so this will catch anything, including a misspelling of a valid directive (which is
// a nice thing to do).
if (tokenType == TokenTypes.IDENTIFIER && token.getValue().charAt(0) == ‘.’) {
errors.add(new ErrorMessage(ErrorMessage.WARNING, token.getSourceMIPSprogram(), token
.getSourceLine(), token.getStartPos(), “MARS does not recognize the ”
+ token.getValue() + ” directive. Ignored.”));
return null;
}
// The directives with lists (.byte, .double, .float, .half, .word, .ascii, .asciiz)
// should be able to extend the list over several lines. Since this method assembles
// only one source line, state information must be stored from one invocation to
// the next, to sense the context of this continuation line. That state information
// is contained in this.dataDirective (the current data directive).
//
if (this.inDataSegment && // 30-Dec-09 DPS Added data segment guard…
(tokenType == TokenTypes.PLUS
|| // because invalid instructions were being caught…
tokenType == TokenTypes.MINUS
|| // here and reported as a directive in text segment!
tokenType == TokenTypes.QUOTED_STRING || tokenType == TokenTypes.IDENTIFIER
|| TokenTypes.isIntegerTokenType(tokenType) || TokenTypes
.isFloatingTokenType(tokenType))) {
this.executeDirectiveContinuation(tokens);
return null;
}
// If we are in the text segment, the variable “token” must now refer to
// an OPERATOR
// token. If not, it is either a syntax error or the specified operator
// is not
// yet implemented.
if (!this.inDataSegment) {
ArrayList instrMatches = this.matchInstruction(token);
if (instrMatches == null)
return ret;
// OK, we’ve got an operator match, let’s check the operands.
Instruction inst = OperandFormat.bestOperandMatch(tokens, instrMatches);
// Here’s the place to flag use of extended (pseudo) instructions
// when setting disabled.
if (inst instanceof ExtendedInstruction && !extendedAssemblerEnabled /* allow la */ && !inst.getName().toLowerCase().equals(“la”)) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(),
token.getStartPos(),
“Extended (pseudo) instruction or format not permitted. See Settings.”));
}
if (OperandFormat.tokenOperandMatch(tokens, inst, errors)) {
programStatement = new ProgramStatement(this.fileCurrentlyBeingAssembled, source,
tokenList, tokens, inst, textAddress.get(), sourceLineNumber);
// instruction length is 4 for all basic instruction, varies for extended instruction
// Modified to permit use of compact expansion if address fits
// in 15 bits. DPS 4-Aug-2009
int instLength = inst.getInstructionLength();
if (compactTranslationCanBeApplied(programStatement)) {
instLength = ((ExtendedInstruction) inst).getCompactInstructionLength();
}
textAddress.increment(instLength);
ret.add(programStatement);
return ret;
}
}
return null;
} // parseLine()
private void detectLabels(TokenList tokens, Macro current) {
if (tokenListBeginsWithLabel(tokens))
current.addLabel(tokens.get(0).getValue());
}
// Determine whether or not a compact (16-bit) translation from
// pseudo-instruction to basic instruction can be applied. If
// the argument is a basic instruction, obviously not. If an
// extended instruction, we have to be operating under a 16-bit
// memory model and the instruction has to have defined an
// alternate compact translation.
private boolean compactTranslationCanBeApplied(ProgramStatement statement) {
return (statement.getInstruction() instanceof ExtendedInstruction
&& Globals.memory.usingCompactMemoryConfiguration() && ((ExtendedInstruction) statement
.getInstruction()).hasCompactTranslation());
}
// //////////////////////////////////////////////////////////////////////////////////
// Pre-process the token list for a statement by stripping off any comment.
// NOTE: the ArrayList parameter is not modified; a new one is cloned and
// returned.
private TokenList stripComment(TokenList tokenList) {
if (tokenList.isEmpty())
return tokenList;
TokenList tokens = (TokenList) tokenList.clone();
// If there is a comment, strip it off.
int last = tokens.size() – 1;
if (tokens.get(last).getType() == TokenTypes.COMMENT) {
tokens.remove(last);
}
return tokens;
} // stripComment()
/**
* Pre-process the token list for a statement by stripping off any label, if
* either are present. Any label definition will be recorded in the symbol
* table. NOTE: the ArrayList parameter will be modified.
*/
private void stripLabels(TokenList tokens) {
// If there is a label, handle it here and strip it off.
boolean thereWasLabel = this.parseAndRecordLabel(tokens);
if (thereWasLabel) {
tokens.remove(0); // Remove the IDENTIFIER.
tokens.remove(0); // Remove the COLON, shifted to 0 by previous remove
}
}
// //////////////////////////////////////////////////////////////////////////////////
// Parse and record label, if there is one. Note the identifier and its colon are
// two separate tokens, since they may be separated by spaces in source code.
private boolean parseAndRecordLabel(TokenList tokens) {
if (tokens.size() < 2) {
return false;
}
else {
Token token = tokens.get(0);
if (tokenListBeginsWithLabel(tokens)) {
if (token.getType() == TokenTypes.OPERATOR) {
// an instruction name was used as label (e.g. lw:), so change its token type
token.setType(TokenTypes.IDENTIFIER);
}
fileCurrentlyBeingAssembled.getLocalSymbolTable().addSymbol(token,
(this.inDataSegment) ? dataAddress.get() : textAddress.get(),
this.inDataSegment, this.errors);
return true;
}
else {
return false;
}
}
} // parseLabel()
private boolean tokenListBeginsWithLabel(TokenList tokens) {
// 2-July-2010. DPS. Remove prohibition of operator names as labels
if (tokens.size() < 2)
return false;
return (tokens.get(0).getType() == TokenTypes.IDENTIFIER || tokens.get(0).getType() == TokenTypes.OPERATOR)
&& tokens.get(1).getType() == TokenTypes.COLON;
}
// //////////////////////////////////////////////////////////////////////////////////
// This source code line is a directive, not a MIPS instruction. Let's carry it out.
private void executeDirective(TokenList tokens) {
Token token = tokens.get(0);
Directives direct = Directives.matchDirective(token.getValue());
if (Globals.debug)
System.out.println("line " + token.getSourceLine() + " is directive " + direct);
if (direct == null) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(), token
.getStartPos(), "\"" + token.getValue()
+ "\" directive is invalid or not implemented in MARS"));
return;
}
else if (direct == Directives.EQV) { /* EQV added by DPS 11 July 2012 */
// Do nothing. This was vetted and processed during tokenizing.
}
else if (direct == Directives.MACRO) {
if (tokens.size() < 2) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(),
token.getStartPos(), "\"" + token.getValue()
+ "\" directive requires at least one argument."));
return;
}
if (tokens.get(1).getType() != TokenTypes.IDENTIFIER) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(),
tokens.get(1).getStartPos(), "Invalid Macro name \""
+ tokens.get(1).getValue() + "\""));
return;
}
if (inMacroSegment) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(),
token.getStartPos(), "Nested macros are not allowed"));
return;
}
inMacroSegment = true;
MacroPool pool = fileCurrentlyBeingAssembled.getLocalMacroPool();
pool.beginMacro(tokens.get(1));
for (int i = 2; i < tokens.size(); i++) {
Token arg = tokens.get(i);
if (arg.getType() == TokenTypes.RIGHT_PAREN
|| arg.getType() == TokenTypes.LEFT_PAREN)
continue;
if (!Macro.tokenIsMacroParameter(arg.getValue(), true)) {
errors.add(new ErrorMessage(arg.getSourceMIPSprogram(), arg.getSourceLine(),
arg.getStartPos(), "Invalid macro argument '" + arg.getValue() + "'"));
return;
}
pool.getCurrent().addArg(arg.getValue());
}
}
else if (direct == Directives.END_MACRO) {
if (tokens.size() > 1) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(),
token.getStartPos(), “invalid text after .END_MACRO”));
return;
}
if (!inMacroSegment) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(),
token.getStartPos(), “.END_MACRO without .MACRO”));
return;
}
inMacroSegment = false;
fileCurrentlyBeingAssembled.getLocalMacroPool().commitMacro(token);
}
else if (inMacroSegment) {
// should not parse lines even directives in macro segment
return;
}
else if (direct == Directives.DATA || direct == Directives.KDATA) {
this.inDataSegment = true;
this.autoAlign = true;
this.dataAddress.setAddressSpace((direct == Directives.DATA) ? this.dataAddress.USER
: this.dataAddress.KERNEL);
if (tokens.size() > 1 && TokenTypes.isIntegerTokenType(tokens.get(1).getType())) {
this.dataAddress.set(Binary.stringToInt(tokens.get(1).getValue())); // KENV 1/6/05
}
}
else if (direct == Directives.TEXT || direct == Directives.KTEXT) {
this.inDataSegment = false;
this.textAddress.setAddressSpace((direct == Directives.TEXT) ? this.textAddress.USER
: this.textAddress.KERNEL);
if (tokens.size() > 1 && TokenTypes.isIntegerTokenType(tokens.get(1).getType())) {
this.textAddress.set(Binary.stringToInt(tokens.get(1).getValue())); // KENV 1/6/05
}
}
else if (direct == Directives.WORD || direct == Directives.HALF
|| direct == Directives.BYTE || direct == Directives.FLOAT
|| direct == Directives.DOUBLE) {
this.dataDirective = direct;
if (passesDataSegmentCheck(token) && tokens.size() > 1) { // DPS
// 11/20/06, added text segment prohibition
storeNumeric(tokens, direct, errors);
}
}
else if (direct == Directives.ASCII || direct == Directives.ASCIIZ) {
this.dataDirective = direct;
if (passesDataSegmentCheck(token)) {
storeStrings(tokens, direct, errors);
}
}
else if (direct == Directives.ALIGN) {
if (passesDataSegmentCheck(token)) {
if (tokens.size() != 2) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(),
token.getSourceLine(), token.getStartPos(), “\”” + token.getValue()
+ “\” requires one operand”));
return;
}
if (!TokenTypes.isIntegerTokenType(tokens.get(1).getType())
|| Binary.stringToInt(tokens.get(1).getValue()) < 0) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(),
token.getSourceLine(), token.getStartPos(), "\"" + token.getValue()
+ "\" requires a non-negative integer"));
return;
}
int value = Binary.stringToInt(tokens.get(1).getValue()); // KENV 1/6/05
if (value == 0) {
this.autoAlign = false;
}
else {
this.dataAddress.set(this.alignToBoundary(this.dataAddress.get(),
(int) Math.pow(2, value)));
}
}
}
else if (direct == Directives.SPACE) {
if (passesDataSegmentCheck(token)) {
if (tokens.size() != 2) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(),
token.getSourceLine(), token.getStartPos(), "\"" + token.getValue()
+ "\" requires one operand"));
return;
}
if (!TokenTypes.isIntegerTokenType(tokens.get(1).getType())
|| Binary.stringToInt(tokens.get(1).getValue()) < 0) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(),
token.getSourceLine(), token.getStartPos(), "\"" + token.getValue()
+ "\" requires a non-negative integer"));
return;
}
int value = Binary.stringToInt(tokens.get(1).getValue()); // KENV 1/6/05
this.dataAddress.increment(value);
}
}
else if (direct == Directives.EXTERN) {
if (tokens.size() != 3) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(),
token.getStartPos(), "\"" + token.getValue()
+ "\" directive requires two operands (label and size)."));
return;
}
if (!TokenTypes.isIntegerTokenType(tokens.get(2).getType())
|| Binary.stringToInt(tokens.get(2).getValue()) < 0) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(),
token.getStartPos(), "\"" + token.getValue()
+ "\" requires a non-negative integer size"));
return;
}
int size = Binary.stringToInt(tokens.get(2).getValue());
// If label already in global symtab, do nothing. If not, add it right now.
if (Globals.symbolTable.getAddress(tokens.get(1).getValue()) == SymbolTable.NOT_FOUND) {
Globals.symbolTable.addSymbol(tokens.get(1), this.externAddress,
Symbol.DATA_SYMBOL, errors);
this.externAddress += size;
}
}
else if (direct == Directives.SET) {
errors.add(new ErrorMessage(ErrorMessage.WARNING, token.getSourceMIPSprogram(), token
.getSourceLine(), token.getStartPos(),
"MARS currently ignores the .set directive."));
}
else if (direct == Directives.GLOBL) {
if (tokens.size() < 2) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(),
token.getStartPos(), "\"" + token.getValue()
+ "\" directive requires at least one argument."));
return;
}
// SPIM limits .globl list to one label, why not extend it to a list?
for (int i = 1; i < tokens.size(); i++) {
// Add it to a list of labels to be processed at the end of the
// pass. At that point, transfer matching symbol definitions from
// local symbol table to global symbol table.
Token label = tokens.get(i);
if (label.getType() != TokenTypes.IDENTIFIER) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(),
token.getSourceLine(), token.getStartPos(), "\"" + token.getValue()
+ "\" directive argument must be label."));
return;
}
globalDeclarationList.add(label);
}
}
else {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(), token
.getStartPos(), "\"" + token.getValue()
+ "\" directive recognized but not yet implemented."));
return;
}
} // executeDirective()
// //////////////////////////////////////////////////////////////////////////////
// Process the list of .globl labels, if any, declared and defined in this file.
// We'll just move their symbol table entries from local symbol table to global
// symbol table at the end of the first assembly pass.
private void transferGlobals() {
for (int i = 0; i < globalDeclarationList.size(); i++) {
Token label = globalDeclarationList.get(i);
Symbol symtabEntry = fileCurrentlyBeingAssembled.getLocalSymbolTable().getSymbol(
label.getValue());
if (symtabEntry == null) {
errors.add(new ErrorMessage(fileCurrentlyBeingAssembled, label.getSourceLine(),
label.getStartPos(), "\"" + label.getValue()
+ "\" declared global label but not defined."));
}
else {
if (Globals.symbolTable.getAddress(label.getValue()) != SymbolTable.NOT_FOUND) {
errors.add(new ErrorMessage(fileCurrentlyBeingAssembled, label.getSourceLine(),
label.getStartPos(), "\"" + label.getValue()
+ "\" already defined as global in a different file."));
}
else {
fileCurrentlyBeingAssembled.getLocalSymbolTable().removeSymbol(label);
Globals.symbolTable.addSymbol(label, symtabEntry.getAddress(),
symtabEntry.getType(), errors);
}
}
}
}
// //////////////////////////////////////////////////////////////////////////////////
// This source code line, if syntactically correct, is a continuation of a
// directive list begun on on previous line.
private void executeDirectiveContinuation(TokenList tokens) {
Directives direct = this.dataDirective;
if (direct == Directives.WORD || direct == Directives.HALF || direct == Directives.BYTE
|| direct == Directives.FLOAT || direct == Directives.DOUBLE) {
if (tokens.size() > 0) {
storeNumeric(tokens, direct, errors);
}
}
else if (direct == Directives.ASCII || direct == Directives.ASCIIZ) {
if (passesDataSegmentCheck(tokens.get(0))) {
storeStrings(tokens, direct, errors);
}
}
} // executeDirectiveContinuation()
// //////////////////////////////////////////////////////////////////////////////////
// Given token, find the corresponding Instruction object. If token was not
// recognized as OPERATOR, there is a problem.
private ArrayList matchInstruction(Token token) {
if (token.getType() != TokenTypes.OPERATOR) {
if (token.getSourceMIPSprogram().getLocalMacroPool()
.matchesAnyMacroName(token.getValue()))
this.errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token
.getSourceLine(), token.getStartPos(), “forward reference or invalid parameters for macro \””
+ token.getValue() + “\””));
else
this.errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token
.getSourceLine(), token.getStartPos(), “\”” + token.getValue()
+ “\” is not a recognized operator”));
return null;
}
ArrayList inst = Globals.instructionSet.matchOperator(token.getValue());
if (inst == null) { // This should NEVER happen…
this.errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(),
token.getStartPos(), “Internal Assembler error: \”” + token.getValue()
+ “\” tokenized OPERATOR then not recognized”));
}
return inst;
} // matchInstruction()
// //////////////////////////////////////////////////////////////////////////////////
// Processes the .word/.half/.byte/.float/.double directive.
// Can also handle “directive continuations”, e.g. second or subsequent line
// of a multiline list, which does not contain the directive token. Just pass the
// current directive as argument.
private void storeNumeric(TokenList tokens, Directives directive, ErrorList errors) {
Token token = tokens.get(0);
// A double-check; should have already been caught…removed “.word” exemption 11/20/06
if (!passesDataSegmentCheck(token))
return;
// Correctly handles case where this is a “directive continuation” line.
int tokenStart = 0;
if (token.getType() == TokenTypes.DIRECTIVE)
tokenStart = 1;
// Set byte length in memory of each number (e.g. WORD is 4, BYTE is 1, etc)
int lengthInBytes = DataTypes.getLengthInBytes(directive);
// Handle the “value : n” format, which replicates the value “n” times.
if (tokens.size() == 4 && tokens.get(2).getType() == TokenTypes.COLON) {
Token valueToken = tokens.get(1);
Token repetitionsToken = tokens.get(3);
// DPS 15-jul-08, allow “:” for repetition for all numeric
// directives (originally just .word)
// Conditions for correctly-formed replication:
// (integer directive AND integer value OR floating directive AND
// (integer value OR floating value))
// AND integer repetition value
if (!(Directives.isIntegerDirective(directive)
&& TokenTypes.isIntegerTokenType(valueToken.getType()) || Directives
.isFloatingDirective(directive)
&& (TokenTypes.isIntegerTokenType(valueToken.getType()) || TokenTypes
.isFloatingTokenType(valueToken.getType())))
|| !TokenTypes.isIntegerTokenType(repetitionsToken.getType())) {
errors.add(new ErrorMessage(fileCurrentlyBeingAssembled,
valueToken.getSourceLine(), valueToken.getStartPos(),
“malformed expression”));
return;
}
int repetitions = Binary.stringToInt(repetitionsToken.getValue()); // KENV 1/6/05
if (repetitions <= 0) {
errors.add(new ErrorMessage(fileCurrentlyBeingAssembled, repetitionsToken
.getSourceLine(), repetitionsToken.getStartPos(),
"repetition factor must be positive"));
return;
}
if (this.inDataSegment) {
if (this.autoAlign) {
this.dataAddress
.set(this.alignToBoundary(this.dataAddress.get(), lengthInBytes));
}
for (int i = 0; i < repetitions; i++) {
if (Directives.isIntegerDirective(directive)) {
storeInteger(valueToken, directive, errors);
}
else {
storeRealNumber(valueToken, directive, errors);
}
}
} // WHAT ABOUT .KDATA SEGMENT?
/***************************************************************************
* /****** NOTE of 11/20/06. Below will always throw exception b/c
* you cannot use Memory.set() with text segment addresses and the
* "not valid address" produced here is misleading. Added data
* segment check prior to this point, so this "else" will never be
* executed. I'm leaving it in just in case MARS in the future adds
* capability of writing to the text segment (e.g. ability to
* de-assemble a binary value into its corresponding MIPS
* instruction)
*
* else { // not in data segment...which we assume to mean in text
* segment. try { for (int i=0; i < repetitions; i++) {
* Globals.memory.set(this.textAddress.get(),
* Binary.stringToInt(valueToken.getValue()), lengthInBytes);
* this.textAddress.increment(lengthInBytes); } } catch
* (AddressErrorException e) { errors.add(new
* ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(),
* token.getStartPos(), "\""+this.textAddress.get()+
* "\" is not a valid text segment address")); } }
************************************************************************/
return;
}
// if not in ".word w : n" format, must just be list of one or more values.
for (int i = tokenStart; i < tokens.size(); i++) {
token = tokens.get(i);
if (Directives.isIntegerDirective(directive)) {
storeInteger(token, directive, errors);
}
if (Directives.isFloatingDirective(directive)) {
storeRealNumber(token, directive, errors);
}
}
return;
} // storeNumeric()
// //////////////////////////////////////////////////////////////////////////////
// Store integer value given integer (word, half, byte) directive.
// Called by storeNumeric()
// NOTE: The token itself may be a label, in which case the correct action is
// to store the address of that label (into however many bytes specified).
private void storeInteger(Token token, Directives directive, ErrorList errors) {
int lengthInBytes = DataTypes.getLengthInBytes(directive);
if (TokenTypes.isIntegerTokenType(token.getType())) {
int value = Binary.stringToInt(token.getValue());
int fullvalue = value;
// DPS 4-Jan-2013. Overriding 6-Jan-2005 KENV changes.
// If value is out of range for the directive, will simply truncate
// the leading bits (includes sign bits). This is what SPIM does.
// But will issue a warning (not error) which SPIM does not do.
if (directive == Directives.BYTE) {
value = value & 0x000000FF;
}
else if (directive == Directives.HALF) {
value = value & 0x0000FFFF;
}
if (DataTypes.outOfRange(directive, fullvalue)) {
errors.add(new ErrorMessage(ErrorMessage.WARNING, token.getSourceMIPSprogram(), token.getSourceLine(),
token.getStartPos(), "\"" + token.getValue()
+ "\" is out-of-range for a signed value and possibly truncated"));
}
if (this.inDataSegment) {
writeToDataSegment(value, lengthInBytes, token, errors);
}
/******
* NOTE of 11/20/06. "try" below will always throw exception b/c you
* cannot use Memory.set() with text segment addresses and the
* "not valid address" produced here is misleading. Added data
* segment check prior to this point, so this "else" will never be
* executed. I'm leaving it in just in case MARS in the future adds
* capability of writing to the text segment (e.g. ability to
* de-assemble a binary value into its corresponding MIPS
* instruction)
********/
else {
try {
Globals.memory.set(this.textAddress.get(), value, lengthInBytes);
}
catch (AddressErrorException e) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(),
token.getSourceLine(), token.getStartPos(), "\""
+ this.textAddress.get()
+ "\" is not a valid text segment address"));
return;
}
this.textAddress.increment(lengthInBytes);
}
} // end of "if integer token type"
else if (token.getType() == TokenTypes.IDENTIFIER) {
if (this.inDataSegment) {
int value = fileCurrentlyBeingAssembled.getLocalSymbolTable()
.getAddressLocalOrGlobal(token.getValue());
if (value == SymbolTable.NOT_FOUND) {
// Record value 0 for now, then set up backpatch entry
int dataAddress = writeToDataSegment(0, lengthInBytes, token, errors);
currentFileDataSegmentForwardReferences.add(dataAddress, lengthInBytes, token);
}
else { // label already defined, so write its address
writeToDataSegment(value, lengthInBytes, token, errors);
}
} // Data segment check done previously, so this "else" will not be.
// See 11/20/06 note above.
else {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(),
token.getStartPos(), "\"" + token.getValue()
+ "\" label as directive operand not permitted in text segment"));
}
} // end of "if label"
else {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(), token
.getStartPos(), "\"" + token.getValue()
+ "\" is not a valid integer constant or label"));
}
}// storeInteger
// //////////////////////////////////////////////////////////////////////////////
// Store real (fixed or floating point) value given floating (float, double) directive.
// Called by storeNumeric()
private void storeRealNumber(Token token, Directives directive, ErrorList errors) {
int lengthInBytes = DataTypes.getLengthInBytes(directive);
double value;
if (TokenTypes.isIntegerTokenType(token.getType())
|| TokenTypes.isFloatingTokenType(token.getType())) {
try {
value = Double.parseDouble(token.getValue());
}
catch (NumberFormatException nfe) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(),
token.getStartPos(), "\"" + token.getValue()
+ "\" is not a valid floating point constant"));
return;
}
if (DataTypes.outOfRange(directive, value)) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(),
token.getStartPos(), "\"" + token.getValue()
+ "\" is an out-of-range value"));
return;
}
}
else {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(), token
.getStartPos(), "\"" + token.getValue()
+ "\" is not a valid floating point constant"));
return;
}
// Value has been validated; let's store it.
if (directive == Directives.FLOAT) {
writeToDataSegment(Float.floatToIntBits((float) value), lengthInBytes, token, errors);
}
if (directive == Directives.DOUBLE) {
writeDoubleToDataSegment(value, token, errors);
}
} // storeRealNumber
// //////////////////////////////////////////////////////////////////////////////////
// Use directive argument to distinguish between ASCII and ASCIIZ. The
// latter stores a terminating null byte. Can handle a list of one or more
// strings on a single line.
private void storeStrings(TokenList tokens, Directives direct, ErrorList errors) {
Token token;
// Correctly handles case where this is a "directive continuation" line.
int tokenStart = 0;
if (tokens.get(0).getType() == TokenTypes.DIRECTIVE) {
tokenStart = 1;
}
for (int i = tokenStart; i < tokens.size(); i++) {
token = tokens.get(i);
if (token.getType() != TokenTypes.QUOTED_STRING) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(),
token.getStartPos(), "\"" + token.getValue()
+ "\" is not a valid character string"));
}
else {
String quote = token.getValue();
char theChar;
for (int j = 1; j < quote.length() - 1; j++) {
theChar = quote.charAt(j);
if (theChar == '\\') {
theChar = quote.charAt(++j);
switch (theChar) {
case 'n':
theChar = '\n';
break;
case 't':
theChar = '\t';
break;
case 'r':
theChar = '\r';
break;
case '\\':
theChar = '\\';
break;
case '\'':
theChar = '\'';
break;
case '"':
theChar = '"';
break;
case 'b':
theChar = '\b';
break;
case 'f':
theChar = '\f';
break;
case '0':
theChar = '\0';
break;
// Not implemented: \ n = octal character (n is number)
// \ x n = hex character (n is number)
// \ u n = unicode character (n is number)
// There are of course no spaces in these escape
// codes...
}
}
try {
Globals.memory.set(this.dataAddress.get(), (int) theChar,
DataTypes.CHAR_SIZE);
}
catch (AddressErrorException e) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token
.getSourceLine(), token.getStartPos(), "\""
+ this.dataAddress.get() + "\" is not a valid data segment address"));
}
this.dataAddress.increment(DataTypes.CHAR_SIZE);
}
if (direct == Directives.ASCIIZ) {
try {
Globals.memory.set(this.dataAddress.get(), 0, DataTypes.CHAR_SIZE);
}
catch (AddressErrorException e) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token
.getSourceLine(), token.getStartPos(), "\""
+ this.dataAddress.get() + "\" is not a valid data segment address"));
}
this.dataAddress.increment(DataTypes.CHAR_SIZE);
}
}
}
} // storeStrings()
// //////////////////////////////////////////////////////////////////////////////////
// Simply check to see if we are in data segment. Generate error if not.
private boolean passesDataSegmentCheck(Token token) {
if (!this.inDataSegment) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(), token
.getStartPos(), "\"" + token.getValue()
+ "\" directive cannot appear in text segment"));
return false;
}
else {
return true;
}
}
// //////////////////////////////////////////////////////////////////////////////////
// Writes the given int value into current data segment address. Works for
// all the integer types plus float (caller is responsible for doing floatToIntBits).
// Returns address at which the value was stored.
private int writeToDataSegment(int value, int lengthInBytes, Token token, ErrorList errors) {
if (this.autoAlign) {
this.dataAddress.set(this.alignToBoundary(this.dataAddress.get(), lengthInBytes));
}
try {
Globals.memory.set(this.dataAddress.get(), value, lengthInBytes);
}
catch (AddressErrorException e) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(), token
.getStartPos(), "\"" + this.dataAddress.get()
+ "\" is not a valid data segment address"));
return this.dataAddress.get();
}
int address = this.dataAddress.get();
this.dataAddress.increment(lengthInBytes);
return address;
}
// //////////////////////////////////////////////////////////////////////////////////
// Writes the given double value into current data segment address. Works
// only for DOUBLE floating
// point values -- Memory class doesn't have method for writing 8 bytes, so
// use setWord twice.
private void writeDoubleToDataSegment(double value, Token token, ErrorList errors) {
int lengthInBytes = DataTypes.DOUBLE_SIZE;
if (this.autoAlign) {
this.dataAddress.set(this.alignToBoundary(this.dataAddress.get(), lengthInBytes));
}
try {
Globals.memory.setDouble(this.dataAddress.get(), value);
}
catch (AddressErrorException e) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(), token
.getStartPos(), "\"" + this.dataAddress.get()
+ "\" is not a valid data segment address"));
return;
}
this.dataAddress.increment(lengthInBytes);
}
// //////////////////////////////////////////////////////////////////////////////////
// If address is multiple of byte boundary, returns address. Otherwise, returns address
// which is next higher multiple of the byte boundary. Used for aligning data segment.
// For instance if args are 6 and 4, returns 8 (next multiple of 4 higher than 6).
// NOTE: it will fix any symbol table entries for this address too. See else part.
private int alignToBoundary(int address, int byteBoundary) {
int remainder = address % byteBoundary;
if (remainder == 0) {
return address;
}
else {
int alignedAddress = address + byteBoundary - remainder;
fileCurrentlyBeingAssembled.getLocalSymbolTable().fixSymbolTableAddress(address,
alignedAddress);
return alignedAddress;
}
}
// ///////////////////////////////////////////////////////////////////////////////////
// Private class used as Comparator to sort the final ArrayList of
// ProgramStatements.
// Sorting is based on unsigned integer value of
// ProgramStatement.getAddress()
private class ProgramStatementComparator implements Comparator {
// Will be used to sort the collection. Unsigned int compare, because
// all kernel 32-bit
// addresses have 1 in high order bit, which makes the int negative.
// "Unsigned" compare
// is needed when signs of the two operands differ.
public int compare(Object obj1, Object obj2) {
if (obj1 instanceof ProgramStatement && obj2 instanceof ProgramStatement) {
int addr1 = ((ProgramStatement) obj1).getAddress();
int addr2 = ((ProgramStatement) obj2).getAddress();
return (addr1 < 0 && addr2 >= 0 || addr1 >= 0 && addr2 < 0) ? addr2 : addr1 - addr2;
}
else {
throw new ClassCastException();
}
}
// Take a hard line.
public boolean equals(Object obj) {
return this == obj;
}
}
// ///////////////////////////////////////////////////////////////////////////////////
// Private class to simultaneously track addresses in both user and kernel
// address spaces.
// Instantiate one for data segment and one for text segment.
private class UserKernelAddressSpace {
int[] address;
int currentAddressSpace;
private final int USER = 0, KERNEL = 1;
// Initially use user address space, not kernel.
private UserKernelAddressSpace(int userBase, int kernelBase) {
address = new int[2];
address[USER] = userBase;
address[KERNEL] = kernelBase;
currentAddressSpace = USER;
}
private int get() {
return address[currentAddressSpace];
}
private void set(int value) {
address[currentAddressSpace] = value;
}
private void increment(int increment) {
address[currentAddressSpace] += increment;
}
private void setAddressSpace(int addressSpace) {
if (addressSpace == USER || addressSpace == KERNEL) {
currentAddressSpace = addressSpace;
}
else {
throw new IllegalArgumentException();
}
}
}
// //////////////////////////////////////////////////////////////////////////
// Handy class to handle forward label references appearing as data
// segment operands. This is needed because the data segment is comletely
// processed by the end of the first assembly pass, and its directives may
// contain labels as operands. When this occurs, the label's associated
// address becomes the operand value. If it is a forward reference, we will
// save the necessary information in this object for finding and patching in
// the correct address at the end of the first pass (for this file or for all
// files if more than one).
//
// If such a parsed label refers to a local or global label not defined yet,
// pertinent information is added to this object:
// - memory address that needs the label's address,
// - number of bytes (addresses are 4 bytes but may be used with any of
// the integer directives: .word, .half, .byte)
// - the label's token. Normally need only the name but error message needs more.
private class DataSegmentForwardReferences {
private ArrayList forwardReferenceList;
private DataSegmentForwardReferences() {
forwardReferenceList = new ArrayList();
}
private int size() {
return forwardReferenceList.size();
}
// Add a new forward reference entry. Client must supply the following:
// - memory address to receive the label's address once resolved
// - number of address bytes to store (1 for .byte, 2 for .half, 4 for .word)
// - the label's token. All its information will be needed if error message generated.
private void add(int patchAddress, int length, Token token) {
forwardReferenceList.add(new DataSegmentForwardReference(patchAddress, length, token));
}
// Add the entries of another DataSegmentForwardReferences object to this one.
// Can be used at the end of each source file to dump all unresolved references
// into a common list to be processed after all source files parsed.
private void add(DataSegmentForwardReferences another) {
forwardReferenceList.addAll(another.forwardReferenceList);
}
// Clear out the list. Allows you to re-use it.
private void clear() {
forwardReferenceList.clear();
}
// Will traverse the list of forward references, attempting to resolve them.
// For each entry it will first search the provided local symbol table and
// failing that, the global one. If passed the global symbol table, it will
// perform a second, redundant, search. If search is successful, the patch
// is applied and the forward reference removed. If search is not successful,
// the forward reference remains (it is either undefined or a global label
// defined in a file not yet parsed).
private int resolve(SymbolTable localSymtab) {
int count = 0;
int labelAddress;
DataSegmentForwardReference entry;
for (int i = 0; i < forwardReferenceList.size(); i++) {
entry = (DataSegmentForwardReference) forwardReferenceList.get(i);
labelAddress = localSymtab.getAddressLocalOrGlobal(entry.token.getValue());
if (labelAddress != SymbolTable.NOT_FOUND) {
// patch address has to be valid b/c we already stored there...
try {
Globals.memory.set(entry.patchAddress, labelAddress, entry.length);
}
catch (AddressErrorException aee) {
}
forwardReferenceList.remove(i);
i--; // needed because removal shifted the remaining list indices down
count++;
}
}
return count;
}
// Call this when you are confident that remaining list entries are to
// undefined labels.
private void generateErrorMessages(ErrorList errors) {
DataSegmentForwardReference entry;
for (int i = 0; i < forwardReferenceList.size(); i++) {
entry = (DataSegmentForwardReference) forwardReferenceList.get(i);
errors.add(new ErrorMessage(entry.token.getSourceMIPSprogram(), entry.token
.getSourceLine(), entry.token.getStartPos(), "Symbol \""
+ entry.token.getValue() + "\" not found in symbol table."));
}
}
// inner-inner class to hold each entry of the forward reference list.
private class DataSegmentForwardReference {
int patchAddress;
int length;
Token token;
DataSegmentForwardReference(int patchAddress, int length, Token token) {
this.patchAddress = patchAddress;
this.length = length;
this.token = token;
}
}
}
}
DataTypes
package mars.assembler;
public final synchronized class DataTypes {
public static final int DOUBLE_SIZE = 8;
public static final int FLOAT_SIZE = 4;
public static final int WORD_SIZE = 4;
public static final int HALF_SIZE = 2;
public static final int BYTE_SIZE = 1;
public static final int CHAR_SIZE = 1;
public static final int MAX_WORD_VALUE = 2147483647;
public static final int MIN_WORD_VALUE = -2147483648;
public static final int MAX_HALF_VALUE = 32767;
public static final int MIN_HALF_VALUE = -32768;
public static final int MAX_UHALF_VALUE = 65535;
public static final int MIN_UHALF_VALUE = 0;
public static final int MAX_BYTE_VALUE = 127;
public static final int MIN_BYTE_VALUE = -128;
public static final double MAX_FLOAT_VALUE = 3.4028234663852886E38;
public static final double LOW_FLOAT_VALUE = -3.4028234663852886E38;
public static final double MAX_DOUBLE_VALUE = 1.7976931348623157E308;
public static final double LOW_DOUBLE_VALUE = -1.7976931348623157E308;
public void DataTypes();
public static int getLengthInBytes(Directives);
public static boolean outOfRange(Directives, int);
public static boolean outOfRange(Directives, double);
}
mars/assembler/DataTypes.java
mars/assembler/DataTypes.javapackage mars.assembler;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Information about MIPS data types.
* @author Pete Sanderson
* @version August 2003
**/
public final class DataTypes {
/** Number of bytes occupied by MIPS double is 8. **/
public static final int DOUBLE_SIZE = 8;
/** Number of bytes occupied by MIPS float is 4. **/
public static final int FLOAT_SIZE = 4;
/** Number of bytes occupied by MIPS word is 4. **/
public static final int WORD_SIZE = 4;
/** Number of bytes occupied by MIPS halfword is 2. **/
public static final int HALF_SIZE = 2;
/** Number of bytes occupied by MIPS byte is 1. **/
public static final int BYTE_SIZE = 1;
/** Number of bytes occupied by MIPS character is 1. **/
public static final int CHAR_SIZE = 1;
/** Maximum value that can be stored in a MIPS word is 231-1 **/
public static final int MAX_WORD_VALUE = Integer.MAX_VALUE;
/** Lowest value that can be stored in a MIPS word is -231 **/
public static final int MIN_WORD_VALUE = Integer.MIN_VALUE;
/** Maximum value that can be stored in a MIPS halfword is 215-1 **/
public static final int MAX_HALF_VALUE = 32767; //(int)Math.pow(2,15) – 1;
/** Lowest value that can be stored in a MIPS halfword is -215 **/
public static final int MIN_HALF_VALUE = -32768; //0 – (int) Math.pow(2,15);
/** Maximum value that can be stored in an unsigned MIPS halfword is 216-1 **/
public static final int MAX_UHALF_VALUE = 65535;
/** Lowest value that can be stored in na unsigned MIPS halfword is 0 **/
public static final int MIN_UHALF_VALUE = 0;
/** Maximum value that can be stored in a MIPS byte is 27-1 **/
public static final int MAX_BYTE_VALUE = Byte.MAX_VALUE;
/** Lowest value that can be stored in a MIPS byte is -27 **/
public static final int MIN_BYTE_VALUE = Byte.MIN_VALUE;
/** Maximum positive finite value that can be stored in a MIPS float is same as Java Float **/
public static final double MAX_FLOAT_VALUE = Float.MAX_VALUE;
/** Largest magnitude negative value that can be stored in a MIPS float (negative of the max) **/
public static final double LOW_FLOAT_VALUE = -Float.MAX_VALUE;
/** Maximum positive finite value that can be stored in a MIPS double is same as Java Double **/
public static final double MAX_DOUBLE_VALUE = Double.MAX_VALUE;
/** Largest magnitude negative value that can be stored in a MIPS double(negative of the max) **/
public static final double LOW_DOUBLE_VALUE = -Double.MAX_VALUE;
/**
* Get length in bytes for numeric MIPS directives.
* @param direct Directive to be measured.
* @return Returns length in bytes for values of that type. If type is not numeric
* (or not implemented yet), returns 0.
**/
public static int getLengthInBytes(Directives direct) {
if (direct == Directives.FLOAT)
return FLOAT_SIZE;
else if (direct == Directives.DOUBLE)
return DOUBLE_SIZE;
else if (direct == Directives.WORD)
return WORD_SIZE;
else if (direct == Directives.HALF)
return HALF_SIZE;
else if (direct == Directives.BYTE)
return BYTE_SIZE;
else
return 0;
}
/**
* Determines whether given integer value falls within value range for given directive.
* @param direct Directive that controls storage allocation for value.
* @param value The value to be stored.
* @return Returns true if value can be stored in the number of bytes allowed
* by the given directive (.word, .half, .byte), false otherwise.
**/
public static boolean outOfRange(Directives direct, int value) {
if (direct == Directives.HALF && (value < MIN_HALF_VALUE || value > MAX_HALF_VALUE))
return true;
else if (direct == Directives.BYTE && (value < MIN_BYTE_VALUE || value > MAX_BYTE_VALUE))
return true;
else
return false;
}
/**
* Determines whether given floating point value falls within value range for given directive.
* For float, this refers to range of the data type, not precision. Example: 1.23456789012345
* be stored in a float with loss of precision. It’s within the range. But 1.23e500 cannot be
* stored in a float because the exponent 500 is too large (float allows 8 bits for exponent).
* @param direct Directive that controls storage allocation for value.
* @param value The value to be stored.
* @return Returns true if value is within range of
* the given directive (.float, .double), false otherwise.
**/
public static boolean outOfRange(Directives direct, double value) {
if (direct == Directives.FLOAT && (value < LOW_FLOAT_VALUE || value > MAX_FLOAT_VALUE))
return true;
else
return false;
}
}
Directives
package mars.assembler;
public final synchronized class Directives {
private static java.util.ArrayList directiveList;
public static final Directives DATA;
public static final Directives TEXT;
public static final Directives WORD;
public static final Directives ASCII;
public static final Directives ASCIIZ;
public static final Directives BYTE;
public static final Directives ALIGN;
public static final Directives HALF;
public static final Directives SPACE;
public static final Directives DOUBLE;
public static final Directives FLOAT;
public static final Directives EXTERN;
public static final Directives KDATA;
public static final Directives KTEXT;
public static final Directives GLOBL;
public static final Directives SET;
public static final Directives EQV;
public static final Directives MACRO;
public static final Directives END_MACRO;
public static final Directives INCLUDE;
private String descriptor;
private String description;
private void Directives();
private void Directives(String, String);
public static Directives matchDirective(String);
public static java.util.ArrayList prefixMatchDirectives(String);
public String toString();
public String getName();
public String getDescription();
public static java.util.ArrayList getDirectiveList();
public static boolean isIntegerDirective(Directives);
public static boolean isFloatingDirective(Directives);
static void
}
mars/assembler/Directives.java
mars/assembler/Directives.java package mars.assembler;
import java.util.ArrayList;
/*
Copyright (c) 2003-2012, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Class representing MIPS assembler directives. If Java had enumerated types, these
* would probably be implemented that way. Each directive is represented by a unique object.
* The directive name is indicative of the directive it represents. For example, DATA
* represents the MIPS .data directive.
*
* @author Pete Sanderson
* @version August 2003
**/
public final class Directives {
private static ArrayList directiveList = new ArrayList();
public static final Directives DATA = new Directives(“.data”, “Subsequent items stored in Data segment at next available address”);
public static final Directives TEXT = new Directives(“.text”, “Subsequent items (instructions) stored in Text segment at next available address”);
public static final Directives WORD = new Directives(“.word”, “Store the listed value(s) as 32 bit words on word boundary”);
public static final Directives ASCII = new Directives(“.ascii”, “Store the string in the Data segment but do not add null terminator”);
public static final Directives ASCIIZ = new Directives(“.asciiz”, “Store the string in the Data segment and add null terminator”);
public static final Directives BYTE = new Directives(“.byte”, “Store the listed value(s) as 8 bit bytes”);
public static final Directives ALIGN = new Directives(“.align”, “Align next data item on specified byte boundary (0=byte, 1=half, 2=word, 3=double)”);
public static final Directives HALF = new Directives(“.half”, “Store the listed value(s) as 16 bit halfwords on halfword boundary”);
public static final Directives SPACE = new Directives(“.space”, “Reserve the next specified number of bytes in Data segment”);
public static final Directives DOUBLE = new Directives(“.double”, “Store the listed value(s) as double precision floating point”);
public static final Directives FLOAT = new Directives(“.float”, “Store the listed value(s) as single precision floating point”);
public static final Directives EXTERN = new Directives(“.extern”, “Declare the listed label and byte length to be a global data field”);
public static final Directives KDATA = new Directives(“.kdata”, “Subsequent items stored in Kernel Data segment at next available address”);
public static final Directives KTEXT = new Directives(“.ktext”, “Subsequent items (instructions) stored in Kernel Text segment at next available address”);
public static final Directives GLOBL = new Directives(“.globl”, “Declare the listed label(s) as global to enable referencing from other files”);
public static final Directives SET = new Directives(“.set”, “Set assembler variables. Currently ignored but included for SPIM compatability”);
/* EQV added by DPS 11 July 2012 */
public static final Directives EQV = new Directives(“.eqv”, “Substitute second operand for first. First operand is symbol, second operand is expression (like #define)”);
/* MACRO and END_MACRO added by Mohammad Sekhavat Oct 2012 */
public static final Directives MACRO = new Directives(“.macro”, “Begin macro definition. See .end_macro”);
public static final Directives END_MACRO = new Directives(“.end_macro”, “End macro definition. See .macro”);
/* INCLUDE added by DPS 11 Jan 2013 */
public static final Directives INCLUDE = new Directives(“.include”, “Insert the contents of the specified file. Put filename in quotes.”);
private String descriptor;
private String description; // help text
private Directives() {
// private ctor assures no objects can be created other than those above.
this.descriptor = “generic”;
this.description = “”;
directiveList.add(this);
}
private Directives(String name, String description) {
this.descriptor = name;
this.description = description;
directiveList.add(this);
}
/**
* Find Directive object, if any, which matches the given String.
*
* @param str A String containing candidate directive name (e.g. “.ascii”)
* @return If match is found, returns matching Directives object, else returns null.
**/
public static Directives matchDirective(String str) {
Directives match;
for (int i=0; i
**/
public static ArrayList prefixMatchDirectives(String str) {
ArrayList matches = null;
for (int i=0; i
*/
public class Macro {
private String name;
private MIPSprogram program;
private ArrayList
/**
* first and last line number of macro definition. first line starts with
* .macro directive and last line is .end_macro directive.
*/
private int fromLine, toLine;
private int origFromLine, origToLine;
/**
* arguments like %arg
will be substituted by macro expansion
*/
private ArrayList
public Macro() {
name = “”;
program = null;
fromLine = toLine = 0;
origFromLine = origToLine = 0;
args = new ArrayList
labels = new ArrayList
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public MIPSprogram getProgram() {
return program;
}
public void setProgram(MIPSprogram program) {
this.program = program;
}
public int getFromLine() {
return fromLine;
}
public int getOriginalFromLine() {
return this.origFromLine;
}
public void setFromLine(int fromLine) {
this.fromLine = fromLine;
}
public void setOriginalFromLine(int origFromLine) {
this.origFromLine = origFromLine;
}
public int getToLine() {
return toLine;
}
public int getOriginalToLine() {
return this.origToLine;
}
public void setToLine(int toLine) {
this.toLine = toLine;
}
public void setOriginalToLine(int origToLine) {
this.origToLine = origToLine;
}
public ArrayList
return args;
}
public void setArgs(ArrayList
this.args = args;
}
/**
* @param obj
* {@link Macro} object to check if their name and count of
* arguments are same
*/
@Override
public boolean equals(Object obj) {
if (obj instanceof Macro) {
Macro macro = (Macro) obj;
return macro.getName().equals(name) && (macro.args.size() == args.size());
}
return super.equals(obj);
}
public void addArg(String value) {
args.add(value);
}
/**
* Substitutes macro arguments in a line of source code inside macro
* definition to be parsed after macro expansion.
* Also appends “_M#” to all labels defined inside macro body where # is value of counter
*
* @param line
* source line number in macro definition to be substituted
* @param args
* @param counter
* unique macro expansion id
* @param errors
* @return line
-th line of source code, with substituted
* arguments
*/
public String getSubstitutedLine(int line, TokenList args, long counter, ErrorList errors) {
TokenList tokens = (TokenList) program.getTokenList().get(line – 1);
String s = program.getSourceLine(line);
for (int i = tokens.size() – 1; i >= 0; i–) {
Token token = tokens.get(i);
if (tokenIsMacroParameter(token.getValue(), true)) {
int repl = -1;
for (int j = 0; j < this.args.size(); j++) {
if (this.args.get(j).equals(token.getValue())) {
repl = j;
break;
}
}
String substitute = token.getValue();
if (repl != -1)
substitute = args.get(repl + 1).toString();
else {
errors.add(new ErrorMessage(program, token.getSourceLine(),
token.getStartPos(), "Unknown macro parameter"));
}
s = replaceToken(s, token, substitute);
}
else if (tokenIsMacroLabel(token.getValue())){
String substitute = token.getValue()+"_M"+counter;
s=replaceToken(s, token, substitute);
}
}
return s;
}
/**
* returns true if value
is name of a label defined in this macro’s body.
* @param value
* @return
*/
private boolean tokenIsMacroLabel(String value) {
return (Collections.binarySearch(labels, value)>=0);
}
/**
* replaces token tokenToBeReplaced
which is occured in source
with substitute
.
* @param source
* @param tokenToBeReplaced
* @param substitute
* @return
*/
// Initially the position of the substitute was based on token position but that proved problematic
// in that the source string does not always match the token list from which the token comes. The
// token list has already had .eqv equivalences applied whereas the source may not. This is because
// the source comes from a macro definition? That has proven to be a tough question to answer.
// DPS 12-feb-2013
private String replaceToken(String source, Token tokenToBeReplaced, String substitute) {
String stringToBeReplaced = tokenToBeReplaced.getValue();
int pos = source.indexOf(stringToBeReplaced);
return (pos < 0) ? source : source.substring(0, pos) + substitute + source.substring(pos+stringToBeReplaced.length());
}
/**
* returns whether tokenValue
is macro parameter or not
* @param tokenValue
* @param acceptSpimStyleParameters accepts SPIM-style parameters which begin with ‘$’ if true
* @return
*/
public static boolean tokenIsMacroParameter(String tokenValue, boolean acceptSpimStyleParameters) {
if (acceptSpimStyleParameters) {
// Bug fix: SPIM accepts parameter names that start with $ instead of %. This can
// lead to problems since register names also start with $. This IF condition
// should filter out register names. Originally filtered those from regular set but not
// from Coprocessor0 or Coprocessor1 register sets. Expanded the condition.
// DPS 7-July-2014.
if (tokenValue.length() > 0 && tokenValue.charAt(0) == ‘$’ &&
RegisterFile.getUserRegister(tokenValue) == null &&
Coprocessor0.getRegister(tokenValue) == null && // added 7-July-2014
Coprocessor1.getRegister(tokenValue) == null) // added 7-July-2014
{
return true;
}
}
return tokenValue.length() > 1 && tokenValue.charAt(0) == ‘%’;
}
public void addLabel(String value) {
labels.add(value);
}
/**
* Operations to be done on this macro before it is committed in macro pool.
*/
public void readyForCommit() {
Collections.sort(labels);
}
}
MacroPool
package mars.assembler;
public synchronized class MacroPool {
private mars.MIPSprogram program;
private java.util.ArrayList macroList;
private Macro current;
private java.util.ArrayList callStack;
private java.util.ArrayList callStackOrigLines;
private int counter;
public void MacroPool(mars.MIPSprogram);
public void beginMacro(Token);
public void commitMacro(Token);
public Macro getMatchingMacro(TokenList, int);
public boolean matchesAnyMacroName(String);
public Macro getCurrent();
public void setCurrent(Macro);
public int getNextCounter();
public java.util.ArrayList getCallStack();
public boolean pushOnCallStack(Token);
public void popFromCallStack();
public String getExpansionHistory();
}
mars/assembler/MacroPool.java
mars/assembler/MacroPool.java package mars.assembler;
import java.util.ArrayList;
import java.util.Stack;
import mars.ErrorList;
import mars.MIPSprogram;
/*
Copyright (c) 2013.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Stores information of macros defined by now.
* Will be used in first pass of assembling MIPS source code. When reached
* .macro
directive, parser calls
* {@link MacroPool#BeginMacro(String, int)} and skips source code lines until
* reaches .end_macro
directive. then calls
* {@link MacroPool#CommitMacro(int)} and the macro information stored in a
* {@link Macro} instance will be added to {@link #macroList}.
* Each {@link MIPSprogram} will have one {@link MacroPool}
* NOTE: Forward referencing macros (macro expansion before its definition in
* source code) and Nested macro definition (defining a macro inside other macro
* definition) are not supported.
*
* @author M.H.Sekhavat
*/
public class MacroPool {
private MIPSprogram program;
/**
* List of macros defined by now
*/
private ArrayList
/**
* @see #BeginMacro(String, int)
*/
private Macro current;
private ArrayList
private ArrayList
/**
* @see #getNextCounter()
*/
private int counter;
/**
* Create an empty MacroPool for given program
* @param mipsProgram associated MIPS program
*/
public MacroPool(MIPSprogram mipsProgram) {
this.program = mipsProgram;
macroList = new ArrayList
callStack=new ArrayList
callStackOrigLines=new ArrayList
current = null;
counter = 0;
}
/**
* This method will be called by parser when reached .macro
* directive.
* Instantiates a new {@link Macro} object and stores it in {@link #current}
* . {@link #current} will be added to {@link #macroList} by
* {@link #CommitMacro(int)}
*
* @param nameToken
* Token containing name of macro after .macro
directive
*/
public void beginMacro(Token nameToken) {
current = new Macro();
current.setName(nameToken.getValue());
current.setFromLine(nameToken.getSourceLine());
current.setOriginalFromLine(nameToken.getOriginalSourceLine());
current.setProgram(program);
}
/**
* This method will be called by parser when reached .end_macro
* directive.
* Adds/Replaces {@link #current} macro into the {@link #macroList}.
*
* @param endToken
* Token containing .end_macro
directive in source code
*/
public void commitMacro(Token endToken) {
current.setToLine(endToken.getSourceLine());
current.setOriginalToLine(endToken.getOriginalSourceLine());
current.readyForCommit();
macroList.add(current);
current = null;
}
/**
* Will be called by parser when reaches a macro expansion call
*
* @param tokens
* tokens passed to macro expansion call
* @return {@link Macro} object matching the name and argument count of
* tokens passed
*/
public Macro getMatchingMacro(TokenList tokens, int callerLine) {
if (tokens.size() < 1)
return null;
Macro ret = null;
Token firstToken = tokens.get(0);
for (Macro macro : macroList) {
if (macro.getName().equals(firstToken.getValue())
&& macro.getArgs().size() + 1 == tokens.size()
//&& macro.getToLine() < callerLine // condition removed; doesn't work nicely in conjunction with .include, and does not seem necessary. DPS 8-MAR-2013
&& (ret == null || ret.getFromLine() < macro.getFromLine()))
ret = macro;
}
return ret;
}
/**
* @param value
* @return true if any macros have been defined with name value
* by now, not concerning arguments count.
*/
public boolean matchesAnyMacroName(String value) {
for (Macro macro : macroList)
if (macro.getName().equals(value))
return true;
return false;
}
public Macro getCurrent() {
return current;
}
public void setCurrent(Macro current) {
this.current = current;
}
/**
* {@link #counter} will be set to 0 on construction of this class and will
* be incremented by each call. parser calls this method once for every
* expansions. it will be a unique id for each expansion of macro in a file
*
* @return counter value
*/
public int getNextCounter() {
return counter++;
}
public ArrayList
return callStack;
}
public boolean pushOnCallStack(Token token) { //returns true if detected expansion loop
int sourceLine = token.getSourceLine();
int origSourceLine = token.getOriginalSourceLine();
if (callStack.contains(sourceLine))
return true;
callStack.add(sourceLine);
callStackOrigLines.add(origSourceLine);
return false;
}
public void popFromCallStack() {
callStack.remove(callStack.size()-1);
callStackOrigLines.remove(callStackOrigLines.size()-1);
}
public String getExpansionHistory() {
String ret=””;
for (int i=0; i
ret+=”->”;
ret+=callStackOrigLines.get(i).toString();
}
return ret;
}
}
OperandFormat
package mars.assembler;
public synchronized class OperandFormat {
private void OperandFormat();
static boolean tokenOperandMatch(TokenList, mars.mips.instructions.Instruction, mars.ErrorList);
static mars.mips.instructions.Instruction bestOperandMatch(TokenList, java.util.ArrayList);
private static boolean numOperandsCheck(TokenList, mars.mips.instructions.Instruction, mars.ErrorList);
private static boolean operandTypeCheck(TokenList, mars.mips.instructions.Instruction, mars.ErrorList);
private static void generateMessage(Token, String, mars.ErrorList);
}
mars/assembler/OperandFormat.java
mars/assembler/OperandFormat.java package mars.assembler;
import mars.*;
import mars.util.Binary;
import mars.mips.instructions.*;
import java.util.*;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Provides utility method related to MIPS operand formats.
*
* @author Pete Sanderson
* @version August 2003
*/
public class OperandFormat {
private OperandFormat() {
}
/*
* Syntax test for correct match in both numbers and types of operands.
*
* @param candidateList List of tokens generated from programmer’s MIPS statement.
* @param spec The (resumably best matched) MIPS instruction.
* @param errors ErrorList into which any error messages generated here will be added.
*
* @return Returns true if the programmer’s statement matches the MIPS
* specification, else returns false.
*/
static boolean tokenOperandMatch(TokenList candidateList, Instruction inst, ErrorList errors) {
if (!numOperandsCheck(candidateList, inst, errors))
return false;
if (!operandTypeCheck(candidateList, inst, errors))
return false;
return true;
}
/*
* If candidate operator token matches more than one instruction mnemonic, then select
* first such Instruction that has an exact operand match. If none match,
* return the first Instruction and let client deal with operand mismatches.
*/
static Instruction bestOperandMatch(TokenList tokenList, ArrayList instrMatches) {
if (instrMatches == null)
return null;
if (instrMatches.size() == 1)
return (Instruction) instrMatches.get(0);
for (int i=0; i
}
mars/assembler/SymbolTable.java
mars/assembler/SymbolTable.java package mars.assembler;
import mars.*;
import java.util.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Creats a table of Symbol objects.
* @author Jason Bumgarner, Jason Shrewsbury
* @version June 2003
**/
public class SymbolTable {
private static String startLabel = “main”;
private String filename;
private ArrayList table;
// Note -1 is legal 32 bit address (0xFFFFFFFF) but it is the high address in
// kernel address space so highly unlikely that any symbol will have this as
// its associated address!
public static final int NOT_FOUND = -1;
/**
* Create a new empty symbol table for given file
* @param filename name of file this symbol table is associated with. Will be
* used only for output/display so it can be any descriptive string.
*/
public SymbolTable(String filename) {
this.filename = filename;
this.table = new ArrayList();
}
/**
* Adds a Symbol object into the array of Symbols.
* @param token The token representing the Symbol.
* @param address The address of the Symbol.
* @param b The type of Symbol, true for data, false for text.
* @param errors List to which to add any processing errors that occur.
**/
public void addSymbol(Token token, int address, boolean b, ErrorList errors) {
String label = token.getValue();
if (getSymbol(label) != null) {
errors.add(new ErrorMessage(token.getSourceMIPSprogram(), token.getSourceLine(),token.getStartPos(),”label \””+label+”\” already defined”));
}
else {
Symbol s= new Symbol(label, address, b);
table.add(s);
if (Globals.debug) System.out.println(“The symbol ” + label + ” with address ” + address + ” has been added to the “+this.filename+” symbol table.”);
}
}
/**
* Removes a symbol from the Symbol table. If not found, it does nothing.
* This will rarely happen (only when variable is declared .globl after already
* being defined in the local symbol table).
* @param token The token representing the Symbol.
**/
public void removeSymbol(Token token) {
String label = token.getValue();
for (int i=0; i < table.size(); i++) {
if (((Symbol)(table.get(i))).getName().equals(label)){
table.remove(i);
if (Globals.debug) System.out.println("The symbol " + label + " has been removed from the "+this.filename+" symbol table.");
break;
}
}
return;
}
/**
* Method to return the address associated with the given label.
* @param s The label.
* @return The memory address of the label given, or NOT_FOUND if not found in symbol table.
**/
public int getAddress(String s){
for(int i=0; i < table.size(); i++){
if (((Symbol)(table.get(i))).getName().equals(s)){
return((Symbol) table.get(i)).getAddress();
}
}
return NOT_FOUND;
}
/**
* Method to return the address associated with the given label. Look first
* in this (local) symbol table then in symbol table of labels declared
* global (.globl directive).
* @param s The label.
* @return The memory address of the label given, or NOT_FOUND if not found in symbol table.
**/
public int getAddressLocalOrGlobal(String s) {
int address = this.getAddress(s);
return (address==NOT_FOUND) ? Globals.symbolTable.getAddress(s) : address ;
}
/**
* Produce Symbol object from symbol table that corresponds to given String.
* @param s target String
* @return Symbol object for requested target, null if not found in symbol table.
**/
public Symbol getSymbol(String s){
for(int i=0; i < table.size(); i++){
if (((Symbol)(table.get(i))).getName().equals(s)){
return (Symbol) table.get(i);
}
}
return null;
}
/**
* Produce Symbol object from symbol table that has the given address.
* @param s String representing address
* @return Symbol object having requested address, null if address not found in symbol table.
**/
public Symbol getSymbolGivenAddress(String s){
int address = 0;
try {
address = mars.util.Binary.stringToInt(s);// DPS 2-Aug-2010: was Integer.parseInt(s) but croaked on hex
}
catch (NumberFormatException e) {
return null;
}
for(int i=0; i < table.size(); i++){
if (((Symbol)(table.get(i))).getAddress() == address){
return (Symbol) table.get(i);
}
}
return null;
}
/**
* Produce Symbol object from either local or global symbol table that has the
* given address.
* @param s String representing address
* @return Symbol object having requested address, null if address not found in symbol table.
**/
public Symbol getSymbolGivenAddressLocalOrGlobal(String s){
Symbol sym = this.getSymbolGivenAddress(s);
return (sym==null) ? Globals.symbolTable.getSymbolGivenAddress(s) : sym ;
}
/**
* For obtaining the Data Symbols.
* @return An ArrayList of Symbol objects.
**/
public ArrayList getDataSymbols(){
ArrayList list= new ArrayList();
for(int i=0; i
this.processCandidateToken(token, program, lineNum, theLine, tokenPos, tokenStartPos, result);
tokenPos = 0;
}
tokenStartPos = linePos+1;
tokenPos = line.length-linePos;
System.arraycopy(line, linePos, token, 0, tokenPos);
this.processCandidateToken(token, program, lineNum, theLine, tokenPos, tokenStartPos, result);
linePos = line.length;
tokenPos = 0;
break;
case ‘ ‘ :
case ‘\t’:
case ‘,’ : // space, tab or comma is delimiter
if (tokenPos > 0) {
this.processCandidateToken(token, program, lineNum, theLine, tokenPos, tokenStartPos, result);
tokenPos = 0;
}
break;
// These two guys are special. Will be recognized as unary if and only if two conditions hold:
// 1. Immediately followed by a digit (will use look-ahead for this).
// 2. Previous token, if any, is _not_ an IDENTIFIER
// Otherwise considered binary and thus a separate token. This is a slight hack but reasonable.
case ‘+’ :
case ‘-‘ :
// Here’s the REAL hack: recognizing signed exponent in E-notation floating point!
// (e.g. 1.2e-5) Add the + or – to the token and keep going. DPS 17 Aug 2005
if (tokenPos > 0 && line.length >= linePos+2 && Character.isDigit(line[linePos+1]) &&
(line[linePos-1]==’e’ || line[linePos-1]==’E’)) {
token[tokenPos++] = c;
break;
}
// End of REAL hack.
if (tokenPos > 0) {
this.processCandidateToken(token, program, lineNum, theLine, tokenPos, tokenStartPos, result);
tokenPos = 0;
}
tokenStartPos = linePos+1;
token[tokenPos++] = c;
if ( !((result.isEmpty() || ((Token)result.get(result.size()-1)).getType() != TokenTypes.IDENTIFIER) &&
(line.length >= linePos+2 && Character.isDigit(line[linePos+1]))) ) {
// treat it as binary…..
this.processCandidateToken(token, program, lineNum, theLine, tokenPos, tokenStartPos, result);
tokenPos = 0;
}
break;
// these are other single-character tokens
case ‘:’ :
case ‘(‘ :
case ‘)’ :
if (tokenPos > 0) {
this.processCandidateToken(token, program, lineNum, theLine, tokenPos, tokenStartPos, result);
tokenPos = 0;
}
tokenStartPos = linePos+1;
token[tokenPos++] = c;
this.processCandidateToken(token, program, lineNum, theLine, tokenPos, tokenStartPos, result);
tokenPos = 0;
break;
case ‘”‘ : // we’re not inside a quoted string, so start a new token…
if (tokenPos > 0) {
this.processCandidateToken(token, program, lineNum, theLine, tokenPos, tokenStartPos, result);
tokenPos = 0;
}
tokenStartPos = linePos+1;
token[tokenPos++] = c;
insideQuotedString = true;
break;
case ‘\” : // start of character constant (single quote).
if (tokenPos > 0) {
this.processCandidateToken(token, program, lineNum, theLine, tokenPos, tokenStartPos, result);
tokenPos = 0;
}
// Our strategy is to process the whole thing right now…
tokenStartPos = linePos+1;
token[tokenPos++] = c; // Put the quote in token[0]
int lookaheadChars = line.length – linePos – 1;
// need minimum 2 more characters, 1 for char and 1 for ending quote
if (lookaheadChars < 2) break; // gonna be an error c = line[++linePos]; token[tokenPos++] = c; // grab second character, put it in token[1] if (c == '\'') break; // gonna be an error: nothing between the quotes c = line[++linePos]; token[tokenPos++] = c; // grab third character, put it in token[2] // Process if we've either reached second, non-escaped, quote or end of line. if (c == '\'' && token[1] != '\\' || lookaheadChars==2) { this.processCandidateToken(token, program, lineNum, theLine, tokenPos, tokenStartPos, result); tokenPos = 0; tokenStartPos = linePos+1; break; } // At this point, there is at least one more character on this line. If we're // still here after seeing a second quote, it was escaped. Not done yet; // we either have an escape code, an octal code (also escaped) or invalid. c = line[++linePos]; token[tokenPos++] = c; // grab fourth character, put it in token[3] // Process, if this is ending quote for escaped character or if at end of line if (c == '\'' || lookaheadChars==3) { this.processCandidateToken(token, program, lineNum, theLine, tokenPos, tokenStartPos, result); tokenPos = 0; tokenStartPos = linePos+1; break; } // At this point, we've handled all legal possibilities except octal, e.g. '\377' // Proceed, if enough characters remain to finish off octal. if (lookaheadChars >= 5) {
c = line[++linePos];
token[tokenPos++] = c; // grab fifth character, put it in token[4]
if (c != ‘\”) {
// still haven’t reached end, last chance for validity!
c = line[++linePos];
token[tokenPos++] = c; // grab sixth character, put it in token[5]
}
}
// process no matter what…we either have a valid character by now or not
this.processCandidateToken(token, program, lineNum, theLine, tokenPos, tokenStartPos, result);
tokenPos = 0;
tokenStartPos = linePos+1;
break;
default :
if (tokenPos == 0)
tokenStartPos = linePos+1;
token[tokenPos++] = c;
break;
} // switch
} // if (insideQuotedString)
linePos++;
} // while
if (tokenPos > 0) {
this.processCandidateToken(token, program, lineNum, theLine, tokenPos, tokenStartPos, result);
tokenPos = 0;
}
if (doEqvSubstitutes) {
result = processEqv(program, lineNum, theLine, result); // DPS 11-July-2012
}
return result;
}
// Process the .eqv directive, which needs to be applied prior to tokenizing of subsequent statements.
// This handles detecting that theLine contains a .eqv directive, in which case it needs
// to be added to the HashMap of equivalents. It also handles detecting that theLine
// contains a symbol that was previously defined in an .eqv directive, in which case
// the substitution needs to be made.
// DPS 11-July-2012
private TokenList processEqv(MIPSprogram program, int lineNum, String theLine, TokenList tokens) {
// See if it is .eqv directive. If so, record it…
// Have to assure it is a well-formed statement right now (can’t wait for assembler).
if (tokens.size()>2 && (tokens.get(0).getType() == TokenTypes.DIRECTIVE || tokens.get(2).getType() == TokenTypes.DIRECTIVE)) {
// There should not be a label but if there is, the directive is in token position 2 (ident, colon, directive).
int dirPos = (tokens.get(0).getType() == TokenTypes.DIRECTIVE) ? 0 : 2;
if (Directives.matchDirective(tokens.get(dirPos).getValue()) == Directives.EQV) {
// Get position in token list of last non-comment token
int tokenPosLastOperand = tokens.size() – ((tokens.get(tokens.size()-1).getType()==TokenTypes.COMMENT)? 2 : 1);
// There have to be at least two non-comment tokens beyond the directive
if (tokenPosLastOperand < dirPos+2) { errors.add(new ErrorMessage(program, lineNum,tokens.get(dirPos).getStartPos(), "Too few operands for "+Directives.EQV.getName()+" directive")); return tokens; } // Token following the directive has to be IDENTIFIER if (tokens.get(dirPos+1).getType() != TokenTypes.IDENTIFIER) { errors.add(new ErrorMessage(program, lineNum,tokens.get(dirPos).getStartPos(), "Malformed "+Directives.EQV.getName()+" directive")); return tokens; } String symbol = tokens.get(dirPos+1).getValue(); // Make sure the symbol is not contained in the expression. Not likely to occur but if left // undetected it will result in infinite recursion. e.g. .eqv ONE, (ONE) for (int i=dirPos+2; i
TokenTypes type = TokenTypes.matchTokenType(value);
if (type == TokenTypes.ERROR) {
errors.add(new ErrorMessage(program, line, tokenStartPos,
theLine+”\nInvalid language element: “+value));
}
Token toke = new Token(type, value, program, line, tokenStartPos);
tokenList.add(toke);
return;
}
// If passed a candidate character literal, attempt to translate it into integer constant.
// If the translation fails, return original value.
private String preprocessCharacterLiteral(String value) {
// must start and end with quote and have something in between
if (value.length() < 3 || value.charAt(0) != '\'' || value.charAt(value.length()-1) != '\'') { return value; } String quotesRemoved = value.substring(1, value.length()-1); // if not escaped, then if one character left return its value else return original. if (quotesRemoved.charAt(0) != '\\') { return (quotesRemoved.length() == 1) ? Integer.toString((int)quotesRemoved.charAt(0)) : value; } // now we know it is escape sequence and have to decode which of the 8: ',",\,n,t,b,r,f if (quotesRemoved.length() == 2) { int escapedCharacterIndex = escapedCharacters.indexOf(quotesRemoved.charAt(1)); return (escapedCharacterIndex >= 0) ? escapedCharactersValues[escapedCharacterIndex] : value;
}
// last valid possibility is 3 digit octal code 000 through 377
if (quotesRemoved.length() == 4) {
try {
int intValue = Integer.parseInt(quotesRemoved.substring(1),8);
if (intValue >= 0 && intValue <= 255) { return Integer.toString(intValue); } } catch (NumberFormatException nfe) { } // if not valid octal, will fall through and reject } return value; } } TokenList package mars.assembler; public synchronized class TokenList implements Cloneable { private java.util.ArrayList tokenList; private String processedLine; public void TokenList(); public void setProcessedLine(String); public String getProcessedLine(); public Token get(int); public void set(int, Token); public int size(); public void add(Token); public void remove(int); public boolean isEmpty(); public String toString(); public String toTypeString(); public Object clone(); } mars/assembler/TokenList.java mars/assembler/TokenList.javapackage mars.assembler; import java.util.ArrayList; /* Copyright (c) 2003-2013, Pete Sanderson and Kenneth Vollmar Developed by Pete Sanderson (psanderson@otterbein.edu) and Kenneth Vollmar (kenvollmar@missouristate.edu) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. (MIT license, http://www.opensource.org/licenses/mit-license.html) */ /** * Represents the list of tokens in a single line of MIPS code. It uses, but is not * a subclass of, ArrayList. * * @author Pete Sanderson * @version August 2003 */ public class TokenList implements Cloneable { private ArrayList tokenList; private String processedLine;// DPS 03-Jan-2013 /** * Constructor for objects of class TokenList */ public TokenList() { tokenList = new ArrayList(); processedLine = ""; // DPS 03-Jan-2013 } /** * Use this to record the source line String for this token list * after possible modification (textual substitution) during * assembly preprocessing. The modified source will be displayed in * the Text Segment Display. * @param line The source line, possibly modified (possibly not) */ // DPS 03-Jan-2013 public void setProcessedLine(String line) { processedLine = line; } /** * Retrieve the source line String associated with this * token list. It may or may not have been modified during * assembly preprocessing. * @return The source line for this token list. */ // DPS 03-Jan-2013/ public String getProcessedLine() { return processedLine; } /** * Returns requested token given position number (starting at 0). * * @param pos Position in token list. * @return the requested token, or ArrayIndexOutOfBounds exception */ public Token get(int pos) { return (Token) tokenList.get(pos); } /** * Replaces token at position with different one. Will throw * ArrayIndexOutOfBounds exception if position does not exist. * * @param pos Position in token list. * @param replacement Replacement token */ public void set(int pos, Token replacement) { tokenList.set(pos, replacement); } /** * Returns number of tokens in list. * * @return token count. */ public int size() { return tokenList.size(); } /** * Adds a Token object to the end of the list. * * @param token Token object to be added. */ public void add(Token token) { tokenList.add(token); } /** * Removes Token object at specified list position. Uses ArrayList remove method. * * @param pos Position in token list. Subsequent Tokens are shifted one position left. * @throws IndexOutOfBoundsException if pos is < 0 or >= size()
*/
public void remove(int pos) {
tokenList.remove(pos);
}
/**
* Returns empty/non-empty status of list.
*
* @return true if list has no tokens, else false.
*/
public boolean isEmpty() {
return tokenList.isEmpty();
}
/**
* Get a String representing the token list.
*
* @return String version of the token list
* (a blank is inserted after each token).
*/
public String toString() {
String stringified = “”;
for (int i=0; i
}
mars/assembler/TokenTypes.java
mars/assembler/TokenTypes.java package mars.assembler;
import mars.*;
import mars.util.*;
import mars.mips.hardware.*;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Constants to identify the types of tokens found in MIPS programs. If Java had
* enumerated types, that’s how these would probably be implemented.
*
* @author Pete Sanderson
* @version August 2003
**/
public final class TokenTypes {
public static final String TOKEN_DELIMITERS = “\t ,()”;
public static final TokenTypes COMMENT = new TokenTypes(“COMMENT”);
public static final TokenTypes DIRECTIVE = new TokenTypes(“DIRECTIVE”);
public static final TokenTypes OPERATOR = new TokenTypes(“OPERATOR”);
public static final TokenTypes DELIMITER = new TokenTypes(“DELIMITER”);
/** note: REGISTER_NAME is token of form $zero whereas REGISTER_NUMBER is token
* of form $0. The former is part of extended assembler, and latter is part
* of basic assembler.
**/
public static final TokenTypes REGISTER_NAME = new TokenTypes(“REGISTER_NAME”); // mnemonic
public static final TokenTypes REGISTER_NUMBER = new TokenTypes(“REGISTER_NUMBER”);
public static final TokenTypes FP_REGISTER_NAME = new TokenTypes(“FP_REGISTER_NAME”);
public static final TokenTypes IDENTIFIER = new TokenTypes(“IDENTIFIER”);
public static final TokenTypes LEFT_PAREN = new TokenTypes(“LEFT_PAREN”);
public static final TokenTypes RIGHT_PAREN = new TokenTypes(“RIGHT_PAREN”);
//public static final TokenTypes INTEGER = new TokenTypes(“INTEGER”);
public static final TokenTypes INTEGER_5 = new TokenTypes(“INTEGER_5”);
public static final TokenTypes INTEGER_16 = new TokenTypes(“INTEGER_16”);
public static final TokenTypes INTEGER_16U = new TokenTypes(“INTEGER_16U”);
public static final TokenTypes INTEGER_32 = new TokenTypes(“INTEGER_32”);
public static final TokenTypes REAL_NUMBER = new TokenTypes(“REAL_NUMBER”);
public static final TokenTypes QUOTED_STRING = new TokenTypes(“QUOTED_STRING”);
public static final TokenTypes PLUS = new TokenTypes(“PLUS”);
public static final TokenTypes MINUS = new TokenTypes(“MINUS”);
public static final TokenTypes COLON = new TokenTypes(“COLON”);
public static final TokenTypes ERROR = new TokenTypes(“ERROR”);
public static final TokenTypes MACRO_PARAMETER = new TokenTypes(“MACRO_PARAMETER”);
private String descriptor;
private TokenTypes() {
// private ctor assures no objects can be created other than those above.
descriptor = “generic”;
}
private TokenTypes(String name) {
descriptor = name;
}
/**
* Produces String equivalent of this token type, which is its name.
*
* @return String containing descriptive name for token type.
**/
public String toString() {
return descriptor;
}
/**
* Classifies the given token into one of the MIPS types.
*
* @param value String containing candidate language element, extracted from MIPS program.
*
* @return Returns the corresponding TokenTypes object if the parameter matches a
* defined MIPS token type, else returns null.
**/
public static TokenTypes matchTokenType(String value)
{
TokenTypes type = null;
// If it starts with single quote (‘), it is a mal-formed character literal
// because a well-formed character literal was converted to string-ified
// integer before getting here…
if (value.charAt(0) == ‘\”)
return TokenTypes.ERROR;
// See if it is a comment
if (value.charAt(0) == ‘#’)
return TokenTypes.COMMENT;
// See if it is one of the simple tokens
if (value.length() == 1) {
switch (value.charAt(0)) {
case ‘(‘ :
return TokenTypes.LEFT_PAREN;
case ‘)’ :
return TokenTypes.RIGHT_PAREN;
case ‘:’ :
return TokenTypes.COLON;
case ‘+’ :
return TokenTypes.PLUS;
case ‘-‘ :
return TokenTypes.MINUS;
}
}
// See if it is a macro parameter
if (Macro.tokenIsMacroParameter(value, false))
return TokenTypes.MACRO_PARAMETER;
// See if it is a register
Register reg = RegisterFile.getUserRegister(value);
if (reg != null)
if (reg.getName().equals(value))
return TokenTypes.REGISTER_NAME;
else
return TokenTypes.REGISTER_NUMBER;
// See if it is a floating point register
reg = Coprocessor1.getRegister(value);
if (reg != null)
return TokenTypes.FP_REGISTER_NAME;
// See if it is an immediate (constant) integer value
// Classify based on # bits needed to represent in binary
// This is needed because most immediate operands limited to 16 bits
// others limited to 5 bits unsigned (shift amounts) others 32 bits.
try {
int i = Binary.stringToInt(value); // KENV 1/6/05
/***************************************************************************
* MODIFICATION AND COMMENT, DPS 3-July-2008
*
* The modifications of January 2005 documented below are being rescinded.
* All hexadecimal immediate values are considered 32 bits in length and
* their classification as INTEGER_5, INTEGER_16, INTEGER_16U (new)
* or INTEGER_32 depends on their 32 bit value. So 0xFFFF will be
* equivalent to 0x0000FFFF instead of 0xFFFFFFFF. This change, along with
* the introduction of INTEGER_16U (adopted from Greg Gibeling of Berkeley),
* required extensive changes to instruction templates especially for
* pseudo-instructions.
*
* This modification also appears inbuildBasicStatementFromBasicInstruction()
* in mars.ProgramStatement.
*
* ///// Begin modification 1/4/05 KENV ///////////////////////////////////////////
* // We have decided to interpret non-signed (no + or -) 16-bit hexadecimal immediate
* // operands as signed values in the range -32768 to 32767. So 0xffff will represent
* // -1, not 65535 (bit 15 as sign bit), 0x8000 will represent -32768 not 32768.
* // NOTE: 32-bit hexadecimal immediate operands whose values fall into this range
* // will be likewise affected, but they are used only in pseudo-instructions. The
* // code in ExtendedInstruction.java to split this number into upper 16 bits for “lui”
* // and lower 16 bits for “ori” works with the original source code token, so it is
* // not affected by this tweak. 32-bit immediates in data segment directives
* // are also processed elsewhere so are not affected either.
* ////////////////////////////////////////////////////////////////////////////////
*
* if ( Binary.isHex(value) &&
* (i >= 32768) &&
* (i <= 65535) ) // Range 0x8000 ... 0xffff
* {
* // Subtract the 0xffff bias, because strings in the
* // range "0x8000" ... "0xffff" are used to represent
* // 16-bit negative numbers, not positive numbers.
* i = i - 65536;
* }
* // ------------- END KENV 1/4/05 MODIFICATIONS --------------
*
************************** END DPS 3-July-2008 COMMENTS *******************************/
// shift operands must be in range 0-31
if (i>=0 && i<=31) {
return TokenTypes.INTEGER_5;
}
if (i>=DataTypes.MIN_UHALF_VALUE && i<=DataTypes.MAX_UHALF_VALUE) {
return TokenTypes.INTEGER_16U;
}
if (i>=DataTypes.MIN_HALF_VALUE && i<=DataTypes.MAX_HALF_VALUE) {
return TokenTypes.INTEGER_16;
}
return TokenTypes.INTEGER_32; // default when no other type is applicable
}
catch(NumberFormatException e)
{
// NO ACTION -- exception suppressed
}
// See if it is a real (fixed or floating point) number. Note that parseDouble()
// accepts integer values but if it were an integer literal we wouldn't get this far.
try {
Double.parseDouble(value);
return TokenTypes.REAL_NUMBER;
}
catch (NumberFormatException e)
{
// NO ACTION -- exception suppressed
}
// See if it is an instruction operator
if (Globals.instructionSet.matchOperator(value) != null)
return TokenTypes.OPERATOR;
// See if it is a directive
if (value.charAt(0) == '.' && Directives.matchDirective(value) != null) {
return TokenTypes.DIRECTIVE;
}
// See if it is a quoted string
if (value.charAt(0) == '"')
return TokenTypes.QUOTED_STRING;
// Test for identifier goes last because I have defined tokens for various
// MIPS constructs (such as operators and directives) that also could fit
// the lexical specifications of an identifier, and those need to be
// recognized first.
if (isValidIdentifier(value))
return TokenTypes.IDENTIFIER;
// Matches no MIPS language token.
return TokenTypes.ERROR;
}
/**
*
* Lets you know if given tokentype is for integers (INTGER_5, INTEGER_16, INTEGER_32).
*
* @param type the TokenType of interest
* @return true if type is an integer type, false otherwise.
**/
public static boolean isIntegerTokenType(TokenTypes type) {
return type == TokenTypes.INTEGER_5 || type == TokenTypes.INTEGER_16 ||
type == TokenTypes.INTEGER_16U || type == TokenTypes.INTEGER_32;
}
/**
*
* Lets you know if given tokentype is for floating point numbers (REAL_NUMBER).
*
* @param type the TokenType of interest
* @return true if type is an floating point type, false otherwise.
**/
public static boolean isFloatingTokenType(TokenTypes type) {
return type == TokenTypes.REAL_NUMBER;
}
// COD2, A-51: "Identifiers are a sequence of alphanumeric characters,
// underbars (_), and dots (.) that do not begin with a number."
// Ideally this would be in a separate Identifier class but I did not see an immediate
// need beyond this method (refactoring effort would probably identify other uses
// related to symbol table).
//
// DPS 14-Jul-2008: added '$' as valid symbol. Permits labels to include $.
// MIPS-target GCC will produce labels that start with $.
public static boolean isValidIdentifier(String value) {
boolean result =
(Character.isLetter(value.charAt(0)) || value.charAt(0)=='_' || value.charAt(0)=='.' || value.charAt(0)=='$');
int index = 1;
while (result && index < value.length()) {
if (!(Character.isLetterOrDigit(value.charAt(index)) || value.charAt(index)=='_' || value.charAt(index)=='.' || value.charAt(index)=='$'))
result = false;
index++;
}
return result;
}
}
TranslationCode
package mars.assembler;
public abstract interface TranslationCode {
public abstract void translate();
}
mars/assembler/TranslationCode.java
mars/assembler/TranslationCode.javapackage mars.assembler;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* This interface is intended for use by ExtendedInstruction objects to define, using
* the translate() method, how to translate the extended (pseudo) instruction into
* a sequence of one or more basic instructions, which can then be translated into
* binary machine code.
*
* @author Pete Sanderson
* @version August 2003
*/
public interface TranslationCode {
/**
* This is a callback method defined in anonymous class specified as
* argument to ExtendedInstruction constructor. It is called when
* assembler finds a program statement matching that ExtendedInstruction,
*/
public void translate();
}
ErrorList
package mars;
public synchronized class ErrorList {
private java.util.ArrayList messages;
private int errorCount;
private int warningCount;
public static final String ERROR_MESSAGE_PREFIX = Error;
public static final String WARNING_MESSAGE_PREFIX = Warning;
public static final String FILENAME_PREFIX = in ;
public static final String LINE_PREFIX = line ;
public static final String POSITION_PREFIX = column ;
public static final String MESSAGE_SEPARATOR = : ;
public void ErrorList();
public java.util.ArrayList getErrorMessages();
public boolean errorsOccurred();
public boolean warningsOccurred();
public void add(ErrorMessage);
public void add(ErrorMessage, int);
public int errorCount();
public int warningCount();
public boolean errorLimitExceeded();
public int getErrorLimit();
public String generateErrorReport();
public String generateWarningReport();
public String generateErrorAndWarningReport();
private String generateReport(boolean);
}
mars/ErrorList.java
mars/ErrorList.java package mars;
import java.util.*;
import java.io.*;
/*
Copyright (c) 2003-2012, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Maintains list of generated error messages, regardless of source (tokenizing, parsing,
* assembly, execution).
*
* @author Pete Sanderson
* @version August 2003
**/
public class ErrorList {
private ArrayList messages;
private int errorCount;
private int warningCount;
public static final String ERROR_MESSAGE_PREFIX = "Error";
public static final String WARNING_MESSAGE_PREFIX = "Warning";
public static final String FILENAME_PREFIX = " in ";
public static final String LINE_PREFIX = " line ";
public static final String POSITION_PREFIX = " column ";
public static final String MESSAGE_SEPARATOR = ": ";
/**
* Constructor for ErrorList
**/
public ErrorList() {
messages = new ArrayList();
errorCount = 0;
warningCount = 0;
}
/**
* Get ArrayList of error messages.
* @return ArrayList of ErrorMessage objects
*/
public ArrayList getErrorMessages() {
return messages;
}
/**
* Determine whether error has occured or not.
* @return true if an error has occurred (does not include warnings), false otherwise.
**/
public boolean errorsOccurred() {
return (errorCount != 0 );
}
/**
* Determine whether warning has occured or not.
* @return true if an warning has occurred, false otherwise.
**/
public boolean warningsOccurred() {
return (warningCount != 0 );
}
/** Add new error message to end of list.
* @param mess ErrorMessage object to be added to end of error list.
**/
public void add(ErrorMessage mess){
add(mess, messages.size());
}
/** Add new error message at specified index position.
* @param mess ErrorMessage object to be added to end of error list.
* @param index position in error list
**/
public void add(ErrorMessage mess, int index) {
if (errorCount > getErrorLimit()) {
return;
}
if (errorCount == getErrorLimit()) {
messages.add(new ErrorMessage((MIPSprogram)null, mess.getLine(), mess.getPosition(),”Error Limit of “+getErrorLimit()+” exceeded.”));
errorCount++; // subsequent errors will not be added; see if statement above
return;
}
messages.add(index, mess);
if (mess.isWarning()) {
warningCount++;
}
else {
errorCount++;
}
}
/**
* Count of number of error messages in list.
* @return Number of error messages in list.
**/
public int errorCount() {
return this.errorCount;
}
/**
* Count of number of warning messages in list.
* @return Number of warning messages in list.
**/
public int warningCount() {
return this.warningCount;
}
/**
* Check to see if error limit has been exceeded.
* @return True if error limit exceeded, false otherwise.
**/
public boolean errorLimitExceeded() {
return this.errorCount > getErrorLimit();
}
/**
* Get limit on number of error messages to be generated
* by one assemble operation.
* @return error limit.
**/
public int getErrorLimit() {
return Globals.maximumErrorMessages;
}
/**
* Produce error report.
* @return String containing report.
**/
public String generateErrorReport() {
return generateReport(ErrorMessage.ERROR);
}
/**
* Produce warning report.
* @return String containing report.
**/
public String generateWarningReport() {
return generateReport(ErrorMessage.WARNING);
}
/**
* Produce report containing both warnings and errors, warnings first.
* @return String containing report.
**/
public String generateErrorAndWarningReport() {
return generateWarningReport()+generateErrorReport();
}
// Produces either error or warning report.
private String generateReport(boolean isWarning) {
StringBuffer report = new StringBuffer(“”);
String reportLine;
for (int i = 0; i < messages.size(); i++) {
ErrorMessage m = (ErrorMessage) messages.get(i);
if ((isWarning && m.isWarning()) || (!isWarning && !m.isWarning())) {
reportLine = ((isWarning) ? WARNING_MESSAGE_PREFIX : ERROR_MESSAGE_PREFIX) + FILENAME_PREFIX;
if (m.getFilename().length() > 0)
reportLine = reportLine + (new File(m.getFilename()).getPath()); //.getName());
if (m.getLine() > 0)
reportLine = reportLine + LINE_PREFIX +m.getMacroExpansionHistory()+ m.getLine();
if (m.getPosition() > 0)
reportLine = reportLine + POSITION_PREFIX + m.getPosition();
reportLine = reportLine + MESSAGE_SEPARATOR + m.getMessage() + “\n”;
report.append(reportLine);
}
}
return report.toString();
}
} // ErrorList
ErrorMessage
package mars;
public synchronized class ErrorMessage {
private boolean isWarning;
private String filename;
private int line;
private int position;
private String message;
private String macroExpansionHistory;
public static final boolean WARNING = 1;
public static final boolean ERROR = 0;
public void ErrorMessage(String, int, int, String);
public void ErrorMessage(String, int, int, String, String);
public void ErrorMessage(boolean, String, int, int, String, String);
public void ErrorMessage(MIPSprogram, int, int, String);
public void ErrorMessage(boolean, MIPSprogram, int, int, String);
public void ErrorMessage(ProgramStatement, String);
private java.util.ArrayList parseMacroHistory(String);
public String getFilename();
public int getLine();
public int getPosition();
public String getMessage();
public boolean isWarning();
public String getMacroExpansionHistory();
private static String getExpansionHistory(MIPSprogram);
}
mars/ErrorMessage.java
mars/ErrorMessage.java package mars;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.ArrayList;
/*
Copyright (c) 2003-2012, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Represents occurrance of an error detected during tokenizing, assembly or simulation.
* @author Pete Sanderson
* @version August 2003
**/
public class ErrorMessage {
private boolean isWarning; // allow for warnings too (added Nov 2006)
private String filename; // name of source file (added Oct 2006)
private int line; // line in source code where error detected
private int position; // position in source line where error detected
private String message;
private String macroExpansionHistory;
/**
* Constant to indicate this message is warning not error
*/
public static final boolean WARNING = true;
/**
* Constant to indicate this message is error not warning
*/
public static final boolean ERROR = false;
/**
* Constructor for ErrorMessage.
* @param filename String containing name of source file in which this error appears.
* @param line Line number in source program being processed when error occurred.
* @param position Position within line being processed when error occurred. Normally is starting
* position of source token.
* @param message String containing appropriate error message.
* @deprecated Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.
**/
// Added filename October 2006
@Deprecated
public ErrorMessage(String filename, int line, int position, String message) {
this(ERROR, filename, line, position, message, “”);
}
/**
* Constructor for ErrorMessage.
* @param filename String containing name of source file in which this error appears.
* @param line Line number in source program being processed when error occurred.
* @param position Position within line being processed when error occurred. Normally is starting
* position of source token.
* @param message String containing appropriate error message.
* @param macroExpansionHistory
* @deprecated Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.
**/
// Added macroExpansionHistory Dec 2012
@Deprecated
public ErrorMessage(String filename, int line, int position, String message, String macroExpansionHistory) {
this(ERROR, filename, line, position, message, macroExpansionHistory);
}
/**
* Constructor for ErrorMessage.
* @param isWarning set to WARNING if message is a warning not error, else set to ERROR or omit.
* @param filename String containing name of source file in which this error appears.
* @param line Line number in source program being processed when error occurred.
* @param position Position within line being processed when error occurred. Normally is starting
* position of source token.
* @param message String containing appropriate error message.
* @param macroExpansionHistory provided so message for macro can include both definition and usage line numbers
* @deprecated Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.
**/
@Deprecated
public ErrorMessage(boolean isWarning, String filename, int line, int position, String message, String macroExpansionHistory) {
this.isWarning = isWarning;
this.filename = filename;
this.line = line;
this.position = position;
this.message = message;
this.macroExpansionHistory=macroExpansionHistory;
}
/**
* Constructor for ErrorMessage. Assumes line number is calculated after any .include files expanded, and
* if there were, it will adjust filename and line number so message reflects original file and line number.
* @param sourceMIPSprogram MIPSprogram object of source file in which this error appears.
* @param line Line number in source program being processed when error occurred.
* @param position Position within line being processed when error occurred. Normally is starting
* position of source token.
* @param message String containing appropriate error message.
**/
public ErrorMessage(MIPSprogram sourceMIPSprogram, int line, int position, String message) {
this(ERROR, sourceMIPSprogram, line, position, message);
}
/**
* Constructor for ErrorMessage. Assumes line number is calculated after any .include files expanded, and
* if there were, it will adjust filename and line number so message reflects original file and line number.
* @param isWarning set to WARNING if message is a warning not error, else set to ERROR or omit.
* @param sourceMIPSprogram MIPSprogram object of source file in which this error appears.
* @param line Line number in source program being processed when error occurred.
* @param position Position within line being processed when error occurred. Normally is starting
* position of source token.
* @param message String containing appropriate error message.
**/
public ErrorMessage(boolean isWarning, MIPSprogram sourceMIPSprogram, int line, int position, String message) {
this.isWarning = isWarning;
if (sourceMIPSprogram == null) {
this.filename = “”;
this.line = line;
}
else {
if (sourceMIPSprogram.getSourceLineList() == null) {
this.filename = sourceMIPSprogram.getFilename();
this.line = line;
}
else {
mars.assembler.SourceLine sourceLine = sourceMIPSprogram.getSourceLineList().get(line-1);
this.filename = sourceLine.getFilename();
this.line = sourceLine.getLineNumber();
}
}
this.position = position;
this.message = message;
this.macroExpansionHistory = getExpansionHistory(sourceMIPSprogram);
}
/**
* Constructor for ErrorMessage, to be used for runtime exceptions.
* @param statement The ProgramStatement object for the instruction causing the runtime error
* @param message String containing appropriate error message.
**/
// Added January 2013
public ErrorMessage(ProgramStatement statement, String message) {
this.isWarning = ERROR;
this.filename = (statement.getSourceMIPSprogram() == null)
? “” : statement.getSourceMIPSprogram().getFilename();
this.position = 0;
this.message = message;
// Somewhere along the way we lose the macro history, but can
// normally recreate it here. The line number for macro use (in the
// expansion) comes with the ProgramStatement.getSourceLine().
// The line number for the macro definition comes embedded in
// the source code from ProgramStatement.getSource(), which is
// displayed in the Text Segment display. It would previously
// have had the macro definition line prepended in brackets,
// e.g. “<13> syscall # finished”. So I’ll extract that
// bracketed number here and include it in the error message.
// Looks bass-ackwards, but to get the line numbers to display correctly
// for runtime error occurring in macro expansion (expansion->definition), need
// to assign to the opposite variables.
ArrayList
if (defineLine.size() == 0) {
this.line = statement.getSourceLine();
this.macroExpansionHistory = “”;
}
else {
this.line = defineLine.get(0);
this.macroExpansionHistory = “”+statement.getSourceLine();
}
}
private ArrayList
Pattern pattern = Pattern.compile(“<\\d+>“);
Matcher matcher = pattern.matcher(string);
String verify = new String(string).trim();
ArrayList
while (matcher.find()) {
String match = matcher.group();
if (verify.indexOf(match)==0) {
try {
int line = Integer.parseInt(match.substring(1,match.length()-1));
macroHistory.add(line);
}
catch (NumberFormatException e) {
break;
}
verify = verify.substring(match.length()).trim();
}
else {
break;
}
}
return macroHistory;
}
/**
* Produce name of file containing error.
* @return Returns String containing name of source file containing the error.
*/
// Added October 2006
public String getFilename() {
return filename;
}
/**
* Produce line number of error.
* @return Returns line number in source program where error occurred.
*/
public int getLine() {
return line;
}
/**
* Produce position within erroneous line.
* @return Returns position within line of source program where error occurred.
*/
public int getPosition() {
return position;
}
/**
* Produce error message.
* @return Returns String containing textual error message.
*/
public String getMessage() {
return message;
}
/**
* Determine whether this message represents error or warning.
* @return Returns true if this message reflects warning, false if error.
*/
// Method added 28 Nov 2006
public boolean isWarning() {
return this.isWarning;
}
/**
* Returns string describing macro expansion. Empty string if none.
* @return string describing macro expansion
*/
// Method added by Mohammad Sekavat Dec 2012
public String getMacroExpansionHistory() {
if (macroExpansionHistory==null || macroExpansionHistory.length()==0)
return “”;
return macroExpansionHistory+”->”;
}
// Added by Mohammad Sekavat Dec 2012
private static String getExpansionHistory(MIPSprogram sourceMIPSprogram) {
if (sourceMIPSprogram==null || sourceMIPSprogram.getLocalMacroPool()==null)
return “”;
return sourceMIPSprogram.getLocalMacroPool().getExpansionHistory();
}
} // ErrorMessage
Globals
package mars;
public synchronized class Globals {
private static String configPropertiesFile;
private static String syscallPropertiesFile;
public static mips.instructions.InstructionSet instructionSet;
public static MIPSprogram program;
public static assembler.SymbolTable symbolTable;
public static mips.hardware.Memory memory;
public static Object memoryAndRegistersLock;
public static boolean debug;
static Settings settings;
public static String userInputAlert;
public static final String imagesPath = /images/;
public static final String helpPath = /help/;
private static boolean initialized;
static venus.VenusUI gui;
public static final String version = 4.5;
public static final java.util.ArrayList fileExtensions;
public static final int maximumMessageCharacters;
public static final int maximumErrorMessages;
public static final int maximumBacksteps;
public static final String copyrightYears;
public static final String copyrightHolders;
public static final String ASCII_NON_PRINT;
public static final String[] ASCII_TABLE;
public static int exitCode;
public static boolean runSpeedPanelExists;
public void Globals();
private static String getCopyrightYears();
private static String getCopyrightHolders();
public static void setGui(venus.VenusUI);
public static venus.VenusUI getGui();
public static Settings getSettings();
public static void initialize(boolean);
private static int getMessageLimit();
private static int getErrorLimit();
private static int getBackstepLimit();
public static String getAsciiNonPrint();
public static String[] getAsciiStrings();
private static int getIntegerProperty(String, String, int);
private static java.util.ArrayList getFileExtensions();
public static java.util.ArrayList getExternalTools();
public static String getPropertyEntry(String, String);
public java.util.ArrayList getSyscallOverrides();
static void
}
mars/Globals.java
mars/Globals.java package mars;
import mars.mips.instructions.syscalls.*;
import mars.mips.instructions.*;
import mars.mips.hardware.*;
import mars.assembler.*;
import mars.venus.*;
import mars.util.*;
import java.io.*;
import java.util.*;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Collection of globally-available data structures.
*
* @author Pete Sanderson
* @version August 2003
*/
public class Globals
{
// List these first because they are referenced by methods called at initialization.
private static String configPropertiesFile = “Config”;
private static String syscallPropertiesFile = “Syscall”;
/** The set of implemented MIPS instructions. **/
public static InstructionSet instructionSet;
/** the program currently being worked with. Used by GUI only, not command line. **/
public static MIPSprogram program;
/** Symbol table for file currently being assembled. **/
public static SymbolTable symbolTable;
/** Simulated MIPS memory component. **/
public static Memory memory;
/** Lock variable used at head of synchronized block to guard MIPS memory and registers **/
public static Object memoryAndRegistersLock = new Object();
/** Flag to determine whether or not to produce internal debugging information. **/
public static boolean debug = false;
/** Object that contains various settings that can be accessed modified internally. **/
static Settings settings;
/** String to GUI’s RunI/O text area when echoing user input from pop-up dialog. */
public static String userInputAlert = “**** user input : “;
/** Path to folder that contains images */
// The leading “/” in filepath prevents package name from being pre-pended.
public static final String imagesPath = “/images/”;
/** Path to folder that contains help text */
public static final String helpPath = “/help/”;
/* Flag that indicates whether or not instructionSet has been initialized. */
private static boolean initialized = false;
/* The GUI being used (if any) with this simulator. */
static VenusUI gui = null;
/** The current MARS version number. Can’t wait for “initialize()” call to get it. */
public static final String version = “4.5”;
/** List of accepted file extensions for MIPS assembly source files. */
public static final ArrayList fileExtensions = getFileExtensions();
/** Maximum length of scrolled message window (MARS Messages and Run I/O) */
public static final int maximumMessageCharacters = getMessageLimit();
/** Maximum number of assembler errors produced by one assemble operation */
public static final int maximumErrorMessages = getErrorLimit();
/** Maximum number of back-step operations to buffer */
public static final int maximumBacksteps = getBackstepLimit();
/** MARS copyright years */
public static final String copyrightYears = getCopyrightYears();
/** MARS copyright holders */
public static final String copyrightHolders = getCopyrightHolders();
/** Placeholder for non-printable ASCII codes */
public static final String ASCII_NON_PRINT = getAsciiNonPrint();
/** Array of strings to display for ASCII codes in ASCII display of data segment. ASCII code 0-255 is array index. */
public static final String[] ASCII_TABLE = getAsciiStrings();
/** MARS exit code — useful with SYSCALL 17 when running from command line (not GUI) */
public static int exitCode = 0;
public static boolean runSpeedPanelExists = false;
private static String getCopyrightYears() {
return “2003-2014”;
}
private static String getCopyrightHolders() {
return “Pete Sanderson and Kenneth Vollmar”;
}
public static void setGui(VenusUI g) {
gui = g;
}
public static VenusUI getGui() {
return gui;
}
public static Settings getSettings() {
return settings;
}
/**
* Method called once upon system initialization to create the global data structures.
**/
public static void initialize(boolean gui) {
if (!initialized) {
memory = Memory.getInstance(); //clients can use Memory.getInstance instead of Globals.memory
instructionSet = new InstructionSet();
instructionSet.populate();
symbolTable = new SymbolTable(“global”);
settings = new Settings(gui);
initialized = true;
debug = false;
memory.clear(); // will establish memory configuration from setting
}
}
// Read byte limit of Run I/O or MARS Messages text to buffer.
private static int getMessageLimit() {
return getIntegerProperty(configPropertiesFile, “MessageLimit”, 1000000);
}
// Read limit on number of error messages produced by one assemble operation.
private static int getErrorLimit() {
return getIntegerProperty(configPropertiesFile, “ErrorLimit”, 200);
}
// Read backstep limit (number of operations to buffer) from properties file.
private static int getBackstepLimit() {
return getIntegerProperty(configPropertiesFile, “BackstepLimit”, 1000);
}
// Read ASCII default display character for non-printing characters, from properties file.
public static String getAsciiNonPrint() {
String anp = getPropertyEntry(configPropertiesFile, “AsciiNonPrint”);
return (anp == null) ? “.” : ( (anp.equals(“space”)) ? ” ” : anp );
}
// Read ASCII strings for codes 0-255, from properties file. If string
// value is “null”, substitute value of ASCII_NON_PRINT. If string is
// “space”, substitute string containing one space character.
public static String[] getAsciiStrings() {
String let = getPropertyEntry(configPropertiesFile,”AsciiTable”);
String placeHolder = getAsciiNonPrint();
String[] lets = let.split(” +”);
int maxLength = 0;
for (int i = 0; i < lets.length; i++) {
if (lets[i].equals("null")) lets[i] = placeHolder;
if (lets[i].equals("space")) lets[i] = " ";
if (lets[i].length() > maxLength) maxLength = lets[i].length();
}
String padding = ” “;
maxLength++;
for (int i = 0; i < lets.length; i++) {
lets[i] = padding.substring(0,maxLength-lets[i].length()) + lets[i];
}
return lets;
}
// Read and return integer property value for given file and property name.
// Default value is returned if property file or name not found.
private static int getIntegerProperty(String propertiesFile, String propertyName, int defaultValue) {
int limit = defaultValue; // just in case no entry is found
Properties properties = PropertiesFile.loadPropertiesFromFile(propertiesFile);
try {
limit = Integer.parseInt(properties.getProperty(propertyName, Integer.toString(defaultValue)));
}
catch (NumberFormatException nfe) { } // do nothing, I already have a default
return limit;
}
// Read assembly language file extensions from properties file. Resulting
// string is tokenized into array list (assume StringTokenizer default delimiters).
private static ArrayList getFileExtensions() {
ArrayList extensionsList = new ArrayList();
String extensions = getPropertyEntry(configPropertiesFile,"Extensions");
if (extensions != null) {
StringTokenizer st = new StringTokenizer(extensions);
while (st.hasMoreTokens()) {
extensionsList.add(st.nextToken());
}
}
return extensionsList;
}
/**
* Get list of MarsTools that reside outside the MARS distribution.
* Currently this is done by adding the tool's path name to the list
* of values for the external_tools property. Use ";" as delimiter!
* @return ArrayList. Each item is file path to .class file
* of a class that implements MarsTool. If none, returns empty list.
*/
public static ArrayList getExternalTools() {
ArrayList toolsList = new ArrayList();
String delimiter = ";";
String tools = getPropertyEntry(configPropertiesFile,"ExternalTools");
if (tools != null) {
StringTokenizer st = new StringTokenizer(tools, delimiter);
while (st.hasMoreTokens()) {
toolsList.add(st.nextToken());
}
}
return toolsList;
}
/**
* Read and return property file value (if any) for requested property.
* @param propertiesFile name of properties file (do NOT include filename extension,
* which is assumed to be ".properties")
* @param propertyName String containing desired property name
* @return String containing associated value; null if property not found
*/
public static String getPropertyEntry(String propertiesFile, String propertyName) {
return PropertiesFile.loadPropertiesFromFile(propertiesFile).getProperty(propertyName);
}
/**
* Read any syscall number assignment overrides from config file.
* @return ArrayList of SyscallNumberOverride objects
*/
public ArrayList getSyscallOverrides() {
ArrayList overrides = new ArrayList();
Properties properties = PropertiesFile.loadPropertiesFromFile(syscallPropertiesFile);
Enumeration keys = properties.keys();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
overrides.add(new SyscallNumberOverride(key,properties.getProperty(key)));
}
return overrides;
}
}
MarsLaunch$1
package mars;
synchronized class MarsLaunch$1 implements Runnable {
void MarsLaunch$1(MarsLaunch);
public void run();
}
MarsLaunch$2
package mars;
synchronized class MarsLaunch$2 implements java.util.Observer {
private int lastAddress;
void MarsLaunch$2(MarsLaunch);
public void update(java.util.Observable, Object);
}
MarsLaunch
package mars;
public synchronized class MarsLaunch {
private boolean simulate;
private int displayFormat;
private boolean verbose;
private boolean assembleProject;
private boolean pseudo;
private boolean delayedBranching;
private boolean warningsAreErrors;
private boolean startAtMain;
private boolean countInstructions;
private boolean selfModifyingCode;
private static final String rangeSeparator = -;
private static final int splashDuration = 2000;
private static final int memoryWordsPerLine = 4;
private static final int DECIMAL = 0;
private static final int HEXADECIMAL = 1;
private static final int ASCII = 2;
private java.util.ArrayList registerDisplayList;
private java.util.ArrayList memoryDisplayList;
private java.util.ArrayList filenameList;
private MIPSprogram code;
private int maxSteps;
private int instructionCount;
private java.io.PrintStream out;
private java.util.ArrayList dumpTriples;
private java.util.ArrayList programArgumentList;
private int assembleErrorExitCode;
private int simulateErrorExitCode;
public void MarsLaunch(String[]);
private void dumpSegments();
private void launchIDE();
private boolean parseCommandArgs(String[]);
private boolean runCommand();
private String[] checkMemoryAddressRange(String) throws NumberFormatException;
private void establishObserver();
private void displayMiscellaneousPostMortem();
private void displayRegistersPostMortem();
private String formatIntForDisplay(int);
private void displayMemoryPostMortem();
private void processDisplayMessagesToErrSwitch(String[], String);
private void displayCopyright(String[], String);
private void displayHelp();
}
mars/MarsLaunch.java
mars/MarsLaunch.java package mars;
import mars.venus.*;
import mars.util.*;
import mars.mips.dump.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import java.io.*;
import java.util.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.JOptionPane; // KENV 9/8/2004
/*
Copyright (c) 2003-2012, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Launch the Mars application
*
* @author Pete Sanderson
* @version December 2009
**/
public class MarsLaunch {
/**
* Main takes a number of command line arguments.
Usage: Mars [options] filename
Valid options (not case sensitive, separate by spaces) are:
a — assemble only, do not simulate
ad — both a and d
ae
ascii — display memory or register contents interpreted as ASCII
b — brief – do not display register/memory address along with contents
d — print debugging statements
da — both a and d
db — MIPS delayed branching is enabled.
dec — display memory or register contents in decimal.
dump — dump memory contents to file. Option has 3 arguments, e.g.
dump <segment> <format> <file>. Also supports
an address range (see m-n below). Current supported
segments are .text and .data. Current supported dump formats
are Binary, HexText, BinaryText.
h — display help. Use by itself and with no filename
hex — display memory or register contents in hexadecimal (default)
ic — display count of MIPS basic instructions ‘executed'”);
mc — set memory configuration. Option has 1 argument, e.g.
mc <config$gt;, where <config$gt; is Default
for the MARS default 32-bit address space, CompactDataAtZero for
a 32KB address space with data segment at address 0, or CompactTextAtZero
for a 32KB address space with text segment at address 0.
me — display MARS messages to standard err instead of standard out. Can separate via redirection.
nc — do not display copyright notice (for cleaner redirected/piped output).
np — No Pseudo-instructions allowed (“ne” will work also).
p — Project mode – assemble all files in the same directory as given file.
se
sm — Start execution at Main – Execution will start at program statement globally labeled main.
smc — Self Modifying Code – Program can write and branch to either text or data segment
we — assembler Warnings will be considered Errors
If 0, negative or not specified, there is no maximum.
$
content to display at end of run. Option may be repeated.
content to display at end of run. Option may be repeated. $ not required.
display at end of run.
pa — Program Arguments follow in a space-separated list. This
option must be placed AFTER ALL FILE NAMES, because everything
that follows it is interpreted as a program argument to be
made available to the MIPS program at runtime.
**/
private boolean simulate;
private int displayFormat;
private boolean verbose; // display register name or address along with contents
private boolean assembleProject; // assemble only the given file or all files in its directory
private boolean pseudo; // pseudo instructions allowed in source code or not.
private boolean delayedBranching; // MIPS delayed branching is enabled.
private boolean warningsAreErrors; // Whether assembler warnings should be considered errors.
private boolean startAtMain; // Whether to start execution at statement labeled ‘main’
private boolean countInstructions; // Whether to count and report number of instructions executed
private boolean selfModifyingCode; // Whether to allow self-modifying code (e.g. write to text segment)
private static final String rangeSeparator = “-“;
private static final int splashDuration = 2000; // time in MS to show splash screen
private static final int memoryWordsPerLine = 4; // display 4 memory words, tab separated, per line
private static final int DECIMAL = 0; // memory and register display format
private static final int HEXADECIMAL = 1;// memory and register display format
private static final int ASCII = 2;// memory and register display format
private ArrayList registerDisplayList;
private ArrayList memoryDisplayList;
private ArrayList filenameList;
private MIPSprogram code;
private int maxSteps;
private int instructionCount;
private PrintStream out; // stream for display of command line output
private ArrayList dumpTriples = null; // each element holds 3 arguments for dump option
private ArrayList programArgumentList; // optional program args for MIPS program (becomes argc, argv)
private int assembleErrorExitCode; // MARS command exit code to return if assemble error occurs
private int simulateErrorExitCode;// MARS command exit code to return if simulation error occurs
public MarsLaunch(String[] args) {
boolean gui = (args.length == 0);
Globals.initialize(gui);
if (gui) {
launchIDE();
}
else { // running from command line.
// assure command mode works in headless environment (generates exception if not)
System.setProperty(“java.awt.headless”, “true”);
simulate = true;
displayFormat = HEXADECIMAL;
verbose = true;
assembleProject = false;
pseudo = true;
delayedBranching = false;
warningsAreErrors = false;
startAtMain = false;
countInstructions = false;
selfModifyingCode = false;
instructionCount = 0;
assembleErrorExitCode = 0;
simulateErrorExitCode = 0;
registerDisplayList = new ArrayList();
memoryDisplayList = new ArrayList();
filenameList = new ArrayList();
MemoryConfigurations.setCurrentConfiguration(MemoryConfigurations.getDefaultConfiguration());
// do NOT use Globals.program for command line MARS — it triggers ‘backstep’ log.
code = new MIPSprogram();
maxSteps = -1;
out = System.out;
if (parseCommandArgs(args)) {
if (runCommand()) {
displayMiscellaneousPostMortem();
displayRegistersPostMortem();
displayMemoryPostMortem();
}
dumpSegments();
}
System.exit(Globals.exitCode);
}
}
/////////////////////////////////////////////////////////////
// Perform any specified dump operations. See “dump” option.
//
private void dumpSegments() {
if (dumpTriples == null)
return;
for (int i=0; i
// Using “p” project option PLUS listing more than one filename on command line.
// Add the additional files, avoiding duplicates.
filenameList.remove(0); // first one has already been processed
ArrayList moreFilesToAssemble = FilenameFinder.getFilenameList(filenameList, FilenameFinder.MATCH_ALL_EXTENSIONS);
// Remove any duplicates then merge the two lists.
for (int index2 = 0; index2
arg.indexOf(rangeSeparator) < arg.length()-1) {
// assume correct format, two numbers separated by -, no embedded spaces.
// If that doesn't work it is invalid.
memoryRange = new String[2];
memoryRange[0] = arg.substring(0,arg.indexOf(rangeSeparator));
memoryRange[1] = arg.substring(arg.indexOf(rangeSeparator)+1);
// NOTE: I will use homegrown decoder, because Integer.decode will throw
// exception on address higher than 0x7FFFFFFF (e.g. sign bit is 1).
if (Binary.stringToInt(memoryRange[0]) > Binary.stringToInt(memoryRange[1]) ||
!Memory.wordAligned(Binary.stringToInt(memoryRange[0])) ||
!Memory.wordAligned(Binary.stringToInt(memoryRange[1]))) {
throw new NumberFormatException();
}
}
return memoryRange;
}
/////////////////////////////////////////////////////////////////
// Required for counting instructions executed, if that option is specified.
// DPS 19 July 2012
private void establishObserver() {
if (countInstructions) {
Observer instructionCounter =
new Observer() {
private int lastAddress = 0;
public void update(Observable o, Object obj) {
if (obj instanceof AccessNotice) {
AccessNotice notice = (AccessNotice) obj;
if (!notice.accessIsFromMIPS())
return;
if (notice.getAccessType() != AccessNotice.READ)
return;
MemoryAccessNotice m = (MemoryAccessNotice) notice;
int a = m.getAddress();
if (a == lastAddress)
return;
lastAddress = a;
instructionCount++;
}
}
};
try {
Globals.memory.addObserver(instructionCounter, Memory.textBaseAddress, Memory.textLimitAddress);
}
catch (AddressErrorException aee) {
out.println(“Internal error: MarsLaunch uses incorrect text segment address for instruction observer”);
}
}
}
//////////////////////////////////////////////////////////////////////
// Displays any specified runtime properties. Initially just instruction count
// DPS 19 July 2012
private void displayMiscellaneousPostMortem() {
if (countInstructions) {
out.println(“\n”+instructionCount);
}
}
//////////////////////////////////////////////////////////////////////
// Displays requested register or registers
private void displayRegistersPostMortem() {
int value; // handy local to use throughout the next couple loops
String strValue;
// Display requested register contents
out.println();
Iterator regIter = registerDisplayList.iterator();
while (regIter.hasNext()) {
String reg = regIter.next().toString();
if (RegisterFile.getUserRegister(reg)!=null) {
// integer register
if (verbose)
out.print(reg+”\t”);
value = RegisterFile.getUserRegister(reg).getValue();
out.println( formatIntForDisplay(value) );
}
else {
// floating point register
float fvalue = Coprocessor1.getFloatFromRegister(reg);
int ivalue = Coprocessor1.getIntFromRegister(reg);
double dvalue = Double.NaN;
long lvalue = 0;
boolean hasDouble = false;
try {
dvalue = Coprocessor1.getDoubleFromRegisterPair(reg);
lvalue = Coprocessor1.getLongFromRegisterPair(reg);
hasDouble = true;
}
catch (InvalidRegisterAccessException irae) { }
if (verbose) {
out.print(reg+”\t”);
}
if (displayFormat == HEXADECIMAL) {
// display float (and double, if applicable) in hex
out.print(
Binary.binaryStringToHexString(
Binary.intToBinaryString(ivalue)));
if (hasDouble) {
out.println(“\t”+
Binary.binaryStringToHexString(
Binary.longToBinaryString(lvalue)));
}
else {
out.println(“”);
}
}
else if (displayFormat == DECIMAL) {
// display float (and double, if applicable) in decimal
out.print(fvalue);
if (hasDouble) {
out.println(“\t”+dvalue);
}
else {
out.println(“”);
}
}
else { // displayFormat == ASCII
out.print(Binary.intToAscii(ivalue));
if (hasDouble) {
out.println(“\t”+
Binary.intToAscii(Binary.highOrderLongToInt(lvalue))+
Binary.intToAscii(Binary.lowOrderLongToInt(lvalue)));
}
else {
out.println(“”);
}
}
}
}
}
//////////////////////////////////////////////////////////////////////
// Formats int value for display: decimal, hex, ascii
private String formatIntForDisplay(int value) {
String strValue;
switch (displayFormat) {
case DECIMAL :
strValue = “”+value;
break;
case HEXADECIMAL :
strValue = Binary.intToHexString(value);
break;
case ASCII :
strValue = Binary.intToAscii(value);
break;
default :
strValue = Binary.intToHexString(value);
}
return strValue;
}
//////////////////////////////////////////////////////////////////////
// Displays requested memory range or ranges
private void displayMemoryPostMortem() {
int value;
// Display requested memory range contents
Iterator memIter = memoryDisplayList.iterator();
int addressStart=0, addressEnd=0;
while (memIter.hasNext()) {
try { // This will succeed; error would have been caught during command arg parse
addressStart = Binary.stringToInt(memIter.next().toString());
addressEnd = Binary.stringToInt(memIter.next().toString());
}
catch (NumberFormatException nfe) {
}
int valuesDisplayed = 0;
for (int addr=addressStart; addr<=addressEnd; addr+=Memory.WORD_LENGTH_BYTES) {
if (addr < 0 && addressEnd > 0)
break; // happens only if addressEnd is 0x7ffffffc
if (valuesDisplayed % memoryWordsPerLine == 0) {
out.print( (valuesDisplayed > 0) ? “\n” : “”);
if (verbose) {
out.print(“Mem[“+Binary.intToHexString(addr)+”]\t”);
}
}
try {
// Allow display of binary text segment (machine code) DPS 14-July-2008
if (Memory.inTextSegment(addr) || Memory.inKernelTextSegment(addr)) {
Integer iValue = Globals.memory.getRawWordOrNull(addr);
value = (iValue==null) ? 0 : iValue.intValue();
}
else {
value = Globals.memory.getWord(addr);
}
out.print( formatIntForDisplay(value)+”\t”);
}
catch (AddressErrorException aee) {
out.print(“Invalid address: “+addr+”\t”);
}
valuesDisplayed++;
}
out.println();
}
}
///////////////////////////////////////////////////////////////////////
// If option to display MARS messages to standard err (System.err) is
// present, it must be processed before all others. Since messages may
// be output as early as during the command parse.
private void processDisplayMessagesToErrSwitch(String[] args, String displayMessagesToErrSwitch) {
for (int i=0; i
out.println(” ascii — display memory or register contents interpreted as ASCII codes.”);
out.println(” b — brief – do not display register/memory address along with contents”);
out.println(” d — display MARS debugging statements”);
out.println(” db — MIPS delayed branching is enabled”);
out.println(” dec — display memory or register contents in decimal.”);
out.println(” dump
out.println(” in specified format to specified file. Option may be repeated.”);
out.println(” Dump occurs at the end of simulation unless ‘a’ option is used.”);
out.println(” Segment and format are case-sensitive and possible values are:”);
out.println(”
out.println(”
out.println(” h — display this help. Use by itself with no filename.”);
out.println(” hex — display memory or register contents in hexadecimal (default)”);
out.println(” ic — display count of MIPS basic instructions ‘executed'”);
out.println(” mc
out.println(” case-sensitive and possible values are: Default for the default”);
out.println(” 32-bit address space, CompactDataAtZero for a 32KB memory with”);
out.println(” data segment at address 0, or CompactTextAtZero for a 32KB”);
out.println(” memory with text segment at address 0.”);
out.println(” me — display MARS messages to standard err instead of standard out. “);
out.println(” Can separate messages from program output using redirection”);
out.println(” nc — do not display copyright notice (for cleaner redirected/piped output).”);
out.println(” np — use of pseudo instructions and formats not permitted”);
out.println(” p — Project mode – assemble all files in the same directory as given file.”);
out.println(” se
out.println(” sm — start execution at statement with global label main, if defined”);
out.println(” smc — Self Modifying Code – Program can write and branch to either text or data segment”);
out.println(”
out.println(” If 0, negative or not specified, there is no maximum.”);
out.println(” $
out.println(” content to display at end of run. Option may be repeated.”);
out.println(“
out.println(” content to display at end of run. Option may be repeated. “);
out.println(” The $ is not required.”);
out.println(“
out.println(” display at end of run.
out.println(” must be on word boundary,
out.println(” pa — Program Arguments follow in a space-separated list. This”);
out.println(” option must be placed AFTER ALL FILE NAMES, because everything”);
out.println(” that follows it is interpreted as a program argument to be”);
out.println(” made available to the MIPS program at runtime.”);
out.println(“If more than one filename is listed, the first is assumed to be the main”);
out.println(“unless the global statement label ‘main’ is defined in one of the files.”);
out.println(“Exception handler not automatically assembled. Add it to the file list.”);
out.println(“Options used here do not affect MARS Settings menu values and vice versa.”);
}
}
MarsSplashScreen$ImageBackgroundPanel
package mars;
synchronized class MarsSplashScreen$ImageBackgroundPanel extends javax.swing.JPanel {
java.awt.Image image;
public void MarsSplashScreen$ImageBackgroundPanel(MarsSplashScreen);
protected void paintComponent(java.awt.Graphics);
}
MarsSplashScreen
package mars;
public synchronized class MarsSplashScreen extends javax.swing.JWindow {
private int duration;
public void MarsSplashScreen(int);
public void showSplash();
}
package mars;
import java.awt.*;
import javax.swing.*;
/*
Copyright (c) 2003-2010, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Produces MARS splash screen.
* Adapted from http://www.java-tips.org/content/view/1267/2/
*/
public class MarsSplashScreen extends JWindow {
private int duration;
public MarsSplashScreen(int d) {
duration = d;
}
/**
* A simple little method to show a title screen in the center
* of the screen for the amount of time given in the constructor
*/
public void showSplash() {
ImageBackgroundPanel content = new ImageBackgroundPanel();
this.setContentPane(content);
// Set the window’s bounds, centering the window
// Wee bit of a hack. I’ve hardcoded the image dimensions of
// MarsSurfacePathfinder.jpg, because obtaining them via
// getHeight() and getWidth() is not trival — it is possible
// that at the time of the call the image has not completed
// loading so the Image object doesn’t know how big it is.
// So observers are involved — see the API.
int width = 390;
int height =215;
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension screen = tk.getScreenSize();
int x = (screen.width-width)/2;
int y = (screen.height-height)/2;
setBounds(x,y,width,height);
// Build the splash screen
JLabel title = new JLabel(“MARS: Mips Assembler and Runtime Simulator”, JLabel.CENTER);
JLabel copyrt1 = new JLabel
(”
Version “+Globals.version+” Copyright (c) “+Globals.copyrightYears+””, JLabel.CENTER);
JLabel copyrt2 = new JLabel
(”
“+Globals.copyrightHolders+””, JLabel.CENTER);
title.setFont(new Font(“Sans-Serif”, Font.BOLD, 16));
title.setForeground(Color.black);
copyrt1.setFont(new Font(“Sans-Serif”, Font.BOLD, 14));
copyrt2.setFont(new Font(“Sans-Serif”, Font.BOLD, 14));
copyrt1.setForeground(Color.white);
copyrt2.setForeground(Color.white);
content.add(title,BorderLayout.NORTH);
content.add(copyrt1,BorderLayout.CENTER);
content.add(copyrt2,BorderLayout.SOUTH);
// Display it
setVisible(true);
// Wait a little while, maybe while loading resources
try { Thread.sleep(duration); }
catch (Exception e) {}
setVisible(false);
}
class ImageBackgroundPanel extends JPanel
{
Image image;
public ImageBackgroundPanel()
{
try
{
image = new ImageIcon(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource(Globals.imagesPath+”MarsSurfacePathfinder.jpg”))).getImage();
}
catch (Exception e) {System.out.println(e); /*handled in paintComponent()*/ }
}
@Override
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
if (image != null)
g.drawImage(image, 0,0,this.getWidth(),this.getHeight(),this);
}
}
}
AbstractDumpFormat
package mars.mips.dump;
public abstract synchronized class AbstractDumpFormat implements DumpFormat {
private String name;
private String commandDescriptor;
private String description;
private String extension;
public void AbstractDumpFormat(String, String, String, String);
public String getFileExtension();
public String getDescription();
public String toString();
public String getCommandDescriptor();
public abstract void dumpMemoryRange(java.io.File, int, int) throws mars.mips.hardware.AddressErrorException, java.io.IOException;
}
mars/mips/dump/AbstractDumpFormat.java
mars/mips/dump/AbstractDumpFormat.java package mars.mips.dump;
import mars.mips.hardware.*;
import java.io.*;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Abstract class for memory dump file formats. Provides constructors and
* defaults for everything except the dumpMemoryRange method itself.
*
* @author Pete Sanderson
* @version December 2007
*/
public abstract class AbstractDumpFormat implements DumpFormat {
private String name, commandDescriptor, description, extension;
/**
* Typical constructor. Note you cannot creates objects from this
* class but subclass constructor can call this one.
* @param name Brief descriptive name to be displayed in selection list.
* @param commandDescriptor One-word descriptive name to be used by MARS command mode parser and user.
* Any spaces in this string will be removed.
* @param description Description to go with standard file extension for
* display in file save dialog or to be used as tool tip.
* @param extension Standard file extension for this format. Null if none.
*/
public AbstractDumpFormat(String name, String commandDescriptor,
String description, String extension) {
this.name = name;
this.commandDescriptor = (commandDescriptor==null) ? null : commandDescriptor.replaceAll(” “,””);
this.description = description;
this.extension = extension;
}
/**
* Get the file extension associated with this format.
* @return String containing file extension — without the leading “.” — or
* null if there is no standard extension.
*/
public String getFileExtension() {
return extension;
}
/**
* Get a short description of the format, suitable for displaying along with
* the extension, in the file save dialog, or as a tool tip.
* @return String containing short description to go with the extension
* or for use as tool tip. Possibly null.
*/
public String getDescription() {
return description;
}
/**
* String representing this object.
* @return Name given for this object.
*
*/
public String toString() {
return name;
}
/**
* One-word description of format to be used by MARS command mode parser
* and user in conjunction with the “dump” option.
* @return One-word String describing the format.
*
*/
public String getCommandDescriptor() {
return commandDescriptor;
}
/**
* Write MIPS memory contents according to the
* specification for this format.
*
* @param file File in which to store MIPS memory contents.
* @param firstAddress first (lowest) memory address to dump. In bytes but
* must be on word boundary.
* @param lastAddress last (highest) memory address to dump. In bytes but
* must be on word boundary. Will dump the word that starts at this address.
* @throws AddressErrorException if firstAddress is invalid or not on a word boundary.
* @throws IOException if error occurs during file output.
*/
public abstract void dumpMemoryRange(File file, int firstAddress, int lastAddress)
throws AddressErrorException, IOException;
}
AsciiTextDumpFormat
package mars.mips.dump;
public synchronized class AsciiTextDumpFormat extends AbstractDumpFormat {
public void AsciiTextDumpFormat();
public void dumpMemoryRange(java.io.File, int, int) throws mars.mips.hardware.AddressErrorException, java.io.IOException;
}
mars/mips/dump/AsciiTextDumpFormat.java
mars/mips/dump/AsciiTextDumpFormat.java package mars.mips.dump;
import mars.util.Binary;
import mars.Globals;
import mars.mips.hardware.*;
import java.io.*;
/*
Copyright (c) 2003-2011, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Class that represents the “ASCII text” memory dump format. Memory contents
* are interpreted as ASCII codes. The output
* is a text file with one word of MIPS memory per line. The word is formatted
* to leave three spaces for each character. Non-printing characters
* rendered as period (.) as placeholder. Common escaped characters
* rendered using backslash and single-character descriptor, e.g. \t for tab.
* @author Pete Sanderson
* @version December 2010
*/
public class AsciiTextDumpFormat extends AbstractDumpFormat {
/**
* Constructor. There is no standard file extension for this format.
*/
public AsciiTextDumpFormat() {
super(“ASCII Text”, “AsciiText”, “Memory contents interpreted as ASCII characters”, null);
}
/**
* Interpret MIPS memory contents as ASCII characters. Each line of
* text contains one memory word written in ASCII characters. Those
* corresponding to tab, newline, null, etc are rendered as backslash
* followed by single-character code, e.g. \t for tab, \0 for null.
* Non-printing character (control code,
* values above 127) is rendered as a period (.). Written
* using PrintStream’s println() method.
* Adapted by Pete Sanderson from code written by Greg Gibeling.
*
* @param file File in which to store MIPS memory contents.
* @param firstAddress first (lowest) memory address to dump. In bytes but
* must be on word boundary.
* @param lastAddress last (highest) memory address to dump. In bytes but
* must be on word boundary. Will dump the word that starts at this address.
* @throws AddressErrorException if firstAddress is invalid or not on a word boundary.
* @throws IOException if error occurs during file output.
*/
public void dumpMemoryRange(File file, int firstAddress, int lastAddress)
throws AddressErrorException, IOException {
PrintStream out = new PrintStream(new FileOutputStream(file));
String string = null;
try {
for (int address = firstAddress; address <= lastAddress; address += Memory.WORD_LENGTH_BYTES) {
Integer temp = Globals.memory.getRawWordOrNull(address);
if (temp == null)
break;
out.println(Binary.intToAscii(temp.intValue()));
}
}
finally {
out.close();
}
}
}
BinaryDumpFormat
package mars.mips.dump;
public synchronized class BinaryDumpFormat extends AbstractDumpFormat {
public void BinaryDumpFormat();
public void dumpMemoryRange(java.io.File, int, int) throws mars.mips.hardware.AddressErrorException, java.io.IOException;
}
mars/mips/dump/BinaryDumpFormat.java
mars/mips/dump/BinaryDumpFormat.java package mars.mips.dump;
import mars.Globals;
import mars.mips.hardware.*;
import java.io.*;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Class that represents the "binary" memory dump format. The output
* is a binary file containing the memory words as a byte stream. Output
* is produced using PrintStream's write() method.
* @author Pete Sanderson
* @version December 2007
*/
public class BinaryDumpFormat extends AbstractDumpFormat {
/**
* Constructor. There is no standard file extension for this format.
*/
public BinaryDumpFormat() {
super("Binary", "Binary", "Written as byte stream to binary file", null);
}
/**
* Write MIPS memory contents in pure binary format. One byte at a time
* using PrintStream's write() method. Adapted by Pete Sanderson from
* code written by Greg Gibeling.
*
* @param file File in which to store MIPS memory contents.
* @param firstAddress first (lowest) memory address to dump. In bytes but
* must be on word boundary.
* @param lastAddress last (highest) memory address to dump. In bytes but
* must be on word boundary. Will dump the word that starts at this address.
* @throws AddressErrorException if firstAddress is invalid or not on a word boundary.
* @throws IOException if error occurs during file output.
*/
public void dumpMemoryRange(File file, int firstAddress, int lastAddress)
throws AddressErrorException, IOException {
PrintStream out = new PrintStream(new FileOutputStream(file));
try {
for (int address = firstAddress; address <= lastAddress; address += Memory.WORD_LENGTH_BYTES) {
Integer temp = Globals.memory.getRawWordOrNull(address);
if (temp == null)
break;
int word = temp.intValue();
for (int i = 0; i < 4; i++)
out.write((word >>> (i << 3)) & 0xFF);
}
}
finally {
out.close();
}
}
}
BinaryTextDumpFormat
package mars.mips.dump;
public synchronized class BinaryTextDumpFormat extends AbstractDumpFormat {
public void BinaryTextDumpFormat();
public void dumpMemoryRange(java.io.File, int, int) throws mars.mips.hardware.AddressErrorException, java.io.IOException;
}
mars/mips/dump/BinaryTextDumpFormat.java
mars/mips/dump/BinaryTextDumpFormat.java package mars.mips.dump;
import mars.Globals;
import mars.mips.hardware.*;
import java.io.*;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Class that represents the "binary text" memory dump format. The output
* is a text file with one word of MIPS memory per line. The word is formatted
* using '0' and '1' characters, e.g. 01110101110000011111110101010011.
* @author Pete Sanderson
* @version December 2007
*/
public class BinaryTextDumpFormat extends AbstractDumpFormat {
/**
* Constructor. There is no standard file extension for this format.
*/
public BinaryTextDumpFormat() {
super("Binary Text", "BinaryText", "Written as '0' and '1' characters to text file", null);
}
/**
* Write MIPS memory contents in binary text format. Each line of
* text contains one memory word written as 32 '0' and '1' characters. Written
* using PrintStream's println() method.
* Adapted by Pete Sanderson from code written by Greg Gibeling.
*
* @param file File in which to store MIPS memory contents.
* @param firstAddress first (lowest) memory address to dump. In bytes but
* must be on word boundary.
* @param lastAddress last (highest) memory address to dump. In bytes but
* must be on word boundary. Will dump the word that starts at this address.
* @throws AddressErrorException if firstAddress is invalid or not on a word boundary.
* @throws IOException if error occurs during file output.
*/
public void dumpMemoryRange(File file, int firstAddress, int lastAddress)
throws AddressErrorException, IOException {
PrintStream out = new PrintStream(new FileOutputStream(file));
String string = null;
try {
for (int address = firstAddress; address <= lastAddress; address += Memory.WORD_LENGTH_BYTES) {
Integer temp = Globals.memory.getRawWordOrNull(address);
if (temp == null)
break;
string = Integer.toBinaryString(temp.intValue());
while (string.length() < 32) {
string = '0' + string;
}
out.println(string);
}
}
finally {
out.close();
}
}
}
DumpFormat
package mars.mips.dump;
public abstract interface DumpFormat {
public abstract String getFileExtension();
public abstract String getDescription();
public abstract String getCommandDescriptor();
public abstract String toString();
public abstract void dumpMemoryRange(java.io.File, int, int) throws mars.mips.hardware.AddressErrorException, java.io.IOException;
}
mars/mips/dump/DumpFormat.java
mars/mips/dump/DumpFormat.java package mars.mips.dump;
import mars.mips.hardware.*;
import java.io.*;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Interface for memory dump file formats. All MARS needs to be able
* to do is save an assembled program or data in the specified manner for
* a given format. Formats are specified through classes
* that implement this interface.
*
* @author Pete Sanderson
* @version December 2007
*/
public interface DumpFormat {
/**
* Get the file extension associated with this format.
* @return String containing file extension -- without the leading "." -- or
* null if there is no standard extension.
*/
public String getFileExtension();
/**
* Get a short description of the format, suitable
* for displaying along with the extension, if any, in the file
* save dialog and also for displaying as a tool tip.
* @return String containing short description to go with the extension
* or as tool tip when mouse hovers over GUI component representing
* this format.
*/
public String getDescription();
/**
* A short one-word descriptor that will be used by the MARS
* command line parser (and the MARS command line user) to specify
* that this format is to be used.
*/
public String getCommandDescriptor();
/**
* Descriptive name for the format.
* @return Format name.
*
*/
public String toString();
/**
* Write MIPS memory contents according to the
* specification for this format.
*
* @param file File in which to store MIPS memory contents.
* @param firstAddress first (lowest) memory address to dump. In bytes but
* must be on word boundary.
* @param lastAddress last (highest) memory address to dump. In bytes but
* must be on word boundary. Will dump the word that starts at this address.
* @throws AddressErrorException if firstAddress is invalid or not on a word boundary.
* @throws IOException if error occurs during file output.
*/
public void dumpMemoryRange(File file, int firstAddress, int lastAddress)
throws AddressErrorException, IOException;
}
DumpFormatLoader
package mars.mips.dump;
public synchronized class DumpFormatLoader {
private static final String CLASS_PREFIX = mars.mips.dump.;
private static final String DUMP_DIRECTORY_PATH = mars/mips/dump;
private static final String SYSCALL_INTERFACE = DumpFormat.class;
private static final String CLASS_EXTENSION = class;
private static java.util.ArrayList formatList;
public void DumpFormatLoader();
public java.util.ArrayList loadDumpFormats();
public static DumpFormat findDumpFormatGivenCommandDescriptor(java.util.ArrayList, String);
static void
}
mars/mips/dump/DumpFormatLoader.java
mars/mips/dump/DumpFormatLoader.java package mars.mips.dump;
import mars.*;
import mars.util.*;
import java.util.*;
import java.lang.reflect.*;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/****************************************************************************/
/* This class provides functionality to bring external memory dump format definitions
* into MARS. This is adapted from the ToolLoader class, which is in turn adapted
* from Bret Barker’s GameServer class from the book “Developing Games In Java”.
*/
public class DumpFormatLoader {
private static final String CLASS_PREFIX = “mars.mips.dump.”;
private static final String DUMP_DIRECTORY_PATH = “mars/mips/dump”;
private static final String SYSCALL_INTERFACE = “DumpFormat.class”;
private static final String CLASS_EXTENSION = “class”;
private static ArrayList formatList = null;
/**
* Dynamically loads dump formats into an ArrayList. This method is adapted from
* the loadGameControllers() method in Bret Barker’s GameServer class.
* Barker (bret@hypefiend.com) is co-author of the book “Developing Games
* in Java”. Also see the ToolLoader and SyscallLoader classes elsewhere in MARS.
*/
public ArrayList loadDumpFormats() {
// The list will be populated only the first time this method is called.
if (formatList == null) {
formatList = new ArrayList();
// grab all class files in the dump directory
ArrayList candidates = FilenameFinder.getFilenameList(this.getClass( ).getClassLoader(),
DUMP_DIRECTORY_PATH, CLASS_EXTENSION);
for( int i = 0; i < candidates.size(); i++) {
String file = (String) candidates.get(i);
try {
// grab the class, make sure it implements DumpFormat, instantiate, add to list
String formatClassName = CLASS_PREFIX+file.substring(0, file.indexOf(CLASS_EXTENSION)-1);
Class clas = Class.forName(formatClassName);
if (DumpFormat.class.isAssignableFrom(clas) &&
!Modifier.isAbstract(clas.getModifiers()) &&
!Modifier.isInterface(clas.getModifiers()) ) {
formatList.add(clas.newInstance());
}
}
catch (Exception e) {
System.out.println("Error instantiating DumpFormat from file " + file + ": "+e);
}
}
}
return formatList;
}
public static DumpFormat findDumpFormatGivenCommandDescriptor(ArrayList formatList, String formatCommandDescriptor) {
DumpFormat match = null;
for (int i=0; i
tmp_chksum += 0xFF & temp.intValue();
tmp_chksum += 0xFF & (temp.intValue()>>8);
tmp_chksum += 0xFF & (temp.intValue()>>16);
tmp_chksum += 0xFF & (temp.intValue()>>24);
tmp_chksum = tmp_chksum % 256;
tmp_chksum = ~tmp_chksum + 1;
chksum = Integer.toHexString(0xFF & tmp_chksum);
if(chksum.length()==1) chksum = ‘0’ + chksum;
String finalstr = “:04″+addr+”00″+string+chksum;
out.println(finalstr.toUpperCase());
}
out.println(“:00000001FF”);
}
finally {
out.close();
}
}
}
MIFDumpFormat
package mars.mips.dump;
public synchronized class MIFDumpFormat {
public void MIFDumpFormat();
public void dumpMemoryRange(java.io.File, int, int) throws mars.mips.hardware.AddressErrorException, java.io.IOException;
}
mars/mips/dump/MIFDumpFormat.java
mars/mips/dump/MIFDumpFormat.java package mars.mips.dump;
import mars.Globals;
import mars.mips.hardware.*;
import java.io.*;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* The Memory Initialization File (.mif) VHDL-supported file format
* This is documented for the Altera platform at
* www.altera.com/support/software/nativelink/quartus2/glossary/def_mif.html.
*
* @author Pete Sanderson
* @version December 2007
*/
// NOT READY FOR PRIME TIME. WHEN IT IS, UNCOMMENT THE “extends” CLAUSE
// AND THE SUPERCLASS CONSTRUCTOR CALL SO THE FORMAT LOADER WILL ACCEPT IT
// AND IT WILL BE ADDED TO THE LIST.
public class MIFDumpFormat { //extends AbstractDumpFormat {
/**
* Constructor. File extention is “mif”.
*/
public MIFDumpFormat() {
// super(“MIF”, “MIF”, “Written as Memory Initialization File (Altera)”, “mif”);
}
/**
* Write MIPS memory contents according to the Memory Initialization File
* (MIF) specification.
*
* @param file File in which to store MIPS memory contents.
* @param firstAddress first (lowest) memory address to dump. In bytes but
* must be on word boundary.
* @param lastAddress last (highest) memory address to dump. In bytes but
* must be on word boundary. Will dump the word that starts at this address.
* @throws AddressErrorException if firstAddress is invalid or not on a word boundary.
* @throws IOException if error occurs during file output.
*/
public void dumpMemoryRange(File file, int firstAddress, int lastAddress)
throws AddressErrorException, IOException {
}
}
SegmentWindowDumpFormat
package mars.mips.dump;
public synchronized class SegmentWindowDumpFormat extends AbstractDumpFormat {
public void SegmentWindowDumpFormat();
public void dumpMemoryRange(java.io.File, int, int) throws mars.mips.hardware.AddressErrorException, java.io.IOException;
}
mars/mips/dump/SegmentWindowDumpFormat.java
mars/mips/dump/SegmentWindowDumpFormat.java package mars.mips.dump;
import mars.Globals;
import mars.ProgramStatement;
import mars.util.Binary;
import mars.mips.hardware.*;
import java.io.*;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
*
* Dump MIPS memory contents in Segment Window format. Each line of
* text output resembles the Text Segment Window or Data Segment Window
* depending on which segment is selected for the dump. Written
* using PrintStream’s println() method. Each line of Text Segment
* Window represents one word of text segment memory. The line
* includes (1) address, (2) machine code in hex, (3) basic instruction,
* (4) source line. Each line of Data Segment Window represents 8
* words of data segment memory. The line includes address of first
* word for that line followed by 8 32-bit values.
*
* In either case, addresses and values are displayed in decimal or
* hexadecimal representation according to the corresponding settings.
*
* @author Pete Sanderson
* @version January 2008
*/
public class SegmentWindowDumpFormat extends AbstractDumpFormat {
/**
* Constructor. There is no standard file extension for this format.
*/
public SegmentWindowDumpFormat() {
super(“Text/Data Segment Window”, “SegmentWindow”, ” Text Segment Window or Data Segment Window format to text file”, null);
}
/**
* Write MIPS memory contents in Segment Window format. Each line of
* text output resembles the Text Segment Window or Data Segment Window
* depending on which segment is selected for the dump. Written
* using PrintStream’s println() method.
*
* @param file File in which to store MIPS memory contents.
* @param firstAddress first (lowest) memory address to dump. In bytes but
* must be on word boundary.
* @param lastAddress last (highest) memory address to dump. In bytes but
* must be on word boundary. Will dump the word that starts at this address.
* @throws AddressErrorException if firstAddress is invalid or not on a word boundary.
* @throws IOException if error occurs during file output.
*/
public void dumpMemoryRange(File file, int firstAddress, int lastAddress)
throws AddressErrorException, IOException {
PrintStream out = new PrintStream(new FileOutputStream(file));
boolean hexAddresses = Globals.getSettings().getDisplayAddressesInHex();
// If address in data segment, print in same format as Data Segment Window
if (Memory.inDataSegment(firstAddress)) {
boolean hexValues = Globals.getSettings().getDisplayValuesInHex();
int offset = 0;
String string=””;
try {
for (int address = firstAddress; address <= lastAddress; address += Memory.WORD_LENGTH_BYTES) {
if (offset % 8 == 0) {
string = ((hexAddresses) ? Binary.intToHexString(address) : Binary.unsignedIntToIntString(address)) + " ";
}
offset++;
Integer temp = Globals.memory.getRawWordOrNull(address);
if (temp == null)
break;
string += ((hexValues)
? Binary.intToHexString(temp.intValue())
: (" "+temp).substring(temp.toString().length())
) + " ";
if (offset % 8 == 0) {
out.println(string);
string = "";
}
}
}
finally {
out.close();
}
return;
}
if (!Memory.inTextSegment(firstAddress)) {
return;
}
// If address in text segment, print in same format as Text Segment Window
out.println(" Address Code Basic Source");
// 12345678901234567890123456789012345678901234567890
// 1 2 3 4 5
out.println();
String string = null;
try {
for (int address = firstAddress; address <= lastAddress; address += Memory.WORD_LENGTH_BYTES) {
string = ((hexAddresses) ? Binary.intToHexString(address) : Binary.unsignedIntToIntString(address)) + " ";
Integer temp = Globals.memory.getRawWordOrNull(address);
if (temp == null)
break;
string += Binary.intToHexString(temp.intValue()) + " ";
try {
ProgramStatement ps = Globals.memory.getStatement(address);
string += (ps.getPrintableBasicAssemblyStatement()+" ").substring(0,22);
string += (((ps.getSource()=="") ? "" : new Integer(ps.getSourceLine()).toString())+" ").substring(0,5);
string += ps.getSource();
}
catch (AddressErrorException aee) {
}
out.println(string);
}
}
finally {
out.close();
}
}
}
AccessNotice
package mars.mips.hardware;
public abstract synchronized class AccessNotice {
public static final int READ = 0;
public static final int WRITE = 1;
private int accessType;
private Thread thread;
protected void AccessNotice(int);
public int getAccessType();
public Thread getThread();
public boolean accessIsFromGUI();
public boolean accessIsFromMIPS();
}
mars/mips/hardware/AccessNotice.java
mars/mips/hardware/AccessNotice.javapackage mars.mips.hardware;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Object provided to Observers of runtime access to MIPS memory or registers.
* The access types READ and WRITE defined here; use subclasses defined for
* MemoryAccessNotice and RegisterAccessNotice. This is abstract class.
*
* @author Pete Sanderson
* @version July 2005
*/
public abstract class AccessNotice {
/** Indicates the purpose of access was to read. */
public static final int READ = 0;
/** Indicates the purpose of access was to write. */
public static final int WRITE = 1;
private int accessType;
private Thread thread;
protected AccessNotice(int type) {
if (type != READ && type != WRITE) {
throw new IllegalArgumentException();
}
accessType = type;
thread = Thread.currentThread();
}
/** Get the access type: READ or WRITE.
* @return Access type, either AccessNotice.READ or AccessNotice.WRITE
*/
public int getAccessType() {
return accessType;
}
/** Get reference to thread that created this notice
* @return Return reference to the thread that created this notice.
*/
public Thread getThread() {
return thread;
}
/** Query whether the access originated from MARS GUI (AWT event queue)
* @return true if this access originated from MARS GUI, false otherwise
*/
// 'A' is the first character of the main AWT event queue thread name.
// "AWT-EventQueue-0"
public boolean accessIsFromGUI() {
return thread.getName().startsWith("AWT");
}
/** Query whether the access originated from executing MIPS program
* @return true if this access originated from executing MIPS program, false otherwise
*/
// Thread to execute the MIPS program is instantiated in SwingWorker.java.
// There it is given the name "MIPS" to replace the default "Thread-x".
public boolean accessIsFromMIPS() {
return thread.getName().startsWith("MIPS");
}
}
AddressErrorException
package mars.mips.hardware;
public synchronized class AddressErrorException extends Exception {
private int address;
private int type;
public void AddressErrorException(String, int, int);
public int getAddress();
public int getType();
}
mars/mips/hardware/AddressErrorException.java
mars/mips/hardware/AddressErrorException.javapackage mars.mips.hardware;
import mars.util.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Represents MIPS AddressErrorException. This is generated by the assembler when the
* source code references a memory address not valid for the context.
*
* @author Pete Sanderson
* @version August 2003
**/
public class AddressErrorException extends Exception {
private int address;
private int type; // Exceptions.ADDRESS_EXCEPTION_LOAD,Exceptions.ADDRESS_EXCEPTION_STORE
/**
* Constructor for the AddressErrorException class
*
* @param addr The erroneous memory address.
**/
public AddressErrorException(String message, int exceptType, int addr) {
super(message+Binary.intToHexString(addr));
address = addr;
type = exceptType;
}
/**
* Get the erroneous memory address.
*
* @return The erroneous memory address.
**/
public int getAddress() {
return address;
}
/**
* Get the exception type (load or store).
*
* @return Exception type: Exceptions.ADDRESS_EXCEPTION_LOAD, Exceptions.ADDRESS_EXCEPTION_STORE
**/
public int getType() {
return type;
}
}
Coprocessor0
package mars.mips.hardware;
public synchronized class Coprocessor0 {
public static final int VADDR = 8;
public static final int STATUS = 12;
public static final int CAUSE = 13;
public static final int EPC = 14;
public static final int EXCEPTION_LEVEL = 1;
public static final int DEFAULT_STATUS_VALUE = 65297;
private static Register[] registers;
public void Coprocessor0();
public static void showRegisters();
public static int updateRegister(String, int);
public static int updateRegister(int, int);
public static int getValue(int);
public static int getNumber(String);
public static Register[] getRegisters();
public static int getRegisterPosition(Register);
public static Register getRegister(String);
public static void resetRegisters();
public static void addRegistersObserver(java.util.Observer);
public static void deleteRegistersObserver(java.util.Observer);
static void
}
mars/mips/hardware/Coprocessor0.java
mars/mips/hardware/Coprocessor0.java package mars.mips.hardware;
import mars.Globals;
import java.util.*;
/*
Copyright (c) 2003-2009, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Represents Coprocessor 0. We will use only its interrupt/exception registers.
* @author Pete Sanderson
* @version August 2005
**/
public class Coprocessor0 {
/** Coprocessor register names
*/
public static final int VADDR = 8;
public static final int STATUS = 12;
public static final int CAUSE = 13;
public static final int EPC = 14;
public static final int EXCEPTION_LEVEL = 1; // bit position in STATUS register
// bits 8-15 (mask for interrupt levels) all set, bit 4 (user mode) set,
// bit 1 (exception level) not set, bit 0 (interrupt enable) set.
public static final int DEFAULT_STATUS_VALUE = 0x0000FF11;
private static Register [] registers =
{ new Register(“$8 (vaddr)”, 8, 0),
new Register(“$12 (status)”, 12, DEFAULT_STATUS_VALUE),
new Register(“$13 (cause)”, 13, 0),
new Register(“$14 (epc)”, 14, 0)
};
/**
* Method for displaying the register values for debugging.
**/
public static void showRegisters(){
for (int i=0; i< registers.length; i++){
System.out.println("Name: " + registers[i].getName());
System.out.println("Number: " + registers[i].getNumber());
System.out.println("Value: " + registers[i].getValue());
System.out.println("");
}
}
/**
* Sets the value of the register given to the value given.
* @param n name of register to set the value of ($n, where n is reg number).
* @param val The desired value for the register.
* @return old value in register prior to update
**/
public static int updateRegister(String n, int val){
int oldValue = 0;
for (int i=0; i< registers.length; i++){
if(("$"+registers[i].getNumber()).equals(n) || registers[i].getName().equals(n)) {
oldValue = registers[i].getValue();
registers[i].setValue(val);
break;
}
}
return oldValue;
}
/**
* This method updates the register value who's number is num.
* @param num Number of register to set the value of.
* @param val The desired value for the register.
* @return old value in register prior to update
**/
public static int updateRegister(int num, int val){
int old = 0;
for (int i=0; i< registers.length; i++){
if(registers[i].getNumber()== num) {
old = (Globals.getSettings().getBackSteppingEnabled())
? Globals.program.getBackStepper().addCoprocessor0Restore(num,registers[i].setValue(val))
: registers[i].setValue(val);
break;
}
}
return old;
}
/**
* Returns the value of the register who's number is num.
* @param num The register number.
* @return The value of the given register. 0 for non-implemented registers
**/
public static int getValue(int num){
for (int i=0; i< registers.length; i++){
if(registers[i].getNumber()== num) {
return registers[i].getValue();
}
}
return 0;
}
/**
* For getting the number representation of the register.
* @param n The string formatted register name to look for.
* @return The number of the register represented by the string. -1 if no match.
**/
public static int getNumber(String n){
for (int i=0; i< registers.length; i++){
if(("$"+registers[i].getNumber()).equals(n) || registers[i].getName().equals(n)) {
return registers[i].getNumber();
}
}
return -1;
}
/**
* For returning the set of registers.
* @return The set of registers.
**/
public static Register[] getRegisters(){
return registers;
}
/**
* Coprocessor0 implements only selected registers, so the register number
* (8, 12, 13, 14) does not correspond to its position in the list of registers
* (0, 1, 2, 3).
* @param r A coprocessor0 Register
* @return the list position of given register, -1 if not found.
**/
public static int getRegisterPosition(Register r){
for (int i=0; i< registers.length; i++){
if(registers[i]==r) {
return i;
}
}
return -1;
}
/**
* Get register object corresponding to given name. If no match, return null.
* @param rname The register name, in $0 format.
* @return The register object,or null if not found.
**/
public static Register getRegister(String rname) {
for (int i=0; i< registers.length; i++){
if(("$"+registers[i].getNumber()).equals(rname) || registers[i].getName().equals(rname)) {
return registers[i];
}
}
return null;
}
/**
* Method to reinitialize the values of the registers.
**/
public static void resetRegisters(){
for(int i=0; i< registers.length; i++){
registers[i].resetValue();
}
}
/**
* Each individual register is a separate object and Observable. This handy method
* will add the given Observer to each one.
*/
public static void addRegistersObserver(Observer observer) {
for (int i=0; i
}
mars/mips/hardware/Coprocessor1.java
mars/mips/hardware/Coprocessor1.java package mars.mips.hardware;
import mars.util.*;
import mars.Globals;
import java.util.*;
/*
Copyright (c) 2003-2009, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Represents Coprocessor 1, the Floating Point Unit (FPU)
* @author Pete Sanderson
* @version July 2005
**/
// Adapted from RegisterFile class developed by Bumgarner et al in 2003.
// The FPU registers will be implemented by Register objects. Such objects
// can only hold int values, but we can use Float.floatToIntBits() to translate
// a 32 bit float value into its equivalent 32-bit int representation, and
// Float.intBitsToFloat() to bring it back. More importantly, there are
// similar methods Double.doubleToLongBits() and Double.LongBitsToDouble()
// which can be used to extend a double value over 2 registers. The resulting
// long is split into 2 int values (high order 32 bits, low order 32 bits) for
// storing into registers, and reassembled upon retrieval.
public class Coprocessor1 {
private static Register [] registers =
{ new Register(“$f0”, 0, 0), new Register(“$f1”, 1, 0),
new Register(“$f2”, 2, 0), new Register(“$f3”, 3, 0),
new Register(“$f4”, 4, 0), new Register(“$f5”, 5, 0),
new Register(“$f6”, 6, 0), new Register(“$f7”, 7, 0),
new Register(“$f8”, 8, 0), new Register(“$f9”, 9, 0),
new Register(“$f10”, 10, 0),new Register(“$f11”, 11, 0),
new Register(“$f12”, 12, 0),new Register(“$f13”, 13, 0),
new Register(“$f14”, 14, 0),new Register(“$f15”, 15, 0),
new Register(“$f16”, 16, 0),new Register(“$f17”, 17, 0),
new Register(“$f18”, 18, 0),new Register(“$f19”, 19, 0),
new Register(“$f20”, 20, 0),new Register(“$f21”, 21, 0),
new Register(“$f22”, 22, 0),new Register(“$f23”, 23, 0),
new Register(“$f24”, 24, 0),new Register(“$f25”, 25, 0),
new Register(“$f26”, 26, 0),new Register(“$f27”, 27, 0),
new Register(“$f28”, 28, 0),new Register(“$f29”, 29, 0),
new Register(“$f30”, 30, 0),new Register(“$f31”, 31, 0)
};
// The 8 condition flags will be stored in bits 0-7 for flags 0-7.
private static Register condition = new Register(“cf”,32, 0);
private static int numConditionFlags = 8;
/**
* Method for displaying the register values for debugging.
**/
public static void showRegisters(){
for (int i=0; i< registers.length; i++){
System.out.println("Name: " + registers[i].getName());
System.out.println("Number: " + registers[i].getNumber());
System.out.println("Value: " + registers[i].getValue());
System.out.println("");
}
}
/**
* Sets the value of the FPU register given to the value given.
* @param reg Register to set the value of.
* @param val The desired float value for the register.
**/
public static void setRegisterToFloat(String reg, float val){
setRegisterToFloat(getRegisterNumber(reg), val);
}
/**
* Sets the value of the FPU register given to the value given.
* @param reg Register to set the value of.
* @param val The desired float value for the register.
**/
public static void setRegisterToFloat(int reg, float val){
if(reg >= 0 && reg < registers.length) {
registers[reg].setValue(Float.floatToRawIntBits(val));
}
}
/**
* Sets the value of the FPU register given to the 32-bit
* pattern given by the int parameter.
* @param reg Register to set the value of.
* @param val The desired int bit pattern for the register.
**/
public static void setRegisterToInt(String reg, int val){
setRegisterToInt(getRegisterNumber(reg), val);
}
/**
* Sets the value of the FPU register given to the 32-bit
* pattern given by the int parameter.
* @param reg Register to set the value of.
* @param val The desired int bit pattern for the register.
**/
public static void setRegisterToInt(int reg, int val){
if(reg >= 0 && reg < registers.length) {
registers[reg].setValue(val);
}
}
/**
* Sets the value of the FPU register given to the double value given. The register
* must be even-numbered, and the low order 32 bits are placed in it. The high order
* 32 bits are placed in the (odd numbered) register that follows it.
* @param reg Register to set the value of.
* @param val The desired double value for the register.
* @throws InvalidRegisterAccessException if register ID is invalid or odd-numbered.
**/
public static void setRegisterPairToDouble(int reg, double val)
throws InvalidRegisterAccessException {
if (reg % 2 != 0) {
throw new InvalidRegisterAccessException();
}
long bits = Double.doubleToRawLongBits(val);
registers[reg+1].setValue(Binary.highOrderLongToInt(bits)); // high order 32 bits
registers[reg].setValue(Binary.lowOrderLongToInt(bits)); // low order 32 bits
}
/**
* Sets the value of the FPU register given to the double value given. The register
* must be even-numbered, and the low order 32 bits are placed in it. The high order
* 32 bits are placed in the (odd numbered) register that follows it.
* @param reg Register to set the value of.
* @param val The desired double value for the register.
* @throws InvalidRegisterAccessException if register ID is invalid or odd-numbered.
**/
public static void setRegisterPairToDouble(String reg, double val)
throws InvalidRegisterAccessException {
setRegisterPairToDouble(getRegisterNumber(reg), val);
}
/**
* Sets the value of the FPU register pair given to the long value containing 64 bit pattern
* given. The register
* must be even-numbered, and the low order 32 bits from the long are placed in it. The high order
* 32 bits from the long are placed in the (odd numbered) register that follows it.
* @param reg Register to set the value of. Must be even register of even/odd pair.
* @param val The desired double value for the register.
* @throws InvalidRegisterAccessException if register ID is invalid or odd-numbered.
**/
public static void setRegisterPairToLong(int reg, long val)
throws InvalidRegisterAccessException {
if (reg % 2 != 0) {
throw new InvalidRegisterAccessException();
}
registers[reg+1].setValue(Binary.highOrderLongToInt(val)); // high order 32 bits
registers[reg].setValue(Binary.lowOrderLongToInt(val)); // low order 32 bits
}
/**
* Sets the value of the FPU register pair given to the long value containing 64 bit pattern
* given. The register
* must be even-numbered, and the low order 32 bits from the long are placed in it. The high order
* 32 bits from the long are placed in the (odd numbered) register that follows it.
* @param reg Register to set the value of. Must be even register of even/odd pair.
* @param val The desired long value containing the 64 bits for the register pair.
* @throws InvalidRegisterAccessException if register ID is invalid or odd-numbered.
**/
public static void setRegisterPairToLong(String reg, long val)
throws InvalidRegisterAccessException {
setRegisterPairToLong(getRegisterNumber(reg), val);
}
/**
* Gets the float value stored in the given FPU register.
* @param reg Register to get the value of.
* @return The float value stored by that register.
**/
public static float getFloatFromRegister(int reg){
float result = 0F;
if(reg >= 0 && reg < registers.length) {
result = Float.intBitsToFloat(registers[reg].getValue());
}
return result;
}
/**
* Gets the float value stored in the given FPU register.
* @param reg Register to get the value of.
* @return The float value stored by that register.
**/
public static float getFloatFromRegister(String reg) {
return getFloatFromRegister(getRegisterNumber(reg));
}
/**
* Gets the 32-bit int bit pattern stored in the given FPU register.
* @param reg Register to get the value of.
* @return The int bit pattern stored by that register.
**/
public static int getIntFromRegister(int reg){
int result = 0;
if(reg >= 0 && reg < registers.length) {
result = registers[reg].getValue();
}
return result;
}
/**
* Gets the 32-bit int bit pattern stored in the given FPU register.
* @param reg Register to get the value of.
* @return The int bit pattern stored by that register.
**/
public static int getIntFromRegister(String reg) {
return getIntFromRegister(getRegisterNumber(reg));
}
/**
* Gets the double value stored in the given FPU register. The register
* must be even-numbered.
* @param reg Register to get the value of. Must be even number of even/odd pair.
* @throws InvalidRegisterAccessException if register ID is invalid or odd-numbered.
**/
public static double getDoubleFromRegisterPair(int reg)
throws InvalidRegisterAccessException {
double result = 0.0;
if (reg % 2 != 0) {
throw new InvalidRegisterAccessException();
}
long bits = Binary.twoIntsToLong(registers[reg+1].getValue(),registers[reg].getValue());
return Double.longBitsToDouble(bits);
}
/**
* Gets the double value stored in the given FPU register. The register
* must be even-numbered.
* @param reg Register to get the value of. Must be even number of even/odd pair.
* @throws InvalidRegisterAccessException if register ID is invalid or odd-numbered.
**/
public static double getDoubleFromRegisterPair(String reg)
throws InvalidRegisterAccessException {
return getDoubleFromRegisterPair(getRegisterNumber(reg));
}
/**
* Gets a long representing the double value stored in the given double
* precision FPU register.
* The register must be even-numbered.
* @param reg Register to get the value of. Must be even number of even/odd pair.
* @throws InvalidRegisterAccessException if register ID is invalid or odd-numbered.
**/
public static long getLongFromRegisterPair(int reg)
throws InvalidRegisterAccessException {
double result = 0.0;
if (reg % 2 != 0) {
throw new InvalidRegisterAccessException();
}
return Binary.twoIntsToLong(registers[reg+1].getValue(),registers[reg].getValue());
}
/**
* Gets the double value stored in the given FPU register. The register
* must be even-numbered.
* @param reg Register to get the value of. Must be even number of even/odd pair.
* @throws InvalidRegisterAccessException if register ID is invalid or odd-numbered.
**/
public static long getLongFromRegisterPair(String reg)
throws InvalidRegisterAccessException {
return getLongFromRegisterPair(getRegisterNumber(reg));
}
/**
* This method updates the FPU register value who's number is num. Note the
* registers themselves hold an int value. There are helper methods available
* to which you can give a float or double to store.
* @param num FPU register to set the value of.
* @param val The desired int value for the register.
**/
public static int updateRegister(int num, int val){
int old = 0;
for (int i=0; i< registers.length; i++){
if(registers[i].getNumber()== num) {
old = (Globals.getSettings().getBackSteppingEnabled())
? Globals.program.getBackStepper().addCoprocessor1Restore(num,registers[i].setValue(val))
: registers[i].setValue(val);
break;
}
}
return old;
}
/**
* Returns the value of the FPU register who's number is num. Returns the
* raw int value actually stored there. If you need a float, use
* Float.intBitsToFloat() to get the equivent float.
* @param num The FPU register number.
* @return The int value of the given register.
**/
public static int getValue(int num){
return registers[num].getValue();
}
/**
* For getting the number representation of the FPU register.
* @param n The string formatted register name to look for.
* @return The number of the register represented by the string.
**/
public static int getRegisterNumber(String n){
int j=-1;
for (int i=0; i< registers.length; i++){
if(registers[i].getName().equals(n)) {
j= registers[i].getNumber();
break;
}
}
return j;
}
/**
* For returning the set of registers.
* @return The set of registers.
**/
public static Register[] getRegisters(){
return registers;
}
/**
* Get register object corresponding to given name. If no match, return null.
* @param rName The FPU register name, must be "$f0" through "$f31".
* @return The register object,or null if not found.
**/
public static Register getRegister(String rName) {
Register reg = null;
if (rName.charAt(0) == '$' && rName.length() > 1 && rName.charAt(1) == ‘f’) {
try {
// check for register number 0-31.
reg = registers[Binary.stringToInt(rName.substring(2))]; // KENV 1/6/05
}
catch (Exception e) {
// handles both NumberFormat and ArrayIndexOutOfBounds
reg = null;
}
}
return reg;
}
/**
* Method to reinitialize the values of the registers.
**/
public static void resetRegisters(){
for(int i=0; i < registers.length; i++)
registers[i].resetValue();
clearConditionFlags();
}
/**
* Each individual register is a separate object and Observable. This handy method
* will add the given Observer to each one.
*/
public static void addRegistersObserver(Observer observer) {
for (int i=0; i
flag = 0;
return Binary.bitValue(condition.getValue(), flag);
}
/**
* Get array of condition flags (0-7).
*
* @return array of int condition flags
*/
public static int getConditionFlags() {
return condition.getValue();
}
/**
* Clear all condition flags (0-7).
*
*/
public static void clearConditionFlags() {
condition.setValue(0); // sets all 32 bits to 0.
}
/**
* Set all condition flags (0-7).
*
*/
public static void setConditionFlags() {
condition.setValue(-1); // sets all 32 bits to 1.
}
/**
* Get count of condition flags.
*
* @return number of condition flags
*/
public static int getConditionFlagCount() {
return numConditionFlags;
}
}
InvalidRegisterAccessException
package mars.mips.hardware;
public synchronized class InvalidRegisterAccessException extends Exception {
private mars.ErrorList errs;
public void InvalidRegisterAccessException();
}
mars/mips/hardware/InvalidRegisterAccessException.java
mars/mips/hardware/InvalidRegisterAccessException.javapackage mars.mips.hardware;
import mars.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Represents attempt to access double precision register using an odd
* (e.g. $f1, $f23) register name.
*
* @author Pete Sanderson
* @version July 2005
**/
public class InvalidRegisterAccessException extends Exception {
private ErrorList errs;
/**
* Constructor for IllegalRegisterException.
*
**/
public InvalidRegisterAccessException() {
}
}
Memory$MemoryObservable
package mars.mips.hardware;
synchronized class Memory$MemoryObservable extends java.util.Observable implements Comparable {
private int lowAddress;
private int highAddress;
public void Memory$MemoryObservable(Memory, java.util.Observer, int, int);
public boolean match(int);
public void notifyObserver(MemoryAccessNotice);
public int compareTo(Object);
}
Memory
package mars.mips.hardware;
public synchronized class Memory extends java.util.Observable {
public static int textBaseAddress;
public static int dataSegmentBaseAddress;
public static int externBaseAddress;
public static int globalPointer;
public static int dataBaseAddress;
public static int heapBaseAddress;
public static int stackPointer;
public static int stackBaseAddress;
public static int userHighAddress;
public static int kernelBaseAddress;
public static int kernelTextBaseAddress;
public static int exceptionHandlerAddress;
public static int kernelDataBaseAddress;
public static int memoryMapBaseAddress;
public static int kernelHighAddress;
public static final int WORD_LENGTH_BYTES = 4;
public static final boolean LITTLE_ENDIAN = 1;
public static final boolean BIG_ENDIAN = 0;
private static boolean byteOrder;
public static int heapAddress;
java.util.Collection observables;
private static final int BLOCK_LENGTH_WORDS = 1024;
private static final int BLOCK_TABLE_LENGTH = 1024;
private int[][] dataBlockTable;
private int[][] kernelDataBlockTable;
private int[][] stackBlockTable;
private static final int MMIO_TABLE_LENGTH = 16;
private int[][] memoryMapBlockTable;
private static final int TEXT_BLOCK_LENGTH_WORDS = 1024;
private static final int TEXT_BLOCK_TABLE_LENGTH = 1024;
private mars.ProgramStatement[][] textBlockTable;
private mars.ProgramStatement[][] kernelTextBlockTable;
public static int dataSegmentLimitAddress;
public static int textLimitAddress;
public static int kernelDataSegmentLimitAddress;
public static int kernelTextLimitAddress;
public static int stackLimitAddress;
public static int memoryMapLimitAddress;
private static Memory uniqueMemoryInstance;
private static final boolean STORE = 1;
private static final boolean FETCH = 0;
private void Memory();
public static Memory getInstance();
public void clear();
public static void setConfiguration();
public boolean usingCompactMemoryConfiguration();
private void initialize();
public int allocateBytesFromHeap(int) throws IllegalArgumentException;
public void setByteOrder(boolean);
public boolean getByteOrder();
public int set(int, int, int) throws AddressErrorException;
public int setRawWord(int, int) throws AddressErrorException;
public int setWord(int, int) throws AddressErrorException;
public int setHalf(int, int) throws AddressErrorException;
public int setByte(int, int) throws AddressErrorException;
public double setDouble(int, double) throws AddressErrorException;
public void setStatement(int, mars.ProgramStatement) throws AddressErrorException;
public int get(int, int) throws AddressErrorException;
private int get(int, int, boolean) throws AddressErrorException;
public int getRawWord(int) throws AddressErrorException;
public Integer getRawWordOrNull(int) throws AddressErrorException;
public int getAddressOfFirstNull(int, int) throws AddressErrorException;
public int getWord(int) throws AddressErrorException;
public int getWordNoNotify(int) throws AddressErrorException;
public int getHalf(int) throws AddressErrorException;
public int getByte(int) throws AddressErrorException;
public mars.ProgramStatement getStatement(int) throws AddressErrorException;
public mars.ProgramStatement getStatementNoNotify(int) throws AddressErrorException;
private mars.ProgramStatement getStatement(int, boolean) throws AddressErrorException;
public static boolean wordAligned(int);
public static boolean doublewordAligned(int);
public static int alignToWordBoundary(int);
public static boolean inTextSegment(int);
public static boolean inKernelTextSegment(int);
public static boolean inDataSegment(int);
public static boolean inKernelDataSegment(int);
public static boolean inMemoryMapSegment(int);
public void addObserver(java.util.Observer);
public void addObserver(java.util.Observer, int) throws AddressErrorException;
public void addObserver(java.util.Observer, int, int) throws AddressErrorException;
public int countObservers();
public void deleteObserver(java.util.Observer);
public void deleteObservers();
public void notifyObservers();
public void notifyObservers(Object);
private java.util.Collection getNewMemoryObserversCollection();
private void notifyAnyObservers(int, int, int, int);
private int storeBytesInTable(int[][], int, int, int);
private int fetchBytesFromTable(int[][], int, int);
private synchronized int storeOrFetchBytesInTable(int[][], int, int, int, boolean);
private synchronized int storeWordInTable(int[][], int, int);
private synchronized int fetchWordFromTable(int[][], int);
private synchronized Integer fetchWordOrNullFromTable(int[][], int);
private int replaceByte(int, int, int, int);
private int reverseBytes(int);
private void storeProgramStatement(int, mars.ProgramStatement, int, mars.ProgramStatement[][]);
private mars.ProgramStatement readProgramStatement(int, int, mars.ProgramStatement[][], boolean);
static void
}
mars/mips/hardware/Memory.java
mars/mips/hardware/Memory.java package mars.mips.hardware;
import mars.*;
import mars.util.*;
import mars.simulator.*;
import mars.mips.instructions.*;
import java.util.*;
/*
Copyright (c) 2003-2009, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Represents MIPS memory. Different segments are represented by different data structs.
*
* @author Pete Sanderson
* @version August 2003
*/
/////////////////////////////////////////////////////////////////////
// NOTE: This implementation is purely big-endian. MIPS can handle either one.
/////////////////////////////////////////////////////////////////////
public class Memory extends Observable {
/** base address for (user) text segment: 0x00400000 **/
public static int textBaseAddress = MemoryConfigurations.getDefaultTextBaseAddress(); //0x00400000;
/** base address for (user) data segment: 0x10000000 **/
public static int dataSegmentBaseAddress = MemoryConfigurations.getDefaultDataSegmentBaseAddress(); //0x10000000;
/** base address for .extern directive: 0x10000000 **/
public static int externBaseAddress = MemoryConfigurations.getDefaultExternBaseAddress(); //0x10000000;
/** base address for storing globals **/
public static int globalPointer = MemoryConfigurations.getDefaultGlobalPointer(); //0x10008000;
/** base address for storage of non-global static data in data segment: 0x10010000 (from SPIM) **/
public static int dataBaseAddress = MemoryConfigurations.getDefaultDataBaseAddress(); //0x10010000; // from SPIM not MIPS
/** base address for heap: 0x10040000 (I think from SPIM not MIPS) **/
public static int heapBaseAddress = MemoryConfigurations.getDefaultHeapBaseAddress(); //0x10040000; // I think from SPIM not MIPS
/** starting address for stack: 0x7fffeffc (this is from SPIM not MIPS) **/
public static int stackPointer = MemoryConfigurations.getDefaultStackPointer(); //0x7fffeffc;
/** base address for stack: 0x7ffffffc (this is mine – start of highest word below kernel space) **/
public static int stackBaseAddress = MemoryConfigurations.getDefaultStackBaseAddress(); //0x7ffffffc;
/** highest address accessible in user (not kernel) mode. **/
public static int userHighAddress = MemoryConfigurations.getDefaultUserHighAddress(); //0x7fffffff;
/** kernel boundary. Only OS can access this or higher address **/
public static int kernelBaseAddress = MemoryConfigurations.getDefaultKernelBaseAddress(); //0x80000000;
/** base address for kernel text segment: 0x80000000 **/
public static int kernelTextBaseAddress = MemoryConfigurations.getDefaultKernelTextBaseAddress(); //0x80000000;
/** starting address for exception handlers: 0x80000180 **/
public static int exceptionHandlerAddress = MemoryConfigurations.getDefaultExceptionHandlerAddress(); //0x80000180;
/** base address for kernel data segment: 0x90000000 **/
public static int kernelDataBaseAddress = MemoryConfigurations.getDefaultKernelDataBaseAddress(); //0x90000000;
/** starting address for memory mapped I/O: 0xffff0000 (-65536) **/
public static int memoryMapBaseAddress = MemoryConfigurations.getDefaultMemoryMapBaseAddress(); //0xffff0000;
/** highest address acessible in kernel mode. **/
public static int kernelHighAddress = MemoryConfigurations.getDefaultKernelHighAddress(); //0xffffffff;
/** MIPS word length in bytes. **/
// NOTE: Much of the code is hardwired for 4 byte words. Refactoring this is low priority.
public static final int WORD_LENGTH_BYTES = 4;
/** Constant representing byte order of each memory word. Little-endian means lowest
numbered byte is right most [3][2][1][0]. */
public static final boolean LITTLE_ENDIAN = true;
/** Constant representing byte order of each memory word. Big-endian means lowest
numbered byte is left most [0][1][2][3]. */
public static final boolean BIG_ENDIAN = false;
/** Current setting for endian (default LITTLE_ENDIAN) **/
private static boolean byteOrder = LITTLE_ENDIAN;
public static int heapAddress;
// Memory will maintain a collection of observables. Each one is associated
// with a specific memory address or address range, and each will have at least
// one observer registered with it. When memory access is made, make sure only
// observables associated with that address send notices to their observers.
// This assures that observers are not bombarded with notices from memory
// addresses they do not care about.
//
// Would like a tree-like implementation, but that is complicated by this fact:
// key for insertion into the tree would be based on Comparable using both low
// and high end of address range, but retrieval from the tree has to be based
// on target address being ANYWHERE IN THE RANGE (not an exact key match).
Collection observables = getNewMemoryObserversCollection();
// The data segment is allocated in blocks of 1024 ints (4096 bytes). Each block is
// referenced by a “block table” entry, and the table has 1024 entries. The capacity
// is thus 1024 entries * 4096 bytes = 4 MB. Should be enough to cover most
// programs!! Beyond that it would go to an “indirect” block (similar to Unix i-nodes),
// which is not implemented.
//
// Although this scheme is an array of arrays, it is relatively space-efficient since
// only the table is created initially. A 4096-byte block is not allocated until a value
// is written to an address within it. Thus most small programs will use only 8K bytes
// of space (the table plus one block). The index into both arrays is easily computed
// from the address; access time is constant.
//
// SPIM stores statically allocated data (following first .data directive) starting
// at location 0x10010000. This is the first Data Segment word beyond the reach of $gp
// used in conjunction with signed 16 bit immediate offset. $gp has value 0x10008000
// and with the signed 16 bit offset can reach from 0x10008000 – 0xFFFF = 0x10000000
// (Data Segment base) to 0x10008000 + 0x7FFF = 0x1000FFFF (the byte preceding 0x10010000).
//
// Using my scheme, 0x10010000 falls at the beginning of the 17’th block — table entry 16.
// SPIM uses a heap base address of 0x10040000 which is not part of the MIPS specification.
// (I don’t have a reference for that offhand…) Using my scheme, 0x10040000 falls at
// the start of the 65’th block — table entry 64. That leaves (1024-64) * 4096 = 3,932,160
// bytes of space available without going indirect.
private static final int BLOCK_LENGTH_WORDS = 1024; // allocated blocksize 1024 ints == 4K bytes
private static final int BLOCK_TABLE_LENGTH = 1024; // Each entry of table points to a block.
private int[][] dataBlockTable;
private int[][] kernelDataBlockTable;
// The stack is modeled similarly to the data segment. It cannot share the same
// data structure because the stack base address is very large. To store it in the
// same data structure would require implementation of indirect blocks, which has not
// been realized. So the stack gets its own table of blocks using the same dimensions
// and allocation scheme used for data segment.
//
// The other major difference is the stack grows DOWNWARD from its base address, not
// upward. I.e., the stack base is the largest stack address. This turns the whole
// scheme for translating memory address to block-offset on its head! The simplest
// solution is to calculate relative address (offset from base) by subtracting the
// desired address from the stack base address (rather than subtracting base address
// from desired address). Thus as the address gets smaller the offset gets larger.
// Everything else works the same, so it shares some private helper methods with
// data segment algorithms.
private int[][] stackBlockTable;
// Memory mapped I/O is simulated with a separate table using the same structure and
// logic as data segment. Memory is allocated in 4K byte blocks. But since MMIO
// address range is limited to 0xffff0000 to 0xfffffffc, there are only 64K bytes
// total. Thus there will be a maximum of 16 blocks, and I suspect never more than
// one since only the first few addresses are typically used. The only exception
// may be a rogue program generating such addresses in a loop. Note that the
// MMIO addresses are interpreted by Java as negative numbers since it does not
// have unsigned types. As long as the absolute address is correctly translated
// into a table offset, this is of no concern.
private static final int MMIO_TABLE_LENGTH = 16; // Each entry of table points to a 4K block.
private int[][] memoryMapBlockTable;
// I use a similar scheme for storing instructions. MIPS text segment ranges from
// 0x00400000 all the way to data segment (0x10000000) a range of about 250 MB! So
// I’ll provide table of blocks with similar capacity. This differs from data segment
// somewhat in that the block entries do not contain int’s, but instead contain
// references to ProgramStatement objects.
private static final int TEXT_BLOCK_LENGTH_WORDS = 1024; // allocated blocksize 1024 ints == 4K bytes
private static final int TEXT_BLOCK_TABLE_LENGTH = 1024; // Each entry of table points to a block.
private ProgramStatement[][] textBlockTable;
private ProgramStatement[][] kernelTextBlockTable;
// Set “top” address boundary to go with each “base” address. This determines permissable
// address range for user program. Currently limit is 4MB, or 1024 * 1024 * 4 bytes based
// on the table structures described above (except memory mapped IO, limited to 64KB by range).
public static int dataSegmentLimitAddress = dataSegmentBaseAddress +
BLOCK_LENGTH_WORDS * BLOCK_TABLE_LENGTH * WORD_LENGTH_BYTES;
public static int textLimitAddress = textBaseAddress +
TEXT_BLOCK_LENGTH_WORDS * TEXT_BLOCK_TABLE_LENGTH * WORD_LENGTH_BYTES;
public static int kernelDataSegmentLimitAddress = kernelDataBaseAddress +
BLOCK_LENGTH_WORDS * BLOCK_TABLE_LENGTH * WORD_LENGTH_BYTES;
public static int kernelTextLimitAddress = kernelTextBaseAddress +
TEXT_BLOCK_LENGTH_WORDS * TEXT_BLOCK_TABLE_LENGTH * WORD_LENGTH_BYTES;
public static int stackLimitAddress = stackBaseAddress –
BLOCK_LENGTH_WORDS * BLOCK_TABLE_LENGTH * WORD_LENGTH_BYTES;
public static int memoryMapLimitAddress = memoryMapBaseAddress +
BLOCK_LENGTH_WORDS * MMIO_TABLE_LENGTH * WORD_LENGTH_BYTES;
// This will be a Singleton class, only one instance is ever created. Since I know the
// Memory object is always needed, I’ll go ahead and create it at the time of class loading.
// (greedy rather than lazy instantiation). The constructor is private and getInstance()
// always returns this instance.
private static Memory uniqueMemoryInstance = new Memory();
/*
* Private constructor for Memory. Separate data structures for text and data segments.
**/
private Memory() {
initialize();
}
/**
* Returns the unique Memory instance, which becomes in essence global.
*/
public static Memory getInstance() {
return uniqueMemoryInstance;
}
/**
* Explicitly clear the contents of memory. Typically done at start of assembly.
*/
public void clear() {
setConfiguration();
initialize();
}
/**
* Sets current memory configuration for simulated MIPS. Configuration is
* collection of memory segment addresses. e.g. text segment starting at
* address 0x00400000. Configuration can be modified starting with MARS 3.7.
*/
public static void setConfiguration() {
textBaseAddress = MemoryConfigurations.getCurrentConfiguration().getTextBaseAddress(); //0x00400000;
dataSegmentBaseAddress = MemoryConfigurations.getCurrentConfiguration().getDataSegmentBaseAddress(); //0x10000000;
externBaseAddress = MemoryConfigurations.getCurrentConfiguration().getExternBaseAddress(); //0x10000000;
globalPointer = MemoryConfigurations.getCurrentConfiguration().getGlobalPointer(); //0x10008000;
dataBaseAddress = MemoryConfigurations.getCurrentConfiguration().getDataBaseAddress(); //0x10010000; // from SPIM not MIPS
heapBaseAddress = MemoryConfigurations.getCurrentConfiguration().getHeapBaseAddress(); //0x10040000; // I think from SPIM not MIPS
stackPointer = MemoryConfigurations.getCurrentConfiguration().getStackPointer(); //0x7fffeffc;
stackBaseAddress = MemoryConfigurations.getCurrentConfiguration().getStackBaseAddress(); //0x7ffffffc;
userHighAddress = MemoryConfigurations.getCurrentConfiguration().getUserHighAddress(); //0x7fffffff;
kernelBaseAddress = MemoryConfigurations.getCurrentConfiguration().getKernelBaseAddress(); //0x80000000;
kernelTextBaseAddress = MemoryConfigurations.getCurrentConfiguration().getKernelTextBaseAddress(); //0x80000000;
exceptionHandlerAddress = MemoryConfigurations.getCurrentConfiguration().getExceptionHandlerAddress(); //0x80000180;
kernelDataBaseAddress = MemoryConfigurations.getCurrentConfiguration().getKernelDataBaseAddress(); //0x90000000;
memoryMapBaseAddress = MemoryConfigurations.getCurrentConfiguration().getMemoryMapBaseAddress(); //0xffff0000;
kernelHighAddress = MemoryConfigurations.getCurrentConfiguration().getKernelHighAddress(); //0xffffffff;
dataSegmentLimitAddress = Math.min(MemoryConfigurations.getCurrentConfiguration().getDataSegmentLimitAddress(),
dataSegmentBaseAddress +
BLOCK_LENGTH_WORDS * BLOCK_TABLE_LENGTH * WORD_LENGTH_BYTES);
textLimitAddress = Math.min(MemoryConfigurations.getCurrentConfiguration().getTextLimitAddress(),
textBaseAddress +
TEXT_BLOCK_LENGTH_WORDS * TEXT_BLOCK_TABLE_LENGTH * WORD_LENGTH_BYTES);
kernelDataSegmentLimitAddress = Math.min(MemoryConfigurations.getCurrentConfiguration().getKernelDataSegmentLimitAddress(),
kernelDataBaseAddress +
BLOCK_LENGTH_WORDS * BLOCK_TABLE_LENGTH * WORD_LENGTH_BYTES);
kernelTextLimitAddress = Math.min(MemoryConfigurations.getCurrentConfiguration().getKernelTextLimitAddress(),
kernelTextBaseAddress +
TEXT_BLOCK_LENGTH_WORDS * TEXT_BLOCK_TABLE_LENGTH * WORD_LENGTH_BYTES);
stackLimitAddress = Math.max(MemoryConfigurations.getCurrentConfiguration().getStackLimitAddress(),
stackBaseAddress –
BLOCK_LENGTH_WORDS * BLOCK_TABLE_LENGTH * WORD_LENGTH_BYTES);
memoryMapLimitAddress = Math.min(MemoryConfigurations.getCurrentConfiguration().getMemoryMapLimitAddress(),
memoryMapBaseAddress +
BLOCK_LENGTH_WORDS * MMIO_TABLE_LENGTH * WORD_LENGTH_BYTES);
/* System.out.println(“dataSegmentLimitAddress “+Binary.intToHexString(dataSegmentLimitAddress));
System.out.println(“textLimitAddress “+Binary.intToHexString(textLimitAddress));
System.out.println(“kernelDataSegmentLimitAddress “+Binary.intToHexString(kernelDataSegmentLimitAddress));
System.out.println(“kernelTextLimitAddress “+Binary.intToHexString(kernelTextLimitAddress));
System.out.println(“stackLimitAddress “+Binary.intToHexString(stackLimitAddress));
System.out.println(“memoryMapLimitAddress “+Binary.intToHexString(memoryMapLimitAddress));
*/
}
/**
* Determine whether the current memory configuration has a maximum address that can be stored
* in 16 bits.
* @return true if maximum address can be stored in 16 bits or less, false otherwise
*/
public boolean usingCompactMemoryConfiguration() {
return (kernelHighAddress & 0x00007fff) == kernelHighAddress;
}
private void initialize() {
heapAddress = heapBaseAddress;
textBlockTable = new ProgramStatement[TEXT_BLOCK_TABLE_LENGTH][];
dataBlockTable = new int[BLOCK_TABLE_LENGTH][]; // array of null int[] references
kernelTextBlockTable = new ProgramStatement[TEXT_BLOCK_TABLE_LENGTH][];
kernelDataBlockTable = new int[BLOCK_TABLE_LENGTH][];
stackBlockTable = new int[BLOCK_TABLE_LENGTH][];
memoryMapBlockTable = new int[MMIO_TABLE_LENGTH][];
System.gc(); // call garbage collector on any Table memory just deallocated.
}
/**
* Returns the next available word-aligned heap address. There is no recycling and
* no heap management! There is however nearly 4MB of heap space available in Mars.
*
* @param numBytes Number of bytes requested. Should be multiple of 4, otherwise next higher multiple of 4 allocated.
* @return address of allocated heap storage.
* @throws IllegalArgumentException if number of requested bytes is negative or exceeds available heap storage
*/
public int allocateBytesFromHeap(int numBytes) throws IllegalArgumentException {
int result = heapAddress;
if (numBytes < 0) {
throw new IllegalArgumentException("request ("+numBytes+") is negative heap amount");
}
int newHeapAddress = heapAddress + numBytes;
if (newHeapAddress % 4 != 0) {
newHeapAddress = newHeapAddress + (4 - newHeapAddress % 4) ; // next higher multiple of 4
}
if (newHeapAddress >= dataSegmentLimitAddress) {
throw new IllegalArgumentException(“request (“+numBytes+”) exceeds available heap storage”);
}
heapAddress = newHeapAddress;
return result;
}
/**
* Set byte order to either LITTLE_ENDIAN or BIG_ENDIAN. Default is LITTLE_ENDIAN.
*
* @param order either LITTLE_ENDIAN or BIG_ENDIAN
*/
public void setByteOrder(boolean order) {
byteOrder = order;
}
/**
* Retrieve memory byte order. Default is LITTLE_ENDIAN (like PCs).
*
* @return either LITTLE_ENDIAN or BIG_ENDIAN
*/
public boolean getByteOrder() {
return byteOrder;
}
/* ******************************* THE SETTER METHODS ******************************/
///////////////////////////////////////////////////////////////////////////////////////
/**
* Starting at the given address, write the given value over the given number of bytes.
* This one does not check for word boundaries, and copies one byte at a time.
* If length == 1, takes value from low order byte. If 2, takes from low order half-word.
*
* @param address Starting address of Memory address to be set.
* @param value Value to be stored starting at that address.
* @param length Number of bytes to be written.
* @return old value that was replaced by the set operation
**/
// Allocates blocks if necessary.
public int set(int address, int value, int length) throws AddressErrorException {
int oldValue = 0;
if (Globals.debug) System.out.println(“memory[“+address+”] set to “+value+”(“+length+” bytes)”);
int relativeByteAddress;
if (inDataSegment(address)) {
// in data segment. Will write one byte at a time, w/o regard to boundaries.
relativeByteAddress = address – dataSegmentBaseAddress; // relative to data segment start, in bytes
oldValue = storeBytesInTable(dataBlockTable, relativeByteAddress, length, value);
}
else if (address > stackLimitAddress && address <= stackBaseAddress) {
// in stack. Handle similarly to data segment write, except relative byte
// address calculated "backward" because stack addresses grow down from base.
relativeByteAddress = stackBaseAddress - address;
oldValue = storeBytesInTable(stackBlockTable, relativeByteAddress, length, value);
}
else if (inTextSegment(address)) {
// Burch Mod (Jan 2013): replace throw with call to setStatement
// DPS adaptation 5-Jul-2013: either throw or call, depending on setting
if (Globals.getSettings().getBooleanSetting(Settings.SELF_MODIFYING_CODE_ENABLED)) {
ProgramStatement oldStatement = getStatementNoNotify(address);
if (oldStatement != null) {
oldValue = oldStatement.getBinaryStatement();
}
setStatement(address, new ProgramStatement(value, address));
}
else {
throw new AddressErrorException(
"Cannot write directly to text segment!",
Exceptions.ADDRESS_EXCEPTION_STORE, address);
}
}
else if (address >= memoryMapBaseAddress && address < memoryMapLimitAddress) {
// memory mapped I/O.
relativeByteAddress = address - memoryMapBaseAddress;
oldValue = storeBytesInTable(memoryMapBlockTable, relativeByteAddress, length, value);
}
else if (inKernelDataSegment(address)) {
// in kernel data segment. Will write one byte at a time, w/o regard to boundaries.
relativeByteAddress = address - kernelDataBaseAddress; // relative to data segment start, in bytes
oldValue = storeBytesInTable(kernelDataBlockTable, relativeByteAddress, length, value);
}
else if (inKernelTextSegment(address)) {
// DEVELOPER: PLEASE USE setStatement() TO WRITE TO KERNEL TEXT SEGMENT...
throw new AddressErrorException(
"DEVELOPER: You must use setStatement() to write to kernel text segment!",
Exceptions.ADDRESS_EXCEPTION_STORE, address);
}
else {
// falls outside Mars addressing range
throw new AddressErrorException("address out of range ",
Exceptions.ADDRESS_EXCEPTION_STORE, address);
}
notifyAnyObservers(AccessNotice.WRITE, address, length, value);
return oldValue;
}
///////////////////////////////////////////////////////////////////////////////////////
/**
* Starting at the given word address, write the given value over 4 bytes (a word).
* It must be written as is, without adjusting for byte order (little vs big endian).
* Address must be word-aligned.
*
* @param address Starting address of Memory address to be set.
* @param value Value to be stored starting at that address.
* @return old value that was replaced by the set operation.
* @throws AddressErrorException If address is not on word boundary.
**/
public int setRawWord(int address, int value) throws AddressErrorException {
int relative, oldValue=0;
if (address % WORD_LENGTH_BYTES != 0) {
throw new AddressErrorException("store address not aligned on word boundary ",
Exceptions.ADDRESS_EXCEPTION_STORE, address);
}
if (inDataSegment(address)) {
// in data segment
relative = (address - dataSegmentBaseAddress) >> 2; // convert byte address to words
oldValue = storeWordInTable(dataBlockTable, relative, value);
}
else if (address > stackLimitAddress && address <= stackBaseAddress) {
// in stack. Handle similarly to data segment write, except relative
// address calculated "backward" because stack addresses grow down from base.
relative = (stackBaseAddress - address) >> 2; // convert byte address to words
oldValue = storeWordInTable(stackBlockTable, relative, value);
}
else if (inTextSegment(address)) {
// Burch Mod (Jan 2013): replace throw with call to setStatement
// DPS adaptation 5-Jul-2013: either throw or call, depending on setting
if (Globals.getSettings().getBooleanSetting(Settings.SELF_MODIFYING_CODE_ENABLED)) {
ProgramStatement oldStatement = getStatementNoNotify(address);
if (oldStatement != null) {
oldValue = oldStatement.getBinaryStatement();
}
setStatement(address, new ProgramStatement(value, address));
}
else {
throw new AddressErrorException(
“Cannot write directly to text segment!”,
Exceptions.ADDRESS_EXCEPTION_STORE, address);
}
}
else if (address >= memoryMapBaseAddress && address < memoryMapLimitAddress) {
// memory mapped I/O.
relative = (address - memoryMapBaseAddress) >> 2; // convert byte address to word
oldValue = storeWordInTable(memoryMapBlockTable, relative, value);
}
else if (inKernelDataSegment(address)) {
// in data segment
relative = (address – kernelDataBaseAddress) >> 2; // convert byte address to words
oldValue = storeWordInTable(kernelDataBlockTable, relative, value);
}
else if (inKernelTextSegment(address)) {
// DEVELOPER: PLEASE USE setStatement() TO WRITE TO KERNEL TEXT SEGMENT…
throw new AddressErrorException(
“DEVELOPER: You must use setStatement() to write to kernel text segment!”,
Exceptions.ADDRESS_EXCEPTION_STORE, address);
}
else {
// falls outside Mars addressing range
throw new AddressErrorException(“store address out of range “,
Exceptions.ADDRESS_EXCEPTION_STORE, address);
}
notifyAnyObservers(AccessNotice.WRITE, address, WORD_LENGTH_BYTES, value);
if (Globals.getSettings().getBackSteppingEnabled()) {
Globals.program.getBackStepper().addMemoryRestoreRawWord(address,oldValue);
}
return oldValue;
}
///////////////////////////////////////////////////////////////////////////////////////
/**
* Starting at the given word address, write the given value over 4 bytes (a word).
* The address must be word-aligned.
*
* @param address Starting address of Memory address to be set.
* @param value Value to be stored starting at that address.
* @return old value that was replaced by setWord operation.
* @throws AddressErrorException If address is not on word boundary.
**/
public int setWord(int address, int value) throws AddressErrorException {
if (address % WORD_LENGTH_BYTES != 0) {
throw new AddressErrorException(
“store address not aligned on word boundary “,
Exceptions.ADDRESS_EXCEPTION_STORE,address);
}
return (Globals.getSettings().getBackSteppingEnabled())
? Globals.program.getBackStepper().addMemoryRestoreWord(address,set(address, value, WORD_LENGTH_BYTES))
: set(address, value, WORD_LENGTH_BYTES);
}
///////////////////////////////////////////////////////////////////////////////////////
/**
* Starting at the given halfword address, write the lower 16 bits of given value
* into 2 bytes (a halfword).
*
* @param address Starting address of Memory address to be set.
* @param value Value to be stored starting at that address. Only low order 16 bits used.
* @return old value that was replaced by setHalf operation.
* @throws AddressErrorException If address is not on halfword boundary.
**/
public int setHalf(int address, int value) throws AddressErrorException {
if (address % 2 != 0) {
throw new AddressErrorException(“store address not aligned on halfword boundary “,
Exceptions.ADDRESS_EXCEPTION_STORE, address);
}
return (Globals.getSettings().getBackSteppingEnabled())
? Globals.program.getBackStepper().addMemoryRestoreHalf(address,set(address,value,2))
: set(address, value, 2);
}
///////////////////////////////////////////////////////////////////////////////////////
/**
* Writes low order 8 bits of given value into specified Memory byte.
*
* @param address Address of Memory byte to be set.
* @param value Value to be stored at that address. Only low order 8 bits used.
* @return old value that was replaced by setByte operation.
**/
public int setByte(int address, int value) throws AddressErrorException {
return (Globals.getSettings().getBackSteppingEnabled())
? Globals.program.getBackStepper().addMemoryRestoreByte(address,set(address,value,1))
: set(address, value, 1);
}
///////////////////////////////////////////////////////////////////////////////////////
/**
* Writes 64 bit double value starting at specified Memory address. Note that
* high-order 32 bits are stored in higher (second) memory word regardless
* of “endianness”.
*
* @param address Starting address of Memory address to be set.
* @param value Value to be stored at that address.
* @return old value that was replaced by setDouble operation.
**/
public double setDouble(int address, double value) throws AddressErrorException {
int oldHighOrder, oldLowOrder;
long longValue = Double.doubleToLongBits(value);
oldHighOrder = set(address+4, Binary.highOrderLongToInt(longValue),4);
oldLowOrder = set(address, Binary.lowOrderLongToInt(longValue),4);
return Double.longBitsToDouble(Binary.twoIntsToLong(oldHighOrder, oldLowOrder));
}
////////////////////////////////////////////////////////////////////////////////
/**
* Stores ProgramStatement in Text Segment.
* @param address Starting address of Memory address to be set. Must be word boundary.
* @param statement Machine code to be stored starting at that address — for simulation
* purposes, actually stores reference to ProgramStatement instead of 32-bit machine code.
* @throws AddressErrorException If address is not on word boundary or is outside Text Segment.
* @see ProgramStatement
**/
public void setStatement(int address, ProgramStatement statement) throws AddressErrorException {
if (address % 4 != 0 || !(inTextSegment(address) || inKernelTextSegment(address))) {
throw new AddressErrorException(
“store address to text segment out of range or not aligned to word boundary “,
Exceptions.ADDRESS_EXCEPTION_STORE, address);
}
if (Globals.debug) System.out.println(“memory[“+address+”] set to “+statement.getBinaryStatement());
if (inTextSegment(address)) {
storeProgramStatement(address, statement, textBaseAddress, textBlockTable);
}
else {
storeProgramStatement(address, statement, kernelTextBaseAddress, kernelTextBlockTable);
}
}
/******************************** THE GETTER METHODS ******************************/
//////////////////////////////////////////////////////////////////////////////////////////
/**
* Starting at the given word address, read the given number of bytes (max 4).
* This one does not check for word boundaries, and copies one byte at a time.
* If length == 1, puts value in low order byte. If 2, puts into low order half-word.
* @param address Starting address of Memory address to be read.
* @param length Number of bytes to be read.
* @return Value stored starting at that address.
**/
public int get(int address, int length) throws AddressErrorException {
return get(address, length, true);
}
// Does the real work, but includes option to NOT notify observers.
private int get(int address, int length, boolean notify) throws AddressErrorException {
int value = 0;
int relativeByteAddress;
if (inDataSegment(address)) {
// in data segment. Will read one byte at a time, w/o regard to boundaries.
relativeByteAddress = address – dataSegmentBaseAddress; // relative to data segment start, in bytes
value = fetchBytesFromTable(dataBlockTable, relativeByteAddress, length);
}
else if (address > stackLimitAddress && address <= stackBaseAddress) {
// in stack. Similar to data, except relative address computed "backward"
relativeByteAddress = stackBaseAddress - address;
value = fetchBytesFromTable(stackBlockTable, relativeByteAddress, length);
}
else if (address >= memoryMapBaseAddress && address < memoryMapLimitAddress) {
// memory mapped I/O.
relativeByteAddress = address - memoryMapBaseAddress;
value = fetchBytesFromTable(memoryMapBlockTable, relativeByteAddress, length);
}
else if (inTextSegment(address)) {
// Burch Mod (Jan 2013): replace throw with calls to getStatementNoNotify & getBinaryStatement
// DPS adaptation 5-Jul-2013: either throw or call, depending on setting
if (Globals.getSettings().getBooleanSetting(Settings.SELF_MODIFYING_CODE_ENABLED)) {
ProgramStatement stmt = getStatementNoNotify(address);
value = stmt == null ? 0 : stmt.getBinaryStatement();
}
else {
throw new AddressErrorException(
"Cannot read directly from text segment!",
Exceptions.ADDRESS_EXCEPTION_LOAD, address);
}
}
else if (inKernelDataSegment(address)) {
// in kernel data segment. Will read one byte at a time, w/o regard to boundaries.
relativeByteAddress = address - kernelDataBaseAddress; // relative to data segment start, in bytes
value = fetchBytesFromTable(kernelDataBlockTable, relativeByteAddress, length);
}
else if (inKernelTextSegment(address)) {
// DEVELOPER: PLEASE USE getStatement() TO READ FROM KERNEL TEXT SEGMENT...
throw new AddressErrorException(
"DEVELOPER: You must use getStatement() to read from kernel text segment!",
Exceptions.ADDRESS_EXCEPTION_LOAD, address);
}
else {
// falls outside Mars addressing range
throw new AddressErrorException("address out of range ",
Exceptions.ADDRESS_EXCEPTION_LOAD, address);
}
if (notify) notifyAnyObservers(AccessNotice.READ, address, length, value);
return value;
}
/////////////////////////////////////////////////////////////////////////
/**
* Starting at the given word address, read a 4 byte word as an int.
* It transfers the 32 bit value "raw" as stored in memory, and does not adjust
* for byte order (big or little endian). Address must be word-aligned.
*
* @param address Starting address of word to be read.
* @return Word (4-byte value) stored starting at that address.
* @throws AddressErrorException If address is not on word boundary.
**/
// Note: the logic here is repeated in getRawWordOrNull() below. Logic is
// simplified by having this method just call getRawWordOrNull() then
// return either the int of its return value, or 0 if it returns null.
// Doing so would be detrimental to simulation runtime performance, so
// I decided to keep the duplicate logic.
public int getRawWord(int address) throws AddressErrorException {
int value = 0;
int relative;
if (address % WORD_LENGTH_BYTES != 0) {
throw new AddressErrorException("address for fetch not aligned on word boundary",
Exceptions.ADDRESS_EXCEPTION_LOAD, address);
}
if (inDataSegment(address)) {
// in data segment
relative = (address - dataSegmentBaseAddress) >> 2; // convert byte address to words
value = fetchWordFromTable(dataBlockTable, relative);
}
else if (address > stackLimitAddress && address <= stackBaseAddress) {
// in stack. Similar to data, except relative address computed "backward"
relative = (stackBaseAddress - address) >> 2; // convert byte address to words
value = fetchWordFromTable(stackBlockTable, relative);
}
else if (address >= memoryMapBaseAddress && address < memoryMapLimitAddress) {
// memory mapped I/O.
relative = (address - memoryMapBaseAddress) >> 2;
value = fetchWordFromTable(memoryMapBlockTable, relative);
}
else if (inTextSegment(address)) {
// Burch Mod (Jan 2013): replace throw with calls to getStatementNoNotify & getBinaryStatement
// DPS adaptation 5-Jul-2013: either throw or call, depending on setting
if (Globals.getSettings().getBooleanSetting(Settings.SELF_MODIFYING_CODE_ENABLED)) {
ProgramStatement stmt = getStatementNoNotify(address);
value = stmt == null ? 0 : stmt.getBinaryStatement();
}
else {
throw new AddressErrorException(
“Cannot read directly from text segment!”,
Exceptions.ADDRESS_EXCEPTION_LOAD, address);
}
}
else if (inKernelDataSegment(address)) {
// in kernel data segment
relative = (address – kernelDataBaseAddress) >> 2; // convert byte address to words
value = fetchWordFromTable(kernelDataBlockTable, relative);
}
else if (inKernelTextSegment(address)) {
// DEVELOPER: PLEASE USE getStatement() TO READ FROM KERNEL TEXT SEGMENT…
throw new AddressErrorException(
“DEVELOPER: You must use getStatement() to read from kernel text segment!”,
Exceptions.ADDRESS_EXCEPTION_LOAD, address);
}
else {
// falls outside Mars addressing range
throw new AddressErrorException(“address out of range “,
Exceptions.ADDRESS_EXCEPTION_LOAD, address);
}
notifyAnyObservers(AccessNotice.READ, address, Memory.WORD_LENGTH_BYTES,value);
return value;
}
/////////////////////////////////////////////////////////////////////////
/**
* Starting at the given word address, read a 4 byte word as an int and return Integer.
* It transfers the 32 bit value “raw” as stored in memory, and does not adjust
* for byte order (big or little endian). Address must be word-aligned.
*
* Returns null if reading from text segment and there is no instruction at the
* requested address. Returns null if reading from data segment and this is the
* first reference to the MARS 4K memory allocation block (i.e., an array to
* hold the memory has not been allocated).
*
* This method was developed by Greg Giberling of UC Berkeley to support the memory
* dump feature that he implemented in Fall 2007.
*
* @param address Starting address of word to be read.
* @return Word (4-byte value) stored starting at that address as an Integer. Conditions
* that cause return value null are described above.
* @throws AddressErrorException If address is not on word boundary.
**/
// See note above, with getRawWord(), concerning duplicated logic.
public Integer getRawWordOrNull(int address) throws AddressErrorException {
Integer value = null;
int relative;
if (address % WORD_LENGTH_BYTES != 0) {
throw new AddressErrorException(“address for fetch not aligned on word boundary”,
Exceptions.ADDRESS_EXCEPTION_LOAD, address);
}
if (inDataSegment(address)) {
// in data segment
relative = (address – dataSegmentBaseAddress) >> 2; // convert byte address to words
value = fetchWordOrNullFromTable(dataBlockTable, relative);
}
else if (address > stackLimitAddress && address <= stackBaseAddress) {
// in stack. Similar to data, except relative address computed "backward"
relative = (stackBaseAddress - address) >> 2; // convert byte address to words
value = fetchWordOrNullFromTable(stackBlockTable, relative);
}
else if (inTextSegment(address) || inKernelTextSegment(address)) {
try {
value = (getStatementNoNotify(address) == null) ? null : new Integer(getStatementNoNotify(address).getBinaryStatement());
}
catch (AddressErrorException aee) {
value = null; }
}
else if (inKernelDataSegment(address)) {
// in kernel data segment
relative = (address – kernelDataBaseAddress) >> 2; // convert byte address to words
value = fetchWordOrNullFromTable(kernelDataBlockTable, relative);
}
else {
// falls outside Mars addressing range
throw new AddressErrorException(“address out of range “, Exceptions.ADDRESS_EXCEPTION_LOAD, address);
}
// Do not notify observers. This read operation is initiated by the
// dump feature, not the executing MIPS program.
return value;
}
/**
* Look for first “null” memory value in an address range. For text segment (binary code), this
* represents a word that does not contain an instruction. Normally use this to find the end of
* the program. For data segment, this represents the first block of simulated memory (block length
* currently 4K words) that has not been referenced by an assembled/executing program.
*
* @param baseAddress lowest MIPS address to be searched; the starting point
* @param limitAddress highest MIPS address to be searched
* @return lowest address within specified range that contains “null” value as described above.
* @throws AddressErrorException if the base address is not on a word boundary
*/
public int getAddressOfFirstNull(int baseAddress, int limitAddress) throws AddressErrorException {
int address = baseAddress;
for (; address < limitAddress; address += Memory.WORD_LENGTH_BYTES) {
if (getRawWordOrNull(address) == null) {
break;
}
}
return address;
}
///////////////////////////////////////////////////////////////////////////////////////
/**
* Starting at the given word address, read a 4 byte word as an int.
* Does not use "get()"; we can do it faster here knowing we're working only
* with full words.
*
* @param address Starting address of word to be read.
* @return Word (4-byte value) stored starting at that address.
* @throws AddressErrorException If address is not on word boundary.
**/
public int getWord(int address) throws AddressErrorException {
if (address % WORD_LENGTH_BYTES != 0) {
throw new AddressErrorException("fetch address not aligned on word boundary ",
Exceptions.ADDRESS_EXCEPTION_LOAD, address);
}
return get(address, WORD_LENGTH_BYTES, true);
}
///////////////////////////////////////////////////////////////////////////////////////
/**
* Starting at the given word address, read a 4 byte word as an int.
* Does not use "get()"; we can do it faster here knowing we're working only
* with full words. Observers are NOT notified.
*
* @param address Starting address of word to be read.
* @return Word (4-byte value) stored starting at that address.
* @throws AddressErrorException If address is not on word boundary.
**/
public int getWordNoNotify(int address) throws AddressErrorException {
if (address % WORD_LENGTH_BYTES != 0) {
throw new AddressErrorException("fetch address not aligned on word boundary ",
Exceptions.ADDRESS_EXCEPTION_LOAD, address);
}
return get(address, WORD_LENGTH_BYTES, false);
}
///////////////////////////////////////////////////////////////////////////////////////
/**
* Starting at the given word address, read a 2 byte word into lower 16 bits of int.
*
* @param address Starting address of word to be read.
* @return Halfword (2-byte value) stored starting at that address, stored in lower 16 bits.
* @throws AddressErrorException If address is not on halfword boundary.
**/
public int getHalf(int address) throws AddressErrorException {
if (address % 2 != 0) {
throw new AddressErrorException("fetch address not aligned on halfword boundary ",
Exceptions.ADDRESS_EXCEPTION_LOAD, address);
}
return get(address, 2);
}
///////////////////////////////////////////////////////////////////////////////////////
/**
* Reads specified Memory byte into low order 8 bits of int.
*
* @param address Address of Memory byte to be read.
* @return Value stored at that address. Only low order 8 bits used.
**/
public int getByte(int address) throws AddressErrorException {
return get(address, 1);
}
////////////////////////////////////////////////////////////////////////////////
/**
* Gets ProgramStatement from Text Segment.
* @param address Starting address of Memory address to be read. Must be word boundary.
* @return reference to ProgramStatement object associated with that address, or null if none.
* @throws AddressErrorException If address is not on word boundary or is outside Text Segment.
* @see ProgramStatement
**/
public ProgramStatement getStatement(int address) throws AddressErrorException {
return getStatement(address, true);
/*
if (address % 4 != 0 || !(inTextSegment(address) || inKernelTextSegment(address))) {
throw new AddressErrorException(
"fetch address for text segment out of range or not aligned to word boundary ",
Exceptions.ADDRESS_EXCEPTION_LOAD, address);
}
if (inTextSegment(address)) {
return readProgramStatement(address, textBaseAddress, textBlockTable, true);
}
else {
return readProgramStatement(address, kernelTextBaseAddress, kernelTextBlockTable,true);
}
*/
}
////////////////////////////////////////////////////////////////////////////////
/**
* Gets ProgramStatement from Text Segment without notifying observers.
* @param address Starting address of Memory address to be read. Must be word boundary.
* @return reference to ProgramStatement object associated with that address, or null if none.
* @throws AddressErrorException If address is not on word boundary or is outside Text Segment.
* @see ProgramStatement
**/
public ProgramStatement getStatementNoNotify(int address) throws AddressErrorException {
return getStatement(address, false);
/*
if (address % 4 != 0 || !(inTextSegment(address) || inKernelTextSegment(address))) {
throw new AddressErrorException(
"fetch address for text segment out of range or not aligned to word boundary ",
Exceptions.ADDRESS_EXCEPTION_LOAD, address);
}
if (inTextSegment(address)) {
return readProgramStatement(address, textBaseAddress, textBlockTable, false);
}
else {
return readProgramStatement(address, kernelTextBaseAddress, kernelTextBlockTable, false);
}
*/
}
//////////
private ProgramStatement getStatement(int address, boolean notify) throws AddressErrorException {
if (!wordAligned(address)) {
throw new AddressErrorException(
"fetch address for text segment not aligned to word boundary ",
Exceptions.ADDRESS_EXCEPTION_LOAD, address);
}
if (!Globals.getSettings().getBooleanSetting(Settings.SELF_MODIFYING_CODE_ENABLED)
&& !(inTextSegment(address) || inKernelTextSegment(address))) {
throw new AddressErrorException(
"fetch address for text segment out of range ",
Exceptions.ADDRESS_EXCEPTION_LOAD, address);
}
if (inTextSegment(address))
return readProgramStatement(address, textBaseAddress, textBlockTable, notify);
else if (inKernelTextSegment(address))
return readProgramStatement(address, kernelTextBaseAddress, kernelTextBlockTable, notify);
else
return new ProgramStatement(get(address, WORD_LENGTH_BYTES), address);
}
/********************************* THE UTILITIES *************************************/
/**
* Utility to determine if given address is word-aligned.
* @param address the address to check
* @return true if address is word-aligned, false otherwise
*/
public static boolean wordAligned(int address) {
return (address % WORD_LENGTH_BYTES == 0);
}
/**
* Utility to determine if given address is doubleword-aligned.
* @param address the address to check
* @return true if address is doubleword-aligned, false otherwise
*/
public static boolean doublewordAligned(int address) {
return (address % (WORD_LENGTH_BYTES+WORD_LENGTH_BYTES) == 0);
}
/**
* Utility method to align given address to next full word boundary, if not already
* aligned.
* @param address a memory address (any int value is potentially valid)
* @return address aligned to next word boundary (divisible by 4)
*/
public static int alignToWordBoundary(int address) {
if (!wordAligned(address)) {
if (address > 0)
address += (4-(address % WORD_LENGTH_BYTES));
else
address -= (4-(address % WORD_LENGTH_BYTES));
}
return address;
}
/**
* Handy little utility to find out if given address is in MARS text
* segment (starts at Memory.textBaseAddress).
* Note that MARS does not implement the entire MIPS text segment space,
* but it does implement enough for hundreds of thousands of lines
* of code.
* @param address integer memory address
* @return true if that address is within MARS-defined text segment,
* false otherwise.
*/
public static boolean inTextSegment(int address) {
return address >= textBaseAddress && address < textLimitAddress;
}
/**
* Handy little utility to find out if given address is in MARS kernel
* text segment (starts at Memory.kernelTextBaseAddress).
* @param address integer memory address
* @return true if that address is within MARS-defined kernel text segment,
* false otherwise.
*/
public static boolean inKernelTextSegment(int address) {
return address >= kernelTextBaseAddress && address < kernelTextLimitAddress;
}
/**
* Handy little utility to find out if given address is in MARS data
* segment (starts at Memory.dataSegmentBaseAddress).
* Note that MARS does not implement the entire MIPS data segment space,
* but it does support at least 4MB.
* @param address integer memory address
* @return true if that address is within MARS-defined data segment,
* false otherwise.
*/
public static boolean inDataSegment(int address) {
return address >= dataSegmentBaseAddress && address < dataSegmentLimitAddress;
}
/**
* Handy little utility to find out if given address is in MARS kernel data
* segment (starts at Memory.kernelDataSegmentBaseAddress).
* @param address integer memory address
* @return true if that address is within MARS-defined kernel data segment,
* false otherwise.
*/
public static boolean inKernelDataSegment(int address) {
return address >= kernelDataBaseAddress && address < kernelDataSegmentLimitAddress;
}
/**
* Handy little utility to find out if given address is in the Memory Map area
* starts at Memory.memoryMapBaseAddress, range 0xffff0000 to 0xffffffff.
* @param address integer memory address
* @return true if that address is within MARS-defined memory map (MMIO) area,
* false otherwise.
*/
public static boolean inMemoryMapSegment(int address) {
return address >= memoryMapBaseAddress && address < kernelHighAddress;
}
///////////////////////////////////////////////////////////////////////////
// ALL THE OBSERVABLE STUFF GOES HERE. FOR COMPATIBILITY, Memory IS STILL
// EXTENDING OBSERVABLE, BUT WILL NOT USE INHERITED METHODS. WILL INSTEAD
// USE A COLLECTION OF MemoryObserver OBJECTS, EACH OF WHICH IS COMBINATION
// OF AN OBSERVER WITH AN ADDRESS RANGE.
/**
* Method to accept registration from observer for any memory address. Overrides
* inherited method. Note to observers: this class delegates Observable operations
* so notices will come from the delegate, not the memory object.
* @param obs the observer
*/
public void addObserver(Observer obs) {
try { // split so start address always >= end address
this.addObserver(obs, 0, 0x7ffffffc);
this.addObserver(obs,0x80000000,0xfffffffc);
}
catch (AddressErrorException aee) {
System.out.println(“Internal Error in Memory.addObserver: “+aee);
}
}
/**
* Method to accept registration from observer for specific address. This includes
* the memory word starting at the given address. Note to observers: this class delegates Observable operations
* so notices will come from the delegate, not the memory object.
*
* @param obs the observer
* @param addr the memory address which must be on word boundary
*/
public void addObserver(Observer obs, int addr) throws AddressErrorException {
this.addObserver(obs, addr, addr);
}
/**
* Method to accept registration from observer for specific address range. The
* last byte included in the address range is the last byte of the word specified
* by the ending address. Note to observers: this class delegates Observable operations
* so notices will come from the delegate, not the memory object.
*
* @param obs the observer
* @param startAddr the low end of memory address range, must be on word boundary
* @param endAddr the high end of memory address range, must be on word boundary
*/
public void addObserver(Observer obs, int startAddr, int endAddr) throws AddressErrorException {
if (startAddr % WORD_LENGTH_BYTES != 0) {
throw new AddressErrorException(“address not aligned on word boundary “,
Exceptions.ADDRESS_EXCEPTION_LOAD, startAddr);
}
if (endAddr!=startAddr && endAddr % WORD_LENGTH_BYTES != 0) {
throw new AddressErrorException(“address not aligned on word boundary “,
Exceptions.ADDRESS_EXCEPTION_LOAD, startAddr);
}
// upper half of address space (above 0x7fffffff) has sign bit 1 thus is seen as
// negative.
if (startAddr>=0 && endAddr<0) {
throw new AddressErrorException("range cannot cross 0x8000000; please split it up",
Exceptions.ADDRESS_EXCEPTION_LOAD, startAddr);
}
if (endAddr
return -1;
}
return 0; // they have to be equal at this point.
}
}
/********************************* THE HELPERS *************************************/
////////////////////////////////////////////////////////////////////////////////
//
// Method to notify any observers of memory operation that has just occurred.
//
// The “|| Globals.getGui()==null” is a hack added 19 July 2012 DPS. IF MIPS simulation
// is from command mode, Globals.program is null but still want ability to observe.
private void notifyAnyObservers(int type, int address, int length, int value) {
if ((Globals.program != null || Globals.getGui()==null) && this.observables.size() > 0) {
Iterator it = this.observables.iterator();
MemoryObservable mo;
while (it.hasNext()) {
mo = (MemoryObservable)it.next();
if (mo.match(address)) {
mo.notifyObserver(new MemoryAccessNotice(type, address, length, value));
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
//
// Helper method to store 1, 2 or 4 byte value in table that represents MIPS
// memory. Originally used just for data segment, but now also used for stack.
// Both use different tables but same storage method and same table size
// and block size.
// Modified 29 Dec 2005 to return old value of replaced bytes.
//
private static final boolean STORE = true;
private static final boolean FETCH = false;
private int storeBytesInTable(int [][] blockTable,
int relativeByteAddress, int length, int value) {
return storeOrFetchBytesInTable(blockTable, relativeByteAddress, length, value, STORE);
}
////////////////////////////////////////////////////////////////////////////////
//
// Helper method to fetch 1, 2 or 4 byte value from table that represents MIPS
// memory. Originally used just for data segment, but now also used for stack.
// Both use different tables but same storage method and same table size
// and block size.
//
private int fetchBytesFromTable(int[][] blockTable, int relativeByteAddress, int length) {
return storeOrFetchBytesInTable(blockTable, relativeByteAddress, length, 0, FETCH);
}
////////////////////////////////////////////////////////////////////////////////
//
// The helper’s helper. Works for either storing or fetching, little or big endian.
// When storing/fetching bytes, most of the work is calculating the correct array element(s)
// and element byte(s). This method performs either store or fetch, as directed by its
// client using STORE or FETCH in last arg.
// Modified 29 Dec 2005 to return old value of replaced bytes, for STORE.
//
private synchronized int storeOrFetchBytesInTable(int [][] blockTable,
int relativeByteAddress, int length, int value, boolean op) {
int relativeWordAddress, block, offset, bytePositionInMemory, bytePositionInValue;
int oldValue = 0; // for STORE, return old values of replaced bytes
int loopStopper = 3-length;
// IF added DPS 22-Dec-2008. NOTE: has NOT been tested with Big-Endian.
// Fix provided by Saul Spatz; comments that follow are his.
// If address in stack segment is 4k + m, with 0 < m < 4, then the
// relativeByteAddress we want is stackBaseAddress - 4k + m, but the
// address actually passed in is stackBaseAddress - (4k + m), so we
// need to add 2m. Because of the change in sign, we get the
// expression 4-delta below in place of m.
if (blockTable == stackBlockTable) {
int delta = relativeByteAddress % 4;
if (delta != 0) {
relativeByteAddress += ( 4 - delta ) << 1;
}
}
for (bytePositionInValue = 3; bytePositionInValue > loopStopper; bytePositionInValue–) {
bytePositionInMemory = relativeByteAddress % 4;
relativeWordAddress = relativeByteAddress >> 2;
block = relativeWordAddress / BLOCK_LENGTH_WORDS; // Block number
offset = relativeWordAddress % BLOCK_LENGTH_WORDS; // Word within that block
if (blockTable[block] == null) {
if (op==STORE)
blockTable[block] = new int[BLOCK_LENGTH_WORDS];
else
return 0;
}
if (byteOrder == LITTLE_ENDIAN) bytePositionInMemory = 3 – bytePositionInMemory;
if (op == STORE) {
oldValue = replaceByte(blockTable[block][offset], bytePositionInMemory,
oldValue, bytePositionInValue);
blockTable[block][offset] = replaceByte(value, bytePositionInValue,
blockTable[block][offset], bytePositionInMemory);
}
else {// op == FETCH
value = replaceByte(blockTable[block][offset], bytePositionInMemory,
value, bytePositionInValue);
}
relativeByteAddress++;
}
return (op == STORE) ? oldValue : value;
}
////////////////////////////////////////////////////////////////////////////////
//
// Helper method to store 4 byte value in table that represents MIPS memory.
// Originally used just for data segment, but now also used for stack.
// Both use different tables but same storage method and same table size
// and block size. Assumes address is word aligned, no endian processing.
// Modified 29 Dec 2005 to return overwritten value.
private synchronized int storeWordInTable(int[][] blockTable, int relative, int value) {
int block, offset, oldValue;
block = relative / BLOCK_LENGTH_WORDS;
offset = relative % BLOCK_LENGTH_WORDS;
if (blockTable[block] == null) {
// First time writing to this block, so allocate the space.
blockTable[block] = new int[BLOCK_LENGTH_WORDS];
}
oldValue = blockTable[block][offset];
blockTable[block][offset] = value;
return oldValue;
}
////////////////////////////////////////////////////////////////////////////////
//
// Helper method to fetch 4 byte value from table that represents MIPS memory.
// Originally used just for data segment, but now also used for stack.
// Both use different tables but same storage method and same table size
// and block size. Assumes word alignment, no endian processing.
//
private synchronized int fetchWordFromTable(int[][] blockTable, int relative) {
int value = 0;
int block, offset;
block = relative / BLOCK_LENGTH_WORDS;
offset = relative % BLOCK_LENGTH_WORDS;
if (blockTable[block] == null) {
// first reference to an address in this block. Assume initialized to 0.
value = 0;
}
else {
value = blockTable[block][offset];
}
return value;
}
////////////////////////////////////////////////////////////////////////////////
//
// Helper method to fetch 4 byte value from table that represents MIPS memory.
// Originally used just for data segment, but now also used for stack.
// Both use different tables but same storage method and same table size
// and block size. Assumes word alignment, no endian processing.
//
// This differs from “fetchWordFromTable()” in that it returns an Integer and
// returns null instead of 0 if the 4K table has not been allocated. Developed
// by Greg Gibeling of UC Berkeley, fall 2007.
//
private synchronized Integer fetchWordOrNullFromTable(int[][] blockTable, int relative) {
int value = 0;
int block, offset;
block = relative / BLOCK_LENGTH_WORDS;
offset = relative % BLOCK_LENGTH_WORDS;
if (blockTable[block] == null) {
// first reference to an address in this block. Assume initialized to 0.
return null;
}
else {
value = blockTable[block][offset];
}
return new Integer(value);
}
////////////////////////////////////////////////////////////////////////////////////
// Returns result of substituting specified byte of source value into specified byte
// of destination value. Byte positions are 0-1-2-3, listed from most to least
// significant. No endian issues. This is a private helper method used by get() & set().
private int replaceByte(int sourceValue, int bytePosInSource, int destValue, int bytePosInDest) {
return
// Set source byte value into destination byte position; set other 24 bits to 0’s…
((sourceValue >> (24 – (bytePosInSource << 3)) & 0xFF)
<< (24 - (bytePosInDest << 3)))
// and bitwise-OR it with...
|
// Set 8 bits in destination byte position to 0's, other 24 bits are unchanged.
(destValue & ~(0xFF << (24 - (bytePosInDest << 3))));
}
///////////////////////////////////////////////////////////////////////
// Reverses byte sequence of given value. Can use to convert between big and
// little endian if needed.
private int reverseBytes(int source) {
return (source >> 24 & 0x000000FF) |
(source >> 8 & 0x0000FF00) |
(source << 8 & 0x00FF0000) |
(source << 24);
}
///////////////////////////////////////////////////////////////////////
// Store a program statement at the given address. Address has already been verified
// as valid. It may be either in user or kernel text segment, as specified by arguments.
private void storeProgramStatement(int address, ProgramStatement statement,
int baseAddress, ProgramStatement[][] blockTable) {
int relative = (address - baseAddress) >> 2; // convert byte address to words
int block = relative / BLOCK_LENGTH_WORDS;
int offset = relative % BLOCK_LENGTH_WORDS;
if (block < TEXT_BLOCK_TABLE_LENGTH) {
if (blockTable[block] == null) {
// No instructions are stored in this block, so allocate the block.
blockTable[block] = new ProgramStatement[BLOCK_LENGTH_WORDS];
}
blockTable[block][offset] = statement;
}
}
///////////////////////////////////////////////////////////////////////
// Read a program statement from the given address. Address has already been verified
// as valid. It may be either in user or kernel text segment, as specified by arguments.
// Returns associated ProgramStatement or null if none.
// Last parameter controls whether or not observers will be notified.
private ProgramStatement readProgramStatement(int address, int baseAddress, ProgramStatement[][] blockTable, boolean notify) {
int relative = (address - baseAddress) >> 2; // convert byte address to words
int block = relative / TEXT_BLOCK_LENGTH_WORDS;
int offset = relative % TEXT_BLOCK_LENGTH_WORDS;
if (block < TEXT_BLOCK_TABLE_LENGTH) {
if (blockTable[block] == null || blockTable[block][offset] == null) {
// No instructions are stored in this block or offset.
if (notify) notifyAnyObservers(AccessNotice.READ, address, Instruction.INSTRUCTION_LENGTH,0);
return null;
}
else {
if (notify) notifyAnyObservers(AccessNotice.READ, address, Instruction.INSTRUCTION_LENGTH, blockTable[block][offset].getBinaryStatement());
return blockTable[block][offset];
}
}
if (notify) notifyAnyObservers(AccessNotice.READ, address, Instruction.INSTRUCTION_LENGTH,0);
return null;
}
}
MemoryAccessNotice
package mars.mips.hardware;
public synchronized class MemoryAccessNotice extends AccessNotice {
private int address;
private int length;
private int value;
void MemoryAccessNotice(int, int, int, int);
public void MemoryAccessNotice(int, int, int);
public int getAddress();
public int getLength();
public int getValue();
public String toString();
}
mars/mips/hardware/MemoryAccessNotice.java
mars/mips/hardware/MemoryAccessNotice.javapackage mars.mips.hardware;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Object provided to Observers of runtime access to MIPS memory.
* Observer can get the access type (R/W), address and length in bytes (4,2,1).
*
* @author Pete Sanderson
* @version July 2005
*/
public class MemoryAccessNotice extends AccessNotice {
private int address;
private int length;
private int value;
/** Constructor will be called only within this package, so assume
* address and length are in valid ranges.
*/
MemoryAccessNotice(int type, int address, int length, int value) {
super(type);
this.address = address;
this.length = length;
this.value = value;
}
/** Constructor will be called only within this package, so assume
* address is in valid range.
*/
public MemoryAccessNotice(int type, int address, int value) {
super(type);
this.address = address;
this.length = Memory.WORD_LENGTH_BYTES;
this.value = value;
}
/** Fetch the memory address that was accessed. */
public int getAddress() {
return address;
}
/** Fetch the length in bytes of the access operation (4,2,1). */
public int getLength() {
return length;
}
/** Fetch the value of the access operation (the value read or written). */
public int getValue() {
return value;
}
/** String representation indicates access type, address and length in bytes */
public String toString() {
return ((this.getAccessType()==AccessNotice.READ) ? "R " : "W ") +
"Mem " + address + " " + length + "B = "+value;
}
}
MemoryConfiguration
package mars.mips.hardware;
public synchronized class MemoryConfiguration {
private String configurationIdentifier;
private String configurationName;
private String[] configurationItemNames;
private int[] configurationItemValues;
public void MemoryConfiguration(String, String, String[], int[]);
public String getConfigurationIdentifier();
public String getConfigurationName();
public int[] getConfigurationItemValues();
public String[] getConfigurationItemNames();
public int getTextBaseAddress();
public int getDataSegmentBaseAddress();
public int getExternBaseAddress();
public int getGlobalPointer();
public int getDataBaseAddress();
public int getHeapBaseAddress();
public int getStackPointer();
public int getStackBaseAddress();
public int getUserHighAddress();
public int getKernelBaseAddress();
public int getKernelTextBaseAddress();
public int getExceptionHandlerAddress();
public int getKernelDataBaseAddress();
public int getMemoryMapBaseAddress();
public int getKernelHighAddress();
public int getDataSegmentLimitAddress();
public int getTextLimitAddress();
public int getKernelDataSegmentLimitAddress();
public int getKernelTextLimitAddress();
public int getStackLimitAddress();
public int getMemoryMapLimitAddress();
}
mars/mips/hardware/MemoryConfiguration.java
mars/mips/hardware/MemoryConfiguration.java package mars.mips.hardware;
/*
Copyright (c) 2003-2009, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Models the memory configuration for the simulated MIPS machine.
* "configuration" refers to the starting memory addresses for
* the various memory segments.
* The default configuration is based on SPIM. Starting with MARS 3.7,
* the configuration can be changed.
*
* @author Pete Sanderson
* @version August 2009
*/
public class MemoryConfiguration {
// Identifier is used for saving setting; name is used for display
private String configurationIdentifier, configurationName;
private String[] configurationItemNames;
private int[] configurationItemValues;
public MemoryConfiguration(String ident, String name, String[] items, int[] values) {
this.configurationIdentifier = ident;
this.configurationName = name;
this.configurationItemNames = items;
this.configurationItemValues = values;
}
public String getConfigurationIdentifier() {
return configurationIdentifier;
}
public String getConfigurationName() {
return configurationName;
}
public int[] getConfigurationItemValues() {
return configurationItemValues;
}
public String[] getConfigurationItemNames() {
return configurationItemNames;
}
public int getTextBaseAddress() {
return configurationItemValues[0];
}
public int getDataSegmentBaseAddress() {
return configurationItemValues[1];
}
public int getExternBaseAddress() {
return configurationItemValues[2];
}
public int getGlobalPointer() {
return configurationItemValues[3];
}
public int getDataBaseAddress() {
return configurationItemValues[4];
}
public int getHeapBaseAddress() {
return configurationItemValues[5];
}
public int getStackPointer() {
return configurationItemValues[6];
}
public int getStackBaseAddress() {
return configurationItemValues[7];
}
public int getUserHighAddress() {
return configurationItemValues[8];
}
public int getKernelBaseAddress() {
return configurationItemValues[9];
}
public int getKernelTextBaseAddress() {
return configurationItemValues[10];
}
public int getExceptionHandlerAddress() {
return configurationItemValues[11];
}
public int getKernelDataBaseAddress() {
return configurationItemValues[12];
}
public int getMemoryMapBaseAddress() {
return configurationItemValues[13];
}
public int getKernelHighAddress () {
return configurationItemValues[14];
}
public int getDataSegmentLimitAddress() {
return configurationItemValues[15];
}
public int getTextLimitAddress() {
return configurationItemValues[16];
}
public int getKernelDataSegmentLimitAddress() {
return configurationItemValues[17];
}
public int getKernelTextLimitAddress() {
return configurationItemValues[18];
}
public int getStackLimitAddress() {
return configurationItemValues[19];
}
public int getMemoryMapLimitAddress() {
return configurationItemValues[20];
}
}
MemoryConfigurations
package mars.mips.hardware;
public synchronized class MemoryConfigurations {
private static java.util.ArrayList configurations;
private static MemoryConfiguration defaultConfiguration;
private static MemoryConfiguration currentConfiguration;
private static final String[] configurationItemNames;
private static int[] defaultConfigurationItemValues;
private static int[] dataBasedCompactConfigurationItemValues;
private static int[] textBasedCompactConfigurationItemValues;
public void MemoryConfigurations();
public static void buildConfigurationCollection();
public static java.util.Iterator getConfigurationsIterator();
public static MemoryConfiguration getConfigurationByName(String);
public static MemoryConfiguration getDefaultConfiguration();
public static MemoryConfiguration getCurrentConfiguration();
public static boolean setCurrentConfiguration(MemoryConfiguration);
public static int getDefaultTextBaseAddress();
public static int getDefaultDataSegmentBaseAddress();
public static int getDefaultExternBaseAddress();
public static int getDefaultGlobalPointer();
public static int getDefaultDataBaseAddress();
public static int getDefaultHeapBaseAddress();
public static int getDefaultStackPointer();
public static int getDefaultStackBaseAddress();
public static int getDefaultUserHighAddress();
public static int getDefaultKernelBaseAddress();
public static int getDefaultKernelTextBaseAddress();
public static int getDefaultExceptionHandlerAddress();
public static int getDefaultKernelDataBaseAddress();
public static int getDefaultMemoryMapBaseAddress();
public static int getDefaultKernelHighAddress();
public int getDefaultDataSegmentLimitAddress();
public int getDefaultTextLimitAddress();
public int getDefaultKernelDataSegmentLimitAddress();
public int getDefaultKernelTextLimitAddress();
public int getDefaultStackLimitAddress();
public int getMemoryMapLimitAddress();
static void
}
mars/mips/hardware/MemoryConfigurations.java
mars/mips/hardware/MemoryConfigurations.java package mars.mips.hardware;
import mars.Globals;
import java.util.*;
/*
Copyright (c) 2003-2009, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Models the collection of MIPS memory configurations.
* The default configuration is based on SPIM. Starting with MARS 3.7,
* the configuration can be changed.
*
* @author Pete Sanderson
* @version August 2009
*/
public class MemoryConfigurations {
private static ArrayList configurations = null;
private static MemoryConfiguration defaultConfiguration;
private static MemoryConfiguration currentConfiguration;
// Be careful, these arrays are parallel and position-sensitive.
// The getters in this and in MemoryConfiguration depend on this
// sequence. Should be refactored… The order comes from the
// original listed order in Memory.java, where most of these were
// “final” until Mars 3.7 and changeable memory configurations.
private static final String[] configurationItemNames = {
“.text base address”,
“data segment base address”,
“.extern base address”,
“global pointer $gp”,
“.data base address”,
“heap base address”,
“stack pointer $sp”,
“stack base address”,
“user space high address”,
“kernel space base address”,
“.ktext base address”,
“exception handler address”,
“.kdata base address”,
“MMIO base address”,
“kernel space high address”,
“data segment limit address”,
“text limit address”,
“kernel data segment limit address”,
“kernel text limit address”,
“stack limit address”,
“memory map limit address”
};
// Default configuration comes from SPIM
private static int[] defaultConfigurationItemValues = {
0x00400000, // .text Base Address
0x10000000, // Data Segment base address
0x10000000, // .extern Base Address
0x10008000, // Global Pointer $gp)
0x10010000, // .data base Address
0x10040000, // heap base address
0x7fffeffc, // stack pointer $sp (from SPIM not MIPS)
0x7ffffffc, // stack base address
0x7fffffff, // highest address in user space
0x80000000, // lowest address in kernel space
0x80000000, // .ktext base address
0x80000180, // exception handler address
0x90000000, // .kdata base address
0xffff0000, // MMIO base address
0xffffffff, // highest address in kernel (and memory)
0x7fffffff, // data segment limit address
0x0ffffffc, // text limit address
0xfffeffff, // kernel data segment limit address
0x8ffffffc, // kernel text limit address
0x10040000, // stack limit address
0xffffffff // memory map limit address
};
// Compact allows 16 bit addressing, data segment starts at 0
private static int[] dataBasedCompactConfigurationItemValues = {
0x00003000, // .text Base Address
0x00000000, // Data Segment base address
0x00001000, // .extern Base Address
0x00001800, // Global Pointer $gp)
0x00000000, // .data base Address
0x00002000, // heap base address
0x00002ffc, // stack pointer $sp
0x00002ffc, // stack base address
0x00003fff, // highest address in user space
0x00004000, // lowest address in kernel space
0x00004000, // .ktext base address
0x00004180, // exception handler address
0x00005000, // .kdata base address
0x00007f00, // MMIO base address
0x00007fff, // highest address in kernel (and memory)
0x00002fff, // data segment limit address
0x00003ffc, // text limit address
0x00007eff, // kernel data segment limit address
0x00004ffc, // kernel text limit address
0x00002000, // stack limit address
0x00007fff // memory map limit address
};
// Compact allows 16 bit addressing, text segment starts at 0
private static int[] textBasedCompactConfigurationItemValues = {
0x00000000, // .text Base Address
0x00001000, // Data Segment base address
0x00001000, // .extern Base Address
0x00001800, // Global Pointer $gp)
0x00002000, // .data base Address
0x00003000, // heap base address
0x00003ffc, // stack pointer $sp
0x00003ffc, // stack base address
0x00003fff, // highest address in user space
0x00004000, // lowest address in kernel space
0x00004000, // .ktext base address
0x00004180, // exception handler address
0x00005000, // .kdata base address
0x00007f00, // MMIO base address
0x00007fff, // highest address in kernel (and memory)
0x00003fff, // data segment limit address
0x00000ffc, // text limit address
0x00007eff, // kernel data segment limit address
0x00004ffc, // kernel text limit address
0x00003000, // stack limit address
0x00007fff // memory map limit address
};
public MemoryConfigurations() {
}
public static void buildConfigurationCollection() {
if (configurations == null) {
configurations = new ArrayList();
configurations.add(new MemoryConfiguration(“Default”, “Default”, configurationItemNames, defaultConfigurationItemValues));
configurations.add(new MemoryConfiguration(“CompactDataAtZero”, “Compact, Data at Address 0”, configurationItemNames, dataBasedCompactConfigurationItemValues));
configurations.add(new MemoryConfiguration(“CompactTextAtZero”, “Compact, Text at Address 0”, configurationItemNames, textBasedCompactConfigurationItemValues));
defaultConfiguration = (MemoryConfiguration) configurations.get(0);
currentConfiguration = defaultConfiguration;
// Get current config from settings
//String currentConfigurationIdentifier = Globals.getSettings().getMemoryConfiguration();
setCurrentConfiguration(getConfigurationByName(Globals.getSettings().getMemoryConfiguration()));
// Iterator configurationsIterator = getConfigurationsIterator();
// while (configurationsIterator.hasNext()) {
// MemoryConfiguration config = (MemoryConfiguration)configurationsIterator.next();
// if (currentConfigurationIdentifier.equals(config.getConfigurationIdentifier())) {
// setCurrentConfiguration(config);
// }
// }
}
}
public static Iterator getConfigurationsIterator() {
if (configurations == null) {
buildConfigurationCollection();
}
return configurations.iterator();
}
public static MemoryConfiguration getConfigurationByName(String name) {
Iterator configurationsIterator = getConfigurationsIterator();
while (configurationsIterator.hasNext()) {
MemoryConfiguration config = (MemoryConfiguration)configurationsIterator.next();
if (name.equals(config.getConfigurationIdentifier())) {
return config;
}
}
return null;
}
public static MemoryConfiguration getDefaultConfiguration() {
if (defaultConfiguration == null) {
buildConfigurationCollection();
}
return defaultConfiguration;
}
public static MemoryConfiguration getCurrentConfiguration() {
if (currentConfiguration == null) {
buildConfigurationCollection();
}
return currentConfiguration;
}
public static boolean setCurrentConfiguration(MemoryConfiguration config) {
if (config == null)
return false;
if (config != currentConfiguration) {
currentConfiguration = config;
Globals.memory.clear();
RegisterFile.getUserRegister(“$gp”).changeResetValue(config.getGlobalPointer());
RegisterFile.getUserRegister(“$sp”).changeResetValue(config.getStackPointer());
RegisterFile.getProgramCounterRegister().changeResetValue(config.getTextBaseAddress());
RegisterFile.initializeProgramCounter(config.getTextBaseAddress());
RegisterFile.resetRegisters();
return true;
}
else {
return false;
}
}
//// Use these to intialize Memory static variables at launch
public static int getDefaultTextBaseAddress() {
return defaultConfigurationItemValues[0];
}
public static int getDefaultDataSegmentBaseAddress() {
return defaultConfigurationItemValues[1];
}
public static int getDefaultExternBaseAddress() {
return defaultConfigurationItemValues[2];
}
public static int getDefaultGlobalPointer() {
return defaultConfigurationItemValues[3];
}
public static int getDefaultDataBaseAddress() {
return defaultConfigurationItemValues[4];
}
public static int getDefaultHeapBaseAddress() {
return defaultConfigurationItemValues[5];
}
public static int getDefaultStackPointer() {
return defaultConfigurationItemValues[6];
}
public static int getDefaultStackBaseAddress() {
return defaultConfigurationItemValues[7];
}
public static int getDefaultUserHighAddress() {
return defaultConfigurationItemValues[8];
}
public static int getDefaultKernelBaseAddress() {
return defaultConfigurationItemValues[9];
}
public static int getDefaultKernelTextBaseAddress() {
return defaultConfigurationItemValues[10];
}
public static int getDefaultExceptionHandlerAddress() {
return defaultConfigurationItemValues[11];
}
public static int getDefaultKernelDataBaseAddress() {
return defaultConfigurationItemValues[12];
}
public static int getDefaultMemoryMapBaseAddress() {
return defaultConfigurationItemValues[13];
}
public static int getDefaultKernelHighAddress () {
return defaultConfigurationItemValues[14];
}
public int getDefaultDataSegmentLimitAddress() {
return defaultConfigurationItemValues[15];
}
public int getDefaultTextLimitAddress() {
return defaultConfigurationItemValues[16];
}
public int getDefaultKernelDataSegmentLimitAddress() {
return defaultConfigurationItemValues[17];
}
public int getDefaultKernelTextLimitAddress() {
return defaultConfigurationItemValues[18];
}
public int getDefaultStackLimitAddress() {
return defaultConfigurationItemValues[19];
}
public int getMemoryMapLimitAddress() {
return defaultConfigurationItemValues[20];
}
}
Register
package mars.mips.hardware;
public synchronized class Register extends java.util.Observable {
private String name;
private int number;
private int resetValue;
private volatile int value;
public void Register(String, int, int);
public String getName();
public synchronized int getValue();
public synchronized int getValueNoNotify();
public int getResetValue();
public int getNumber();
public synchronized int setValue(int);
public synchronized void resetValue();
public synchronized void changeResetValue(int);
private void notifyAnyObservers(int);
}
mars/mips/hardware/Register.java
mars/mips/hardware/Register.java package mars.mips.hardware;
import mars.*;
import java.util.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Abstraction to represent a register of a MIPS Assembler.
* @author Jason Bumgarner, Jason Shrewsbury, Ben Sherman
* @version June 2003
**/
public class Register extends Observable {
private String name;
private int number, resetValue;
// volatile should be enough to allow safe multi-threaded access
// w/o the use of synchronized methods. getValue and setValue
// are the only methods here used by the register collection
// (RegisterFile, Coprocessor0, Coprocessor1) methods.
private volatile int value;
/**
* Creates a new register with specified name, number, and value.
* @param n The name of the register.
* @param num The number of the register.
* @param val The inital (and reset) value of the register.
*/
public Register(String n, int num, int val){
name= n;
number=num;
value= val;
resetValue = val;
}
/**
* Returns the name of the Register.
* @return name The name of the Register.
*/
public String getName(){
return name;
}
/**
* Returns the value of the Register. Observers are notified
* of the READ operation.
* @return value The value of the Register.
*/
public synchronized int getValue(){
notifyAnyObservers(AccessNotice.READ);
return value;
}
/**
* Returns the value of the Register. Observers are not notified.
* Added for release 3.8.
* @return value The value of the Register.
*/
public synchronized int getValueNoNotify(){
return value;
}
/**
* Returns the reset value of the Register.
* @return The reset (initial) value of the Register.
*/
public int getResetValue(){
return resetValue;
}
/**
* Returns the number of the Register.
* @return number The number of the Register.
*/
public int getNumber(){
return number;
}
/**
* Sets the value of the register to the val passed to it.
* Observers are notified of the WRITE operation.
* @param val Value to set the Register to.
* @return previous value of register
*/
public synchronized int setValue(int val){
int old = value;
value = val;
notifyAnyObservers(AccessNotice.WRITE);
return old;
}
/**
* Resets the value of the register to the value it was constructed with.
* Observers are not notified.
*/
public synchronized void resetValue(){
value = resetValue;
}
/**
* Change the register’s reset value; the value to which it will be
* set when resetValue() is called.
*/
public synchronized void changeResetValue(int reset) {
resetValue = reset;
}
//
// Method to notify any observers of register operation that has just occurred.
//
private void notifyAnyObservers(int type) {
if (this.countObservers() > 0){// && Globals.program != null) && Globals.program.inSteppedExecution()) {
this.setChanged();
this.notifyObservers(new RegisterAccessNotice(type, this.name));
}
}
}
RegisterAccessNotice
package mars.mips.hardware;
public synchronized class RegisterAccessNotice extends AccessNotice {
private String registerName;
void RegisterAccessNotice(int, String);
public String getRegisterName();
public String toString();
}
mars/mips/hardware/RegisterAccessNotice.java
mars/mips/hardware/RegisterAccessNotice.javapackage mars.mips.hardware;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Object provided to Observers of runtime access to MIPS register.
* Observer can get the access type (R/W) and register number.
*
* @author Pete Sanderson
* @version July 2005
*/
public class RegisterAccessNotice extends AccessNotice {
private String registerName;
/** Constructor will be called only within this package, so assume
* register number is in valid range.
*/
RegisterAccessNotice(int type, String registerName) {
super(type);
this.registerName = registerName;
}
/** Fetch the register number of register accessed. */
public String getRegisterName() {
return registerName;
}
/** String representation indicates access type and which register */
public String toString() {
return ((this.getAccessType()==AccessNotice.READ) ? “R ” : “W “) +
“Reg ” + registerName;
}
}
RegisterFile
package mars.mips.hardware;
public synchronized class RegisterFile {
public static final int GLOBAL_POINTER_REGISTER = 28;
public static final int STACK_POINTER_REGISTER = 29;
private static Register[] regFile;
private static Register programCounter;
private static Register hi;
private static Register lo;
public void RegisterFile();
public static void showRegisters();
public static int updateRegister(int, int);
public static void updateRegister(String, int);
public static int getValue(int);
public static int getNumber(String);
public static Register[] getRegisters();
public static Register getUserRegister(String);
public static void initializeProgramCounter(int);
public static void initializeProgramCounter(boolean);
public static int setProgramCounter(int);
public static int getProgramCounter();
public static Register getProgramCounterRegister();
public static int getInitialProgramCounter();
public static void resetRegisters();
public static void incrementPC();
public static void addRegistersObserver(java.util.Observer);
public static void deleteRegistersObserver(java.util.Observer);
static void
}
mars/mips/hardware/RegisterFile.java
mars/mips/hardware/RegisterFile.java package mars.mips.hardware;
import java.util.Observer;
import mars.Globals;
import mars.assembler.SymbolTable;
import mars.mips.instructions.Instruction;
import mars.util.Binary;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Represents the collection of MIPS registers.
* @author Jason Bumgarner, Jason Shrewsbury
* @version June 2003
**/
public class RegisterFile {
public static final int GLOBAL_POINTER_REGISTER = 28;
public static final int STACK_POINTER_REGISTER = 29;
private static Register [] regFile =
{ new Register(“$zero”, 0, 0), new Register(“$at”, 1, 0),
new Register(“$v0”, 2, 0),new Register(“$v1”, 3, 0),
new Register(“$a0”, 4, 0),new Register(“$a1”, 5, 0),
new Register(“$a2”, 6, 0),new Register(“$a3”, 7, 0),
new Register(“$t0”, 8, 0),new Register(“$t1”, 9, 0),
new Register(“$t2”, 10, 0),new Register(“$t3”, 11, 0),
new Register(“$t4”, 12, 0),new Register(“$t5”, 13, 0),
new Register(“$t6”, 14, 0),new Register(“$t7”, 15, 0),
new Register(“$s0”, 16, 0),new Register(“$s1”, 17, 0),
new Register(“$s2”, 18, 0),new Register(“$s3”, 19, 0),
new Register(“$s4”, 20, 0),new Register(“$s5”, 21, 0),
new Register(“$s6”, 22, 0),new Register(“$s7”, 23, 0),
new Register(“$t8”, 24, 0),new Register(“$t9”, 25, 0),
new Register(“$k0”, 26, 0),new Register(“$k1”, 27, 0),
new Register(“$gp”, GLOBAL_POINTER_REGISTER, Memory.globalPointer),
new Register(“$sp”, STACK_POINTER_REGISTER, Memory.stackPointer),
new Register(“$fp”, 30, 0),new Register(“$ra”, 31, 0)
};
private static Register programCounter= new Register(“pc”, 32, Memory.textBaseAddress);
private static Register hi= new Register(“hi”, 33, 0);//this is an internal register with arbitrary number
private static Register lo= new Register(“lo”, 34, 0);// this is an internal register with arbitrary number
/**
* Method for displaying the register values for debugging.
**/
public static void showRegisters(){
for (int i=0; i< regFile.length; i++){
System.out.println("Name: " + regFile[i].getName());
System.out.println("Number: " + regFile[i].getNumber());
System.out.println("Value: " + regFile[i].getValue());
System.out.println("");
}
}
/**
* This method updates the register value who's number is num. Also handles the lo and hi registers
* @param num Register to set the value of.
* @param val The desired value for the register.
**/
public static int updateRegister(int num, int val){
int old = 0;
if(num == 0){
//System.out.println("You can not change the value of the zero register.");
}
else {
for (int i=0; i< regFile.length; i++){
if(regFile[i].getNumber()== num) {
old = (Globals.getSettings().getBackSteppingEnabled())
? Globals.program.getBackStepper().addRegisterFileRestore(num,regFile[i].setValue(val))
: regFile[i].setValue(val);
break;
}
}
}
if(num== 33){//updates the hi register
old = (Globals.getSettings().getBackSteppingEnabled())
? Globals.program.getBackStepper().addRegisterFileRestore(num,hi.setValue(val))
: hi.setValue(val);
}
else if(num== 34){// updates the low register
old = (Globals.getSettings().getBackSteppingEnabled())
? Globals.program.getBackStepper().addRegisterFileRestore(num,lo.setValue(val))
: lo.setValue(val);
}
return old;
}
/**
* Sets the value of the register given to the value given.
* @param reg Name of register to set the value of.
* @param val The desired value for the register.
**/
public static void updateRegister(String reg, int val){
if(reg.equals("zero")){
//System.out.println("You can not change the value of the zero register.");
}
else{
for (int i=0; i< regFile.length; i++){
if(regFile[i].getName().equals(reg)) {
updateRegister(i,val);
break;
}
}}
}
/**
* Returns the value of the register who's number is num.
* @param num The register number.
* @return The value of the given register.
**/
public static int getValue(int num){
if(num==33){
return hi.getValue();
}
else if(num==34){
return lo.getValue();
}
else
return regFile[num].getValue();
}
/**
* For getting the number representation of the register.
* @param n The string formatted register name to look for.
* @return The number of the register represented by the string
* or -1 if no match.
**/
public static int getNumber(String n){
int j=-1;
for (int i=0; i< regFile.length; i++){
if(regFile[i].getName().equals(n)) {
j= regFile[i].getNumber();
break;
}
}
return j;
}
/**
* For returning the set of registers.
* @return The set of registers.
**/
public static Register[] getRegisters(){
return regFile;
}
/**
* Get register object corresponding to given name. If no match, return null.
* @param Rname The register name, either in $0 or $zero format.
* @return The register object,or null if not found.
**/
public static Register getUserRegister(String Rname) {
Register reg = null;
if (Rname.charAt(0) == '$') {
try {
// check for register number 0-31.
reg = regFile[Binary.stringToInt(Rname.substring(1))]; // KENV 1/6/05
}
catch (Exception e) {
// handles both NumberFormat and ArrayIndexOutOfBounds
// check for register mnemonic $zero thru $ra
reg = null; // just to be sure
// just do linear search; there aren't that many registers
for (int i=0; i < regFile.length; i++) {
if (Rname.equals(regFile[i].getName())) {
reg = regFile[i];
break;
}
}
}
}
return reg;
}
/**
* For initializing the Program Counter. Do not use this to implement jumps and
* branches, as it will NOT record a backstep entry with the restore value.
* If you need backstepping capability, use setProgramCounter instead.
* @param value The value to set the Program Counter to.
**/
public static void initializeProgramCounter(int value){
programCounter.setValue(value);
}
/**
* Will initialize the Program Counter to either the default reset value, or the address
* associated with source program global label "main", if it exists as a text segment label
* and the global setting is set.
* @param startAtMain If true, will set program counter to address of statement labeled
* 'main' (or other defined start label) if defined. If not defined, or if parameter false,
* will set program counter to default reset value.
**/
public static void initializeProgramCounter(boolean startAtMain) {
int mainAddr = Globals.symbolTable.getAddress(SymbolTable.getStartLabel());
if (startAtMain && mainAddr != SymbolTable.NOT_FOUND && (Memory.inTextSegment(mainAddr) || Memory.inKernelTextSegment(mainAddr))) {
initializeProgramCounter(mainAddr);
}
else {
initializeProgramCounter(programCounter.getResetValue());
}
}
/**
* For setting the Program Counter. Note that ordinary PC update should be done using
* incrementPC() method. Use this only when processing jumps and branches.
* @param value The value to set the Program Counter to.
* @return previous PC value
**/
public static int setProgramCounter(int value){
int old = programCounter.getValue();
programCounter.setValue(value);
if (Globals.getSettings().getBackSteppingEnabled()) {
Globals.program.getBackStepper().addPCRestore(old);
}
return old;
}
/**
* For returning the program counters value.
* @return The program counters value as an int.
**/
public static int getProgramCounter(){
return programCounter.getValue();
}
/**
* Returns Register object for program counter. Use with caution.
* @return program counter's Register object.
*/
public static Register getProgramCounterRegister() {
return programCounter;
}
/**
* For returning the program counter's initial (reset) value.
* @return The program counter's initial value
**/
public static int getInitialProgramCounter(){
return programCounter.getResetValue();
}
/**
* Method to reinitialize the values of the registers.
* NOTE: Should not be called from command-mode MARS because this
* this method uses global settings from the registry. Command-mode must operate
* using only the command switches, not registry settings. It can be called
* from tools running stand-alone, and this is done in
* AbstractMarsToolAndApplication
.
**/
public static void resetRegisters(){
for(int i=0; i< regFile.length; i++){
regFile[i].resetValue();
}
initializeProgramCounter(Globals .getSettings().getStartAtMain());// replaces "programCounter.resetValue()", DPS 3/3/09
hi.resetValue();
lo.resetValue();
}
/**
* Method to increment the Program counter in the general case (not a jump or branch).
**/
public static void incrementPC(){
programCounter.setValue(programCounter.getValue() + Instruction.INSTRUCTION_LENGTH);
}
/**
* Each individual register is a separate object and Observable. This handy method
* will add the given Observer to each one. Currently does not apply to Program
* Counter.
*/
public static void addRegistersObserver(Observer observer) {
for (int i=0; i
}
mars/mips/instructions/BasicInstructionFormat.java
mars/mips/instructions/BasicInstructionFormat.javapackage mars.mips.instructions;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* These are the MIPS-defined formats of basic machine instructions. The R-format indicates
* the instruction works only with registers. The I-format indicates the instruction
* works with an immediate value (e.g. constant). The J-format indicates this is a Jump
* instruction. The I-branch-format is defined by me, not MIPS, to to indicate this is
* a Branch instruction, specifically to distinguish immediate
* values used as target addresses.
*
* @author Pete Sanderson
* @version August 2003
*/
public class BasicInstructionFormat {
public static final BasicInstructionFormat R_FORMAT = new BasicInstructionFormat();
public static final BasicInstructionFormat I_FORMAT = new BasicInstructionFormat();
public static final BasicInstructionFormat I_BRANCH_FORMAT = new BasicInstructionFormat();
public static final BasicInstructionFormat J_FORMAT = new BasicInstructionFormat();
// private default constructor prevents objects of this class other than those above.
private BasicInstructionFormat() {
}
}
ExtendedInstruction
package mars.mips.instructions;
public synchronized class ExtendedInstruction extends Instruction {
private java.util.ArrayList translationStrings;
private java.util.ArrayList compactTranslationStrings;
public void ExtendedInstruction(String, String, String, String);
public void ExtendedInstruction(String, String, String);
public void ExtendedInstruction(String, String);
public int getInstructionLength();
public java.util.ArrayList getBasicIntructionTemplateList();
public int getCompactInstructionLength();
public boolean hasCompactTranslation();
public java.util.ArrayList getCompactBasicIntructionTemplateList();
public static String makeTemplateSubstitutions(mars.MIPSprogram, String, mars.assembler.TokenList);
private static String substitute(String, String, String);
private static String substituteFirst(String, String, String);
private java.util.ArrayList buildTranslationList(String);
private int getInstructionLength(java.util.ArrayList);
}
mars/mips/instructions/ExtendedInstruction.java
mars/mips/instructions/ExtendedInstruction.java package mars.mips.instructions;
import mars.*;
import mars.util.*;
import mars.assembler.*;
import mars.mips.hardware.*;
import java.util.*;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* ExtendedInstruction represents a MIPS extended (a.k.a pseudo) instruction. This
* assembly language instruction does not have a corresponding machine instruction. Instead
* it is translated by the extended assembler into one or more basic instructions (operations
* that have a corresponding machine instruction). The TranslationCode object is
* responsible for performing the translation.
*
* @author Pete Sanderson
* @version August 2003
*/
public class ExtendedInstruction extends Instruction {
private ArrayList translationStrings, compactTranslationStrings;
/**
* Constructor for ExtendedInstruction.
*
* @param example A String containing example use of the MIPS extended instruction.
* @param translation Specifications for translating this instruction into a sequence
* of one or more MIPS basic instructions.
* @param compactTranslation Alternative translation that can be used if running under
* a compact (16 bit) memory configuration.
* @param description a helpful description to be included on help requests
*
* The presence of an alternative “compact translation” can optimize code generation
* by assuming that data label addresses are 16 bits instead of 32
**/
public ExtendedInstruction(String example, String translation, String compactTranslation, String description) {
this.exampleFormat = example;
this.description = description;
this.mnemonic = this.extractOperator(example);
this.createExampleTokenList();
this.translationStrings = buildTranslationList(translation);
this.compactTranslationStrings = buildTranslationList(compactTranslation);
}
/**
* Constructor for ExtendedInstruction. No compact translation is provided.
*
* @param example A String containing example use of the MIPS extended instruction.
* @param translation Specifications for translating this instruction into a sequence
* of one or more MIPS basic instructions.
* @param description a helpful description to be included on help requests
**/
public ExtendedInstruction(String example, String translation, String description) {
this.exampleFormat = example;
this.description = description;
this.mnemonic = this.extractOperator(example);
this.createExampleTokenList();
this.translationStrings = buildTranslationList(translation);
this.compactTranslationStrings = null;
}
/**
* Constructor for ExtendedInstruction, where no instruction description or
* compact translation is provided.
*
* @param example A String containing example use of the MIPS extended instruction.
* @param translation Specifications for translating this instruction into a sequence
* of one or more MIPS basic instructions.
**/
public ExtendedInstruction(String example, String translation) {
this(example, translation, “”);
}
/**
* Get length in bytes that this extended instruction requires in its
* binary form. The answer depends on how many basic instructions it
* expands to. This may vary, if expansion includes a nop, depending on
* whether or not delayed branches are enabled. Each requires 4 bytes.
* @return int length in bytes of corresponding binary instruction(s).
*/
public int getInstructionLength() {
return getInstructionLength(translationStrings);
}
/**
* Get ArrayList of Strings that represent list of templates for
* basic instructions generated by this extended instruction.
* @return ArrayList of Strings.
*/
public ArrayList getBasicIntructionTemplateList() {
return translationStrings;
}
/**
* Get length in bytes that this extended instruction requires in its
* binary form if it includes an alternative expansion for compact
* memory (16 bit addressing) configuration. The answer depends on
* how many basic instructions it expands to. This may vary, if
* expansion includes a nop, depending on whether or not delayed
* branches are enabled. Each requires 4 bytes.
* @return int length in bytes of corresponding binary instruction(s).
* Returns 0 if an alternative expansion is not defined for this
* instruction.
*/
public int getCompactInstructionLength() {
return getInstructionLength(compactTranslationStrings);
}
/**
* Determine whether or not this pseudo-instruction has a second
* translation optimized for 16 bit address space: a compact version.
*/
public boolean hasCompactTranslation() {
return compactTranslationStrings != null;
}
/**
* Get ArrayList of Strings that represent list of templates for
* basic instructions generated by the “compact” or 16-bit version
* of this extended instruction.
* @return ArrayList of Strings. Returns null if the instruction does not
* have a compact alternative.
*/
public ArrayList getCompactBasicIntructionTemplateList() {
return compactTranslationStrings;
}
/**
* Given a basic instruction template and the list of tokens from an extended
* instruction statement, substitute operands from the token list appropriately into the
* template to generate the basic statement. Assumes the extended instruction statement has
* been translated from source form to basic assembly form (e.g. register mnemonics
* translated to corresponding register numbers).
* Operand format of source statement is already verified correct.
* Assume the template has correct number and positions of operands.
* Template is String with special markers. In the list below, n represents token position (1,2,3,etc)
* in source statement (operator is token 0, parentheses count but commas don’t):
*
- RGn means substitute register found in n’th token of source statement
* - NRn means substitute next higher register than the one in n’th token of source code
* - OPn means substitute n’th token of source code as is
* - LLn means substitute low order 16 bits from label address in source token n.
* - LLnU means substitute low order 16 bits (unsigned) from label address in source token n.
* - LLnPm (m=1,2,3,4) means substitute low order 16 bits from label address in source token n, after adding m.
* - LHn means substitute high order 16 bits from label address in source token n. Must add 1 if address bit 15 is 1.
* - LHnPm (m=1,2,3,4) means substitute high order 16 bits from label address in source token n, after adding m. Must then add 1 if bit 15 is 1.
* - VLn means substitute low order 16 bits from 32 bit value in source token n.
* - VLnU means substitute low order 16 bits (unsigned) from 32 bit value in source token n.
* - VLnPm (m=1,2,3,4) means substitute low order 16 bits from 32 bit value in source token n, after adding m to value.
* - VLnPmU (m=1,2,3,4) means substitute low order 16 bits (unsigned) from 32 bit value in source token n, after adding m to value.
* - VHLn means substitute high order 16 bits from 32 bit value in source token n. Use this if later combined with low order 16 bits using “ori $1,$1,VLn”. See logical and branch operations.
* - VHn means substitute high order 16 bits from 32 bit value in source token n, then add 1 if value’s bit 15 is 1. Use this only if later instruction uses VLn($1) to calculate 32 bit address. See loads and stores.
* - VHLnPm (m=1,2,3,4) means substitute high order 16 bits from 32 bit value in source token n, after adding m. See VHLn.
* - VHnPm (m=1,2,3,4) means substitute high order 16 bits from 32 bit value in source token n, after adding m. Must then add 1 if bit 15 is 1. See VHn.
* - LLP is similar to LLn, but is needed for “label+100000” address offset. Immediate is added before taking low order 16.
* - LLPU is similar to LLnU, but is needed for “label+100000” address offset. Immediate is added before taking low order 16 (unsigned).
* - LLPPm (m=1,2,3,4) is similar to LLP except m is added along with mmediate before taking low order 16.
* - LHPA is similar to LHn, but is needed for “label+100000” address offset. Immediate is added before taking high order 16.
* - LHPN is similar to LHPA, used only by “la” instruction. Address resolved by “ori” so do not add 1 if bit 15 is 1.
* - LHPAPm (m=1,2,3,4) is similar to LHPA except value m is added along with immediate before taking high order 16.
* - LHL means substitute high order 16 bits from label address in token 2 of “la” (load address) source statement.
* - LAB means substitute textual label from last token of source statement. Used for various branches.
* - S32 means substitute the result of subtracting the constant value in last token from 32. Used by “ror”, “rol”.
* - DBNOP means Delayed Branching NOP – generate a “nop” instruction but only if delayed branching is enabled. Added in 3.4.1 release.
* - BROFFnm means substitute n if delayed branching is NOT enabled otherwise substitute m. n and m are single digit numbers indicating constant branch offset (in words). Added in 3.4.1 release.
*
*
* @param template a String containing template for basic statement.
* @param tokenList a TokenList containing tokens from extended instruction.
* @return String representing basic assembler statement.
*/
public static String makeTemplateSubstitutions(MIPSprogram program, String template, TokenList theTokenList) {
String instruction = template;
int index;
// Added 22 Jan 2008 by DPS. The DBNOP template means to generate a “nop” instruction if delayed branching
// is enabled and generate no instruction otherwise.
//This is the goal, but it leads to a cascade of
// additional changes, so for now I will generate “nop” in either case, then come back to it for the
// next major release.
if (instruction.indexOf(“DBNOP”)>=0) {
return Globals.getSettings().getDelayedBranchingEnabled() ? “nop” : “”;
}
// substitute first operand token for template’s RG1 or OP1, second for RG2 or OP2, etc
for (int op=1; op
// Label, last operand, has already been translated to address by symtab lookup
String label = theTokenList.get(op).getValue();
int addr = 0;
int add = instruction.charAt(index+4)-48; // extract the digit following P
try {
addr = Binary.stringToInt(label) + add; // KENV 1/6/05
}
catch (NumberFormatException e) {
// this won’t happen…
}
// If bit 15 is 1, that means lower 16 bits will become a negative offset! To
// compensate if that is the case, we need to add 1 to the high 16 bits.
int extra = Binary.bitValue(addr,15);
instruction = substitute(instruction,”LH”+op+”P”+add,String.valueOf((addr >> 16)+extra));
}
// substitute upper 16 bits of label address
// NOTE: form LHnPm will not match here since it is discovered and substituted above.
if (instruction.indexOf(“LH”+op)>=0) {
// Label, last operand, has already been translated to address by symtab lookup
String label = theTokenList.get(op).getValue();
int addr = 0;
try {
addr = Binary.stringToInt(label); // KENV 1/6/05
}
catch (NumberFormatException e) {
// this won’t happen…
}
// If bit 15 is 1, that means lower 16 bits will become a negative offset! To
// compensate if that is the case, we need to add 1 to the high 16 bits.
int extra = Binary.bitValue(addr,15);
instruction = substitute(instruction,”LH”+op,String.valueOf((addr >> 16)+extra));
}
// substitute lower 16 bits of label address, after adding single digit that follows P
if ((index=instruction.indexOf(“LL”+op+”P”))>=0) {
// label has already been translated to address by symtab lookup.
String label = theTokenList.get(op).getValue();
int addr = 0;
int add = instruction.charAt(index+4)-48; // digit that follows P
try {
addr = Binary.stringToInt(label) + add; // KENV 1/6/05
}
catch (NumberFormatException e) {
// this won’t happen…
}
instruction = substitute(instruction,”LL”+op+”P”+add,String.valueOf(addr << 16 >> 16));//addr & 0xffff));
}
// substitute lower 16 bits of label address.
// NOTE: form LLnPm will not match here since it is discovered and substituted above.
if ((index=instruction.indexOf(“LL”+op))>=0) {
// label has already been translated to address by symtab lookup.
String label = theTokenList.get(op).getValue();
int addr = 0;
try {
addr = Binary.stringToInt(label); // KENV 1/6/05
}
catch (NumberFormatException e) {
// this won’t happen…
}
if ((instruction.length() > index+3) && (instruction.charAt(index+3) == ‘U’)) {
instruction = substitute(instruction,”LL”+op+”U”,String.valueOf(addr & 0xffff));
}
else {
instruction = substitute(instruction,”LL”+op,String.valueOf(addr << 16 >> 16));//addr & 0xffff));
}
}
// Substitute upper 16 bits of value after adding 1,2,3,4, (any single digit)
// Added by DPS on 22 Jan 2008 to fix “ble” and “bgt” bug [do not adjust for bit 15==1]
if ((index=instruction.indexOf(“VHL”+op+”P”))>=0) {
String value = theTokenList.get(op).getValue();
int val = 0;
int add = instruction.charAt(index+5)-‘0’; // amount to add: 1,2,3,4 (any single digit)
try { // KENV 1/6/05
val = Binary.stringToInt(value) + add;
}
catch (NumberFormatException e) {
// this won’t happen…
}
instruction = substitute(instruction,”VHL”+op+”P”+add,String.valueOf(val >> 16));
}
// substitute upper 16 bits of value after adding 1,2,3,4, then adjust
// if necessary, if resulting bit 15 is 1 (see “extra” below)
if ((index=instruction.indexOf(“VH”+op+”P”))>=0) {
String value = theTokenList.get(op).getValue();
int val = 0;
int add = instruction.charAt(index+4)-‘0’; // amount to add: 1,2,3,4 (any single digit)
try { // KENV 1/6/05
val = Binary.stringToInt(value) + add;
}
catch (NumberFormatException e) {
// this won’t happen…
}
// If bit 15 is 1, that means lower 16 bits will become a negative offset! To
// compensate if that is the case, we need to add 1 to the high 16 bits.
int extra = Binary.bitValue(val,15);
instruction = substitute(instruction,”VH”+op+”P”+add,String.valueOf((val >> 16)+extra));
}
// substitute upper 16 bits of value, adjusted if necessary (see “extra” below)
// NOTE: if VHnPm appears it will not match here; already substituted by code above
if (instruction.indexOf(“VH”+op)>=0) {
String value = theTokenList.get(op).getValue();
int val = 0;
try {
val = Binary.stringToInt(value); // KENV 1/6/05
}
catch (NumberFormatException e) {
// this won’t happen…
}
// If bit 15 is 1, that means lower 16 bits will become a negative offset! To
// compensate if that is the case, we need to add 1 to the high 16 bits.
int extra = Binary.bitValue(val,15);
instruction = substitute(instruction,”VH”+op,String.valueOf((val >> 16)+extra));
}
// substitute lower 16 bits of value after adding specified amount (1,2,3,4)
if ((index=instruction.indexOf(“VL”+op+”P”))>=0) {
String value = theTokenList.get(op).getValue();
int val = 0;
int add = instruction.charAt(index+4)-‘0’; // P is followed by 1,2,3,4(any single digit OK)
try { // KENV 1/6/05
val = Binary.stringToInt(value) + add;
}
catch (NumberFormatException e) {
// this won’t happen…
}
if ((instruction.length() > index+5) && (instruction.charAt(index+5) == ‘U’)) {
instruction = substitute(instruction,”VL”+op+”P”+add+”U”,String.valueOf(val & 0xffff));
}
else {
instruction = substitute(instruction,”VL”+op+”P”+add,String.valueOf(val << 16 >> 16));//val & 0xffff));
}
}
// substitute lower 16 bits of value. NOTE: VLnPm already substituted by above code.
if ((index=instruction.indexOf(“VL”+op))>=0) {
String value = theTokenList.get(op).getValue();
int val = 0;
try {
val = Binary.stringToInt(value); // KENV 1/6/05
}
catch (NumberFormatException e) {
// this won’t happen…
}
if ((instruction.length() > index+3) && (instruction.charAt(index+3) == ‘U’)) {
instruction = substitute(instruction,”VL”+op+”U”,String.valueOf(val & 0xffff));
}
else {
instruction = substitute(instruction,”VL”+op,String.valueOf(val << 16 >> 16));//val & 0xffff));
}
}
// substitute upper 16 bits of 32 bit value
if (instruction.indexOf(“VHL”+op)>=0) {
// value has to be second operand token.
String value = theTokenList.get(op).getValue(); // has to be token 2 position
int val = 0;
try {
val = Binary.stringToInt(value); // KENV 1/6/05
}
catch (NumberFormatException e) {
// this won’t happen…
}
instruction = substitute(instruction,”VHL”+op,String.valueOf(val >> 16));
}
}
// substitute upper 16 bits of label address for “la”
if (instruction.indexOf(“LHL”)>=0) {
// Label has already been translated to address by symtab lookup
String label = theTokenList.get(2).getValue(); // has to be token 2 position
int addr = 0;
try {
addr = Binary.stringToInt(label); // KENV 1/6/05
}
catch (NumberFormatException e) {
// this won’t happen…
}
instruction = substitute(instruction,”LHL”,String.valueOf(addr >> 16));
}
// substitute upper 16 bits of label address after adding the digit that follows “P” and
// also adding the immediate e.g. here+44($s0)
// Address will be resolved using addition, so need to add 1 to upper half if bit 15 is 1.
if ((index=instruction.indexOf(“LHPAP”))>=0) {
// Label has already been translated to address by symtab lookup
String label = theTokenList.get(2).getValue(); // 2 is only possible token position
String addend= theTokenList.get(4).getValue(); // 4 is only possible token position
int addr = 0;
int add = instruction.charAt(index+5)-48; // extract digit following P
try {
addr = Binary.stringToInt(label) + // KENV 1/6/05
Binary.stringToInt(addend) + add;
}
catch (NumberFormatException e) {
// this won’t happen…
}
// If bit 15 is 1, that means lower 16 bits will become a negative offset! To
// compensate if that is the case, we need to add 1 to the high 16 bits.
int extra = Binary.bitValue(addr,15);
instruction = substitute(instruction,”LHPAP”+add,String.valueOf((addr >> 16) + extra));
}
// substitute upper 16 bits of label address after adding constant e.g. here+4($s0)
// Address will be resolved using addition, so need to add 1 to upper half if bit 15 is 1.
// NOTE: format LHPAPm is recognized and substituted by the code above.
if (instruction.indexOf(“LHPA”)>=0) {
// Label has already been translated to address by symtab lookup
String label = theTokenList.get(2).getValue(); // 2 is only possible token position
String addend= theTokenList.get(4).getValue(); // 4 is only possible token position
int addr = 0;
try {
addr = Binary.stringToInt(label) + // KENV 1/6/05
Binary.stringToInt(addend);
}
catch (NumberFormatException e) {
// this won’t happen…
}
// If bit 15 is 1, that means lower 16 bits will become a negative offset! To
// compensate if that is the case, we need to add 1 to the high 16 bits.
int extra = Binary.bitValue(addr,15);
instruction = substitute(instruction,”LHPA”,String.valueOf((addr >> 16) + extra));
}
// substitute upper 16 bits of label address after adding constant e.g. here+4($s0)
// Address will be resolved using “ori”, so DO NOT adjust upper 16 if bit 15 is 1.
// This only happens in the “la” (load address) instruction.
if (instruction.indexOf(“LHPN”)>=0) {
// Label has already been translated to address by symtab lookup
String label = theTokenList.get(2).getValue(); // 2 is only possible token position
String addend= theTokenList.get(4).getValue(); // 4 is only possible token position
int addr = 0;
try {
addr = Binary.stringToInt(label) + // KENV 1/6/05
Binary.stringToInt(addend);
}
catch (NumberFormatException e) {
// this won’t happen…
}
instruction = substitute(instruction,”LHPN”,String.valueOf(addr >> 16));
}
// substitute lower 16 bits of label address after adding immediate value e.g. here+44($s0)
// and also adding the digit following LLPP in the spec.
if ((index=instruction.indexOf(“LLPP”))>=0) {
// label has already been translated to address by symtab lookup.
String label = theTokenList.get(2).getValue(); // 2 is only possible token position
String addend= theTokenList.get(4).getValue(); // 4 is only possible token position
int addr = 0;
int add = instruction.charAt(index+4)-48; // extract digit following P
try {
addr = Binary.stringToInt(label) + // KENV 1/6/05
Binary.stringToInt(addend) + add;
}
catch (NumberFormatException e) {
// this won’t happen…
}
instruction = substitute(instruction,”LLPP”+add,String.valueOf(addr << 16 >> 16));//addr & 0xffff));
}
// substitute lower 16 bits of label address after adding immediate value e.g. here+44($s0)
// NOTE: format LLPPm is recognized and substituted by the code above
if ((index=instruction.indexOf(“LLP”))>=0) {
// label has already been translated to address by symtab lookup.
String label = theTokenList.get(2).getValue(); // 2 is only possible token position
String addend= theTokenList.get(4).getValue(); // 4 is only possible token position
int addr = 0;
try {
addr = Binary.stringToInt(label) + // KENV 1/6/05
Binary.stringToInt(addend);
}
catch (NumberFormatException e) {
// this won’t happen…
}
if ((instruction.length() > index+3) && (instruction.charAt(index+3) == ‘U’)) {
instruction = substitute(instruction,”LLPU”,String.valueOf(addr & 0xffff));
}
else {
instruction = substitute(instruction,”LLP”,String.valueOf(addr << 16 >> 16));//addr & 0xffff));
}
}
// 23-Jan-2008 DPS. Substitute correct constant branch offset depending on whether or not
// delayed branching is enabled. BROFF is followed by 2 digits. The first is branch offset
// to substitute if delayed branching is DISABLED, second is offset if ENABLED.
if ((index=instruction.indexOf(“BROFF”))>=0) {
try {
String disabled = instruction.substring(index+5, index+6);
String enabled = instruction.substring(index+6, index+7);
instruction = substitute(instruction,”BROFF”+disabled+enabled,
Globals.getSettings().getDelayedBranchingEnabled() ? enabled : disabled );
}
catch (IndexOutOfBoundsException iooe) {
instruction = substitute(instruction,”BROFF”, “BAD_PSEUDO_OP_SPEC”);
}
}
// substitute Next higher Register for registers in token list (for “mfc1.d”,”mtc1.d”)
if (instruction.indexOf(“NR”)>=0) {
for (int op=1; op
instruction = substitute(instruction, “NR”+op,”$”+(regNumber+1));
}
}
catch (NullPointerException e) { // not in RegisterFile, must be Coprocessor1 register
regNumber = Coprocessor1.getRegisterNumber(token);
if (regNumber>=0) {
instruction = substitute(instruction, “NR”+op,”$f”+(regNumber+1));
}
}
}
}
// substitute result of subtracting last token from 32 (rol and ror constant rotate amount)
if (instruction.indexOf(“S32″)>=0) {
String value = theTokenList.get(theTokenList.size()-1).getValue();
int val = 0;
try {
val = Binary.stringToInt(value); // KENV 1/6/05
}
catch (NumberFormatException e) {
// this won’t happen…
}
instruction = substitute(instruction,”S32”,Integer.toString(32-val));
}
// substitute label if necessary
if (instruction.indexOf(“LAB”)>=0) {
// label has to be last token. It has already been translated to address
// by symtab lookup, so I need to get the text label back so parseLine() won’t puke.
String label = theTokenList.get(theTokenList.size()-1).getValue();
Symbol sym = program.getLocalSymbolTable().getSymbolGivenAddressLocalOrGlobal(label);
if (sym!=null) {
// should never be null, since there would not be an address if label were not in symtab!
// DPS 9 Dec 2007: The “substitute()” method will substitute for ALL matches. Here
// we want to substitute only for the first match, for two reasons: (1) a statement
// can only contain one label reference, its last operand, and (2) If the user’s label
// contains the substring “LAB”, then substitute() will go into an infinite loop because
// it will keep matching the substituted string!
instruction = substituteFirst(instruction,”LAB”,sym.getName());
}
}
return instruction;
}
// Performs a String substitution. Java 1.5 adds an overloaded String.replace method to
// do this directly but I wanted to stay 1.4 compatible.
// Modified 12 July 2006 to “substitute all occurances”, not just the first.
private static String substitute(String original, String find, String replacement) {
if (original.indexOf(find)<0 || find.equals(replacement)) {
return original; // second condition prevents infinite loop below
}
int i;
String modified = original;
while ((i=modified.indexOf(find))>=0) {
modified = modified.substring(0, i) + replacement + modified.substring(i + find.length());
}
return modified;
}
// Performs a String substitution, but will only substitute for the first match.
// Java 1.5 adds an overloaded String.replace method to do this directly but I
// wanted to stay 1.4 compatible.
private static String substituteFirst(String original, String find, String replacement) {
if (original.indexOf(find)<0 || find.equals(replacement)) {
return original; // second condition prevents infinite loop below
}
int i;
String modified = original;
if ((i=modified.indexOf(find))>=0) {
modified = modified.substring(0, i) + replacement + modified.substring(i + find.length());
}
return modified;
}
// Takes list of basic instructions that this extended instruction
// expands to, which is a string, and breaks out into separate
// instructions. They are separated by ‘\n’ character.
private ArrayList buildTranslationList(String translation) {
if (translation == null || translation.length() == 0) {
return null;
}
ArrayList translationList = new ArrayList();
StringTokenizer st = new StringTokenizer(translation,”\n”);
while (st.hasMoreTokens()) {
translationList.add(st.nextToken());
}
return translationList;
}
/*
* Get length in bytes that this extended instruction requires in its
* binary form. The answer depends on how many basic instructions it
* expands to. This may vary, if expansion includes a nop, depending on
* whether or not delayed branches are enabled. Each requires 4 bytes.
* Returns length in bytes of corresponding binary instruction(s).
* Returns 0 if the ArrayList is null or empty.
*/
private int getInstructionLength(ArrayList translationList) {
if (translationList == null || translationList.size() == 0) {
return 0;
}
// If instruction template is DBNOP, that means generate a “nop” instruction but only
// if Delayed branching is enabled. Otherwise generate nothing. If generating nothing,
// then don’t count the nop in the instruction length. DPS 23-Jan-2008
int instructionCount = 0;
for (int i=0; i
continue;
instructionCount++;
}
return 4 * instructionCount;
}
}
Instruction
package mars.mips.instructions;
public abstract synchronized class Instruction {
public static final int INSTRUCTION_LENGTH = 4;
public static final int INSTRUCTION_LENGTH_BITS = 32;
public static char[] operandMask;
protected String mnemonic;
protected String exampleFormat;
protected String description;
protected mars.assembler.TokenList tokenList;
public void Instruction();
public String getName();
public String getExampleFormat();
public String getDescription();
public mars.assembler.TokenList getTokenList();
public int getInstructionLength();
protected String extractOperator(String);
protected void createExampleTokenList();
static void
}
mars/mips/instructions/Instruction.java
mars/mips/instructions/Instruction.javapackage mars.mips.instructions;
import mars.assembler.*;
import mars.*;
import java.util.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Base class to represent member of MIPS instruction set.
*
* @author Pete Sanderson and Ken Vollmar
* @version August 2003
*/
public abstract class Instruction {
/**
* Length in bytes of a machine instruction. MIPS is a RISC architecture
* so all instructions are the same length. Currently set to 4.
*/
public static final int INSTRUCTION_LENGTH = 4;
public static final int INSTRUCTION_LENGTH_BITS = 32;
/** Characters used in instruction mask to indicate bit positions
* for ‘f’irst, ‘s’econd, and ‘t’hird operands.
**/
public static char[] operandMask = { ‘f’, ‘s’, ‘t’};
/** The instruction name. **/
protected String mnemonic;
/** Example usage of this instruction. Is provided as subclass constructor argument. **/
protected String exampleFormat;
/** Description of instruction for display to user **/
protected String description;
/** List of tokens generated by tokenizing example usage (see exampleFormat). **/
protected TokenList tokenList;
/**
* Get operation mnemonic
*
* @return operation mnemonic (e.g. addi, sw)
*/
public String getName() {
return mnemonic;
}
/**
* Get string descriptor of instruction’s format. This is an example MIPS
* assembler instruction usage which contains the operator and all operands.
* Operands are separated by commas, an operand that begins with a ‘$’
* represents a register, and an integer operand represents an immediate value
* or address. Here are two examples: “nor $1,$2,$3” and “sw $1,100($2)”
*
* @return String representing example instruction format.
*/
public String getExampleFormat() {
return exampleFormat;
}
/**
* Get string describing the instruction. This is not used internally by
* MARS, but is for display to the user.
*
* @return String describing the instruction.
*/
public String getDescription() {
return description;
}
/**
* Get TokenList corresponding to correct instruction syntax.
* For example, the instruction with format “sw $1,100($2)” yields token list
*
*
* @return TokenList object representing correct instruction usage.
*/
public TokenList getTokenList() {
return tokenList;
}
/**
* Get length in bytes that this instruction requires in its binary form.
* Default is 4 (holds for all basic instructions), but can be overridden
* in subclass.
* @return int length in bytes of corresponding binary instruction(s).
*/
public int getInstructionLength() {
return INSTRUCTION_LENGTH;
}
/** Used by subclass constructors to extract operator mnemonic from the
instruction example. **/
protected String extractOperator(String example) {
StringTokenizer st = new StringTokenizer(example, ” ,\t”);
return st.nextToken();
}
/** Used to build a token list from the example instruction
provided as constructor argument. Parser uses this for syntax checking. **/
protected void createExampleTokenList() {
try {
tokenList = ((new Tokenizer()).tokenizeExampleInstruction(exampleFormat));
} catch (ProcessingException pe) {
System.out.println(“CONFIGURATION ERROR: Instruction example \””+exampleFormat+”\” contains invalid token(s).”);
}
}
}
InstructionSet$1
package mars.mips.instructions;
synchronized class InstructionSet$1 implements SimulationCode {
void InstructionSet$1(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$10
package mars.mips.instructions;
synchronized class InstructionSet$10 implements SimulationCode {
void InstructionSet$10(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$100
package mars.mips.instructions;
synchronized class InstructionSet$100 implements SimulationCode {
void InstructionSet$100(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$101
package mars.mips.instructions;
synchronized class InstructionSet$101 implements SimulationCode {
void InstructionSet$101(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$102
package mars.mips.instructions;
synchronized class InstructionSet$102 implements SimulationCode {
void InstructionSet$102(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$103
package mars.mips.instructions;
synchronized class InstructionSet$103 implements SimulationCode {
void InstructionSet$103(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$104
package mars.mips.instructions;
synchronized class InstructionSet$104 implements SimulationCode {
void InstructionSet$104(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$105
package mars.mips.instructions;
synchronized class InstructionSet$105 implements SimulationCode {
void InstructionSet$105(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$106
package mars.mips.instructions;
synchronized class InstructionSet$106 implements SimulationCode {
void InstructionSet$106(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$107
package mars.mips.instructions;
synchronized class InstructionSet$107 implements SimulationCode {
void InstructionSet$107(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$108
package mars.mips.instructions;
synchronized class InstructionSet$108 implements SimulationCode {
void InstructionSet$108(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$109
package mars.mips.instructions;
synchronized class InstructionSet$109 implements SimulationCode {
void InstructionSet$109(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$11
package mars.mips.instructions;
synchronized class InstructionSet$11 implements SimulationCode {
void InstructionSet$11(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$110
package mars.mips.instructions;
synchronized class InstructionSet$110 implements SimulationCode {
void InstructionSet$110(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$111
package mars.mips.instructions;
synchronized class InstructionSet$111 implements SimulationCode {
void InstructionSet$111(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$112
package mars.mips.instructions;
synchronized class InstructionSet$112 implements SimulationCode {
void InstructionSet$112(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$113
package mars.mips.instructions;
synchronized class InstructionSet$113 implements SimulationCode {
void InstructionSet$113(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$114
package mars.mips.instructions;
synchronized class InstructionSet$114 implements SimulationCode {
void InstructionSet$114(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$115
package mars.mips.instructions;
synchronized class InstructionSet$115 implements SimulationCode {
void InstructionSet$115(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$116
package mars.mips.instructions;
synchronized class InstructionSet$116 implements SimulationCode {
void InstructionSet$116(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$117
package mars.mips.instructions;
synchronized class InstructionSet$117 implements SimulationCode {
void InstructionSet$117(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$118
package mars.mips.instructions;
synchronized class InstructionSet$118 implements SimulationCode {
void InstructionSet$118(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$119
package mars.mips.instructions;
synchronized class InstructionSet$119 implements SimulationCode {
void InstructionSet$119(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$12
package mars.mips.instructions;
synchronized class InstructionSet$12 implements SimulationCode {
void InstructionSet$12(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$120
package mars.mips.instructions;
synchronized class InstructionSet$120 implements SimulationCode {
void InstructionSet$120(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$121
package mars.mips.instructions;
synchronized class InstructionSet$121 implements SimulationCode {
void InstructionSet$121(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$122
package mars.mips.instructions;
synchronized class InstructionSet$122 implements SimulationCode {
void InstructionSet$122(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$123
package mars.mips.instructions;
synchronized class InstructionSet$123 implements SimulationCode {
void InstructionSet$123(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$124
package mars.mips.instructions;
synchronized class InstructionSet$124 implements SimulationCode {
void InstructionSet$124(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$125
package mars.mips.instructions;
synchronized class InstructionSet$125 implements SimulationCode {
void InstructionSet$125(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$126
package mars.mips.instructions;
synchronized class InstructionSet$126 implements SimulationCode {
void InstructionSet$126(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$127
package mars.mips.instructions;
synchronized class InstructionSet$127 implements SimulationCode {
void InstructionSet$127(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$128
package mars.mips.instructions;
synchronized class InstructionSet$128 implements SimulationCode {
void InstructionSet$128(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$129
package mars.mips.instructions;
synchronized class InstructionSet$129 implements SimulationCode {
void InstructionSet$129(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$13
package mars.mips.instructions;
synchronized class InstructionSet$13 implements SimulationCode {
void InstructionSet$13(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$130
package mars.mips.instructions;
synchronized class InstructionSet$130 implements SimulationCode {
void InstructionSet$130(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$131
package mars.mips.instructions;
synchronized class InstructionSet$131 implements SimulationCode {
void InstructionSet$131(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$132
package mars.mips.instructions;
synchronized class InstructionSet$132 implements SimulationCode {
void InstructionSet$132(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$133
package mars.mips.instructions;
synchronized class InstructionSet$133 implements SimulationCode {
void InstructionSet$133(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$134
package mars.mips.instructions;
synchronized class InstructionSet$134 implements SimulationCode {
void InstructionSet$134(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$135
package mars.mips.instructions;
synchronized class InstructionSet$135 implements SimulationCode {
void InstructionSet$135(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$136
package mars.mips.instructions;
synchronized class InstructionSet$136 implements SimulationCode {
void InstructionSet$136(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$137
package mars.mips.instructions;
synchronized class InstructionSet$137 implements SimulationCode {
void InstructionSet$137(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$138
package mars.mips.instructions;
synchronized class InstructionSet$138 implements SimulationCode {
void InstructionSet$138(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$139
package mars.mips.instructions;
synchronized class InstructionSet$139 implements SimulationCode {
void InstructionSet$139(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$14
package mars.mips.instructions;
synchronized class InstructionSet$14 implements SimulationCode {
void InstructionSet$14(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$140
package mars.mips.instructions;
synchronized class InstructionSet$140 implements SimulationCode {
void InstructionSet$140(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$141
package mars.mips.instructions;
synchronized class InstructionSet$141 implements SimulationCode {
void InstructionSet$141(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$142
package mars.mips.instructions;
synchronized class InstructionSet$142 implements SimulationCode {
void InstructionSet$142(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$143
package mars.mips.instructions;
synchronized class InstructionSet$143 implements SimulationCode {
void InstructionSet$143(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$144
package mars.mips.instructions;
synchronized class InstructionSet$144 implements SimulationCode {
void InstructionSet$144(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$145
package mars.mips.instructions;
synchronized class InstructionSet$145 implements SimulationCode {
void InstructionSet$145(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$146
package mars.mips.instructions;
synchronized class InstructionSet$146 implements SimulationCode {
void InstructionSet$146(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$147
package mars.mips.instructions;
synchronized class InstructionSet$147 implements SimulationCode {
void InstructionSet$147(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$148
package mars.mips.instructions;
synchronized class InstructionSet$148 implements SimulationCode {
void InstructionSet$148(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$149
package mars.mips.instructions;
synchronized class InstructionSet$149 implements SimulationCode {
void InstructionSet$149(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$15
package mars.mips.instructions;
synchronized class InstructionSet$15 implements SimulationCode {
void InstructionSet$15(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$150
package mars.mips.instructions;
synchronized class InstructionSet$150 implements SimulationCode {
void InstructionSet$150(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$151
package mars.mips.instructions;
synchronized class InstructionSet$151 implements SimulationCode {
void InstructionSet$151(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$152
package mars.mips.instructions;
synchronized class InstructionSet$152 implements SimulationCode {
void InstructionSet$152(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$153
package mars.mips.instructions;
synchronized class InstructionSet$153 implements SimulationCode {
void InstructionSet$153(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$154
package mars.mips.instructions;
synchronized class InstructionSet$154 implements SimulationCode {
void InstructionSet$154(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$155
package mars.mips.instructions;
synchronized class InstructionSet$155 implements SimulationCode {
void InstructionSet$155(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$16
package mars.mips.instructions;
synchronized class InstructionSet$16 implements SimulationCode {
void InstructionSet$16(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$17
package mars.mips.instructions;
synchronized class InstructionSet$17 implements SimulationCode {
void InstructionSet$17(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$18
package mars.mips.instructions;
synchronized class InstructionSet$18 implements SimulationCode {
void InstructionSet$18(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$19
package mars.mips.instructions;
synchronized class InstructionSet$19 implements SimulationCode {
void InstructionSet$19(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$2
package mars.mips.instructions;
synchronized class InstructionSet$2 implements SimulationCode {
void InstructionSet$2(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$20
package mars.mips.instructions;
synchronized class InstructionSet$20 implements SimulationCode {
void InstructionSet$20(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$21
package mars.mips.instructions;
synchronized class InstructionSet$21 implements SimulationCode {
void InstructionSet$21(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$22
package mars.mips.instructions;
synchronized class InstructionSet$22 implements SimulationCode {
void InstructionSet$22(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$23
package mars.mips.instructions;
synchronized class InstructionSet$23 implements SimulationCode {
void InstructionSet$23(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$24
package mars.mips.instructions;
synchronized class InstructionSet$24 implements SimulationCode {
void InstructionSet$24(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$25
package mars.mips.instructions;
synchronized class InstructionSet$25 implements SimulationCode {
void InstructionSet$25(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$26
package mars.mips.instructions;
synchronized class InstructionSet$26 implements SimulationCode {
void InstructionSet$26(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$27
package mars.mips.instructions;
synchronized class InstructionSet$27 implements SimulationCode {
void InstructionSet$27(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$28
package mars.mips.instructions;
synchronized class InstructionSet$28 implements SimulationCode {
void InstructionSet$28(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$29
package mars.mips.instructions;
synchronized class InstructionSet$29 implements SimulationCode {
void InstructionSet$29(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$3
package mars.mips.instructions;
synchronized class InstructionSet$3 implements SimulationCode {
void InstructionSet$3(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$30
package mars.mips.instructions;
synchronized class InstructionSet$30 implements SimulationCode {
void InstructionSet$30(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$31
package mars.mips.instructions;
synchronized class InstructionSet$31 implements SimulationCode {
void InstructionSet$31(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$32
package mars.mips.instructions;
synchronized class InstructionSet$32 implements SimulationCode {
void InstructionSet$32(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$33
package mars.mips.instructions;
synchronized class InstructionSet$33 implements SimulationCode {
void InstructionSet$33(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$34
package mars.mips.instructions;
synchronized class InstructionSet$34 implements SimulationCode {
void InstructionSet$34(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$35
package mars.mips.instructions;
synchronized class InstructionSet$35 implements SimulationCode {
void InstructionSet$35(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$36
package mars.mips.instructions;
synchronized class InstructionSet$36 implements SimulationCode {
void InstructionSet$36(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$37
package mars.mips.instructions;
synchronized class InstructionSet$37 implements SimulationCode {
void InstructionSet$37(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$38
package mars.mips.instructions;
synchronized class InstructionSet$38 implements SimulationCode {
void InstructionSet$38(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$39
package mars.mips.instructions;
synchronized class InstructionSet$39 implements SimulationCode {
void InstructionSet$39(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$4
package mars.mips.instructions;
synchronized class InstructionSet$4 implements SimulationCode {
void InstructionSet$4(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$40
package mars.mips.instructions;
synchronized class InstructionSet$40 implements SimulationCode {
void InstructionSet$40(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$41
package mars.mips.instructions;
synchronized class InstructionSet$41 implements SimulationCode {
void InstructionSet$41(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$42
package mars.mips.instructions;
synchronized class InstructionSet$42 implements SimulationCode {
void InstructionSet$42(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$43
package mars.mips.instructions;
synchronized class InstructionSet$43 implements SimulationCode {
void InstructionSet$43(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$44
package mars.mips.instructions;
synchronized class InstructionSet$44 implements SimulationCode {
void InstructionSet$44(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$45
package mars.mips.instructions;
synchronized class InstructionSet$45 implements SimulationCode {
void InstructionSet$45(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$46
package mars.mips.instructions;
synchronized class InstructionSet$46 implements SimulationCode {
void InstructionSet$46(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$47
package mars.mips.instructions;
synchronized class InstructionSet$47 implements SimulationCode {
void InstructionSet$47(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$48
package mars.mips.instructions;
synchronized class InstructionSet$48 implements SimulationCode {
void InstructionSet$48(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$49
package mars.mips.instructions;
synchronized class InstructionSet$49 implements SimulationCode {
void InstructionSet$49(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$5
package mars.mips.instructions;
synchronized class InstructionSet$5 implements SimulationCode {
void InstructionSet$5(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$50
package mars.mips.instructions;
synchronized class InstructionSet$50 implements SimulationCode {
void InstructionSet$50(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$51
package mars.mips.instructions;
synchronized class InstructionSet$51 implements SimulationCode {
void InstructionSet$51(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$52
package mars.mips.instructions;
synchronized class InstructionSet$52 implements SimulationCode {
void InstructionSet$52(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$53
package mars.mips.instructions;
synchronized class InstructionSet$53 implements SimulationCode {
void InstructionSet$53(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$54
package mars.mips.instructions;
synchronized class InstructionSet$54 implements SimulationCode {
void InstructionSet$54(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$55
package mars.mips.instructions;
synchronized class InstructionSet$55 implements SimulationCode {
void InstructionSet$55(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$56
package mars.mips.instructions;
synchronized class InstructionSet$56 implements SimulationCode {
void InstructionSet$56(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$57
package mars.mips.instructions;
synchronized class InstructionSet$57 implements SimulationCode {
void InstructionSet$57(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$58
package mars.mips.instructions;
synchronized class InstructionSet$58 implements SimulationCode {
void InstructionSet$58(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$59
package mars.mips.instructions;
synchronized class InstructionSet$59 implements SimulationCode {
void InstructionSet$59(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$6
package mars.mips.instructions;
synchronized class InstructionSet$6 implements SimulationCode {
void InstructionSet$6(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$60
package mars.mips.instructions;
synchronized class InstructionSet$60 implements SimulationCode {
void InstructionSet$60(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$61
package mars.mips.instructions;
synchronized class InstructionSet$61 implements SimulationCode {
void InstructionSet$61(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$62
package mars.mips.instructions;
synchronized class InstructionSet$62 implements SimulationCode {
void InstructionSet$62(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$63
package mars.mips.instructions;
synchronized class InstructionSet$63 implements SimulationCode {
void InstructionSet$63(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$64
package mars.mips.instructions;
synchronized class InstructionSet$64 implements SimulationCode {
void InstructionSet$64(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$65
package mars.mips.instructions;
synchronized class InstructionSet$65 implements SimulationCode {
void InstructionSet$65(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$66
package mars.mips.instructions;
synchronized class InstructionSet$66 implements SimulationCode {
void InstructionSet$66(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$67
package mars.mips.instructions;
synchronized class InstructionSet$67 implements SimulationCode {
void InstructionSet$67(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$68
package mars.mips.instructions;
synchronized class InstructionSet$68 implements SimulationCode {
void InstructionSet$68(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$69
package mars.mips.instructions;
synchronized class InstructionSet$69 implements SimulationCode {
void InstructionSet$69(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$7
package mars.mips.instructions;
synchronized class InstructionSet$7 implements SimulationCode {
void InstructionSet$7(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$70
package mars.mips.instructions;
synchronized class InstructionSet$70 implements SimulationCode {
void InstructionSet$70(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$71
package mars.mips.instructions;
synchronized class InstructionSet$71 implements SimulationCode {
void InstructionSet$71(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$72
package mars.mips.instructions;
synchronized class InstructionSet$72 implements SimulationCode {
void InstructionSet$72(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$73
package mars.mips.instructions;
synchronized class InstructionSet$73 implements SimulationCode {
void InstructionSet$73(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$74
package mars.mips.instructions;
synchronized class InstructionSet$74 implements SimulationCode {
void InstructionSet$74(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$75
package mars.mips.instructions;
synchronized class InstructionSet$75 implements SimulationCode {
void InstructionSet$75(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$76
package mars.mips.instructions;
synchronized class InstructionSet$76 implements SimulationCode {
void InstructionSet$76(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$77
package mars.mips.instructions;
synchronized class InstructionSet$77 implements SimulationCode {
void InstructionSet$77(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$78
package mars.mips.instructions;
synchronized class InstructionSet$78 implements SimulationCode {
void InstructionSet$78(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$79
package mars.mips.instructions;
synchronized class InstructionSet$79 implements SimulationCode {
void InstructionSet$79(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$8
package mars.mips.instructions;
synchronized class InstructionSet$8 implements SimulationCode {
void InstructionSet$8(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$80
package mars.mips.instructions;
synchronized class InstructionSet$80 implements SimulationCode {
void InstructionSet$80(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$81
package mars.mips.instructions;
synchronized class InstructionSet$81 implements SimulationCode {
void InstructionSet$81(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$82
package mars.mips.instructions;
synchronized class InstructionSet$82 implements SimulationCode {
void InstructionSet$82(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$83
package mars.mips.instructions;
synchronized class InstructionSet$83 implements SimulationCode {
void InstructionSet$83(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$84
package mars.mips.instructions;
synchronized class InstructionSet$84 implements SimulationCode {
void InstructionSet$84(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$85
package mars.mips.instructions;
synchronized class InstructionSet$85 implements SimulationCode {
void InstructionSet$85(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$86
package mars.mips.instructions;
synchronized class InstructionSet$86 implements SimulationCode {
void InstructionSet$86(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$87
package mars.mips.instructions;
synchronized class InstructionSet$87 implements SimulationCode {
void InstructionSet$87(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$88
package mars.mips.instructions;
synchronized class InstructionSet$88 implements SimulationCode {
void InstructionSet$88(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$89
package mars.mips.instructions;
synchronized class InstructionSet$89 implements SimulationCode {
void InstructionSet$89(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$9
package mars.mips.instructions;
synchronized class InstructionSet$9 implements SimulationCode {
void InstructionSet$9(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$90
package mars.mips.instructions;
synchronized class InstructionSet$90 implements SimulationCode {
void InstructionSet$90(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$91
package mars.mips.instructions;
synchronized class InstructionSet$91 implements SimulationCode {
void InstructionSet$91(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$92
package mars.mips.instructions;
synchronized class InstructionSet$92 implements SimulationCode {
void InstructionSet$92(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$93
package mars.mips.instructions;
synchronized class InstructionSet$93 implements SimulationCode {
void InstructionSet$93(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$94
package mars.mips.instructions;
synchronized class InstructionSet$94 implements SimulationCode {
void InstructionSet$94(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$95
package mars.mips.instructions;
synchronized class InstructionSet$95 implements SimulationCode {
void InstructionSet$95(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$96
package mars.mips.instructions;
synchronized class InstructionSet$96 implements SimulationCode {
void InstructionSet$96(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$97
package mars.mips.instructions;
synchronized class InstructionSet$97 implements SimulationCode {
void InstructionSet$97(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$98
package mars.mips.instructions;
synchronized class InstructionSet$98 implements SimulationCode {
void InstructionSet$98(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$99
package mars.mips.instructions;
synchronized class InstructionSet$99 implements SimulationCode {
void InstructionSet$99(InstructionSet);
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
InstructionSet$MatchMap
package mars.mips.instructions;
synchronized class InstructionSet$MatchMap implements Comparable {
private int mask;
private int maskLength;
private java.util.HashMap matchMap;
public void InstructionSet$MatchMap(int, java.util.HashMap);
public boolean equals(Object);
public int compareTo(Object);
public BasicInstruction find(int);
}
InstructionSet
package mars.mips.instructions;
public synchronized class InstructionSet {
private java.util.ArrayList instructionList;
private java.util.ArrayList opcodeMatchMaps;
private SyscallLoader syscallLoader;
public void InstructionSet();
public java.util.ArrayList getInstructionList();
public void populate();
public BasicInstruction findByBinaryCode(int);
private void addPseudoInstructions();
public java.util.ArrayList matchOperator(String);
public java.util.ArrayList prefixMatchOperator(String);
private void findAndSimulateSyscall(int, mars.ProgramStatement) throws mars.ProcessingException;
private void processBranch(int);
private void processJump(int);
private void processReturnAddress(int);
}
mars/mips/instructions/InstructionSet.java
mars/mips/instructions/InstructionSet.java package mars.mips.instructions;
import mars.simulator.*;
import mars.mips.hardware.*;
import mars.mips.instructions.syscalls.*;
import mars.*;
import mars.util.*;
import java.util.*;
import java.io.*;
/*
Copyright (c) 2003-2013, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* The list of Instruction objects, each of which represents a MIPS instruction.
* The instruction may either be basic (translates into binary machine code) or
* extended (translates into sequence of one or more basic instructions).
*
* @author Pete Sanderson and Ken Vollmar
* @version August 2003-5
*/
public class InstructionSet
{
private ArrayList instructionList;
private ArrayList opcodeMatchMaps;
private SyscallLoader syscallLoader;
/**
* Creates a new InstructionSet object.
*/
public InstructionSet()
{
instructionList = new ArrayList();
}
/**
* Retrieve the current instruction set.
*/
public ArrayList getInstructionList()
{
return instructionList;
}
/**
* Adds all instructions to the set. A given extended instruction may have
* more than one Instruction object, depending on how many formats it can have.
* @see Instruction
* @see BasicInstruction
* @see ExtendedInstruction
*/
public void populate()
{
/* Here is where the parade begins. Every instruction is added to the set here.*/
// //////////////////////////////////// BASIC INSTRUCTIONS START HERE ////////////////////////////////
instructionList.add(
new BasicInstruction(“nop”,
“Null operation : machine code is all zeroes”,
BasicInstructionFormat.R_FORMAT,
“000000 00000 00000 00000 00000 000000”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
// Hey I like this so far!
}
}));
instructionList.add(
new BasicInstruction(“add $t1,$t2,$t3”,
“Addition with overflow : set $t1 to ($t2 plus $t3)”,
BasicInstructionFormat.R_FORMAT,
“000000 sssss ttttt fffff 00000 100000”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
int add1 = RegisterFile.getValue(operands[1]);
int add2 = RegisterFile.getValue(operands[2]);
int sum = add1 + add2;
// overflow on A+B detected when A and B have same sign and A+B has other sign.
if ((add1 >= 0 && add2 >= 0 && sum < 0)
|| (add1 < 0 && add2 < 0 && sum >= 0))
{
throw new ProcessingException(statement,
“arithmetic overflow”,Exceptions.ARITHMETIC_OVERFLOW_EXCEPTION);
}
RegisterFile.updateRegister(operands[0], sum);
}
}));
instructionList.add(
new BasicInstruction(“sub $t1,$t2,$t3”,
“Subtraction with overflow : set $t1 to ($t2 minus $t3)”,
BasicInstructionFormat.R_FORMAT,
“000000 sssss ttttt fffff 00000 100010”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
int sub1 = RegisterFile.getValue(operands[1]);
int sub2 = RegisterFile.getValue(operands[2]);
int dif = sub1 – sub2;
// overflow on A-B detected when A and B have opposite signs and A-B has B’s sign
if ((sub1 >= 0 && sub2 < 0 && dif < 0)
|| (sub1 < 0 && sub2 >= 0 && dif >= 0))
{
throw new ProcessingException(statement,
“arithmetic overflow”,Exceptions.ARITHMETIC_OVERFLOW_EXCEPTION);
}
RegisterFile.updateRegister(operands[0], dif);
}
}));
instructionList.add(
new BasicInstruction(“addi $t1,$t2,-100”,
“Addition immediate with overflow : set $t1 to ($t2 plus signed 16-bit immediate)”,
BasicInstructionFormat.I_FORMAT,
“001000 sssss fffff tttttttttttttttt”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
int add1 = RegisterFile.getValue(operands[1]);
int add2 = operands[2] << 16 >> 16;
int sum = add1 + add2;
// overflow on A+B detected when A and B have same sign and A+B has other sign.
if ((add1 >= 0 && add2 >= 0 && sum < 0)
|| (add1 < 0 && add2 < 0 && sum >= 0))
{
throw new ProcessingException(statement,
“arithmetic overflow”,Exceptions.ARITHMETIC_OVERFLOW_EXCEPTION);
}
RegisterFile.updateRegister(operands[0], sum);
}
}));
instructionList.add(
new BasicInstruction(“addu $t1,$t2,$t3”,
“Addition unsigned without overflow : set $t1 to ($t2 plus $t3), no overflow”,
BasicInstructionFormat.R_FORMAT,
“000000 sssss ttttt fffff 00000 100001”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
RegisterFile.updateRegister(operands[0],
RegisterFile.getValue(operands[1])
+ RegisterFile.getValue(operands[2]));
}
}));
instructionList.add(
new BasicInstruction(“subu $t1,$t2,$t3”,
“Subtraction unsigned without overflow : set $t1 to ($t2 minus $t3), no overflow”,
BasicInstructionFormat.R_FORMAT,
“000000 sssss ttttt fffff 00000 100011”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
RegisterFile.updateRegister(operands[0],
RegisterFile.getValue(operands[1])
– RegisterFile.getValue(operands[2]));
}
}));
instructionList.add(
new BasicInstruction(“addiu $t1,$t2,-100”,
“Addition immediate unsigned without overflow : set $t1 to ($t2 plus signed 16-bit immediate), no overflow”,
BasicInstructionFormat.I_FORMAT,
“001001 sssss fffff tttttttttttttttt”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
RegisterFile.updateRegister(operands[0],
RegisterFile.getValue(operands[1])
+ (operands[2] << 16 >> 16));
}
}));
instructionList.add(
new BasicInstruction(“mult $t1,$t2”,
“Multiplication : Set hi to high-order 32 bits, lo to low-order 32 bits of the product of $t1 and $t2 (use mfhi to access hi, mflo to access lo)”,
BasicInstructionFormat.R_FORMAT,
“000000 fffff sssss 00000 00000 011000”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
long product = (long) RegisterFile.getValue(operands[0])
* (long) RegisterFile.getValue(operands[1]);
// Register 33 is HIGH and 34 is LOW
RegisterFile.updateRegister(33, (int) (product >> 32));
RegisterFile.updateRegister(34, (int) ((product << 32) >> 32));
}
}));
instructionList.add(
new BasicInstruction(“multu $t1,$t2”,
“Multiplication unsigned : Set HI to high-order 32 bits, LO to low-order 32 bits of the product of unsigned $t1 and $t2 (use mfhi to access HI, mflo to access LO)”,
BasicInstructionFormat.R_FORMAT,
“000000 fffff sssss 00000 00000 011001”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
long product = (((long) RegisterFile.getValue(operands[0]))<<32>>>32)
* (((long) RegisterFile.getValue(operands[1]))<<32>>>32);
// Register 33 is HIGH and 34 is LOW
RegisterFile.updateRegister(33, (int) (product >> 32));
RegisterFile.updateRegister(34, (int) ((product << 32) >> 32));
}
}));
instructionList.add(
new BasicInstruction(“mul $t1,$t2,$t3”,
“Multiplication without overflow : Set HI to high-order 32 bits, LO and $t1 to low-order 32 bits of the product of $t2 and $t3 (use mfhi to access HI, mflo to access LO)”,
BasicInstructionFormat.R_FORMAT,
“011100 sssss ttttt fffff 00000 000010”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
long product = (long) RegisterFile.getValue(operands[1])
* (long) RegisterFile.getValue(operands[2]);
RegisterFile.updateRegister(operands[0],
(int) ((product << 32) >> 32));
// Register 33 is HIGH and 34 is LOW. Not required by MIPS; SPIM does it.
RegisterFile.updateRegister(33, (int) (product >> 32));
RegisterFile.updateRegister(34, (int) ((product << 32) >> 32));
}
}));
instructionList.add(
new BasicInstruction(“madd $t1,$t2”,
“Multiply add : Multiply $t1 by $t2 then increment HI by high-order 32 bits of product, increment LO by low-order 32 bits of product (use mfhi to access HI, mflo to access LO)”,
BasicInstructionFormat.R_FORMAT,
“011100 fffff sssss 00000 00000 000000”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
long product = (long) RegisterFile.getValue(operands[0])
* (long) RegisterFile.getValue(operands[1]);
// Register 33 is HIGH and 34 is LOW.
long contentsHiLo = Binary.twoIntsToLong(
RegisterFile.getValue(33), RegisterFile.getValue(34));
long sum = contentsHiLo + product;
RegisterFile.updateRegister(33, Binary.highOrderLongToInt(sum));
RegisterFile.updateRegister(34, Binary.lowOrderLongToInt(sum));
}
}));
instructionList.add(
new BasicInstruction(“maddu $t1,$t2”,
“Multiply add unsigned : Multiply $t1 by $t2 then increment HI by high-order 32 bits of product, increment LO by low-order 32 bits of product, unsigned (use mfhi to access HI, mflo to access LO)”,
BasicInstructionFormat.R_FORMAT,
“011100 fffff sssss 00000 00000 000001”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
long product = (((long) RegisterFile.getValue(operands[0]))<<32>>>32)
* (((long) RegisterFile.getValue(operands[1]))<<32>>>32);
// Register 33 is HIGH and 34 is LOW.
long contentsHiLo = Binary.twoIntsToLong(
RegisterFile.getValue(33), RegisterFile.getValue(34));
long sum = contentsHiLo + product;
RegisterFile.updateRegister(33, Binary.highOrderLongToInt(sum));
RegisterFile.updateRegister(34, Binary.lowOrderLongToInt(sum));
}
}));
instructionList.add(
new BasicInstruction(“msub $t1,$t2”,
“Multiply subtract : Multiply $t1 by $t2 then decrement HI by high-order 32 bits of product, decrement LO by low-order 32 bits of product (use mfhi to access HI, mflo to access LO)”,
BasicInstructionFormat.R_FORMAT,
“011100 fffff sssss 00000 00000 000100”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
long product = (long) RegisterFile.getValue(operands[0])
* (long) RegisterFile.getValue(operands[1]);
// Register 33 is HIGH and 34 is LOW.
long contentsHiLo = Binary.twoIntsToLong(
RegisterFile.getValue(33), RegisterFile.getValue(34));
long diff = contentsHiLo – product;
RegisterFile.updateRegister(33, Binary.highOrderLongToInt(diff));
RegisterFile.updateRegister(34, Binary.lowOrderLongToInt(diff));
}
}));
instructionList.add(
new BasicInstruction(“msubu $t1,$t2”,
“Multiply subtract unsigned : Multiply $t1 by $t2 then decrement HI by high-order 32 bits of product, decement LO by low-order 32 bits of product, unsigned (use mfhi to access HI, mflo to access LO)”,
BasicInstructionFormat.R_FORMAT,
“011100 fffff sssss 00000 00000 000101”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
long product = (((long) RegisterFile.getValue(operands[0]))<<32>>>32)
* (((long) RegisterFile.getValue(operands[1]))<<32>>>32);
// Register 33 is HIGH and 34 is LOW.
long contentsHiLo = Binary.twoIntsToLong(
RegisterFile.getValue(33), RegisterFile.getValue(34));
long diff = contentsHiLo – product;
RegisterFile.updateRegister(33, Binary.highOrderLongToInt(diff));
RegisterFile.updateRegister(34, Binary.lowOrderLongToInt(diff));
}
}));
instructionList.add(
new BasicInstruction(“div $t1,$t2”,
“Division with overflow : Divide $t1 by $t2 then set LO to quotient and HI to remainder (use mfhi to access HI, mflo to access LO)”,
BasicInstructionFormat.R_FORMAT,
“000000 fffff sssss 00000 00000 011010”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[1]) == 0)
{
// Note: no exceptions and undefined results for zero div
// COD3 Appendix A says “with overflow” but MIPS 32 instruction set
// specification says “no arithmetic exception under any circumstances”.
return;
}
// Register 33 is HIGH and 34 is LOW
RegisterFile.updateRegister(33,
RegisterFile.getValue(operands[0])
% RegisterFile.getValue(operands[1]));
RegisterFile.updateRegister(34,
RegisterFile.getValue(operands[0])
/ RegisterFile.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction(“divu $t1,$t2”,
“Division unsigned without overflow : Divide unsigned $t1 by $t2 then set LO to quotient and HI to remainder (use mfhi to access HI, mflo to access LO)”,
BasicInstructionFormat.R_FORMAT,
“000000 fffff sssss 00000 00000 011011”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[1]) == 0)
{
// Note: no exceptions, and undefined results for zero divide
return;
}
long oper1 = ((long)RegisterFile.getValue(operands[0])) << 32 >>> 32;
long oper2 = ((long)RegisterFile.getValue(operands[1])) << 32 >>> 32;
// Register 33 is HIGH and 34 is LOW
RegisterFile.updateRegister(33,
(int) (((oper1 % oper2) << 32) >> 32));
RegisterFile.updateRegister(34,
(int) (((oper1 / oper2) << 32) >> 32));
}
}));
instructionList.add(
new BasicInstruction(“mfhi $t1”,
“Move from HI register : Set $t1 to contents of HI (see multiply and divide operations)”,
BasicInstructionFormat.R_FORMAT,
“000000 00000 00000 fffff 00000 010000”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
RegisterFile.updateRegister(operands[0],
RegisterFile.getValue(33));
}
}));
instructionList.add(
new BasicInstruction(“mflo $t1”,
“Move from LO register : Set $t1 to contents of LO (see multiply and divide operations)”,
BasicInstructionFormat.R_FORMAT,
“000000 00000 00000 fffff 00000 010010”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
RegisterFile.updateRegister(operands[0],
RegisterFile.getValue(34));
}
}));
instructionList.add(
new BasicInstruction(“mthi $t1”,
“Move to HI registerr : Set HI to contents of $t1 (see multiply and divide operations)”,
BasicInstructionFormat.R_FORMAT,
“000000 fffff 00000 00000 00000 010001”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
RegisterFile.updateRegister(33,
RegisterFile.getValue(operands[0]));
}
}));
instructionList.add(
new BasicInstruction(“mtlo $t1”,
“Move to LO register : Set LO to contents of $t1 (see multiply and divide operations)”,
BasicInstructionFormat.R_FORMAT,
“000000 fffff 00000 00000 00000 010011”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
RegisterFile.updateRegister(34,
RegisterFile.getValue(operands[0]));
}
}));
instructionList.add(
new BasicInstruction(“and $t1,$t2,$t3”,
“Bitwise AND : Set $t1 to bitwise AND of $t2 and $t3”,
BasicInstructionFormat.R_FORMAT,
“000000 sssss ttttt fffff 00000 100100”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
RegisterFile.updateRegister(operands[0],
RegisterFile.getValue(operands[1])
& RegisterFile.getValue(operands[2]));
}
}));
instructionList.add(
new BasicInstruction(“or $t1,$t2,$t3”,
“Bitwise OR : Set $t1 to bitwise OR of $t2 and $t3”,
BasicInstructionFormat.R_FORMAT,
“000000 sssss ttttt fffff 00000 100101”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
RegisterFile.updateRegister(operands[0],
RegisterFile.getValue(operands[1])
| RegisterFile.getValue(operands[2]));
}
}));
instructionList.add(
new BasicInstruction(“andi $t1,$t2,100”,
“Bitwise AND immediate : Set $t1 to bitwise AND of $t2 and zero-extended 16-bit immediate”,
BasicInstructionFormat.I_FORMAT,
“001100 sssss fffff tttttttttttttttt”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
// ANDing with 0x0000FFFF zero-extends the immediate (high 16 bits always 0).
RegisterFile.updateRegister(operands[0],
RegisterFile.getValue(operands[1])
& (operands[2] & 0x0000FFFF));
}
}));
instructionList.add(
new BasicInstruction(“ori $t1,$t2,100”,
“Bitwise OR immediate : Set $t1 to bitwise OR of $t2 and zero-extended 16-bit immediate”,
BasicInstructionFormat.I_FORMAT,
“001101 sssss fffff tttttttttttttttt”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
// ANDing with 0x0000FFFF zero-extends the immediate (high 16 bits always 0).
RegisterFile.updateRegister(operands[0],
RegisterFile.getValue(operands[1])
| (operands[2] & 0x0000FFFF));
}
}));
instructionList.add(
new BasicInstruction(“nor $t1,$t2,$t3”,
“Bitwise NOR : Set $t1 to bitwise NOR of $t2 and $t3”,
BasicInstructionFormat.R_FORMAT,
“000000 sssss ttttt fffff 00000 100111”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
RegisterFile.updateRegister(operands[0],
~(RegisterFile.getValue(operands[1])
| RegisterFile.getValue(operands[2])));
}
}));
instructionList.add(
new BasicInstruction(“xor $t1,$t2,$t3”,
“Bitwise XOR (exclusive OR) : Set $t1 to bitwise XOR of $t2 and $t3”,
BasicInstructionFormat.R_FORMAT,
“000000 sssss ttttt fffff 00000 100110”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
RegisterFile.updateRegister(operands[0],
RegisterFile.getValue(operands[1])
^ RegisterFile.getValue(operands[2]));
}
}));
instructionList.add(
new BasicInstruction(“xori $t1,$t2,100”,
“Bitwise XOR immediate : Set $t1 to bitwise XOR of $t2 and zero-extended 16-bit immediate”,
BasicInstructionFormat.I_FORMAT,
“001110 sssss fffff tttttttttttttttt”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
// ANDing with 0x0000FFFF zero-extends the immediate (high 16 bits always 0).
RegisterFile.updateRegister(operands[0],
RegisterFile.getValue(operands[1])
^ (operands[2] & 0x0000FFFF));
}
}));
instructionList.add(
new BasicInstruction(“sll $t1,$t2,10”,
“Shift left logical : Set $t1 to result of shifting $t2 left by number of bits specified by immediate”,
BasicInstructionFormat.R_FORMAT,
“000000 00000 sssss fffff ttttt 000000”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
RegisterFile.updateRegister(operands[0],
RegisterFile.getValue(operands[1]) << operands[2]);
}
}));
instructionList.add(
new BasicInstruction("sllv $t1,$t2,$t3",
"Shift left logical variable : Set $t1 to result of shifting $t2 left by number of bits specified by value in low-order 5 bits of $t3",
BasicInstructionFormat.R_FORMAT,
"000000 ttttt sssss fffff 00000 000100",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
// Mask all but low 5 bits of register containing shamt.
RegisterFile.updateRegister(operands[0],
RegisterFile.getValue(operands[1]) <<
(RegisterFile.getValue(operands[2]) & 0x0000001F));
}
}));
instructionList.add(
new BasicInstruction("srl $t1,$t2,10",
"Shift right logical : Set $t1 to result of shifting $t2 right by number of bits specified by immediate",
BasicInstructionFormat.R_FORMAT,
"000000 00000 sssss fffff ttttt 000010",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
// must zero-fill, so use ">>>” instead of “>>”.
RegisterFile.updateRegister(operands[0],
RegisterFile.getValue(operands[1]) >>> operands[2]);
}
}));
instructionList.add(
new BasicInstruction(“sra $t1,$t2,10”,
“Shift right arithmetic : Set $t1 to result of sign-extended shifting $t2 right by number of bits specified by immediate”,
BasicInstructionFormat.R_FORMAT,
“000000 00000 sssss fffff ttttt 000011”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
// must sign-fill, so use “>>”.
RegisterFile.updateRegister(operands[0],
RegisterFile.getValue(operands[1]) >> operands[2]);
}
}));
instructionList.add(
new BasicInstruction(“srav $t1,$t2,$t3”,
“Shift right arithmetic variable : Set $t1 to result of sign-extended shifting $t2 right by number of bits specified by value in low-order 5 bits of $t3”,
BasicInstructionFormat.R_FORMAT,
“000000 ttttt sssss fffff 00000 000111”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
// Mask all but low 5 bits of register containing shamt.Use “>>” to sign-fill.
RegisterFile.updateRegister(operands[0],
RegisterFile.getValue(operands[1]) >>
(RegisterFile.getValue(operands[2]) & 0x0000001F));
}
}));
instructionList.add(
new BasicInstruction(“srlv $t1,$t2,$t3”,
“Shift right logical variable : Set $t1 to result of shifting $t2 right by number of bits specified by value in low-order 5 bits of $t3”,
BasicInstructionFormat.R_FORMAT,
“000000 ttttt sssss fffff 00000 000110”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
// Mask all but low 5 bits of register containing shamt.Use “>>>” to zero-fill.
RegisterFile.updateRegister(operands[0],
RegisterFile.getValue(operands[1]) >>>
(RegisterFile.getValue(operands[2]) & 0x0000001F));
}
}));
instructionList.add(
new BasicInstruction(“lw $t1,-100($t2)”,
“Load word : Set $t1 to contents of effective memory word address”,
BasicInstructionFormat.I_FORMAT,
“100011 ttttt fffff ssssssssssssssss”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
try
{
RegisterFile.updateRegister(operands[0],
Globals.memory.getWord(
RegisterFile.getValue(operands[2]) + operands[1]));
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}));
instructionList.add(
new BasicInstruction(“ll $t1,-100($t2)”,
“Load linked : Paired with Store Conditional (sc) to perform atomic read-modify-write. Treated as equivalent to Load Word (lw) because MARS does not simulate multiple processors.”,
BasicInstructionFormat.I_FORMAT,
“110000 ttttt fffff ssssssssssssssss”,
// The ll (load link) command is supposed to be the front end of an atomic
// operation completed by sc (store conditional), with success or failure
// of the store depending on whether the memory block containing the
// loaded word is modified in the meantime by a different processor.
// Since MARS, like SPIM simulates only a single processor, the store
// conditional will always succeed so there is no need to do anything
// special here. In that case, ll is same as lw. And sc does the same
// thing as sw except in addition it writes 1 into the source register.
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
try
{
RegisterFile.updateRegister(operands[0],
Globals.memory.getWord(
RegisterFile.getValue(operands[2]) + operands[1]));
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}));
instructionList.add(
new BasicInstruction(“lwl $t1,-100($t2)”,
“Load word left : Load from 1 to 4 bytes left-justified into $t1, starting with effective memory byte address and continuing through the low-order byte of its word”,
BasicInstructionFormat.I_FORMAT,
“100010 ttttt fffff ssssssssssssssss”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
try
{
int address = RegisterFile.getValue(operands[2]) + operands[1];
int result = RegisterFile.getValue(operands[0]);
for (int i=0; i<=address % Globals.memory.WORD_LENGTH_BYTES; i++) {
result = Binary.setByte(result,3-i,Globals.memory.getByte(address-i));
}
RegisterFile.updateRegister(operands[0], result);
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}));
instructionList.add(
new BasicInstruction("lwr $t1,-100($t2)",
"Load word right : Load from 1 to 4 bytes right-justified into $t1, starting with effective memory byte address and continuing through the high-order byte of its word",
BasicInstructionFormat.I_FORMAT,
"100110 ttttt fffff ssssssssssssssss",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
try
{
int address = RegisterFile.getValue(operands[2]) + operands[1];
int result = RegisterFile.getValue(operands[0]);
for (int i=0; i<=3-(address % Globals.memory.WORD_LENGTH_BYTES); i++) {
result = Binary.setByte(result,i,Globals.memory.getByte(address+i));
}
RegisterFile.updateRegister(operands[0], result);
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}));
instructionList.add(
new BasicInstruction("sw $t1,-100($t2)",
"Store word : Store contents of $t1 into effective memory word address",
BasicInstructionFormat.I_FORMAT,
"101011 ttttt fffff ssssssssssssssss",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
try
{
Globals.memory.setWord(
RegisterFile.getValue(operands[2]) + operands[1],
RegisterFile.getValue(operands[0]));
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}));
instructionList.add(
new BasicInstruction("sc $t1,-100($t2)",
"Store conditional : Paired with Load Linked (ll) to perform atomic read-modify-write. Stores $t1 value into effective address, then sets $t1 to 1 for success. Always succeeds because MARS does not simulate multiple processors.",
BasicInstructionFormat.I_FORMAT,
"111000 ttttt fffff ssssssssssssssss",
// See comments with "ll" instruction above. "sc" is implemented
// like "sw", except that 1 is placed in the source register.
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
try
{
Globals.memory.setWord(
RegisterFile.getValue(operands[2]) + operands[1],
RegisterFile.getValue(operands[0]));
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
RegisterFile.updateRegister(operands[0],1); // always succeeds
}
}));
instructionList.add(
new BasicInstruction("swl $t1,-100($t2)",
"Store word left : Store high-order 1 to 4 bytes of $t1 into memory, starting with effective byte address and continuing through the low-order byte of its word",
BasicInstructionFormat.I_FORMAT,
"101010 ttttt fffff ssssssssssssssss",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
try
{
int address = RegisterFile.getValue(operands[2]) + operands[1];
int source = RegisterFile.getValue(operands[0]);
for (int i=0; i<=address % Globals.memory.WORD_LENGTH_BYTES; i++) {
Globals.memory.setByte(address-i,Binary.getByte(source,3-i));
}
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}));
instructionList.add(
new BasicInstruction("swr $t1,-100($t2)",
"Store word right : Store low-order 1 to 4 bytes of $t1 into memory, starting with high-order byte of word containing effective byte address and continuing through that byte address",
BasicInstructionFormat.I_FORMAT,
"101110 ttttt fffff ssssssssssssssss",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
try
{
int address = RegisterFile.getValue(operands[2]) + operands[1];
int source = RegisterFile.getValue(operands[0]);
for (int i=0; i<=3-(address % Globals.memory.WORD_LENGTH_BYTES); i++) {
Globals.memory.setByte(address+i,Binary.getByte(source,i));
}
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}));
instructionList.add(
new BasicInstruction("lui $t1,100",
"Load upper immediate : Set high-order 16 bits of $t1 to 16-bit immediate and low-order 16 bits to 0",
BasicInstructionFormat.I_FORMAT,
"001111 00000 fffff ssssssssssssssss",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
RegisterFile.updateRegister(operands[0], operands[1] << 16);
}
}));
instructionList.add(
new BasicInstruction("beq $t1,$t2,label",
"Branch if equal : Branch to statement at label's address if $t1 and $t2 are equal",
BasicInstructionFormat.I_BRANCH_FORMAT,
"000100 fffff sssss tttttttttttttttt",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[0])
== RegisterFile.getValue(operands[1]))
{
processBranch(operands[2]);
}
}
}));
instructionList.add(
new BasicInstruction("bne $t1,$t2,label",
"Branch if not equal : Branch to statement at label's address if $t1 and $t2 are not equal",
BasicInstructionFormat.I_BRANCH_FORMAT,
"000101 fffff sssss tttttttttttttttt",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[0])
!= RegisterFile.getValue(operands[1]))
{
processBranch(operands[2]);
}
}
}));
instructionList.add(
new BasicInstruction("bgez $t1,label",
"Branch if greater than or equal to zero : Branch to statement at label's address if $t1 is greater than or equal to zero",
BasicInstructionFormat.I_BRANCH_FORMAT,
"000001 fffff 00001 ssssssssssssssss",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[0]) >= 0)
{
processBranch(operands[1]);
}
}
}));
instructionList.add(
new BasicInstruction(“bgezal $t1,label”,
“Branch if greater then or equal to zero and link : If $t1 is greater than or equal to zero, then set $ra to the Program Counter and branch to statement at label’s address”,
BasicInstructionFormat.I_BRANCH_FORMAT,
“000001 fffff 10001 ssssssssssssssss”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[0]) >= 0)
{ // the “and link” part
processReturnAddress(31);//RegisterFile.updateRegister(“$ra”,RegisterFile.getProgramCounter());
processBranch(operands[1]);
}
}
}));
instructionList.add(
new BasicInstruction(“bgtz $t1,label”,
“Branch if greater than zero : Branch to statement at label’s address if $t1 is greater than zero”,
BasicInstructionFormat.I_BRANCH_FORMAT,
“000111 fffff 00000 ssssssssssssssss”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[0]) > 0)
{
processBranch(operands[1]);
}
}
}));
instructionList.add(
new BasicInstruction(“blez $t1,label”,
“Branch if less than or equal to zero : Branch to statement at label’s address if $t1 is less than or equal to zero”,
BasicInstructionFormat.I_BRANCH_FORMAT,
“000110 fffff 00000 ssssssssssssssss”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[0]) <= 0)
{
processBranch(operands[1]);
}
}
}));
instructionList.add(
new BasicInstruction("bltz $t1,label",
"Branch if less than zero : Branch to statement at label's address if $t1 is less than zero",
BasicInstructionFormat.I_BRANCH_FORMAT,
"000001 fffff 00000 ssssssssssssssss",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[0]) < 0)
{
processBranch(operands[1]);
}
}
}));
instructionList.add(
new BasicInstruction("bltzal $t1,label",
"Branch if less than zero and link : If $t1 is less than or equal to zero, then set $ra to the Program Counter and branch to statement at label's address",
BasicInstructionFormat.I_BRANCH_FORMAT,
"000001 fffff 10000 ssssssssssssssss",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[0]) < 0)
{ // the "and link" part
processReturnAddress(31);//RegisterFile.updateRegister("$ra",RegisterFile.getProgramCounter());
processBranch(operands[1]);
}
}
}));
instructionList.add(
new BasicInstruction("slt $t1,$t2,$t3",
"Set less than : If $t2 is less than $t3, then set $t1 to 1 else set $t1 to 0",
BasicInstructionFormat.R_FORMAT,
"000000 sssss ttttt fffff 00000 101010",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
RegisterFile.updateRegister(operands[0],
(RegisterFile.getValue(operands[1])
< RegisterFile.getValue(operands[2]))
? 1
: 0);
}
}));
instructionList.add(
new BasicInstruction("sltu $t1,$t2,$t3",
"Set less than unsigned : If $t2 is less than $t3 using unsigned comparision, then set $t1 to 1 else set $t1 to 0",
BasicInstructionFormat.R_FORMAT,
"000000 sssss ttttt fffff 00000 101011",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
int first = RegisterFile.getValue(operands[1]);
int second = RegisterFile.getValue(operands[2]);
if (first >= 0 && second >= 0 || first < 0 && second < 0)
{
RegisterFile.updateRegister(operands[0],
(first < second) ? 1 : 0);
}
else
{
RegisterFile.updateRegister(operands[0],
(first >= 0) ? 1 : 0);
}
}
}));
instructionList.add(
new BasicInstruction(“slti $t1,$t2,-100”,
“Set less than immediate : If $t2 is less than sign-extended 16-bit immediate, then set $t1 to 1 else set $t1 to 0”,
BasicInstructionFormat.I_FORMAT,
“001010 sssss fffff tttttttttttttttt”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
// 16 bit immediate value in operands[2] is sign-extended
RegisterFile.updateRegister(operands[0],
(RegisterFile.getValue(operands[1])
< (operands[2] << 16 >> 16))
? 1
: 0);
}
}));
instructionList.add(
new BasicInstruction(“sltiu $t1,$t2,-100”,
“Set less than immediate unsigned : If $t2 is less than sign-extended 16-bit immediate using unsigned comparison, then set $t1 to 1 else set $t1 to 0”,
BasicInstructionFormat.I_FORMAT,
“001011 sssss fffff tttttttttttttttt”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
int first = RegisterFile.getValue(operands[1]);
// 16 bit immediate value in operands[2] is sign-extended
int second = operands[2] << 16 >> 16;
if (first >= 0 && second >= 0 || first < 0 && second < 0)
{
RegisterFile.updateRegister(operands[0],
(first < second) ? 1 : 0);
}
else
{
RegisterFile.updateRegister(operands[0],
(first >= 0) ? 1 : 0);
}
}
}));
instructionList.add(
new BasicInstruction(“movn $t1,$t2,$t3”,
“Move conditional not zero : Set $t1 to $t2 if $t3 is not zero”,
BasicInstructionFormat.R_FORMAT,
“000000 sssss ttttt fffff 00000 001011”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[2])!=0)
RegisterFile.updateRegister(operands[0], RegisterFile.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction(“movz $t1,$t2,$t3”,
“Move conditional zero : Set $t1 to $t2 if $t3 is zero”,
BasicInstructionFormat.R_FORMAT,
“000000 sssss ttttt fffff 00000 001010”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[2])==0)
RegisterFile.updateRegister(operands[0], RegisterFile.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction(“movf $t1,$t2”,
“Move if FP condition flag 0 false : Set $t1 to $t2 if FPU (Coprocessor 1) condition flag 0 is false (zero)”,
BasicInstructionFormat.R_FORMAT,
“000000 sssss 000 00 fffff 00000 000001”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (Coprocessor1.getConditionFlag(0)==0)
RegisterFile.updateRegister(operands[0], RegisterFile.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction(“movf $t1,$t2,1”,
“Move if specified FP condition flag false : Set $t1 to $t2 if FPU (Coprocessor 1) condition flag specified by the immediate is false (zero)”,
BasicInstructionFormat.R_FORMAT,
“000000 sssss ttt 00 fffff 00000 000001”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (Coprocessor1.getConditionFlag(operands[2])==0)
RegisterFile.updateRegister(operands[0], RegisterFile.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction(“movt $t1,$t2”,
“Move if FP condition flag 0 true : Set $t1 to $t2 if FPU (Coprocessor 1) condition flag 0 is true (one)”,
BasicInstructionFormat.R_FORMAT,
“000000 sssss 000 01 fffff 00000 000001”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (Coprocessor1.getConditionFlag(0)==1)
RegisterFile.updateRegister(operands[0], RegisterFile.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction(“movt $t1,$t2,1”,
“Move if specfied FP condition flag true : Set $t1 to $t2 if FPU (Coprocessor 1) condition flag specified by the immediate is true (one)”,
BasicInstructionFormat.R_FORMAT,
“000000 sssss ttt 01 fffff 00000 000001”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (Coprocessor1.getConditionFlag(operands[2])==1)
RegisterFile.updateRegister(operands[0], RegisterFile.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction(“break 100”,
“Break execution with code : Terminate program execution with specified exception code”,
BasicInstructionFormat.R_FORMAT,
“000000 ffffffffffffffffffff 001101”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{ // At this time I don’t have exception processing or trap handlers
// so will just halt execution with a message.
int[] operands = statement.getOperands();
throw new ProcessingException(statement, “break instruction executed; code = “+
operands[0]+”.”, Exceptions.BREAKPOINT_EXCEPTION);
}
}));
instructionList.add(
new BasicInstruction(“break”,
“Break execution : Terminate program execution with exception”,
BasicInstructionFormat.R_FORMAT,
“000000 00000 00000 00000 00000 001101”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{ // At this time I don’t have exception processing or trap handlers
// so will just halt execution with a message.
throw new ProcessingException(statement, “break instruction executed; no code given.”,
Exceptions.BREAKPOINT_EXCEPTION);
}
}));
instructionList.add(
new BasicInstruction(“syscall”,
“Issue a system call : Execute the system call specified by value in $v0”,
BasicInstructionFormat.R_FORMAT,
“000000 00000 00000 00000 00000 001100”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
findAndSimulateSyscall(RegisterFile.getValue(2),statement);
}
}));
instructionList.add(
new BasicInstruction(“j target”,
“Jump unconditionally : Jump to statement at target address”,
BasicInstructionFormat.J_FORMAT,
“000010 ffffffffffffffffffffffffff”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
processJump(
((RegisterFile.getProgramCounter() & 0xF0000000)
| (operands[0] << 2)));
}
}));
instructionList.add(
new BasicInstruction("jr $t1",
"Jump register unconditionally : Jump to statement whose address is in $t1",
BasicInstructionFormat.R_FORMAT,
"000000 fffff 00000 00000 00000 001000",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
processJump(RegisterFile.getValue(operands[0]));
}
}));
instructionList.add(
new BasicInstruction("jal target",
"Jump and link : Set $ra to Program Counter (return address) then jump to statement at target address",
BasicInstructionFormat.J_FORMAT,
"000011 ffffffffffffffffffffffffff",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
processReturnAddress(31);// RegisterFile.updateRegister(31, RegisterFile.getProgramCounter());
processJump(
(RegisterFile.getProgramCounter() & 0xF0000000)
| (operands[0] << 2));
}
}));
instructionList.add(
new BasicInstruction("jalr $t1,$t2",
"Jump and link register : Set $t1 to Program Counter (return address) then jump to statement whose address is in $t2",
BasicInstructionFormat.R_FORMAT,
"000000 sssss 00000 fffff 00000 001001",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
processReturnAddress(operands[0]);//RegisterFile.updateRegister(operands[0], RegisterFile.getProgramCounter());
processJump(RegisterFile.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction("jalr $t1",
"Jump and link register : Set $ra to Program Counter (return address) then jump to statement whose address is in $t1",
BasicInstructionFormat.R_FORMAT,
"000000 fffff 00000 11111 00000 001001",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
processReturnAddress(31);//RegisterFile.updateRegister(31, RegisterFile.getProgramCounter());
processJump(RegisterFile.getValue(operands[0]));
}
}));
instructionList.add(
new BasicInstruction("lb $t1,-100($t2)",
"Load byte : Set $t1 to sign-extended 8-bit value from effective memory byte address",
BasicInstructionFormat.I_FORMAT,
"100000 ttttt fffff ssssssssssssssss",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
try
{
RegisterFile.updateRegister(operands[0],
Globals.memory.getByte(
RegisterFile.getValue(operands[2])
+ (operands[1] << 16 >> 16))
<< 24
>> 24);
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}));
instructionList.add(
new BasicInstruction(“lh $t1,-100($t2)”,
“Load halfword : Set $t1 to sign-extended 16-bit value from effective memory halfword address”,
BasicInstructionFormat.I_FORMAT,
“100001 ttttt fffff ssssssssssssssss”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
try
{
RegisterFile.updateRegister(operands[0],
Globals.memory.getHalf(
RegisterFile.getValue(operands[2])
+ (operands[1] << 16 >> 16))
<< 16
>> 16);
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}));
instructionList.add(
new BasicInstruction(“lhu $t1,-100($t2)”,
“Load halfword unsigned : Set $t1 to zero-extended 16-bit value from effective memory halfword address”,
BasicInstructionFormat.I_FORMAT,
“100101 ttttt fffff ssssssssssssssss”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
try
{
// offset is sign-extended and loaded halfword value is zero-extended
RegisterFile.updateRegister(operands[0],
Globals.memory.getHalf(
RegisterFile.getValue(operands[2])
+ (operands[1] << 16 >> 16))
& 0x0000ffff);
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}));
instructionList.add(
new BasicInstruction(“lbu $t1,-100($t2)”,
“Load byte unsigned : Set $t1 to zero-extended 8-bit value from effective memory byte address”,
BasicInstructionFormat.I_FORMAT,
“100100 ttttt fffff ssssssssssssssss”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
try
{
RegisterFile.updateRegister(operands[0],
Globals.memory.getByte(
RegisterFile.getValue(operands[2])
+ (operands[1] << 16 >> 16))
& 0x000000ff);
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}));
instructionList.add(
new BasicInstruction(“sb $t1,-100($t2)”,
“Store byte : Store the low-order 8 bits of $t1 into the effective memory byte address”,
BasicInstructionFormat.I_FORMAT,
“101000 ttttt fffff ssssssssssssssss”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
try
{
Globals.memory.setByte(
RegisterFile.getValue(operands[2])
+ (operands[1] << 16 >> 16),
RegisterFile.getValue(operands[0])
& 0x000000ff);
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}));
instructionList.add(
new BasicInstruction(“sh $t1,-100($t2)”,
“Store halfword : Store the low-order 16 bits of $t1 into the effective memory halfword address”,
BasicInstructionFormat.I_FORMAT,
“101001 ttttt fffff ssssssssssssssss”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
try
{
Globals.memory.setHalf(
RegisterFile.getValue(operands[2])
+ (operands[1] << 16 >> 16),
RegisterFile.getValue(operands[0])
& 0x0000ffff);
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}));
instructionList.add(
new BasicInstruction(“clo $t1,$t2”,
“Count number of leading ones : Set $t1 to the count of leading one bits in $t2 starting at most significant bit position”,
BasicInstructionFormat.R_FORMAT,
// MIPS32 requires rd (first) operand to appear twice in machine code.
// It has to be same as rt (third) operand in machine code, but the
// source statement does not have or permit third operand.
// In the machine code, rd and rt are adjacent, but my mask
// substitution cannot handle adjacent placement of the same source
// operand (e.g. “… sssss fffff fffff …”) because it would interpret
// the mask to be the total length of both (10 bits). I could code it
// to have 3 operands then define a pseudo-instruction of two operands
// to translate into this, but then both would show up in instruction set
// list and I don’t want that. So I will use the convention of Computer
// Organization and Design 3rd Edition, Appendix A, and code the rt bits
// as 0’s. The generated code does not match SPIM and would not run
// on a real MIPS machine but since I am providing no means of storing
// the binary code that is not really an issue.
“011100 sssss 00000 fffff 00000 100001”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
int value = RegisterFile.getValue(operands[1]);
int leadingOnes = 0;
int bitPosition = 31;
while (Binary.bitValue(value,bitPosition)==1 && bitPosition>=0) {
leadingOnes++;
bitPosition–;
}
RegisterFile.updateRegister(operands[0], leadingOnes);
}
}));
instructionList.add(
new BasicInstruction(“clz $t1,$t2”,
“Count number of leading zeroes : Set $t1 to the count of leading zero bits in $t2 starting at most significant bit positio”,
BasicInstructionFormat.R_FORMAT,
// See comments for “clo” instruction above. They apply here too.
“011100 sssss 00000 fffff 00000 100000”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
int value = RegisterFile.getValue(operands[1]);
int leadingZeros = 0;
int bitPosition = 31;
while (Binary.bitValue(value,bitPosition)==0 && bitPosition>=0) {
leadingZeros++;
bitPosition–;
}
RegisterFile.updateRegister(operands[0], leadingZeros);
}
}));
instructionList.add(
new BasicInstruction(“mfc0 $t1,$8”,
“Move from Coprocessor 0 : Set $t1 to the value stored in Coprocessor 0 register $8”,
BasicInstructionFormat.R_FORMAT,
“010000 00000 fffff sssss 00000 000000”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
RegisterFile.updateRegister(operands[0],
Coprocessor0.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction(“mtc0 $t1,$8”,
“Move to Coprocessor 0 : Set Coprocessor 0 register $8 to value stored in $t1”,
BasicInstructionFormat.R_FORMAT,
“010000 00100 fffff sssss 00000 000000”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
Coprocessor0.updateRegister(operands[1],
RegisterFile.getValue(operands[0]));
}
}));
/////////////////////// Floating Point Instructions Start Here ////////////////
instructionList.add(
new BasicInstruction(“add.s $f0,$f1,$f3”,
“Floating point addition single precision : Set $f0 to single-precision floating point value of $f1 plus $f3”,
BasicInstructionFormat.R_FORMAT,
“010001 10000 ttttt sssss fffff 000000″,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
float add1 = Float.intBitsToFloat(Coprocessor1.getValue(operands[1]));
float add2 = Float.intBitsToFloat(Coprocessor1.getValue(operands[2]));
float sum = add1 + add2;
// overflow detected when sum is positive or negative infinity.
/*
if (sum == Float.NEGATIVE_INFINITY || sum == Float.POSITIVE_INFINITY) {
throw new ProcessingException(statement,”arithmetic overflow”);
}
*/
Coprocessor1.updateRegister(operands[0], Float.floatToIntBits(sum));
}
}));
instructionList.add(
new BasicInstruction(“sub.s $f0,$f1,$f3”,
“Floating point subtraction single precision : Set $f0 to single-precision floating point value of $f1 minus $f3”,
BasicInstructionFormat.R_FORMAT,
“010001 10000 ttttt sssss fffff 000001”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
float sub1 = Float.intBitsToFloat(Coprocessor1.getValue(operands[1]));
float sub2 = Float.intBitsToFloat(Coprocessor1.getValue(operands[2]));
float diff = sub1 – sub2;
Coprocessor1.updateRegister(operands[0], Float.floatToIntBits(diff));
}
}));
instructionList.add(
new BasicInstruction(“mul.s $f0,$f1,$f3”,
“Floating point multiplication single precision : Set $f0 to single-precision floating point value of $f1 times $f3”,
BasicInstructionFormat.R_FORMAT,
“010001 10000 ttttt sssss fffff 000010”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
float mul1 = Float.intBitsToFloat(Coprocessor1.getValue(operands[1]));
float mul2 = Float.intBitsToFloat(Coprocessor1.getValue(operands[2]));
float prod = mul1 * mul2;
Coprocessor1.updateRegister(operands[0], Float.floatToIntBits(prod));
}
}));
instructionList.add(
new BasicInstruction(“div.s $f0,$f1,$f3”,
“Floating point division single precision : Set $f0 to single-precision floating point value of $f1 divided by $f3”,
BasicInstructionFormat.R_FORMAT,
“010001 10000 ttttt sssss fffff 000011”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
float div1 = Float.intBitsToFloat(Coprocessor1.getValue(operands[1]));
float div2 = Float.intBitsToFloat(Coprocessor1.getValue(operands[2]));
float quot = div1 / div2;
Coprocessor1.updateRegister(operands[0], Float.floatToIntBits(quot));
}
}));
instructionList.add(
new BasicInstruction(“sqrt.s $f0,$f1”,
“Square root single precision : Set $f0 to single-precision floating point square root of $f1”,
BasicInstructionFormat.R_FORMAT,
“010001 10000 00000 sssss fffff 000100”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
float value = Float.intBitsToFloat(Coprocessor1.getValue(operands[1]));
int floatSqrt = 0;
if (value < 0.0f) {
// This is subject to refinement later. Release 4.0 defines floor, ceil, trunc, round
// to act silently rather than raise Invalid Operation exception, so sqrt should do the
// same. An intermediate step would be to define a setting for FCSR Invalid Operation
// flag, but the best solution is to simulate the FCSR register itself.
// FCSR = Floating point unit Control and Status Register. DPS 10-Aug-2010
floatSqrt = Float.floatToIntBits( Float.NaN);
//throw new ProcessingException(statement, "Invalid Operation: sqrt of negative number");
}
else {
floatSqrt = Float.floatToIntBits( (float) Math.sqrt(value));
}
Coprocessor1.updateRegister(operands[0], floatSqrt);
}
}));
instructionList.add(
new BasicInstruction("floor.w.s $f0,$f1",
"Floor single precision to word : Set $f0 to 32-bit integer floor of single-precision float in $f1",
BasicInstructionFormat.R_FORMAT,
"010001 10000 00000 sssss fffff 001111",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
float floatValue = Float.intBitsToFloat(Coprocessor1.getValue(operands[1]));
int floor = (int) Math.floor(floatValue);
// DPS 28-July-2010: Since MARS does not simulate the FSCR, I will take the default
// action of setting the result to 2^31-1, if the value is outside the 32 bit range.
if ( Float.isNaN(floatValue)
|| Float.isInfinite(floatValue)
|| floatValue < (float) Integer.MIN_VALUE
|| floatValue > (float) Integer.MAX_VALUE ) {
floor = Integer.MAX_VALUE;
}
Coprocessor1.updateRegister(operands[0], floor);
}
}));
instructionList.add(
new BasicInstruction(“ceil.w.s $f0,$f1”,
“Ceiling single precision to word : Set $f0 to 32-bit integer ceiling of single-precision float in $f1”,
BasicInstructionFormat.R_FORMAT,
“010001 10000 00000 sssss fffff 001110”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
float floatValue = Float.intBitsToFloat(Coprocessor1.getValue(operands[1]));
int ceiling = (int) Math.ceil(floatValue);
// DPS 28-July-2010: Since MARS does not simulate the FSCR, I will take the default
// action of setting the result to 2^31-1, if the value is outside the 32 bit range.
if ( Float.isNaN(floatValue)
|| Float.isInfinite(floatValue)
|| floatValue < (float) Integer.MIN_VALUE
|| floatValue > (float) Integer.MAX_VALUE ) {
ceiling = Integer.MAX_VALUE;
}
Coprocessor1.updateRegister(operands[0], ceiling);
}
}));
instructionList.add(
new BasicInstruction(“round.w.s $f0,$f1”,
“Round single precision to word : Set $f0 to 32-bit integer round of single-precision float in $f1”,
BasicInstructionFormat.R_FORMAT,
“010001 10000 00000 sssss fffff 001100”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{ // MIPS32 documentation (and IEEE 754) states that round rounds to the nearest but when
// both are equally near it rounds to the even one! SPIM rounds -4.5, -5.5,
// 4.5 and 5.5 to (-4, -5, 5, 6). Curiously, it rounds -5.1 to -4 and -5.6 to -5.
// Until MARS 3.5, I used Math.round, which rounds to nearest but when both are
// equal it rounds toward positive infinity. With Release 3.5, I painstakingly
// carry out the MIPS and IEEE 754 standard.
int[] operands = statement.getOperands();
float floatValue = Float.intBitsToFloat(Coprocessor1.getValue(operands[1]));
int below=0, above=0, round = Math.round(floatValue);
// According to MIPS32 spec, if any of these conditions is true, set
// Invalid Operation in the FCSR (Floating point Control/Status Register) and
// set result to be 2^31-1. MARS does not implement this register (as of release 3.4.1).
// It also mentions the “Invalid Operation Enable bit” in FCSR, that, if set, results
// in immediate exception instead of default value.
if ( Float.isNaN(floatValue)
|| Float.isInfinite(floatValue)
|| floatValue < (float) Integer.MIN_VALUE
|| floatValue > (float) Integer.MAX_VALUE ) {
round = Integer.MAX_VALUE;
}
else {
Float floatObj = new Float(floatValue);
// If we are EXACTLY in the middle, then round to even! To determine this,
// find next higher integer and next lower integer, then see if distances
// are exactly equal.
if (floatValue < 0.0F) {
above = floatObj.intValue(); // truncates
below = above - 1;
}
else {
below = floatObj.intValue(); // truncates
above = below + 1;
}
if (floatValue - below == above - floatValue) { // exactly in the middle?
round = (above%2 == 0) ? above : below;
}
}
Coprocessor1.updateRegister(operands[0], round);
}
}));
instructionList.add(
new BasicInstruction("trunc.w.s $f0,$f1",
"Truncate single precision to word : Set $f0 to 32-bit integer truncation of single-precision float in $f1",
BasicInstructionFormat.R_FORMAT,
"010001 10000 00000 sssss fffff 001101",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
float floatValue = Float.intBitsToFloat(Coprocessor1.getValue(operands[1]));
int truncate = (int) floatValue;// Typecasting will round toward zero, the correct action
// DPS 28-July-2010: Since MARS does not simulate the FSCR, I will take the default
// action of setting the result to 2^31-1, if the value is outside the 32 bit range.
if ( Float.isNaN(floatValue)
|| Float.isInfinite(floatValue)
|| floatValue < (float) Integer.MIN_VALUE
|| floatValue > (float) Integer.MAX_VALUE ) {
truncate = Integer.MAX_VALUE;
}
Coprocessor1.updateRegister(operands[0], truncate);
}
}));
instructionList.add(
new BasicInstruction(“add.d $f2,$f4,$f6”,
“Floating point addition double precision : Set $f2 to double-precision floating point value of $f4 plus $f6”,
BasicInstructionFormat.R_FORMAT,
“010001 10001 ttttt sssss fffff 000000”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1 || operands[1]%2==1 || operands[2]%2==1) {
throw new ProcessingException(statement, “all registers must be even-numbered”);
}
double add1 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[1]+1),Coprocessor1.getValue(operands[1])));
double add2 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[2]+1),Coprocessor1.getValue(operands[2])));
double sum = add1 + add2;
long longSum = Double.doubleToLongBits(sum);
Coprocessor1.updateRegister(operands[0]+1, Binary.highOrderLongToInt(longSum));
Coprocessor1.updateRegister(operands[0], Binary.lowOrderLongToInt(longSum));
}
}));
instructionList.add(
new BasicInstruction(“sub.d $f2,$f4,$f6”,
“Floating point subtraction double precision : Set $f2 to double-precision floating point value of $f4 minus $f6”,
BasicInstructionFormat.R_FORMAT,
“010001 10001 ttttt sssss fffff 000001”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1 || operands[1]%2==1 || operands[2]%2==1) {
throw new ProcessingException(statement, “all registers must be even-numbered”);
}
double sub1 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[1]+1),Coprocessor1.getValue(operands[1])));
double sub2 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[2]+1),Coprocessor1.getValue(operands[2])));
double diff = sub1 – sub2;
long longDiff = Double.doubleToLongBits(diff);
Coprocessor1.updateRegister(operands[0]+1, Binary.highOrderLongToInt(longDiff));
Coprocessor1.updateRegister(operands[0], Binary.lowOrderLongToInt(longDiff));
}
}));
instructionList.add(
new BasicInstruction(“mul.d $f2,$f4,$f6”,
“Floating point multiplication double precision : Set $f2 to double-precision floating point value of $f4 times $f6”,
BasicInstructionFormat.R_FORMAT,
“010001 10001 ttttt sssss fffff 000010”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1 || operands[1]%2==1 || operands[2]%2==1) {
throw new ProcessingException(statement, “all registers must be even-numbered”);
}
double mul1 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[1]+1),Coprocessor1.getValue(operands[1])));
double mul2 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[2]+1),Coprocessor1.getValue(operands[2])));
double prod = mul1 * mul2;
long longProd = Double.doubleToLongBits(prod);
Coprocessor1.updateRegister(operands[0]+1, Binary.highOrderLongToInt(longProd));
Coprocessor1.updateRegister(operands[0], Binary.lowOrderLongToInt(longProd));
}
}));
instructionList.add(
new BasicInstruction(“div.d $f2,$f4,$f6”,
“Floating point division double precision : Set $f2 to double-precision floating point value of $f4 divided by $f6”,
BasicInstructionFormat.R_FORMAT,
“010001 10001 ttttt sssss fffff 000011”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1 || operands[1]%2==1 || operands[2]%2==1) {
throw new ProcessingException(statement, “all registers must be even-numbered”);
}
double div1 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[1]+1),Coprocessor1.getValue(operands[1])));
double div2 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[2]+1),Coprocessor1.getValue(operands[2])));
double quot = div1 / div2;
long longQuot = Double.doubleToLongBits(quot);
Coprocessor1.updateRegister(operands[0]+1, Binary.highOrderLongToInt(longQuot));
Coprocessor1.updateRegister(operands[0], Binary.lowOrderLongToInt(longQuot));
}
}));
instructionList.add(
new BasicInstruction(“sqrt.d $f2,$f4”,
“Square root double precision : Set $f2 to double-precision floating point square root of $f4”,
BasicInstructionFormat.R_FORMAT,
“010001 10001 00000 sssss fffff 000100”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1 || operands[1]%2==1 || operands[2]%2==1) {
throw new ProcessingException(statement, “both registers must be even-numbered”);
}
double value = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[1]+1),Coprocessor1.getValue(operands[1])));
long longSqrt = 0;
if (value < 0.0) {
// This is subject to refinement later. Release 4.0 defines floor, ceil, trunc, round
// to act silently rather than raise Invalid Operation exception, so sqrt should do the
// same. An intermediate step would be to define a setting for FCSR Invalid Operation
// flag, but the best solution is to simulate the FCSR register itself.
// FCSR = Floating point unit Control and Status Register. DPS 10-Aug-2010
longSqrt = Double.doubleToLongBits(Double.NaN);
//throw new ProcessingException(statement, "Invalid Operation: sqrt of negative number");
}
else {
longSqrt = Double.doubleToLongBits(Math.sqrt(value));
}
Coprocessor1.updateRegister(operands[0]+1, Binary.highOrderLongToInt(longSqrt));
Coprocessor1.updateRegister(operands[0], Binary.lowOrderLongToInt(longSqrt));
}
}));
instructionList.add(
new BasicInstruction("floor.w.d $f1,$f2",
"Floor double precision to word : Set $f1 to 32-bit integer floor of double-precision float in $f2",
BasicInstructionFormat.R_FORMAT,
"010001 10001 00000 sssss fffff 001111",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[1]%2==1) {
throw new ProcessingException(statement, "second register must be even-numbered");
}
double doubleValue = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[1]+1),Coprocessor1.getValue(operands[1])));
// DPS 27-July-2010: Since MARS does not simulate the FSCR, I will take the default
// action of setting the result to 2^31-1, if the value is outside the 32 bit range.
int floor = (int) Math.floor(doubleValue);
if ( Double.isNaN(doubleValue)
|| Double.isInfinite(doubleValue)
|| doubleValue < (double) Integer.MIN_VALUE
|| doubleValue > (double) Integer.MAX_VALUE ) {
floor = Integer.MAX_VALUE;
}
Coprocessor1.updateRegister(operands[0], floor);
}
}));
instructionList.add(
new BasicInstruction(“ceil.w.d $f1,$f2”,
“Ceiling double precision to word : Set $f1 to 32-bit integer ceiling of double-precision float in $f2”,
BasicInstructionFormat.R_FORMAT,
“010001 10001 00000 sssss fffff 001110”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[1]%2==1) {
throw new ProcessingException(statement, “second register must be even-numbered”);
}
double doubleValue = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[1]+1),Coprocessor1.getValue(operands[1])));
// DPS 27-July-2010: Since MARS does not simulate the FSCR, I will take the default
// action of setting the result to 2^31-1, if the value is outside the 32 bit range.
int ceiling = (int) Math.ceil(doubleValue);
if ( Double.isNaN(doubleValue)
|| Double.isInfinite(doubleValue)
|| doubleValue < (double) Integer.MIN_VALUE
|| doubleValue > (double) Integer.MAX_VALUE ) {
ceiling = Integer.MAX_VALUE;
}
Coprocessor1.updateRegister(operands[0], ceiling);
}
}));
instructionList.add(
new BasicInstruction(“round.w.d $f1,$f2”,
“Round double precision to word : Set $f1 to 32-bit integer round of double-precision float in $f2”,
BasicInstructionFormat.R_FORMAT,
“010001 10001 00000 sssss fffff 001100”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{ // See comments in round.w.s above, concerning MIPS and IEEE 754 standard.
// Until MARS 3.5, I used Math.round, which rounds to nearest but when both are
// equal it rounds toward positive infinity. With Release 3.5, I painstakingly
// carry out the MIPS and IEEE 754 standard (round to nearest/even).
int[] operands = statement.getOperands();
if (operands[1]%2==1) {
throw new ProcessingException(statement, “second register must be even-numbered”);
}
double doubleValue = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[1]+1),Coprocessor1.getValue(operands[1])));
int below=0, above=0;
int round = (int) Math.round(doubleValue);
// See comments in round.w.s above concerning FSCR…
if ( Double.isNaN(doubleValue)
|| Double.isInfinite(doubleValue)
|| doubleValue < (double) Integer.MIN_VALUE
|| doubleValue > (double) Integer.MAX_VALUE ) {
round = Integer.MAX_VALUE;
}
else {
Double doubleObj = new Double(doubleValue);
// If we are EXACTLY in the middle, then round to even! To determine this,
// find next higher integer and next lower integer, then see if distances
// are exactly equal.
if (doubleValue < 0.0) {
above = doubleObj.intValue(); // truncates
below = above - 1;
}
else {
below = doubleObj.intValue(); // truncates
above = below + 1;
}
if (doubleValue - below == above - doubleValue) { // exactly in the middle?
round = (above%2 == 0) ? above : below;
}
}
Coprocessor1.updateRegister(operands[0], round);
}
}));
instructionList.add(
new BasicInstruction("trunc.w.d $f1,$f2",
"Truncate double precision to word : Set $f1 to 32-bit integer truncation of double-precision float in $f2",
BasicInstructionFormat.R_FORMAT,
"010001 10001 00000 sssss fffff 001101",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[1]%2==1) {
throw new ProcessingException(statement, "second register must be even-numbered");
}
double doubleValue = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[1]+1),Coprocessor1.getValue(operands[1])));
// DPS 27-July-2010: Since MARS does not simulate the FSCR, I will take the default
// action of setting the result to 2^31-1, if the value is outside the 32 bit range.
int truncate = (int) doubleValue; // Typecasting will round toward zero, the correct action.
if ( Double.isNaN(doubleValue)
|| Double.isInfinite(doubleValue)
|| doubleValue < (double) Integer.MIN_VALUE
|| doubleValue > (double) Integer.MAX_VALUE ) {
truncate = Integer.MAX_VALUE;
}
Coprocessor1.updateRegister(operands[0], truncate);
}
}));
instructionList.add(
new BasicInstruction(“bc1t label”,
“Branch if FP condition flag 0 true (BC1T, not BCLT) : If Coprocessor 1 condition flag 0 is true (one) then branch to statement at label’s address”,
BasicInstructionFormat.I_BRANCH_FORMAT,
“010001 01000 00001 ffffffffffffffff”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (Coprocessor1.getConditionFlag(0)==1)
{
processBranch(operands[0]);
}
}
}));
instructionList.add(
new BasicInstruction(“bc1t 1,label”,
“Branch if specified FP condition flag true (BC1T, not BCLT) : If Coprocessor 1 condition flag specified by immediate is true (one) then branch to statement at label’s address”,
BasicInstructionFormat.I_BRANCH_FORMAT,
“010001 01000 fff 01 ssssssssssssssss”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (Coprocessor1.getConditionFlag(operands[0])==1)
{
processBranch(operands[1]);
}
}
}));
instructionList.add(
new BasicInstruction(“bc1f label”,
“Branch if FP condition flag 0 false (BC1F, not BCLF) : If Coprocessor 1 condition flag 0 is false (zero) then branch to statement at label’s address”,
BasicInstructionFormat.I_BRANCH_FORMAT,
“010001 01000 00000 ffffffffffffffff”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (Coprocessor1.getConditionFlag(0)==0)
{
processBranch(operands[0]);
}
}
}));
instructionList.add(
new BasicInstruction(“bc1f 1,label”,
“Branch if specified FP condition flag false (BC1F, not BCLF) : If Coprocessor 1 condition flag specified by immediate is false (zero) then branch to statement at label’s address”,
BasicInstructionFormat.I_BRANCH_FORMAT,
“010001 01000 fff 00 ssssssssssssssss”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (Coprocessor1.getConditionFlag(operands[0])==0)
{
processBranch(operands[1]);
}
}
}));
instructionList.add(
new BasicInstruction(“c.eq.s $f0,$f1”,
“Compare equal single precision : If $f0 is equal to $f1, set Coprocessor 1 condition flag 0 true else set it false”,
BasicInstructionFormat.R_FORMAT,
“010001 10000 sssss fffff 00000 110010”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
float op1 = Float.intBitsToFloat(Coprocessor1.getValue(operands[0]));
float op2 = Float.intBitsToFloat(Coprocessor1.getValue(operands[1]));
if (op1 == op2)
Coprocessor1.setConditionFlag(0);
else
Coprocessor1.clearConditionFlag(0);
}
}));
instructionList.add(
new BasicInstruction(“c.eq.s 1,$f0,$f1”,
“Compare equal single precision : If $f0 is equal to $f1, set Coprocessor 1 condition flag specied by immediate to true else set it to false”,
BasicInstructionFormat.R_FORMAT,
“010001 10000 ttttt sssss fff 00 11 0010”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
float op1 = Float.intBitsToFloat(Coprocessor1.getValue(operands[1]));
float op2 = Float.intBitsToFloat(Coprocessor1.getValue(operands[2]));
if (op1 == op2)
Coprocessor1.setConditionFlag(operands[0]);
else
Coprocessor1.clearConditionFlag(operands[0]);
}
}));
instructionList.add(
new BasicInstruction(“c.le.s $f0,$f1”,
“Compare less or equal single precision : If $f0 is less than or equal to $f1, set Coprocessor 1 condition flag 0 true else set it false”,
BasicInstructionFormat.R_FORMAT,
“010001 10000 sssss fffff 00000 111110”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
float op1 = Float.intBitsToFloat(Coprocessor1.getValue(operands[0]));
float op2 = Float.intBitsToFloat(Coprocessor1.getValue(operands[1]));
if (op1 <= op2)
Coprocessor1.setConditionFlag(0);
else
Coprocessor1.clearConditionFlag(0);
}
}));
instructionList.add(
new BasicInstruction("c.le.s 1,$f0,$f1",
"Compare less or equal single precision : If $f0 is less than or equal to $f1, set Coprocessor 1 condition flag specified by immediate to true else set it to false",
BasicInstructionFormat.R_FORMAT,
"010001 10000 ttttt sssss fff 00 111110",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
float op1 = Float.intBitsToFloat(Coprocessor1.getValue(operands[1]));
float op2 = Float.intBitsToFloat(Coprocessor1.getValue(operands[2]));
if (op1 <= op2)
Coprocessor1.setConditionFlag(operands[0]);
else
Coprocessor1.clearConditionFlag(operands[0]);
}
}));
instructionList.add(
new BasicInstruction("c.lt.s $f0,$f1",
"Compare less than single precision : If $f0 is less than $f1, set Coprocessor 1 condition flag 0 true else set it false",
BasicInstructionFormat.R_FORMAT,
"010001 10000 sssss fffff 00000 111100",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
float op1 = Float.intBitsToFloat(Coprocessor1.getValue(operands[0]));
float op2 = Float.intBitsToFloat(Coprocessor1.getValue(operands[1]));
if (op1 < op2)
Coprocessor1.setConditionFlag(0);
else
Coprocessor1.clearConditionFlag(0);
}
}));
instructionList.add(
new BasicInstruction("c.lt.s 1,$f0,$f1",
"Compare less than single precision : If $f0 is less than $f1, set Coprocessor 1 condition flag specified by immediate to true else set it to false",
BasicInstructionFormat.R_FORMAT,
"010001 10000 ttttt sssss fff 00 111100",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
float op1 = Float.intBitsToFloat(Coprocessor1.getValue(operands[1]));
float op2 = Float.intBitsToFloat(Coprocessor1.getValue(operands[2]));
if (op1 < op2)
Coprocessor1.setConditionFlag(operands[0]);
else
Coprocessor1.clearConditionFlag(operands[0]);
}
}));
instructionList.add(
new BasicInstruction("c.eq.d $f2,$f4",
"Compare equal double precision : If $f2 is equal to $f4 (double-precision), set Coprocessor 1 condition flag 0 true else set it false",
BasicInstructionFormat.R_FORMAT,
"010001 10001 sssss fffff 00000 110010",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1 || operands[1]%2==1) {
throw new ProcessingException(statement, "both registers must be even-numbered");
}
double op1 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[0]+1),Coprocessor1.getValue(operands[0])));
double op2 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[1]+1),Coprocessor1.getValue(operands[1])));
if (op1 == op2)
Coprocessor1.setConditionFlag(0);
else
Coprocessor1.clearConditionFlag(0);
}
}));
instructionList.add(
new BasicInstruction("c.eq.d 1,$f2,$f4",
"Compare equal double precision : If $f2 is equal to $f4 (double-precision), set Coprocessor 1 condition flag specified by immediate to true else set it to false",
BasicInstructionFormat.R_FORMAT,
"010001 10001 ttttt sssss fff 00 110010",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[1]%2==1 || operands[2]%2==1) {
throw new ProcessingException(statement, "both registers must be even-numbered");
}
double op1 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[1]+1),Coprocessor1.getValue(operands[1])));
double op2 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[2]+1),Coprocessor1.getValue(operands[2])));
if (op1 == op2)
Coprocessor1.setConditionFlag(operands[0]);
else
Coprocessor1.clearConditionFlag(operands[0]);
}
}));
instructionList.add(
new BasicInstruction("c.le.d $f2,$f4",
"Compare less or equal double precision : If $f2 is less than or equal to $f4 (double-precision), set Coprocessor 1 condition flag 0 true else set it false",
BasicInstructionFormat.R_FORMAT,
"010001 10001 sssss fffff 00000 111110",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1 || operands[1]%2==1) {
throw new ProcessingException(statement, "both registers must be even-numbered");
}
double op1 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[0]+1),Coprocessor1.getValue(operands[0])));
double op2 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[1]+1),Coprocessor1.getValue(operands[1])));
if (op1 <= op2)
Coprocessor1.setConditionFlag(0);
else
Coprocessor1.clearConditionFlag(0);
}
}));
instructionList.add(
new BasicInstruction("c.le.d 1,$f2,$f4",
"Compare less or equal double precision : If $f2 is less than or equal to $f4 (double-precision), set Coprocessor 1 condition flag specfied by immediate true else set it false",
BasicInstructionFormat.R_FORMAT,
"010001 10001 ttttt sssss fff 00 111110",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[1]%2==1 || operands[2]%2==1) {
throw new ProcessingException(statement, "both registers must be even-numbered");
}
double op1 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[1]+1),Coprocessor1.getValue(operands[1])));
double op2 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[2]+1),Coprocessor1.getValue(operands[2])));
if (op1 <= op2)
Coprocessor1.setConditionFlag(operands[0]);
else
Coprocessor1.clearConditionFlag(operands[0]);
}
}));
instructionList.add(
new BasicInstruction("c.lt.d $f2,$f4",
"Compare less than double precision : If $f2 is less than $f4 (double-precision), set Coprocessor 1 condition flag 0 true else set it false",
BasicInstructionFormat.R_FORMAT,
"010001 10001 sssss fffff 00000 111100",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1 || operands[1]%2==1) {
throw new ProcessingException(statement, "both registers must be even-numbered");
}
double op1 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[0]+1),Coprocessor1.getValue(operands[0])));
double op2 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[1]+1),Coprocessor1.getValue(operands[1])));
if (op1 < op2)
Coprocessor1.setConditionFlag(0);
else
Coprocessor1.clearConditionFlag(0);
}
}));
instructionList.add(
new BasicInstruction("c.lt.d 1,$f2,$f4",
"Compare less than double precision : If $f2 is less than $f4 (double-precision), set Coprocessor 1 condition flag specified by immediate to true else set it to false",
BasicInstructionFormat.R_FORMAT,
"010001 10001 ttttt sssss fff 00 111100",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[1]%2==1 || operands[2]%2==1) {
throw new ProcessingException(statement, "both registers must be even-numbered");
}
double op1 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[1]+1),Coprocessor1.getValue(operands[1])));
double op2 = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[2]+1),Coprocessor1.getValue(operands[2])));
if (op1 < op2)
Coprocessor1.setConditionFlag(operands[0]);
else
Coprocessor1.clearConditionFlag(operands[0]);
}
}));
instructionList.add(
new BasicInstruction("abs.s $f0,$f1",
"Floating point absolute value single precision : Set $f0 to absolute value of $f1, single precision",
BasicInstructionFormat.R_FORMAT,
"010001 10000 00000 sssss fffff 000101",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
// I need only clear the high order bit!
Coprocessor1.updateRegister(operands[0],
Coprocessor1.getValue(operands[1]) & Integer.MAX_VALUE);
}
}));
instructionList.add(
new BasicInstruction("abs.d $f2,$f4",
"Floating point absolute value double precision : Set $f2 to absolute value of $f4, double precision",
BasicInstructionFormat.R_FORMAT,
"010001 10001 00000 sssss fffff 000101",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1 || operands[1]%2==1) {
throw new ProcessingException(statement, "both registers must be even-numbered");
}
// I need only clear the high order bit of high word register!
Coprocessor1.updateRegister(operands[0]+1,
Coprocessor1.getValue(operands[1]+1) & Integer.MAX_VALUE);
Coprocessor1.updateRegister(operands[0],
Coprocessor1.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction("cvt.d.s $f2,$f1",
"Convert from single precision to double precision : Set $f2 to double precision equivalent of single precision value in $f1",
BasicInstructionFormat.R_FORMAT,
"010001 10000 00000 sssss fffff 100001",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1) {
throw new ProcessingException(statement, "first register must be even-numbered");
}
// convert single precision in $f1 to double stored in $f2
long result = Double.doubleToLongBits(
(double)Float.intBitsToFloat(Coprocessor1.getValue(operands[1])));
Coprocessor1.updateRegister(operands[0]+1, Binary.highOrderLongToInt(result));
Coprocessor1.updateRegister(operands[0], Binary.lowOrderLongToInt(result));
}
}));
instructionList.add(
new BasicInstruction("cvt.d.w $f2,$f1",
"Convert from word to double precision : Set $f2 to double precision equivalent of 32-bit integer value in $f1",
BasicInstructionFormat.R_FORMAT,
"010001 10100 00000 sssss fffff 100001",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1) {
throw new ProcessingException(statement, "first register must be even-numbered");
}
// convert integer to double (interpret $f1 value as int?)
long result = Double.doubleToLongBits(
(double)Coprocessor1.getValue(operands[1]));
Coprocessor1.updateRegister(operands[0]+1, Binary.highOrderLongToInt(result));
Coprocessor1.updateRegister(operands[0], Binary.lowOrderLongToInt(result));
}
}));
instructionList.add(
new BasicInstruction("cvt.s.d $f1,$f2",
"Convert from double precision to single precision : Set $f1 to single precision equivalent of double precision value in $f2",
BasicInstructionFormat.R_FORMAT,
"010001 10001 00000 sssss fffff 100000",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
// convert double precision in $f2 to single stored in $f1
if (operands[1]%2==1) {
throw new ProcessingException(statement, "second register must be even-numbered");
}
double val = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[1]+1),Coprocessor1.getValue(operands[1])));
Coprocessor1.updateRegister(operands[0], Float.floatToIntBits((float)val));
}
}));
instructionList.add(
new BasicInstruction("cvt.s.w $f0,$f1",
"Convert from word to single precision : Set $f0 to single precision equivalent of 32-bit integer value in $f2",
BasicInstructionFormat.R_FORMAT,
"010001 10100 00000 sssss fffff 100000",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
// convert integer to single (interpret $f1 value as int?)
Coprocessor1.updateRegister(operands[0],
Float.floatToIntBits((float)Coprocessor1.getValue(operands[1])));
}
}));
instructionList.add(
new BasicInstruction("cvt.w.d $f1,$f2",
"Convert from double precision to word : Set $f1 to 32-bit integer equivalent of double precision value in $f2",
BasicInstructionFormat.R_FORMAT,
"010001 10001 00000 sssss fffff 100100",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
// convert double precision in $f2 to integer stored in $f1
if (operands[1]%2==1) {
throw new ProcessingException(statement, "second register must be even-numbered");
}
double val = Double.longBitsToDouble(Binary.twoIntsToLong(
Coprocessor1.getValue(operands[1]+1),Coprocessor1.getValue(operands[1])));
Coprocessor1.updateRegister(operands[0], (int) val);
}
}));
instructionList.add(
new BasicInstruction("cvt.w.s $f0,$f1",
"Convert from single precision to word : Set $f0 to 32-bit integer equivalent of single precision value in $f1",
BasicInstructionFormat.R_FORMAT,
"010001 10000 00000 sssss fffff 100100",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
// convert single precision in $f1 to integer stored in $f0
Coprocessor1.updateRegister(operands[0],
(int)Float.intBitsToFloat(Coprocessor1.getValue(operands[1])));
}
}));
instructionList.add(
new BasicInstruction("mov.d $f2,$f4",
"Move floating point double precision : Set double precision $f2 to double precision value in $f4",
BasicInstructionFormat.R_FORMAT,
"010001 10001 00000 sssss fffff 000110",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1 || operands[1]%2==1) {
throw new ProcessingException(statement, "both registers must be even-numbered");
}
Coprocessor1.updateRegister(operands[0], Coprocessor1.getValue(operands[1]));
Coprocessor1.updateRegister(operands[0]+1, Coprocessor1.getValue(operands[1]+1));
}
}));
instructionList.add(
new BasicInstruction("movf.d $f2,$f4",
"Move floating point double precision : If condition flag 0 false, set double precision $f2 to double precision value in $f4",
BasicInstructionFormat.R_FORMAT,
"010001 10001 000 00 sssss fffff 010001",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1 || operands[1]%2==1) {
throw new ProcessingException(statement, "both registers must be even-numbered");
}
if (Coprocessor1.getConditionFlag(0)==0) {
Coprocessor1.updateRegister(operands[0], Coprocessor1.getValue(operands[1]));
Coprocessor1.updateRegister(operands[0]+1, Coprocessor1.getValue(operands[1]+1));
}
}
}));
instructionList.add(
new BasicInstruction("movf.d $f2,$f4,1",
"Move floating point double precision : If condition flag specified by immediate is false, set double precision $f2 to double precision value in $f4",
BasicInstructionFormat.R_FORMAT,
"010001 10001 ttt 00 sssss fffff 010001",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1 || operands[1]%2==1) {
throw new ProcessingException(statement, "both registers must be even-numbered");
}
if (Coprocessor1.getConditionFlag(operands[2])==0) {
Coprocessor1.updateRegister(operands[0], Coprocessor1.getValue(operands[1]));
Coprocessor1.updateRegister(operands[0]+1, Coprocessor1.getValue(operands[1]+1));
}
}
}));
instructionList.add(
new BasicInstruction("movt.d $f2,$f4",
"Move floating point double precision : If condition flag 0 true, set double precision $f2 to double precision value in $f4",
BasicInstructionFormat.R_FORMAT,
"010001 10001 000 01 sssss fffff 010001",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1 || operands[1]%2==1) {
throw new ProcessingException(statement, "both registers must be even-numbered");
}
if (Coprocessor1.getConditionFlag(0)==1) {
Coprocessor1.updateRegister(operands[0], Coprocessor1.getValue(operands[1]));
Coprocessor1.updateRegister(operands[0]+1, Coprocessor1.getValue(operands[1]+1));
}
}
}));
instructionList.add(
new BasicInstruction("movt.d $f2,$f4,1",
"Move floating point double precision : If condition flag specified by immediate is true, set double precision $f2 to double precision value in $f4e",
BasicInstructionFormat.R_FORMAT,
"010001 10001 ttt 01 sssss fffff 010001",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1 || operands[1]%2==1) {
throw new ProcessingException(statement, "both registers must be even-numbered");
}
if (Coprocessor1.getConditionFlag(operands[2])==1) {
Coprocessor1.updateRegister(operands[0], Coprocessor1.getValue(operands[1]));
Coprocessor1.updateRegister(operands[0]+1, Coprocessor1.getValue(operands[1]+1));
}
}
}));
instructionList.add(
new BasicInstruction("movn.d $f2,$f4,$t3",
"Move floating point double precision : If $t3 is not zero, set double precision $f2 to double precision value in $f4",
BasicInstructionFormat.R_FORMAT,
"010001 10001 ttttt sssss fffff 010011",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1 || operands[1]%2==1) {
throw new ProcessingException(statement, "both registers must be even-numbered");
}
if (RegisterFile.getValue(operands[2])!=0) {
Coprocessor1.updateRegister(operands[0], Coprocessor1.getValue(operands[1]));
Coprocessor1.updateRegister(operands[0]+1, Coprocessor1.getValue(operands[1]+1));
}
}
}));
instructionList.add(
new BasicInstruction("movz.d $f2,$f4,$t3",
"Move floating point double precision : If $t3 is zero, set double precision $f2 to double precision value in $f4",
BasicInstructionFormat.R_FORMAT,
"010001 10001 ttttt sssss fffff 010010",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1 || operands[1]%2==1) {
throw new ProcessingException(statement, "both registers must be even-numbered");
}
if (RegisterFile.getValue(operands[2])==0) {
Coprocessor1.updateRegister(operands[0], Coprocessor1.getValue(operands[1]));
Coprocessor1.updateRegister(operands[0]+1, Coprocessor1.getValue(operands[1]+1));
}
}
}));
instructionList.add(
new BasicInstruction("mov.s $f0,$f1",
"Move floating point single precision : Set single precision $f0 to single precision value in $f1",
BasicInstructionFormat.R_FORMAT,
"010001 10000 00000 sssss fffff 000110",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
Coprocessor1.updateRegister(operands[0], Coprocessor1.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction("movf.s $f0,$f1",
"Move floating point single precision : If condition flag 0 is false, set single precision $f0 to single precision value in $f1",
BasicInstructionFormat.R_FORMAT,
"010001 10000 000 00 sssss fffff 010001",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (Coprocessor1.getConditionFlag(0)==0)
Coprocessor1.updateRegister(operands[0], Coprocessor1.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction("movf.s $f0,$f1,1",
"Move floating point single precision : If condition flag specified by immediate is false, set single precision $f0 to single precision value in $f1e",
BasicInstructionFormat.R_FORMAT,
"010001 10000 ttt 00 sssss fffff 010001",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (Coprocessor1.getConditionFlag(operands[2])==0)
Coprocessor1.updateRegister(operands[0], Coprocessor1.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction("movt.s $f0,$f1",
"Move floating point single precision : If condition flag 0 is true, set single precision $f0 to single precision value in $f1e",
BasicInstructionFormat.R_FORMAT,
"010001 10000 000 01 sssss fffff 010001",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (Coprocessor1.getConditionFlag(0)==1)
Coprocessor1.updateRegister(operands[0], Coprocessor1.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction("movt.s $f0,$f1,1",
"Move floating point single precision : If condition flag specified by immediate is true, set single precision $f0 to single precision value in $f1e",
BasicInstructionFormat.R_FORMAT,
"010001 10000 ttt 01 sssss fffff 010001",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (Coprocessor1.getConditionFlag(operands[2])==1)
Coprocessor1.updateRegister(operands[0], Coprocessor1.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction("movn.s $f0,$f1,$t3",
"Move floating point single precision : If $t3 is not zero, set single precision $f0 to single precision value in $f1",
BasicInstructionFormat.R_FORMAT,
"010001 10000 ttttt sssss fffff 010011",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[2])!=0)
Coprocessor1.updateRegister(operands[0], Coprocessor1.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction("movz.s $f0,$f1,$t3",
"Move floating point single precision : If $t3 is zero, set single precision $f0 to single precision value in $f1",
BasicInstructionFormat.R_FORMAT,
"010001 10000 ttttt sssss fffff 010010",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[2])==0)
Coprocessor1.updateRegister(operands[0], Coprocessor1.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction("mfc1 $t1,$f1",
"Move from Coprocessor 1 (FPU) : Set $t1 to value in Coprocessor 1 register $f1",
BasicInstructionFormat.R_FORMAT,
"010001 00000 fffff sssss 00000 000000",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
RegisterFile.updateRegister(operands[0], Coprocessor1.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction("mtc1 $t1,$f1",
"Move to Coprocessor 1 (FPU) : Set Coprocessor 1 register $f1 to value in $t1",
BasicInstructionFormat.R_FORMAT,
"010001 00100 fffff sssss 00000 000000",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
Coprocessor1.updateRegister(operands[1], RegisterFile.getValue(operands[0]));
}
}));
instructionList.add(
new BasicInstruction("neg.d $f2,$f4",
"Floating point negate double precision : Set double precision $f2 to negation of double precision value in $f4",
BasicInstructionFormat.R_FORMAT,
"010001 10001 00000 sssss fffff 000111",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1 || operands[1]%2==1) {
throw new ProcessingException(statement, "both registers must be even-numbered");
}
// flip the sign bit of the second register (high order word) of the pair
int value = Coprocessor1.getValue(operands[1]+1);
Coprocessor1.updateRegister(operands[0]+1,
((value < 0) ? (value & Integer.MAX_VALUE) : (value | Integer.MIN_VALUE)));
Coprocessor1.updateRegister(operands[0], Coprocessor1.getValue(operands[1]));
}
}));
instructionList.add(
new BasicInstruction("neg.s $f0,$f1",
"Floating point negate single precision : Set single precision $f0 to negation of single precision value in $f1",
BasicInstructionFormat.R_FORMAT,
"010001 10000 00000 sssss fffff 000111",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
int value = Coprocessor1.getValue(operands[1]);
// flip the sign bit
Coprocessor1.updateRegister(operands[0],
((value < 0) ? (value & Integer.MAX_VALUE) : (value | Integer.MIN_VALUE)));
}
}));
instructionList.add(
new BasicInstruction("lwc1 $f1,-100($t2)",
"Load word into Coprocessor 1 (FPU) : Set $f1 to 32-bit value from effective memory word address",
BasicInstructionFormat.I_FORMAT,
"110001 ttttt fffff ssssssssssssssss",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
try
{
Coprocessor1.updateRegister(operands[0],
Globals.memory.getWord(
RegisterFile.getValue(operands[2]) + operands[1]));
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}));
instructionList.add(// no printed reference, got opcode from SPIM
new BasicInstruction("ldc1 $f2,-100($t2)",
"Load double word Coprocessor 1 (FPU)) : Set $f2 to 64-bit value from effective memory doubleword address",
BasicInstructionFormat.I_FORMAT,
"110101 ttttt fffff ssssssssssssssss",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1) {
throw new ProcessingException(statement, "first register must be even-numbered");
}
// IF statement added by DPS 13-July-2011.
if (!Globals.memory.doublewordAligned(RegisterFile.getValue(operands[2]) + operands[1])) {
throw new ProcessingException(statement,
new AddressErrorException("address not aligned on doubleword boundary ",
Exceptions.ADDRESS_EXCEPTION_LOAD, RegisterFile.getValue(operands[2]) + operands[1]));
}
try
{
Coprocessor1.updateRegister(operands[0],
Globals.memory.getWord(
RegisterFile.getValue(operands[2]) + operands[1]));
Coprocessor1.updateRegister(operands[0]+1,
Globals.memory.getWord(
RegisterFile.getValue(operands[2]) + operands[1] + 4));
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}));
instructionList.add(
new BasicInstruction("swc1 $f1,-100($t2)",
"Store word from Coprocesor 1 (FPU) : Store 32 bit value in $f1 to effective memory word address",
BasicInstructionFormat.I_FORMAT,
"111001 ttttt fffff ssssssssssssssss",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
try
{
Globals.memory.setWord(
RegisterFile.getValue(operands[2]) + operands[1],
Coprocessor1.getValue(operands[0]));
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}));
instructionList.add( // no printed reference, got opcode from SPIM
new BasicInstruction("sdc1 $f2,-100($t2)",
"Store double word from Coprocessor 1 (FPU)) : Store 64 bit value in $f2 to effective memory doubleword address",
BasicInstructionFormat.I_FORMAT,
"111101 ttttt fffff ssssssssssssssss",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (operands[0]%2==1) {
throw new ProcessingException(statement, "first register must be even-numbered");
}
// IF statement added by DPS 13-July-2011.
if (!Globals.memory.doublewordAligned(RegisterFile.getValue(operands[2]) + operands[1])) {
throw new ProcessingException(statement,
new AddressErrorException("address not aligned on doubleword boundary ",
Exceptions.ADDRESS_EXCEPTION_STORE, RegisterFile.getValue(operands[2]) + operands[1]));
}
try
{
Globals.memory.setWord(
RegisterFile.getValue(operands[2]) + operands[1],
Coprocessor1.getValue(operands[0]));
Globals.memory.setWord(
RegisterFile.getValue(operands[2]) + operands[1] + 4,
Coprocessor1.getValue(operands[0]+1));
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}));
//////////////////////////// THE TRAP INSTRUCTIONS & ERET ////////////////////////////
instructionList.add(
new BasicInstruction("teq $t1,$t2",
"Trap if equal : Trap if $t1 is equal to $t2",
BasicInstructionFormat.R_FORMAT,
"000000 fffff sssss 00000 00000 110100",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[0]) == RegisterFile.getValue(operands[1]))
{
throw new ProcessingException(statement,
"trap",Exceptions.TRAP_EXCEPTION);
}
}
}));
instructionList.add(
new BasicInstruction("teqi $t1,-100",
"Trap if equal to immediate : Trap if $t1 is equal to sign-extended 16 bit immediate",
BasicInstructionFormat.I_FORMAT,
"000001 fffff 01100 ssssssssssssssss",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[0]) == (operands[1] << 16 >> 16))
{
throw new ProcessingException(statement,
“trap”,Exceptions.TRAP_EXCEPTION);
}
}
}));
instructionList.add(
new BasicInstruction(“tne $t1,$t2”,
“Trap if not equal : Trap if $t1 is not equal to $t2”,
BasicInstructionFormat.R_FORMAT,
“000000 fffff sssss 00000 00000 110110”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[0]) != RegisterFile.getValue(operands[1]))
{
throw new ProcessingException(statement,
“trap”,Exceptions.TRAP_EXCEPTION);
}
}
}));
instructionList.add(
new BasicInstruction(“tnei $t1,-100”,
“Trap if not equal to immediate : Trap if $t1 is not equal to sign-extended 16 bit immediate”,
BasicInstructionFormat.I_FORMAT,
“000001 fffff 01110 ssssssssssssssss”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[0]) != (operands[1] << 16 >> 16))
{
throw new ProcessingException(statement,
“trap”,Exceptions.TRAP_EXCEPTION);
}
}
}));
instructionList.add(
new BasicInstruction(“tge $t1,$t2”,
“Trap if greater or equal : Trap if $t1 is greater than or equal to $t2”,
BasicInstructionFormat.R_FORMAT,
“000000 fffff sssss 00000 00000 110000”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[0]) >= RegisterFile.getValue(operands[1]))
{
throw new ProcessingException(statement,
“trap”,Exceptions.TRAP_EXCEPTION);
}
}
}));
instructionList.add(
new BasicInstruction(“tgeu $t1,$t2”,
“Trap if greater or equal unsigned : Trap if $t1 is greater than or equal to $t2 using unsigned comparision”,
BasicInstructionFormat.R_FORMAT,
“000000 fffff sssss 00000 00000 110001”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
int first = RegisterFile.getValue(operands[0]);
int second = RegisterFile.getValue(operands[1]);
// if signs same, do straight compare; if signs differ & first negative then first greater else second
if ((first >= 0 && second >= 0 || first < 0 && second < 0) ? (first >= second) : (first < 0) )
{
throw new ProcessingException(statement,
"trap",Exceptions.TRAP_EXCEPTION);
}
}
}));
instructionList.add(
new BasicInstruction("tgei $t1,-100",
"Trap if greater than or equal to immediate : Trap if $t1 greater than or equal to sign-extended 16 bit immediate",
BasicInstructionFormat.I_FORMAT,
"000001 fffff 01000 ssssssssssssssss",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[0]) >= (operands[1] << 16 >> 16))
{
throw new ProcessingException(statement,
“trap”,Exceptions.TRAP_EXCEPTION);
}
}
}));
instructionList.add(
new BasicInstruction(“tgeiu $t1,-100”,
“Trap if greater or equal to immediate unsigned : Trap if $t1 greater than or equal to sign-extended 16 bit immediate, unsigned comparison”,
BasicInstructionFormat.I_FORMAT,
“000001 fffff 01001 ssssssssssssssss”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
int first = RegisterFile.getValue(operands[0]);
// 16 bit immediate value in operands[1] is sign-extended
int second = operands[1] << 16 >> 16;
// if signs same, do straight compare; if signs differ & first negative then first greater else second
if ((first >= 0 && second >= 0 || first < 0 && second < 0) ? (first >= second) : (first < 0) )
{
throw new ProcessingException(statement,
"trap",Exceptions.TRAP_EXCEPTION);
}
}
}));
instructionList.add(
new BasicInstruction("tlt $t1,$t2",
"Trap if less than: Trap if $t1 less than $t2",
BasicInstructionFormat.R_FORMAT,
"000000 fffff sssss 00000 00000 110010",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[0]) < RegisterFile.getValue(operands[1]))
{
throw new ProcessingException(statement,
"trap",Exceptions.TRAP_EXCEPTION);
}
}
}));
instructionList.add(
new BasicInstruction("tltu $t1,$t2",
"Trap if less than unsigned : Trap if $t1 less than $t2, unsigned comparison",
BasicInstructionFormat.R_FORMAT,
"000000 fffff sssss 00000 00000 110011",
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
int first = RegisterFile.getValue(operands[0]);
int second = RegisterFile.getValue(operands[1]);
// if signs same, do straight compare; if signs differ & first positive then first is less else second
if ((first >= 0 && second >= 0 || first < 0 && second < 0) ? (first < second) : (first >= 0) )
{
throw new ProcessingException(statement,
“trap”,Exceptions.TRAP_EXCEPTION);
}
}
}));
instructionList.add(
new BasicInstruction(“tlti $t1,-100”,
“Trap if less than immediate : Trap if $t1 less than sign-extended 16-bit immediate”,
BasicInstructionFormat.I_FORMAT,
“000001 fffff 01010 ssssssssssssssss”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
if (RegisterFile.getValue(operands[0]) < (operands[1] << 16 >> 16))
{
throw new ProcessingException(statement,
“trap”,Exceptions.TRAP_EXCEPTION);
}
}
}));
instructionList.add(
new BasicInstruction(“tltiu $t1,-100”,
“Trap if less than immediate unsigned : Trap if $t1 less than sign-extended 16-bit immediate, unsigned comparison”,
BasicInstructionFormat.I_FORMAT,
“000001 fffff 01011 ssssssssssssssss”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
int[] operands = statement.getOperands();
int first = RegisterFile.getValue(operands[0]);
// 16 bit immediate value in operands[1] is sign-extended
int second = operands[1] << 16 >> 16;
// if signs same, do straight compare; if signs differ & first positive then first is less else second
if ((first >= 0 && second >= 0 || first < 0 && second < 0) ? (first < second) : (first >= 0) )
{
throw new ProcessingException(statement,
“trap”,Exceptions.TRAP_EXCEPTION);
}
}
}));
instructionList.add(
new BasicInstruction(“eret”,
“Exception return : Set Program Counter to Coprocessor 0 EPC register value, set Coprocessor Status register bit 1 (exception level) to zero”,
BasicInstructionFormat.R_FORMAT,
“010000 1 0000000000000000000 011000”,
new SimulationCode()
{
public void simulate(ProgramStatement statement) throws ProcessingException
{
// set EXL bit (bit 1) in Status register to 0 and set PC to EPC
Coprocessor0.updateRegister(Coprocessor0.STATUS,
Binary.clearBit(Coprocessor0.getValue(Coprocessor0.STATUS), Coprocessor0.EXCEPTION_LEVEL));
RegisterFile.setProgramCounter(Coprocessor0.getValue(Coprocessor0.EPC));
}
}));
////////////// READ PSEUDO-INSTRUCTION SPECS FROM DATA FILE AND ADD //////////////////////
addPseudoInstructions();
////////////// GET AND CREATE LIST OF SYSCALL FUNCTION OBJECTS ////////////////////
syscallLoader = new SyscallLoader();
syscallLoader.loadSyscalls();
// Initialization step. Create token list for each instruction example. This is
// used by parser to determine user program correct syntax.
for (int i = 0; i < instructionList.size(); i++)
{
Instruction inst = (Instruction) instructionList.get(i);
inst.createExampleTokenList();
}
HashMap maskMap = new HashMap();
ArrayList matchMaps = new ArrayList();
for (int i = 0; i < instructionList.size(); i++) {
Object rawInstr = instructionList.get(i);
if (rawInstr instanceof BasicInstruction) {
BasicInstruction basic = (BasicInstruction) rawInstr;
Integer mask = Integer.valueOf(basic.getOpcodeMask());
Integer match = Integer.valueOf(basic.getOpcodeMatch());
HashMap matchMap = (HashMap) maskMap.get(mask);
if (matchMap == null) {
matchMap = new HashMap();
maskMap.put(mask, matchMap);
matchMaps.add(new MatchMap(mask, matchMap));
}
matchMap.put(match, basic);
}
}
Collections.sort(matchMaps);
this.opcodeMatchMaps = matchMaps;
}
public BasicInstruction findByBinaryCode(int binaryInstr) {
ArrayList matchMaps = this.opcodeMatchMaps;
for (int i = 0; i < matchMaps.size(); i++) {
MatchMap map = (MatchMap) matchMaps.get(i);
BasicInstruction ret = map.find(binaryInstr);
if (ret != null) return ret;
}
return null;
}
/* METHOD TO ADD PSEUDO-INSTRUCTIONS
*/
private void addPseudoInstructions()
{
InputStream is = null;
BufferedReader in = null;
try
{
// leading "/" prevents package name being prepended to filepath.
is = this.getClass().getResourceAsStream("/PseudoOps.txt");
in = new BufferedReader(new InputStreamReader(is));
}
catch (NullPointerException e)
{
System.out.println(
"Error: MIPS pseudo-instruction file PseudoOps.txt not found.");
System.exit(0);
}
try
{
String line, pseudoOp, template, firstTemplate, token;
String description;
StringTokenizer tokenizer;
while ((line = in.readLine()) != null) {
// skip over: comment lines, empty lines, lines starting with blank.
if (!line.startsWith("#") && !line.startsWith(" ")
&& line.length() > 0) {
description = “”;
tokenizer = new StringTokenizer(line, “\t”);
pseudoOp = tokenizer.nextToken();
template = “”;
firstTemplate = null;
while (tokenizer.hasMoreTokens()) {
token = tokenizer.nextToken();
if (token.startsWith(“#”)) {
// Optional description must be last token in the line.
description = token.substring(1);
break;
}
if (token.startsWith(“COMPACT”)) {
// has second template for Compact (16-bit) memory config — added DPS 3 Aug 2009
firstTemplate = template;
template = “”;
continue;
}
template = template + token;
if (tokenizer.hasMoreTokens()) {
template = template + “\n”;
}
}
ExtendedInstruction inst = (firstTemplate == null)
? new ExtendedInstruction(pseudoOp, template, description)
: new ExtendedInstruction(pseudoOp, firstTemplate, template, description);
instructionList.add(inst);
//if (firstTemplate != null) System.out.println(“\npseudoOp: “+pseudoOp+”\ndefault template:\n”+firstTemplate+”\ncompact template:\n”+template);
}
}
in.close();
}
catch (IOException ioe)
{
System.out.println(
“Internal Error: MIPS pseudo-instructions could not be loaded.”);
System.exit(0);
}
catch (Exception ioe)
{
System.out.println(
“Error: Invalid MIPS pseudo-instruction specification.”);
System.exit(0);
}
}
/**
* Given an operator mnemonic, will return the corresponding Instruction object(s)
* from the instruction set. Uses straight linear search technique.
* @param name operator mnemonic (e.g. addi, sw,…)
* @return list of corresponding Instruction object(s), or null if not found.
*/
public ArrayList matchOperator(String name)
{
ArrayList matchingInstructions = null;
// Linear search for now….
for (int i = 0; i < instructionList.size(); i++)
{
if (((Instruction) instructionList.get(i)).getName().equalsIgnoreCase(name))
{
if (matchingInstructions == null)
matchingInstructions = new ArrayList();
matchingInstructions.add(instructionList.get(i));
}
}
return matchingInstructions;
}
/**
* Given a string, will return the Instruction object(s) from the instruction
* set whose operator mnemonic prefix matches it. Case-insensitive. For example
* "s" will match "sw", "sh", "sb", etc. Uses straight linear search technique.
* @param name a string
* @return list of matching Instruction object(s), or null if none match.
*/
public ArrayList prefixMatchOperator(String name)
{
ArrayList matchingInstructions = null;
// Linear search for now....
if (name != null) {
for (int i = 0; i < instructionList.size(); i++)
{
if (((Instruction) instructionList.get(i)).getName().toLowerCase().startsWith(name.toLowerCase()))
{
if (matchingInstructions == null)
matchingInstructions = new ArrayList();
matchingInstructions.add(instructionList.get(i));
}
}
}
return matchingInstructions;
}
/*
* Method to find and invoke a syscall given its service number. Each syscall
* function is represented by an object in an array list. Each object is of
* a class that implements Syscall or extends AbstractSyscall.
*/
private void findAndSimulateSyscall(int number, ProgramStatement statement)
throws ProcessingException {
Syscall service = syscallLoader.findSyscall(number);
if (service != null) {
service.simulate(statement);
return;
}
throw new ProcessingException(statement,
"invalid or unimplemented syscall service: " +
number + " ", Exceptions.SYSCALL_EXCEPTION);
}
/*
* Method to process a successful branch condition. DO NOT USE WITH JUMP
* INSTRUCTIONS! The branch operand is a relative displacement in words
* whereas the jump operand is an absolute address in bytes.
*
* The parameter is displacement operand from instruction.
*
* Handles delayed branching if that setting is enabled.
*/
// 4 January 2008 DPS: The subtraction of 4 bytes (instruction length) after
// the shift has been removed. It is left in as commented-out code below.
// This has the effect of always branching as if delayed branching is enabled,
// even if it isn't. This mod must work in conjunction with
// ProgramStatement.java, buildBasicStatementFromBasicInstruction() method near
// the bottom (currently line 194, heavily commented).
private void processBranch(int displacement) {
if (Globals.getSettings().getDelayedBranchingEnabled()) {
// Register the branch target address (absolute byte address).
DelayedBranch.register(RegisterFile.getProgramCounter() + (displacement << 2));
}
else {
// Decrement needed because PC has already been incremented
RegisterFile.setProgramCounter(
RegisterFile.getProgramCounter()
+ (displacement << 2)); // - Instruction.INSTRUCTION_LENGTH);
}
}
/*
* Method to process a jump. DO NOT USE WITH BRANCH INSTRUCTIONS!
* The branch operand is a relative displacement in words
* whereas the jump operand is an absolute address in bytes.
*
* The parameter is jump target absolute byte address.
*
* Handles delayed branching if that setting is enabled.
*/
private void processJump(int targetAddress) {
if (Globals.getSettings().getDelayedBranchingEnabled()) {
DelayedBranch.register(targetAddress);
}
else {
RegisterFile.setProgramCounter(targetAddress);
}
}
/*
* Method to process storing of a return address in the given
* register. This is used only by the "and link"
* instructions: jal, jalr, bltzal, bgezal. If delayed branching
* setting is off, the return address is the address of the
* next instruction (e.g. the current PC value). If on, the
* return address is the instruction following that, to skip over
* the delay slot.
*
* The parameter is register number to receive the return address.
*/
private void processReturnAddress(int register) {
RegisterFile.updateRegister(register, RegisterFile.getProgramCounter() +
((Globals.getSettings().getDelayedBranchingEnabled()) ?
Instruction.INSTRUCTION_LENGTH : 0) );
}
private static class MatchMap implements Comparable {
private int mask;
private int maskLength; // number of 1 bits in mask
private HashMap matchMap;
public MatchMap(int mask, HashMap matchMap) {
this.mask = mask;
this.matchMap = matchMap;
int k = 0;
int n = mask;
while (n != 0) {
k++;
n &= n - 1;
}
this.maskLength = k;
}
public boolean equals(Object o) {
return o instanceof MatchMap && mask == ((MatchMap) o).mask;
}
public int compareTo(Object other) {
MatchMap o = (MatchMap) other;
int d = o.maskLength - this.maskLength;
if (d == 0) d = this.mask - o.mask;
return d;
}
public BasicInstruction find(int instr) {
int match = Integer.valueOf(instr & mask);
return (BasicInstruction) matchMap.get(match);
}
}
}
SimulationCode
package mars.mips.instructions;
public abstract interface SimulationCode {
public abstract void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/SimulationCode.java
mars/mips/instructions/SimulationCode.javapackage mars.mips.instructions;
import mars.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Interface to represent the method for simulating the execution of a specific MIPS basic
* instruction. It will be implemented by the anonymous class created in the last
* argument to the BasicInstruction constructor.
*
* @author Pete Sanderson
* @version August 2003
*
*/
public interface SimulationCode {
/**
* Method to simulate the execution of a specific MIPS basic instruction.
*
* @param statement A ProgramStatement representing the MIPS instruction to simulate.
* @throws ProcessingException This is a run-time exception generated during simulation.
**/
public void simulate(ProgramStatement statement) throws ProcessingException;
}
SyscallLoader
package mars.mips.instructions;
synchronized class SyscallLoader {
private static final String CLASS_PREFIX = mars.mips.instructions.syscalls.;
private static final String SYSCALLS_DIRECTORY_PATH = mars/mips/instructions/syscalls;
private static final String SYSCALL_INTERFACE = Syscall.class;
private static final String SYSCALL_ABSTRACT = AbstractSyscall.class;
private static final String CLASS_EXTENSION = class;
private java.util.ArrayList syscallList;
void SyscallLoader();
void loadSyscalls();
private java.util.ArrayList processSyscallNumberOverrides(java.util.ArrayList);
syscalls.Syscall findSyscall(int);
}
mars/mips/instructions/SyscallLoader.java
mars/mips/instructions/SyscallLoader.java package mars.mips.instructions;
import mars.mips.instructions.syscalls.*;
import mars.*;
import mars.util.*;
import java.util.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/****************************************************************************/
/* This class provides functionality to bring external Syscall definitions
* into MARS. This permits anyone with knowledge of the Mars public interfaces,
* in particular of the Memory and Register classes, to write custom MIPS syscall
* functions. This is adapted from the ToolLoader class, which is in turn adapted
* from Bret Barker's GameServer class from the book "Developing Games In Java".
*/
class SyscallLoader {
private static final String CLASS_PREFIX = "mars.mips.instructions.syscalls.";
private static final String SYSCALLS_DIRECTORY_PATH = "mars/mips/instructions/syscalls";
private static final String SYSCALL_INTERFACE = "Syscall.class";
private static final String SYSCALL_ABSTRACT = "AbstractSyscall.class";
private static final String CLASS_EXTENSION = "class";
private ArrayList syscallList;
/*
* Dynamically loads Syscalls into an ArrayList. This method is adapted from
* the loadGameControllers() method in Bret Barker's GameServer class.
* Barker (bret@hypefiend.com) is co-author of the book "Developing Games
* in Java". Also see the "loadMarsTools()" method from ToolLoader class.
*/
void loadSyscalls() {
syscallList = new ArrayList();
// grab all class files in the same directory as Syscall
ArrayList candidates = FilenameFinder.getFilenameList(this.getClass( ).getClassLoader(),
SYSCALLS_DIRECTORY_PATH, CLASS_EXTENSION);
HashMap syscalls = new HashMap();
for( int i = 0; i < candidates.size(); i++) {
String file = (String) candidates.get(i);
// Do not add class if already encountered (happens if run in MARS development directory)
if (syscalls.containsKey(file)) {
continue;
} else {
syscalls.put(file,file);
}
if ((!file.equals(SYSCALL_INTERFACE)) &&
(!file.equals(SYSCALL_ABSTRACT)) ) {
try {
// grab the class, make sure it implements Syscall, instantiate, add to list
String syscallClassName = CLASS_PREFIX+file.substring(0, file.indexOf(CLASS_EXTENSION)-1);
Class clas = Class.forName(syscallClassName);
if (!Syscall.class.isAssignableFrom(clas)) {
continue;
}
Syscall syscall = (Syscall) clas.newInstance();
if (findSyscall(syscall.getNumber()) == null) {
syscallList.add(syscall);
}
else {
throw new Exception("Duplicate service number: "+syscall.getNumber()+
" already registered to "+
findSyscall(syscall.getNumber()).getName());
}
}
catch (Exception e) {
System.out.println("Error instantiating Syscall from file " + file + ": "+e);
System.exit(0);
}
}
}
syscallList = processSyscallNumberOverrides(syscallList);
return;
}
// Will get any syscall number override specifications from MARS config file and
// process them. This will alter syscallList entry for affected names.
private ArrayList processSyscallNumberOverrides(ArrayList syscallList) {
ArrayList overrides = new Globals().getSyscallOverrides();
SyscallNumberOverride override;
Syscall syscall;
for (int index=0; index < overrides.size(); index++) {
override = (SyscallNumberOverride) overrides.get(index);
boolean match = false;
for (int i=0; i < syscallList.size(); i++) {
syscall = (Syscall) syscallList.get(i);
if (override.getName().equals(syscall.getName())) {
// we have a match to service name, assign new number
syscall.setNumber(override.getNumber());
match = true;
}
}
if (!match) {
System.out.println("Error: syscall name '"+override.getName()+
"' in config file does not match any name in syscall list");
System.exit(0);
}
}
// Wait until end to check for duplicate numbers. To do so earlier
// would disallow for instance the exchange of numbers between two
// services. This is N-squared operation but N is small.
// This will also detect duplicates that accidently occur from addition
// of a new Syscall subclass to the collection, even if the config file
// does not contain any overrides.
Syscall syscallA, syscallB;
boolean duplicates = false;
for (int i = 0; i < syscallList.size(); i++) {
syscallA = (Syscall)syscallList.get(i);
for (int j = i+1; j < syscallList.size(); j++) {
syscallB = (Syscall)syscallList.get(j);
if ( syscallA.getNumber() == syscallB.getNumber()) {
System.out.println("Error: syscalls "+syscallA.getName()+" and "+
syscallB.getName()+" are both assigned same number "+syscallA.getNumber());
duplicates = true;
}
}
}
if (duplicates) {
System.exit(0);
}
return syscallList;
}
/*
* Method to find Syscall object associated with given service number.
* Returns null if no associated object found.
*/
Syscall findSyscall(int number) {
// linear search is OK since number of syscalls is small.
Syscall service, match = null;
if (syscallList==null) {
loadSyscalls();
}
for (int index=0; index < syscallList.size(); index++) {
service = (Syscall) syscallList.get(index);
if (service.getNumber() == number) {
match = service;
}
}
return match;
}
}
AbstractSyscall
package mars.mips.instructions.syscalls;
public abstract synchronized class AbstractSyscall implements Syscall {
private int serviceNumber;
private String serviceName;
public void AbstractSyscall(int, String);
public String getName();
public void setNumber(int);
public int getNumber();
public abstract void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/AbstractSyscall.java
mars/mips/instructions/syscalls/AbstractSyscall.java package mars.mips.instructions.syscalls;
import mars.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Abstract class that a MIPS syscall system service may extend. A qualifying service
* must be a class in the mars.mips.instructions.syscalls package that
* implements the Syscall interface, must be compiled into a .class file,
* and its .class file must be in the same folder as Syscall.class.
* Mars will detect a qualifying syscall upon startup, create an instance
* using its no-argument constructor and add it to its syscall list.
* When its service is invoked at runtime ("syscall" instruction
* with its service number stored in register $v0), its simulate()
* method will be invoked.
*
*/
public abstract class AbstractSyscall implements Syscall {
private int serviceNumber;
private String serviceName;
/**
* Constructor is provided so subclass may initialize instance variables.
* @param number default assigned service number
* @param name service name which may be used for reference independent of number
*/
public AbstractSyscall(int number, String name) {
serviceNumber = number;
serviceName = name;
}
/**
* Return the name you have chosen for this syscall. This can be used by a MARS
* user to refer to the service when choosing to override its default service
* number in the configuration file.
* @return service name as a string
*/
public String getName() {
return serviceName;
}
/**
* Set the service number. This is provided to allow MARS implementer or user
* to override the default service number.
* @param num specified service number to override the default.
*/
public void setNumber(int num) {
serviceNumber = num;
}
/**
* Return the assigned service number. This is the number the MIPS programmer
* must store into $v0 before issuing the SYSCALL instruction.
* @return assigned service number
*/
public int getNumber() {
return serviceNumber;
}
/**
* Performs syscall function. It will be invoked when the service is invoked
* at simulation time. Service is identified by value stored in $v0.
* @param statement ProgramStatement object for this syscall instruction.
*/
public abstract void simulate(ProgramStatement statement)
throws ProcessingException;
}
EndOfTrackListener
package mars.mips.instructions.syscalls;
synchronized class EndOfTrackListener implements javax.sound.midi.MetaEventListener {
private boolean endedYet;
void EndOfTrackListener();
public synchronized void meta(javax.sound.midi.MetaMessage);
public synchronized void awaitEndOfTrack() throws InterruptedException;
}
RandomStreams
package mars.mips.instructions.syscalls;
public synchronized class RandomStreams {
static final java.util.HashMap randomStreams;
public void RandomStreams();
static void
}
mars/mips/instructions/syscalls/RandomStreams.java
mars/mips/instructions/syscalls/RandomStreams.java package mars.mips.instructions.syscalls;
import java.util.HashMap;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* This small class serves only to hold a static HashMap for storing
* random number generators for use by all the random number generator
* syscalls.
*/
public class RandomStreams {
/** Collection of pseudorandom number streams available for use in Rand-type syscalls.
* The streams are by default not seeded. */
static final HashMap randomStreams = new HashMap();
}
Syscall
package mars.mips.instructions.syscalls;
public abstract interface Syscall {
public abstract String getName();
public abstract void setNumber(int);
public abstract int getNumber();
public abstract void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/Syscall.java
mars/mips/instructions/syscalls/Syscall.java package mars.mips.instructions.syscalls;
import mars.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Interface for any MIPS syscall system service. A qualifying service
* must be a class in the mars.mips.instructions.syscalls package that
* implements the Syscall interface, must be compiled into a .class file,
* and its .class file must be in the same folder as Syscall.class.
* Mars will detect a qualifying syscall upon startup, create an instance
* using its no-argument constructor and add it to its syscall list.
* When its service is invoked at runtime (“syscall” instruction
* with its service number stored in register $v0), its simulate()
* method will be invoked.
*
*/
public interface Syscall {
/**
* Return a name you have chosen for this syscall. This can be used by a MARS
* user to refer to the service when choosing to override its default service
* number in the configuration file.
* @return service name as a string
*/
public abstract String getName();
/**
* Set the service number. This is provided to allow MARS implementer or user
* to override the default service number.
* @param num specified service number to override the default.
*/
public abstract void setNumber(int num);
/**
* Return the assigned service number. This is the number the MIPS programmer
* must store into $v0 before issuing the SYSCALL instruction.
* @return assigned service number
*/
public abstract int getNumber();
/**
* Performs syscall function. It will be invoked when the service is invoked
* at simulation time. Service is identified by value stored in $v0.
* @param statement ProgramStatement for this syscall statement.
*/
public abstract void simulate(ProgramStatement statement)
throws ProcessingException;
}
SyscallClose
package mars.mips.instructions.syscalls;
public synchronized class SyscallClose extends AbstractSyscall {
public void SyscallClose();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallClose.java
mars/mips/instructions/syscalls/SyscallClose.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to close file descriptor given in $a0.
*
*/
public class SyscallClose extends AbstractSyscall {
/**
* Build an instance of the Close syscall. Default service number
* is 16 and name is “Close”.
*/
public SyscallClose() {
super(16, “Close”);
}
/**
* Performs syscall function to close file descriptor given in $a0.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
SystemIO.closeFile(RegisterFile.getValue(4));
}
}
SyscallConfirmDialog
package mars.mips.instructions.syscalls;
public synchronized class SyscallConfirmDialog extends AbstractSyscall {
public void SyscallConfirmDialog();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallConfirmDialog.java
mars/mips/instructions/syscalls/SyscallConfirmDialog.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
import javax.swing.JOptionPane;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to display a message to user.
*
*/
public class SyscallConfirmDialog extends AbstractSyscall {
/**
* Build an instance of the syscall with its default service number and name.
*/
public SyscallConfirmDialog() {
super(50, “ConfirmDialog”);
}
/**
* System call to display a message to user.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// Input arguments: $a0 = address of null-terminated string that is the message to user
// Output: $a0 contains value of user-chosen option
// 0: Yes
// 1: No
// 2: Cancel
String message = new String(); // = “”;
int byteAddress = RegisterFile.getValue(4);
char ch[] = { ‘ ‘}; // Need an array to convert to String
try
{
ch[0] = (char) Globals.memory.getByte(byteAddress);
while (ch[0] != 0) // only uses single location ch[0]
{
message = message.concat(new String(ch)); // parameter to String constructor is a char[] array
byteAddress++;
ch[0] = (char) Globals.memory.getByte(byteAddress);
}
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
// update register $a0 with the value from showConfirmDialog.
// showConfirmDialog returns an int with one of three possible values:
// 0 —> meaning Yes
// 1 —> meaning No
// 2 —> meaning Cancel
RegisterFile.updateRegister(4, JOptionPane.showConfirmDialog(null, message) );
}
}
SyscallExit
package mars.mips.instructions.syscalls;
public synchronized class SyscallExit extends AbstractSyscall {
public void SyscallExit();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallExit.java
mars/mips/instructions/syscalls/SyscallExit.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to exit the MIPS program.
*
*/
public class SyscallExit extends AbstractSyscall {
/**
* Build an instance of the Exit syscall. Default service number
* is 10 and name is “Exit”.
*/
public SyscallExit() {
super(10, “Exit”);
}
/**
* Performs syscall function to exit the MIPS program.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
throw new ProcessingException(); // empty exception list.
}
}
SyscallExit2
package mars.mips.instructions.syscalls;
public synchronized class SyscallExit2 extends AbstractSyscall {
public void SyscallExit2();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallExit2.java
mars/mips/instructions/syscalls/SyscallExit2.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.*;
import mars.mips.hardware.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to exit the MIPS program with return value given in $a0. Ignored if running from GUI.
*
*/
public class SyscallExit2 extends AbstractSyscall {
/**
* Build an instance of the Exit2 syscall. Default service number
* is 17 and name is “Exit2”.
*/
public SyscallExit2() {
super(17, “Exit2”);
}
/**
* Performs syscall function to exit the MIPS program with return value given in $a0.
* If running in command mode, MARS will exit with that value. If running under GUI,
* return value is ignored.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
if (Globals.getGui()==null) {
Globals.exitCode = RegisterFile.getValue(4);
}
throw new ProcessingException(); // empty error list
}
}
SyscallInputDialogDouble
package mars.mips.instructions.syscalls;
public synchronized class SyscallInputDialogDouble extends AbstractSyscall {
public void SyscallInputDialogDouble();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallInputDialogDouble.java
mars/mips/instructions/syscalls/SyscallInputDialogDouble.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
import javax.swing.JOptionPane;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to input data.
*
*/
public class SyscallInputDialogDouble extends AbstractSyscall {
/**
* Build an instance of the syscall with its default service number and name.
*/
public SyscallInputDialogDouble() {
super(53, “InputDialogDouble”);
}
/**
* System call to input data.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// Input arguments: $a0 = address of null-terminated string that is the message to user
// Outputs:
// $f0 and $f1 contains value of double read. $f1 contains high order word of the double.
// $a1 contains status value
// 0: valid input data, correctly parsed
// -1: input data cannot be correctly parsed
// -2: Cancel was chosen
// -3: OK was chosen but no data had been input into field
String message = new String(); // = “”;
int byteAddress = RegisterFile.getValue(4);
char ch[] = { ‘ ‘}; // Need an array to convert to String
try
{
ch[0] = (char) Globals.memory.getByte(byteAddress);
while (ch[0] != 0) // only uses single location ch[0]
{
message = message.concat(new String(ch)); // parameter to String constructor is a char[] array
byteAddress++;
ch[0] = (char) Globals.memory.getByte(byteAddress);
}
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
// Values returned by Java’s InputDialog:
// A null return value means that “Cancel” was chosen rather than OK.
// An empty string returned (that is, inputValue.length() of zero)
// means that OK was chosen but no string was input.
String inputValue = null;
inputValue = JOptionPane.showInputDialog(message);
try
{
Coprocessor1.setRegisterPairToDouble(0, 0.0); // set $f0 to zero
if (inputValue == null) // Cancel was chosen
{
RegisterFile.updateRegister(5, -2 ); // set $a1 to -2 flag
}
else if (inputValue.length() == 0) // OK was chosen but there was no input
{
RegisterFile.updateRegister(5, -3 ); // set $a1 to -3 flag
}
else
{
double doubleValue = Double.parseDouble(inputValue);
// Successful parse of valid input data
Coprocessor1.setRegisterPairToDouble(0, doubleValue); // set $f0 to input data
RegisterFile.updateRegister(5, 0 ); // set $a1 to valid flag
}
} // end try block
catch (InvalidRegisterAccessException e) // register ID error in this method
{
RegisterFile.updateRegister(5, -1 ); // set $a1 to -1 flag
throw new ProcessingException(statement,
“invalid int reg. access during double input (syscall “+this.getNumber()+”)”,
Exceptions.SYSCALL_EXCEPTION);
}
catch ( NumberFormatException e) // Unsuccessful parse of input data
{
RegisterFile.updateRegister(5, -1 ); // set $a1 to -1 flag
/* Don’t throw exception because returning a status flag
throw new ProcessingException(statement,
“invalid float input (syscall “+this.getNumber()+”)”,
Exceptions.SYSCALL_EXCEPTION);
*/
}
}
}
SyscallInputDialogFloat
package mars.mips.instructions.syscalls;
public synchronized class SyscallInputDialogFloat extends AbstractSyscall {
public void SyscallInputDialogFloat();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallInputDialogFloat.java
mars/mips/instructions/syscalls/SyscallInputDialogFloat.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
import javax.swing.JOptionPane;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to input data.
*
*/
public class SyscallInputDialogFloat extends AbstractSyscall {
/**
* Build an instance of the syscall with its default service number and name.
*/
public SyscallInputDialogFloat() {
super(52, “InputDialogFloat”);
}
/**
* System call to input data.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// Input arguments: $a0 = address of null-terminated string that is the message to user
// Outputs:
// $f0 contains value of float read
// $a1 contains status value
// 0: valid input data, correctly parsed
// -1: input data cannot be correctly parsed
// -2: Cancel was chosen
// -3: OK was chosen but no data had been input into field
String message = new String(); // = “”;
int byteAddress = RegisterFile.getValue(4);
char ch[] = { ‘ ‘}; // Need an array to convert to String
try
{
ch[0] = (char) Globals.memory.getByte(byteAddress);
while (ch[0] != 0) // only uses single location ch[0]
{
message = message.concat(new String(ch)); // parameter to String constructor is a char[] array
byteAddress++;
ch[0] = (char) Globals.memory.getByte(byteAddress);
}
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
// Values returned by Java’s InputDialog:
// A null return value means that “Cancel” was chosen rather than OK.
// An empty string returned (that is, inputValue.length() of zero)
// means that OK was chosen but no string was input.
String inputValue = null;
inputValue = JOptionPane.showInputDialog(message);
try
{
Coprocessor1.setRegisterToFloat(0, (float)0.0); // set $f0 to zero
if (inputValue == null) // Cancel was chosen
{
RegisterFile.updateRegister(5, -2 ); // set $a1 to -2 flag
}
else if (inputValue.length() == 0) // OK was chosen but there was no input
{
RegisterFile.updateRegister(5, -3 ); // set $a1 to -3 flag
}
else
{
float floatValue = Float.parseFloat(inputValue);
//System.out.println(“SyscallInputDialogFloat: floatValue is ” + floatValue);
// Successful parse of valid input data
Coprocessor1.setRegisterToFloat(0, floatValue); // set $f0 to input data
RegisterFile.updateRegister(5, 0 ); // set $a1 to valid flag
}
} // end try block
catch ( NumberFormatException e) // Unsuccessful parse of input data
{
RegisterFile.updateRegister(5, -1 ); // set $a1 to -1 flag
/* Don’t throw exception because returning a status flag
throw new ProcessingException(statement,
“invalid float input (syscall “+this.getNumber()+”)”,
Exceptions.SYSCALL_EXCEPTION);
*/
}
}
}
SyscallInputDialogInt
package mars.mips.instructions.syscalls;
public synchronized class SyscallInputDialogInt extends AbstractSyscall {
public void SyscallInputDialogInt();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallInputDialogInt.java
mars/mips/instructions/syscalls/SyscallInputDialogInt.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
import javax.swing.JOptionPane;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to input data.
*
*/
public class SyscallInputDialogInt extends AbstractSyscall {
/**
* Build an instance of the syscall with its default service number and name.
*/
public SyscallInputDialogInt() {
super(51, “InputDialogInt”);
}
/**
* System call to input data.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// Input arguments: $a0 = address of null-terminated string that is the message to user
// Outputs:
// $a0 contains value of int read
// $a1 contains status value
// 0: valid input data, correctly parsed
// -1: input data cannot be correctly parsed
// -2: Cancel was chosen
// -3: OK was chosen but no data had been input into field
String message = new String(); // = “”;
int byteAddress = RegisterFile.getValue(4);
char ch[] = { ‘ ‘}; // Need an array to convert to String
try
{
ch[0] = (char) Globals.memory.getByte(byteAddress);
while (ch[0] != 0) // only uses single location ch[0]
{
message = message.concat(new String(ch)); // parameter to String constructor is a char[] array
byteAddress++;
ch[0] = (char) Globals.memory.getByte(byteAddress);
}
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
// Values returned by Java’s InputDialog:
// A null return value means that “Cancel” was chosen rather than OK.
// An empty string returned (that is, inputValue.length() of zero)
// means that OK was chosen but no string was input.
String inputValue = null;
inputValue = JOptionPane.showInputDialog(message);
if (inputValue == null) // Cancel was chosen
{
RegisterFile.updateRegister(4, 0 ); // set $a0 to zero
RegisterFile.updateRegister(5, -2 ); // set $a1 to -2 flag
}
else if (inputValue.length() == 0) // OK was chosen but there was no input
{
RegisterFile.updateRegister(4, 0 ); // set $a0 to zero
RegisterFile.updateRegister(5, -3 ); // set $a1 to -3 flag
}
else
{
try
{
int i = Integer.parseInt(inputValue);
// Successful parse of valid input data
RegisterFile.updateRegister(4, i ); // set $a0 to the data read
RegisterFile.updateRegister(5, 0 ); // set $a1 to valid flag
}
catch ( NumberFormatException e)
{
// Unsuccessful parse of input data
RegisterFile.updateRegister(4, 0 ); // set $a0 to zero
RegisterFile.updateRegister(5, -1 ); // set $a1 to -1 flag
}
} // end else
}
}
SyscallInputDialogString
package mars.mips.instructions.syscalls;
public synchronized class SyscallInputDialogString extends AbstractSyscall {
public void SyscallInputDialogString();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallInputDialogString.java
mars/mips/instructions/syscalls/SyscallInputDialogString.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
import javax.swing.JOptionPane;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to input data.
*
*/
public class SyscallInputDialogString extends AbstractSyscall {
/**
* Build an instance of the syscall with its default service number and name.
*/
public SyscallInputDialogString() {
super(54, “InputDialogString”);
}
/**
* System call to input data.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// Input arguments:
// $a0 = address of null-terminated string that is the message to user
// $a1 = address of input buffer for the input string
// $a2 = maximum number of characters to read
// Outputs:
// $a1 contains status value
// 0: valid input data, correctly parsed
// -1: input data cannot be correctly parsed
// -2: Cancel was chosen
// -3: OK was chosen but no data had been input into field
String message = new String(); // = “”;
int byteAddress = RegisterFile.getValue(4); // byteAddress of string is in $a0
char ch[] = { ‘ ‘}; // Need an array to convert to String
try
{
ch[0] = (char) Globals.memory.getByte(byteAddress);
while (ch[0] != 0) // only uses single location ch[0]
{
message = message.concat(new String(ch)); // parameter to String constructor is a char[] array
byteAddress++;
ch[0] = (char) Globals.memory.getByte(byteAddress);
}
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
// Values returned by Java’s InputDialog:
// A null return value means that “Cancel” was chosen rather than OK.
// An empty string returned (that is, inputString.length() of zero)
// means that OK was chosen but no string was input.
String inputString = null;
inputString = JOptionPane.showInputDialog(message);
byteAddress = RegisterFile.getValue(5); // byteAddress of string is in $a1
int maxLength = RegisterFile.getValue(6); // input buffer size for input string is in $a2
try
{
if (inputString == null) // Cancel was chosen
{
RegisterFile.updateRegister(5, -2 ); // set $a1 to -2 flag
}
else if (inputString.length() == 0) // OK was chosen but there was no input
{
RegisterFile.updateRegister(5, -3 ); // set $a1 to -3 flag
}
else
{
// The buffer will contain characters, a ‘\n’ character, and the null character
// Copy the input data to buffer as space permits
for (int index = 0; (index < inputString.length()) && (index < maxLength - 1); index++)
{
Globals.memory.setByte(byteAddress + index,
inputString.charAt(index));
}
if (inputString.length() < maxLength-1)
{
Globals.memory.setByte(byteAddress + (int)Math.min(inputString.length(), maxLength-2), '\n'); // newline at string end
}
Globals.memory.setByte(byteAddress + (int)Math.min((inputString.length()+1), maxLength-1), 0); // null char to end string
if (inputString.length() > maxLength – 1)
{
// length of the input string exceeded the specified maximum
RegisterFile.updateRegister(5, -4 ); // set $a1 to -4 flag
}
else
{
RegisterFile.updateRegister(5, 0 ); // set $a1 to 0 flag
}
} // end else
} // end try
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}
SyscallMessageDialog
package mars.mips.instructions.syscalls;
public synchronized class SyscallMessageDialog extends AbstractSyscall {
public void SyscallMessageDialog();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallMessageDialog.java
mars/mips/instructions/syscalls/SyscallMessageDialog.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
import javax.swing.JOptionPane;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to display a message to user.
*
*/
public class SyscallMessageDialog extends AbstractSyscall {
/**
* Build an instance of the syscall with its default service number and name.
*/
public SyscallMessageDialog() {
super(55, “MessageDialog”);
}
/**
* System call to display a message to user.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// Input arguments:
// $a0 = address of null-terminated string that is the message to user
// $a1 = the type of the message to the user, which is one of:
// 1: error message
// 2: information message
// 3: warning message
// 4: question message
// other: plain message
// Output: none
String message = new String(); // = “”;
int byteAddress = RegisterFile.getValue(4);
char ch[] = { ‘ ‘}; // Need an array to convert to String
try
{
ch[0] = (char) Globals.memory.getByte(byteAddress);
while (ch[0] != 0) // only uses single location ch[0]
{
message = message.concat(new String(ch)); // parameter to String constructor is a char[] array
byteAddress++;
ch[0] = (char) Globals.memory.getByte(byteAddress);
}
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
// Display the dialog.
int msgType = RegisterFile.getValue(5);
if (msgType < 0 || msgType > 3) msgType = -1; // See values in http://java.sun.com/j2se/1.5.0/docs/api/constant-values.html
JOptionPane.showMessageDialog(null, message, null, msgType );
}
}
SyscallMessageDialogDouble
package mars.mips.instructions.syscalls;
public synchronized class SyscallMessageDialogDouble extends AbstractSyscall {
public void SyscallMessageDialogDouble();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallMessageDialogDouble.java
mars/mips/instructions/syscalls/SyscallMessageDialogDouble.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
import javax.swing.JOptionPane;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to display a message to user.
*
*/
public class SyscallMessageDialogDouble extends AbstractSyscall {
/**
* Build an instance of the syscall with its default service number and name.
*/
public SyscallMessageDialogDouble() {
super(58, “MessageDialogDouble”);
}
/**
* System call to display a message to user.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// Input arguments:
// $a0 = address of null-terminated string that is an information-type message to user
// $f12 = double value to display in string form after the first message
// Output: none
String message = new String(); // = “”;
int byteAddress = RegisterFile.getValue(4);
char ch[] = { ‘ ‘}; // Need an array to convert to String
try
{
ch[0] = (char) Globals.memory.getByte(byteAddress);
while (ch[0] != 0) // only uses single location ch[0]
{
message = message.concat(new String(ch)); // parameter to String constructor is a char[] array
byteAddress++;
ch[0] = (char) Globals.memory.getByte(byteAddress);
}
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
// Display the dialog.
try
{
JOptionPane.showMessageDialog(null,
message + Double.toString( Coprocessor1.getDoubleFromRegisterPair(“$f12”) ),
null,
JOptionPane.INFORMATION_MESSAGE );
}
catch (InvalidRegisterAccessException e) // register ID error in this method
{
RegisterFile.updateRegister(5, -1 ); // set $a1 to -1 flag
throw new ProcessingException(statement,
“invalid int reg. access during double input (syscall “+this.getNumber()+”)”,
Exceptions.SYSCALL_EXCEPTION);
}
}
}
SyscallMessageDialogFloat
package mars.mips.instructions.syscalls;
public synchronized class SyscallMessageDialogFloat extends AbstractSyscall {
public void SyscallMessageDialogFloat();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallMessageDialogFloat.java
mars/mips/instructions/syscalls/SyscallMessageDialogFloat.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
import javax.swing.JOptionPane;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to display a message to user.
*
*/
public class SyscallMessageDialogFloat extends AbstractSyscall {
/**
* Build an instance of the syscall with its default service number and name.
*/
public SyscallMessageDialogFloat() {
super(57, “MessageDialogFloat”);
}
/**
* System call to display a message to user.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// Input arguments:
// $a0 = address of null-terminated string that is an information-type message to user
// $f12 = float value to display in string form after the first message
// Output: none
String message = new String(); // = “”;
int byteAddress = RegisterFile.getValue(4);
char ch[] = { ‘ ‘}; // Need an array to convert to String
try
{
ch[0] = (char) Globals.memory.getByte(byteAddress);
while (ch[0] != 0) // only uses single location ch[0]
{
message = message.concat(new String(ch)); // parameter to String constructor is a char[] array
byteAddress++;
ch[0] = (char) Globals.memory.getByte(byteAddress);
}
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
// Display the dialog.
JOptionPane.showMessageDialog(null,
message + Float.toString( Coprocessor1.getFloatFromRegister(“$f12”) ),
null,
JOptionPane.INFORMATION_MESSAGE );
}
}
SyscallMessageDialogInt
package mars.mips.instructions.syscalls;
public synchronized class SyscallMessageDialogInt extends AbstractSyscall {
public void SyscallMessageDialogInt();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallMessageDialogInt.java
mars/mips/instructions/syscalls/SyscallMessageDialogInt.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
import javax.swing.JOptionPane;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to display a message to user.
*
*/
public class SyscallMessageDialogInt extends AbstractSyscall {
/**
* Build an instance of the syscall with its default service number and name.
*/
public SyscallMessageDialogInt() {
super(56, “MessageDialogInt”);
}
/**
* System call to display a message to user.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// Input arguments:
// $a0 = address of null-terminated string that is an information-type message to user
// $a1 = int value to display in string form after the first message
// Output: none
String message = new String(); // = “”;
int byteAddress = RegisterFile.getValue(4);
char ch[] = { ‘ ‘}; // Need an array to convert to String
try
{
ch[0] = (char) Globals.memory.getByte(byteAddress);
while (ch[0] != 0) // only uses single location ch[0]
{
message = message.concat(new String(ch)); // parameter to String constructor is a char[] array
byteAddress++;
ch[0] = (char) Globals.memory.getByte(byteAddress);
}
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
// Display the dialog.
JOptionPane.showMessageDialog(null,
message + Integer.toString(RegisterFile.getValue(5)),
null,
JOptionPane.INFORMATION_MESSAGE );
}
}
SyscallMessageDialogString
package mars.mips.instructions.syscalls;
public synchronized class SyscallMessageDialogString extends AbstractSyscall {
public void SyscallMessageDialogString();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallMessageDialogString.java
mars/mips/instructions/syscalls/SyscallMessageDialogString.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
import javax.swing.JOptionPane;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to display a message to user.
*
*/
public class SyscallMessageDialogString extends AbstractSyscall {
/**
* Build an instance of the syscall with its default service number and name.
*/
public SyscallMessageDialogString() {
super(59, “MessageDialogString”);
}
/**
* System call to display a message to user.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// Input arguments:
// $a0 = address of null-terminated string that is an information-type message to user
// $a1 = address of null-terminated string to display after the first message
// Output: none
String message = new String(); // = “”;
int byteAddress = RegisterFile.getValue(4);
char ch[] = { ‘ ‘}; // Need an array to convert to String
try
{
ch[0] = (char) Globals.memory.getByte(byteAddress);
while (ch[0] != 0) // only uses single location ch[0]
{
message = message.concat(new String(ch)); // parameter to String constructor is a char[] array
byteAddress++;
ch[0] = (char) Globals.memory.getByte(byteAddress);
}
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
String message2 = new String(); // = “”;
byteAddress = RegisterFile.getValue(5);
try
{
ch[0] = (char) Globals.memory.getByte(byteAddress);
while (ch[0] != 0) // only uses single location ch[0]
{
message2 = message2.concat(new String(ch)); // parameter to String constructor is a char[] array
byteAddress++;
ch[0] = (char) Globals.memory.getByte(byteAddress);
}
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
// Display the dialog.
JOptionPane.showMessageDialog(null,
message + message2,
null,
JOptionPane.INFORMATION_MESSAGE );
}
}
SyscallMidiOut
package mars.mips.instructions.syscalls;
public synchronized class SyscallMidiOut extends AbstractSyscall {
static final int rangeLowEnd = 0;
static final int rangeHighEnd = 127;
public void SyscallMidiOut();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallMidiOut.java
mars/mips/instructions/syscalls/SyscallMidiOut.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
/*
Copyright (c) 2003-2009, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to output simulated MIDI tone to sound card. The call returns
* immediately upon generating the tone. By contrast, syscall 33
* (MidiOutSync) does not return until tone duration has elapsed.
*/
public class SyscallMidiOut extends AbstractSyscall {
// Endpoints of ranges for the three “byte” parameters. The duration
// parameter is limited at the high end only by the int range.
static final int rangeLowEnd = 0;
static final int rangeHighEnd = 127;
/**
* Build an instance of the MIDI (simulated) out syscall. Default service number
* is 31 and name is “MidiOut”.
*/
public SyscallMidiOut() {
super(31, “MidiOut”);
}
/**
* Performs syscall function to send MIDI output to sound card. This requires
* four arguments in registers $a0 through $a3.
* $a0 – pitch (note). Integer value from 0 to 127, with 60 being middle-C on a piano.
* $a1 – duration. Integer value in milliseconds.
* $a2 – instrument. Integer value from 0 to 127, with 0 being acoustic grand piano.
* $a3 – volume. Integer value from 0 to 127.
* Default values, in case any parameters are outside the above ranges, are $a0=60, $a1=1000,
* $a2=0, $a3=100.
* See MARS documentation elsewhere or www.midi.org for more information. Note that the pitch,
* instrument and volume value ranges 0-127 are from javax.sound.midi; actual MIDI instruments
* use the range 1-128.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
int pitch = RegisterFile.getValue(4); // $a0
int duration = RegisterFile.getValue(5); // $a1
int instrument = RegisterFile.getValue(6); // $a2
int volume = RegisterFile.getValue(7); // $a3
if (pitch < rangeLowEnd || pitch > rangeHighEnd) pitch = ToneGenerator.DEFAULT_PITCH;
if (duration < 0) duration = ToneGenerator.DEFAULT_DURATION;
if (instrument < rangeLowEnd || instrument > rangeHighEnd) instrument = ToneGenerator.DEFAULT_INSTRUMENT;
if (volume < rangeLowEnd || volume > rangeHighEnd) volume = ToneGenerator.DEFAULT_VOLUME;
new ToneGenerator().generateTone( (byte) pitch, duration, (byte) instrument, (byte) volume);
}
}
SyscallMidiOutSync
package mars.mips.instructions.syscalls;
public synchronized class SyscallMidiOutSync extends AbstractSyscall {
static final int rangeLowEnd = 0;
static final int rangeHighEnd = 127;
public void SyscallMidiOutSync();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallMidiOutSync.java
mars/mips/instructions/syscalls/SyscallMidiOutSync.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
/*
Copyright (c) 2003-2007, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Modified 2009-10-19 by Max Hailperin
to use a specific method for synchronously generating
a tone, rather than using an asyncronous method followed
by a Thread.sleep, because sleeping isn’t a reliable
synchronization method — depending on thread scheduling,
the actual tone generation could have been delayed, in
which case the tone might still be playing when the
sleep ended.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to output simulated MIDI tone to sound card. The call does
* not return until the tone duration has elapsed. By contrast, syscall 31
* (MidiOut) returns immediately upon generating the tone.
*
*/
public class SyscallMidiOutSync extends AbstractSyscall {
// Endpoints of ranges for the three “byte” parameters. The duration
// parameter is limited at the high end only by the int range.
static final int rangeLowEnd = 0;
static final int rangeHighEnd = 127;
/**
* Build an instance of the MIDI (simulated) out syscall. Default service number
* is 33 and name is “MidiOutSync”.
*/
public SyscallMidiOutSync() {
super(33, “MidiOutSync”);
}
/**
* Performs syscall function to send MIDI output to sound card. The syscall does not
* return until after the duration period ($a1) has elapsed. This requires
* four arguments in registers $a0 through $a3.
* $a0 – pitch (note). Integer value from 0 to 127, with 60 being middle-C on a piano.
* $a1 – duration. Integer value in milliseconds.
* $a2 – instrument. Integer value from 0 to 127, with 0 being acoustic grand piano.
* $a3 – volume. Integer value from 0 to 127.
* Default values, in case any parameters are outside the above ranges, are $a0=60, $a1=1000,
* $a2=0, $a3=100.
* See MARS documentation elsewhere or www.midi.org for more information. Note that the pitch,
* instrument and volume value ranges 0-127 are from javax.sound.midi; actual MIDI instruments
* use the range 1-128.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
int pitch = RegisterFile.getValue(4); // $a0
int duration = RegisterFile.getValue(5); // $a1
int instrument = RegisterFile.getValue(6); // $a2
int volume = RegisterFile.getValue(7); // $a3
if (pitch < rangeLowEnd || pitch > rangeHighEnd) pitch = ToneGenerator.DEFAULT_PITCH;
if (duration < 0) duration = ToneGenerator.DEFAULT_DURATION;
if (instrument < rangeLowEnd || instrument > rangeHighEnd) instrument = ToneGenerator.DEFAULT_INSTRUMENT;
if (volume < rangeLowEnd || volume > rangeHighEnd) volume = ToneGenerator.DEFAULT_VOLUME;
new ToneGenerator().generateToneSynchronously( (byte) pitch, duration, (byte) instrument, (byte) volume);
}
}
SyscallNumberOverride
package mars.mips.instructions.syscalls;
public synchronized class SyscallNumberOverride {
private String serviceName;
private int newServiceNumber;
public void SyscallNumberOverride(String, String);
public String getName();
public int getNumber();
}
mars/mips/instructions/syscalls/SyscallNumberOverride.java
mars/mips/instructions/syscalls/SyscallNumberOverride.java package mars.mips.instructions.syscalls;
import java.util.*;
import mars.util.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Represents User override of default syscall number assignment.
* Such overrides are specified in the config.txt file read when
* MARS starts up.
*/
public class SyscallNumberOverride {
private String serviceName;
private int newServiceNumber;
/**
* Constructor is called with two strings: service name and desired
* number. Will throw an exception is number is malformed, but does
* not check validity of the service name or number.
* @param serviceName a String containing syscall service mnemonic.
* @param value a String containing its reassigned syscall service number.
* If this number is previously assigned to a different syscall which does not
* also receive a new number, then an error for duplicate numbers will
* be issued at MARS launch.
*/
public SyscallNumberOverride(String serviceName, String value) {
this.serviceName = serviceName;
try {
this.newServiceNumber = Integer.parseInt(value.trim());
}
catch (NumberFormatException e) {
System.out.println(“Error processing Syscall number override: ‘”+value.trim()+”‘ is not a valid integer”);
System.exit(0);
}
}
/**
* Get the service name as a String.
* @return the service name
*/
public String getName() {
return serviceName;
}
/**
* Get the new service number as an int.
* @return the service number
*/
public int getNumber() {
return newServiceNumber;
}
}
SyscallOpen
package mars.mips.instructions.syscalls;
public synchronized class SyscallOpen extends AbstractSyscall {
public void SyscallOpen();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallOpen.java
mars/mips/instructions/syscalls/SyscallOpen.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to open file name specified by $a0. File descriptor returned in $v0.
* (this was changed from $a0 in MARS 3.7 for SPIM compatibility. The table
* in COD erroneously shows $a0).
*
*/
public class SyscallOpen extends AbstractSyscall {
/**
* Build an instance of the Open file syscall. Default service number
* is 13 and name is “Open”.
*/
public SyscallOpen() {
super(13, “Open”);
}
/**
* Performs syscall function to open file name specified by $a0. File descriptor returned
* in $v0. Only supported flags ($a1) are read-only (0), write-only (1) and
* write-append (9). write-only flag creates file if it does not exist, so it is technically
* write-create. write-append will start writing at end of existing file.
* Mode ($a2) is ignored.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// NOTE: with MARS 3.7, return changed from $a0 to $v0 and the terminology
// of ‘flags’ and ‘mode’ was corrected (they had been reversed).
//
// Arguments: $a0 = filename (string), $a1 = flags, $a2 = mode
// Result: file descriptor (in $v0)
// This code implements the flags:
// Read flag = 0
// Write flag = 1
// Read/Write NOT IMPLEMENTED
// Write/append flag = 9
// This code implements the modes:
// NO MODES IMPLEMENTED — MODE IS IGNORED
// Returns in $v0: a “file descriptor” in the range 0 to SystemIO.SYSCALL_MAXFILES-1,
// or -1 if error
String filename = new String(); // = “”;
int byteAddress = RegisterFile.getValue(4);
char ch[] = { ‘ ‘}; // Need an array to convert to String
try
{
ch[0] = (char) Globals.memory.getByte(byteAddress);
while (ch[0] != 0) // only uses single location ch[0]
{
filename = filename.concat(new String(ch)); // parameter to String constructor is a char[] array
byteAddress++;
ch[0] = (char) Globals.memory.getByte(
byteAddress);
}
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
int retValue = SystemIO.openFile(filename,
RegisterFile.getValue(5));
RegisterFile.updateRegister(2, retValue); // set returned fd value in register
// GETTING RID OF PROCESSING EXCEPTION. IT IS THE RESPONSIBILITY OF THE
// USER PROGRAM TO CHECK FOR BAD FILE OPEN. MARS SHOULD NOT PRE-EMPTIVELY
// TERMINATE MIPS EXECUTION BECAUSE OF IT. Thanks to UCLA student
// Duy Truong for pointing this out. DPS 28-July-2009.
/*
if (retValue < 0) // some error in opening file
{
throw new ProcessingException(statement,
SystemIO.getFileErrorMessage()+" (syscall "+this.getNumber()+")",
Exceptions.SYSCALL_EXCEPTION);
}
*/
}
}
SyscallPrintChar
package mars.mips.instructions.syscalls;
public synchronized class SyscallPrintChar extends AbstractSyscall {
public void SyscallPrintChar();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallPrintChar.java
mars/mips/instructions/syscalls/SyscallPrintChar.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to display character stored in $a0 on the console.
*
*/
public class SyscallPrintChar extends AbstractSyscall {
/**
* Build an instance of the Print Char syscall. Default service number
* is 11 and name is "PrintChar".
*/
public SyscallPrintChar() {
super(11, "PrintChar");
}
/**
* Performs syscall function to print on the console the character stored in $a0.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// mask off the lower byte of register $a0.
// Convert to a one-character string and use the string technique.
char t = (char) (RegisterFile.getValue(4) & 0x000000ff);
SystemIO.printString(new Character(t).toString());
}
}
SyscallPrintDouble
package mars.mips.instructions.syscalls;
public synchronized class SyscallPrintDouble extends AbstractSyscall {
public void SyscallPrintDouble();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallPrintDouble.java
mars/mips/instructions/syscalls/SyscallPrintDouble.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to display double whose bits are stored in $f12 & $f13 onto the console.
* $f13 contains high order word of the double.
*/
public class SyscallPrintDouble extends AbstractSyscall {
/**
* Build an instance of the Print Double syscall. Default service number
* is 3 and name is "PrintDouble".
*/
public SyscallPrintDouble() {
super(3, "PrintDouble");
}
/**
* Performs syscall function to print double whose bits are stored in $f12 & $f13.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// Note: Higher numbered reg contains high order word so concat 13-12.
SystemIO.printString(new Double(Double.longBitsToDouble(
Binary.twoIntsToLong(Coprocessor1.getValue(13),Coprocessor1.getValue(12))
)).toString());
}
}
SyscallPrintFloat
package mars.mips.instructions.syscalls;
public synchronized class SyscallPrintFloat extends AbstractSyscall {
public void SyscallPrintFloat();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallPrintFloat.java
mars/mips/instructions/syscalls/SyscallPrintFloat.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to display on the console float whose bits are stored in $f12
*/
public class SyscallPrintFloat extends AbstractSyscall {
/**
* Build an instance of the Print Float syscall. Default service number
* is 2 and name is "PrintFloat".
*/
public SyscallPrintFloat() {
super(2, "PrintFloat");
}
/**
* Performs syscall function to display float whose bits are stored in $f12
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
SystemIO.printString(new Float(Float.intBitsToFloat(
Coprocessor1.getValue(12))).toString());
}
}
SyscallPrintInt
package mars.mips.instructions.syscalls;
public synchronized class SyscallPrintInt extends AbstractSyscall {
public void SyscallPrintInt();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallPrintInt.java
mars/mips/instructions/syscalls/SyscallPrintInt.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to display integer stored in $a0 on the console.
*
*/
public class SyscallPrintInt extends AbstractSyscall {
/**
* Build an instance of the Print Integer syscall. Default service number
* is 1 and name is "PrintInt".
*/
public SyscallPrintInt() {
super(1, "PrintInt");
}
/**
* Performs syscall function to print on the console the integer stored in $a0.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
SystemIO.printString(
new Integer(RegisterFile.getValue(4)).toString());
}
}
SyscallPrintIntBinary
package mars.mips.instructions.syscalls;
public synchronized class SyscallPrintIntBinary extends AbstractSyscall {
public void SyscallPrintIntBinary();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallPrintIntBinary.java
mars/mips/instructions/syscalls/SyscallPrintIntBinary.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.*;
/*
Copyright (c) 2003-2009, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to display integer stored in $a0 on the console.
*
*/
public class SyscallPrintIntBinary extends AbstractSyscall {
/**
* Build an instance of the Print Integer syscall. Default service number
* is 1 and name is "PrintInt".
*/
public SyscallPrintIntBinary() {
super(35, "PrintIntBinary");
}
/**
* Performs syscall function to print on the console the integer stored in $a0, in hexadecimal format.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
SystemIO.printString(Binary.intToBinaryString(RegisterFile.getValue(4)));
}
}
SyscallPrintIntHex
package mars.mips.instructions.syscalls;
public synchronized class SyscallPrintIntHex extends AbstractSyscall {
public void SyscallPrintIntHex();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallPrintIntHex.java
mars/mips/instructions/syscalls/SyscallPrintIntHex.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.*;
/*
Copyright (c) 2003-2009, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to display integer stored in $a0 on the console.
*
*/
public class SyscallPrintIntHex extends AbstractSyscall {
/**
* Build an instance of the Print Integer syscall. Default service number
* is 1 and name is "PrintInt".
*/
public SyscallPrintIntHex() {
super(34, "PrintIntHex");
}
/**
* Performs syscall function to print on the console the integer stored in $a0, in hexadecimal format.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
SystemIO.printString(Binary.intToHexString(RegisterFile.getValue(4)));
}
}
SyscallPrintIntUnsigned
package mars.mips.instructions.syscalls;
public synchronized class SyscallPrintIntUnsigned extends AbstractSyscall {
public void SyscallPrintIntUnsigned();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallPrintIntUnsigned.java
mars/mips/instructions/syscalls/SyscallPrintIntUnsigned.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.*;
/*
Copyright (c) 2003-2010, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to display integer stored in $a0 on the console as unsigned decimal.
*
*/
public class SyscallPrintIntUnsigned extends AbstractSyscall {
/**
* Build an instance of the Print Integer Unsigned syscall. Default service number
* is 36 and name is "PrintIntUnsigned".
*/
public SyscallPrintIntUnsigned() {
super(36, "PrintIntUnsigned");
}
/**
* Performs syscall function to print on the console the integer stored in $a0.
* The value is treated as unsigned.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
SystemIO.printString(
Binary.unsignedIntToIntString(RegisterFile.getValue(4)));
}
}
SyscallPrintString
package mars.mips.instructions.syscalls;
public synchronized class SyscallPrintString extends AbstractSyscall {
public void SyscallPrintString();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallPrintString.java
mars/mips/instructions/syscalls/SyscallPrintString.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to display string stored starting at address in $a0 onto the console.
*/
public class SyscallPrintString extends AbstractSyscall {
/**
* Build an instance of the Print String syscall. Default service number
* is 4 and name is "PrintString".
*/
public SyscallPrintString() {
super(4, "PrintString");
}
/**
* Performs syscall function to print string stored starting at address in $a0.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
int byteAddress = RegisterFile.getValue(4);
char ch = 0;
try
{
ch = (char) Globals.memory.getByte(byteAddress);
// won't stop until NULL byte reached!
while (ch != 0)
{
SystemIO.printString(new Character(ch).toString());
byteAddress++;
ch = (char) Globals.memory.getByte(byteAddress);
}
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}
SyscallRandDouble
package mars.mips.instructions.syscalls;
public synchronized class SyscallRandDouble extends AbstractSyscall {
public void SyscallRandDouble();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallRandDouble.java
mars/mips/instructions/syscalls/SyscallRandDouble.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
import java.util.Random;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to return a random floating point value.
*
*/
public class SyscallRandDouble extends AbstractSyscall {
/**
* Build an instance of the syscall with its default service number and name.
*/
public SyscallRandDouble() {
super(44, "RandDouble");
}
/**
* System call to the random number generator.
* Return in $f0 the next pseudorandom, uniformly distributed double value between 0.0 and 1.0
* from this random number generator's sequence.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// Input arguments: $a0 = index of pseudorandom number generator
// Return: $f0 = the next pseudorandom, uniformly distributed double value between 0.0 and 1.0
// from this random number generator's sequence.
Integer index = new Integer(RegisterFile.getValue(4));
Random stream = (Random) RandomStreams.randomStreams.get(index);
if (stream == null) {
stream = new Random(); // create a non-seeded stream
RandomStreams.randomStreams.put(index, stream);
}
try {
Coprocessor1.setRegisterPairToDouble(0, stream.nextDouble( ));
}
catch (InvalidRegisterAccessException e) { // register ID error in this method
throw new ProcessingException(statement,
"Internal error storing double to register (syscall "+this.getNumber()+")",
Exceptions.SYSCALL_EXCEPTION);
}
}
}
SyscallRandFloat
package mars.mips.instructions.syscalls;
public synchronized class SyscallRandFloat extends AbstractSyscall {
public void SyscallRandFloat();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallRandFloat.java
mars/mips/instructions/syscalls/SyscallRandFloat.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
import java.util.Random;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to return a random floating point value.
*
*/
public class SyscallRandFloat extends AbstractSyscall {
/**
* Build an instance of the syscall with its default service number and name.
*/
public SyscallRandFloat() {
super(43, "RandFloat");
}
/**
* System call to the random number generator.
* Return in $f0 the next pseudorandom, uniformly distributed float value between 0.0 and 1.0
* from this random number generator's sequence.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// Input arguments: $a0 = index of pseudorandom number generator
// Return: $f0 = the next pseudorandom, uniformly distributed float value between 0.0 and 1.0
// from this random number generator's sequence.
Integer index = new Integer(RegisterFile.getValue(4));
Random stream = (Random) RandomStreams.randomStreams.get(index);
if (stream == null) {
stream = new Random(); // create a non-seeded stream
RandomStreams.randomStreams.put(index, stream);
}
Coprocessor1.setRegisterToFloat(0, stream.nextFloat( ));
}
}
SyscallRandInt
package mars.mips.instructions.syscalls;
public synchronized class SyscallRandInt extends AbstractSyscall {
public void SyscallRandInt();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallRandInt.java
mars/mips/instructions/syscalls/SyscallRandInt.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
import java.util.Random;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to return a random integer.
*
*/
public class SyscallRandInt extends AbstractSyscall {
/**
* Build an instance of the syscall with its default service number and name.
*/
public SyscallRandInt() {
super(41, "RandInt");
}
/**
* System call to the random number generator.
* Return in $a0 the next pseudorandom, uniformly distributed int value from this random number generator's sequence.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// Input arguments: $a0 = index of pseudorandom number generator
// Return: $a0 = the next pseudorandom, uniformly distributed int value from this random number generator's sequence.
Integer index = new Integer(RegisterFile.getValue(4));
Random stream = (Random) RandomStreams.randomStreams.get(index);
if (stream == null) {
stream = new Random(); // create a non-seeded stream
RandomStreams.randomStreams.put(index, stream);
}
RegisterFile.updateRegister(4, stream.nextInt() );
}
}
SyscallRandIntRange
package mars.mips.instructions.syscalls;
public synchronized class SyscallRandIntRange extends AbstractSyscall {
public void SyscallRandIntRange();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallRandIntRange.java
mars/mips/instructions/syscalls/SyscallRandIntRange.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
import java.util.Random;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to return a random integer in a specified range.
*
*/
public class SyscallRandIntRange extends AbstractSyscall {
/**
* Build an instance of the syscall with its default service number and name.
*/
public SyscallRandIntRange() {
super(42, "RandIntRange");
}
/**
* System call to the random number generator, with an upper range specified.
* Return in $a0 the next pseudorandom, uniformly distributed int value between 0 (inclusive)
* and the specified value (exclusive), drawn from this random number generator's sequence.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// Input arguments:
// $a0 = index of pseudorandom number generator
// $a1 = the upper bound of range of returned values.
// Return: $a0 = the next pseudorandom, uniformly distributed int value from this
// random number generator's sequence.
Integer index = new Integer(RegisterFile.getValue(4));
Random stream = (Random) RandomStreams.randomStreams.get(index);
if (stream == null) {
stream = new Random(); // create a non-seeded stream
RandomStreams.randomStreams.put(index, stream);
}
try {
RegisterFile.updateRegister(4, stream.nextInt( RegisterFile.getValue(5) ) );
}
catch (IllegalArgumentException iae) {
throw new ProcessingException(statement,
"Upper bound of range cannot be negative (syscall "+this.getNumber()+")",
Exceptions.SYSCALL_EXCEPTION);
}
}
}
SyscallRandSeed
package mars.mips.instructions.syscalls;
public synchronized class SyscallRandSeed extends AbstractSyscall {
public void SyscallRandSeed();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallRandSeed.java
mars/mips/instructions/syscalls/SyscallRandSeed.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
import java.util.Random;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to set seed for the underlying Java pseudorandom number generator. No values are returned.
*
*/
public class SyscallRandSeed extends AbstractSyscall {
/**
* Build an instance of the syscall with its default service number and name.
*/
public SyscallRandSeed() {
super(40, "RandSeed");
}
/**
* Set the seed of the underlying Java pseudorandom number generator.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// Arguments: $a0 = index of pseudorandom number generator
// $a1 = seed for pseudorandom number generator.
// Result: No values are returned. Sets the seed of the underlying Java pseudorandom number generator.
Integer index = new Integer(RegisterFile.getValue(4));
Random stream = (Random) RandomStreams.randomStreams.get(index);
if (stream == null) {
RandomStreams.randomStreams.put(index, new Random(RegisterFile.getValue(5)));
} else {
stream.setSeed(RegisterFile.getValue(5));
}
}
}
SyscallRead
package mars.mips.instructions.syscalls;
public synchronized class SyscallRead extends AbstractSyscall {
public void SyscallRead();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallRead.java
mars/mips/instructions/syscalls/SyscallRead.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
/*
Copyright (c) 2003-2009, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to read from file descriptor given in $a0. $a1 specifies buffer
* and $a2 specifies length. Number of characters read is returned in $v0.
* (this was changed from $a0 in MARS 3.7 for SPIM compatibility. The table
* in COD erroneously shows $a0). *
*/
public class SyscallRead extends AbstractSyscall {
/**
* Build an instance of the Read file syscall. Default service number
* is 14 and name is "Read".
*/
public SyscallRead() {
super(14, "Read");
}
/**
* Performs syscall function to read from file descriptor given in $a0. $a1 specifies buffer
* and $a2 specifies length. Number of characters read is returned in $v0 (starting MARS 3.7).
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
int byteAddress = RegisterFile.getValue(5); // destination of characters read from file
byte b = 0;
int index = 0;
byte myBuffer[] = new byte[RegisterFile.getValue(6)]; // specified length
// Call to SystemIO.xxxx.read(xxx,xxx,xxx) returns actual length
int retLength = SystemIO.readFromFile(
RegisterFile.getValue(4), // fd
myBuffer, // buffer
RegisterFile.getValue(6)); // length
RegisterFile.updateRegister(2, retLength); // set returned value in register
// Getting rid of processing exception. It is the responsibility of the
// user program to check the syscall's return value. MARS should not
// re-emptively terminate MIPS execution because of it. Thanks to
// UCLA student Duy Truong for pointing this out. DPS 28-July-2009
/*
if (retLength < 0) // some error in opening file
{
throw new ProcessingException(statement,
SystemIO.getFileErrorMessage()+" (syscall 14)",
Exceptions.SYSCALL_EXCEPTION);
}
*/
// copy bytes from returned buffer into MARS memory
try
{
while (index < retLength)
{
Globals.memory.setByte(byteAddress++,
myBuffer[index++]);
}
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}
SyscallReadChar
package mars.mips.instructions.syscalls;
public synchronized class SyscallReadChar extends AbstractSyscall {
public void SyscallReadChar();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallReadChar.java
mars/mips/instructions/syscalls/SyscallReadChar.java package mars.mips.instructions.syscalls;
import mars.*;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to read a character from input console into $a0.
*
*/
public class SyscallReadChar extends AbstractSyscall {
/**
* Build an instance of the Read Char syscall. Default service number
* is 12 and name is "ReadChar".
*/
public SyscallReadChar() {
super(12, "ReadChar");
}
/**
* Performs syscall function to read a character from input console into $a0
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
int value = 0;
try
{
value = SystemIO.readChar(this.getNumber());
}
catch (IndexOutOfBoundsException e) // means null input
{
throw new ProcessingException(statement,
"invalid char input (syscall "+this.getNumber()+")",
Exceptions.SYSCALL_EXCEPTION);
}
// DPS 20 June 2008: changed from 4 ($a0) to 2 ($v0)
RegisterFile.updateRegister(2, value);
}
}
SyscallReadDouble
package mars.mips.instructions.syscalls;
public synchronized class SyscallReadDouble extends AbstractSyscall {
public void SyscallReadDouble();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallReadDouble.java
mars/mips/instructions/syscalls/SyscallReadDouble.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.simulator.*;
import mars.mips.hardware.*;
import mars.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to read the bits of console input double into $f0 and $f1.
* $f1 contains high order word of the double.
*/
public class SyscallReadDouble extends AbstractSyscall {
/**
* Build an instance of the Read Double syscall. Default service number
* is 7 and name is "ReadDouble".
*/
public SyscallReadDouble() {
super(7, "ReadDouble");
}
/**
* Performs syscall function to read the bits of input double into $f0 and $f1.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// Higher numbered reg contains high order word so order is $f1 - $f0.
double doubleValue = 0;
try
{
doubleValue = SystemIO.readDouble(this.getNumber());
}
catch (NumberFormatException e)
{
throw new ProcessingException(statement,
"invalid double input (syscall "+this.getNumber()+")",
Exceptions.SYSCALL_EXCEPTION);
}
long longValue = Double.doubleToRawLongBits(doubleValue);
Coprocessor1.updateRegister(1, Binary.highOrderLongToInt(longValue));
Coprocessor1.updateRegister(0, Binary.lowOrderLongToInt(longValue));
}
}
SyscallReadFloat
package mars.mips.instructions.syscalls;
public synchronized class SyscallReadFloat extends AbstractSyscall {
public void SyscallReadFloat();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallReadFloat.java
mars/mips/instructions/syscalls/SyscallReadFloat.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.simulator.*;
import mars.mips.hardware.*;
import mars.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to read the bits of input float into $f0
*/
public class SyscallReadFloat extends AbstractSyscall {
/**
* Build an instance of the Read Float syscall. Default service number
* is 6 and name is "ReadFloat".
*/
public SyscallReadFloat() {
super(6, "ReadFloat");
}
/**
* Performs syscall function to read the bits of input float into $f0
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
float floatValue = 0;
try
{
floatValue = SystemIO.readFloat(this.getNumber());
}
catch (NumberFormatException e)
{
throw new ProcessingException(statement,
"invalid float input (syscall "+this.getNumber()+")",
Exceptions.SYSCALL_EXCEPTION);
}
Coprocessor1.updateRegister(0, Float.floatToRawIntBits(floatValue));
}
}
SyscallReadInt
package mars.mips.instructions.syscalls;
public synchronized class SyscallReadInt extends AbstractSyscall {
public void SyscallReadInt();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallReadInt.java
mars/mips/instructions/syscalls/SyscallReadInt.java package mars.mips.instructions.syscalls;
import mars.*;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to read an integer from input console into $v0.
*
*/
public class SyscallReadInt extends AbstractSyscall {
/**
* Build an instance of the Read Integer syscall. Default service number
* is 5 and name is "ReadInt".
*/
public SyscallReadInt() {
super(5, "ReadInt");
}
/**
* Performs syscall function to read an integer from input console into $v0
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
int value = 0;
try
{
value = SystemIO.readInteger(this.getNumber());
}
catch (NumberFormatException e)
{
throw new ProcessingException(statement,
"invalid integer input (syscall "+this.getNumber()+")",
Exceptions.SYSCALL_EXCEPTION);
}
RegisterFile.updateRegister(2, value);
}
}
SyscallReadString
package mars.mips.instructions.syscalls;
public synchronized class SyscallReadString extends AbstractSyscall {
public void SyscallReadString();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallReadString.java
mars/mips/instructions/syscalls/SyscallReadString.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to read console input string into buffer starting at address in $a0.
*/
public class SyscallReadString extends AbstractSyscall {
/**
* Build an instance of the Read String syscall. Default service number
* is 8 and name is "ReadString".
*/
public SyscallReadString() {
super(8, "ReadString");
}
/**
* Performs syscall function to read console input string into buffer starting at address in $a0.
* Follows semantics of UNIX 'fgets'. For specified length n,
* string can be no longer than n-1. If less than that, add
* newline to end. In either case, then pad with null byte.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
String inputString = "";
int buf = RegisterFile.getValue(4); // buf addr in $a0
int maxLength = RegisterFile.getValue(5) - 1; // $a1
boolean addNullByte = true;
// Guard against negative maxLength. DPS 13-July-2011
if (maxLength < 0)
{
maxLength = 0;
addNullByte = false;
}
inputString = SystemIO.readString(this.getNumber(), maxLength);
int stringLength = Math.min(maxLength, inputString.length());
try
{
for (int index = 0; index < stringLength; index++)
{
Globals.memory.setByte(buf + index,
inputString.charAt(index));
}
if (stringLength < maxLength)
{
Globals.memory.setByte(buf + stringLength, '\n');
stringLength++;
}
if (addNullByte) Globals.memory.setByte(buf + stringLength, 0);
}
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
}
}
SyscallSbrk
package mars.mips.instructions.syscalls;
public synchronized class SyscallSbrk extends AbstractSyscall {
public void SyscallSbrk();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallSbrk.java
mars/mips/instructions/syscalls/SyscallSbrk.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.simulator.*;
import mars.mips.hardware.*;
import mars.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to allocate amount of heap memory specified in $a0, putting address into $v0.
*
*/
public class SyscallSbrk extends AbstractSyscall {
/**
* Build an instance of the Sbrk syscall. Default service number
* is 9 and name is "Sbrk".
*/
public SyscallSbrk() {
super(9, "Sbrk");
}
/**
* Performs syscall function to allocate amount of heap memory specified in $a0, putting address into $v0.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
int address = 0;
try {
address = Globals.memory.allocateBytesFromHeap(RegisterFile.getValue(4));
}
catch (IllegalArgumentException iae) {
throw new ProcessingException(statement,
iae.getMessage()+" (syscall "+this.getNumber()+")",
Exceptions.SYSCALL_EXCEPTION);
}
RegisterFile.updateRegister(2, address);
}
}
SyscallSleep
package mars.mips.instructions.syscalls;
public synchronized class SyscallSleep extends AbstractSyscall {
public void SyscallSleep();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallSleep.java
mars/mips/instructions/syscalls/SyscallSleep.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to cause the MARS Java thread to sleep for (at least) the specified number of milliseconds.
* This timing will not be precise as the Java implementation will add some overhead.
*
*/
public class SyscallSleep extends AbstractSyscall {
/**
* Build an instance of the syscall with its default service number and name.
*/
public SyscallSleep() {
super(32, "Sleep");
}
/**
* System call to cause the MARS Java thread to sleep for (at least) the specified number of milliseconds.
* This timing will not be precise as the Java implementation will add some overhead.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
// Input arguments: $a0 is the length of time to sleep in milliseconds.
try
{
Thread.sleep(RegisterFile.getValue(4)); // units of milliseconds 1000 millisec = 1 sec.
}
catch (InterruptedException e)
{
return; // no exception handling
}
}
}
SyscallTime
package mars.mips.instructions.syscalls;
public synchronized class SyscallTime extends AbstractSyscall {
public void SyscallTime();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallTime.java
mars/mips/instructions/syscalls/SyscallTime.java package mars.mips.instructions.syscalls;
import mars.*;
import mars.util.*;
import mars.mips.hardware.*;
/*
Copyright (c) 2003-2007, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to read a character from input console into $a0.
*
*/
public class SyscallTime extends AbstractSyscall {
/**
* Build an instance of the Read Char syscall. Default service number
* is 12 and name is "ReadChar".
*/
public SyscallTime() {
super(30, "Time");
}
/**
* Performs syscall function to place current system time into $a0 (low order 32 bits)
* and $a1 (high order 32 bits).
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
long value = new java.util.Date().getTime();
RegisterFile.updateRegister(4, Binary.lowOrderLongToInt(value)); // $a0
RegisterFile.updateRegister(5, Binary.highOrderLongToInt(value)); // $a1
}
}
SyscallWrite
package mars.mips.instructions.syscalls;
public synchronized class SyscallWrite extends AbstractSyscall {
public void SyscallWrite();
public void simulate(mars.ProgramStatement) throws mars.ProcessingException;
}
mars/mips/instructions/syscalls/SyscallWrite.java
mars/mips/instructions/syscalls/SyscallWrite.java package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*;
import mars.simulator.*;
import mars.*;
/*
Copyright (c) 2003-2009, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Service to write to file descriptor given in $a0. $a1 specifies buffer
* and $a2 specifies length. Number of characters written is returned in $v0
* (this was changed from $a0 in MARS 3.7 for SPIM compatibility. The table
* in COD erroneously shows $a0).
*
*/
public class SyscallWrite extends AbstractSyscall {
/**
* Build an instance of the Write file syscall. Default service number
* is 15 and name is "Write".
*/
public SyscallWrite() {
super(15, "Write");
}
/**
* Performs syscall function to write to file descriptor given in $a0. $a1 specifies buffer
* and $a2 specifies length. Number of characters written is returned in $v0, starting in MARS 3.7.
*/
public void simulate(ProgramStatement statement) throws ProcessingException {
int byteAddress = RegisterFile.getValue(5); // source of characters to write to file
byte b = 0;
int reqLength = RegisterFile.getValue(6); // user-requested length
int index = 0;
byte myBuffer[] = new byte[RegisterFile.getValue(6) + 1]; // specified length plus null termination
try
{
b = (byte) Globals.memory.getByte(byteAddress);
while (index < reqLength) // Stop at requested length. Null bytes are included.
// while (index < reqLength && b != 0) // Stop at requested length OR null byte
{
myBuffer[index++] = b;
byteAddress++;
b = (byte) Globals.memory.getByte(byteAddress);
}
myBuffer[index] = 0; // Add string termination
} // end try
catch (AddressErrorException e)
{
throw new ProcessingException(statement, e);
}
int retValue = SystemIO.writeToFile(
RegisterFile.getValue(4), // fd
myBuffer, // buffer
RegisterFile.getValue(6)); // length
RegisterFile.updateRegister(2, retValue); // set returned value in register
// Getting rid of processing exception. It is the responsibility of the
// user program to check the syscall's return value. MARS should not
// re-emptively terminate MIPS execution because of it. Thanks to
// UCLA student Duy Truong for pointing this out. DPS 28-July-2009
/*
if (retValue < 0) // some error in opening file
{
throw new ProcessingException(statement,
SystemIO.getFileErrorMessage());
}
*/
}
}
Tone
package mars.mips.instructions.syscalls;
synchronized class Tone implements Runnable {
public static final int TEMPO = 1000;
public static final int DEFAULT_CHANNEL = 0;
private byte pitch;
private int duration;
private byte instrument;
private byte volume;
private static java.util.concurrent.locks.Lock openLock;
public void Tone(byte, int, byte, byte);
public void run();
private void playTone();
static void
}
ToneGenerator
package mars.mips.instructions.syscalls;
synchronized class ToneGenerator {
public static final byte DEFAULT_PITCH = 60;
public static final int DEFAULT_DURATION = 1000;
public static final byte DEFAULT_INSTRUMENT = 0;
public static final byte DEFAULT_VOLUME = 100;
private static java.util.concurrent.Executor threadPool;
void ToneGenerator();
public void generateTone(byte, int, byte, byte);
public void generateToneSynchronously(byte, int, byte, byte);
static void
}
mars/mips/instructions/syscalls/ToneGenerator.java
mars/mips/instructions/syscalls/ToneGenerator.java
package mars.mips.instructions.syscalls;
import javax.sound.midi.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
/*
Copyright (c) 2003-2007, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
//
// The ToneGenerator and Tone classes were developed by Otterbein College
// student Tony Brock in July 2007. They simulate MIDI output through the
// computers soundcard using classes and methods of the javax.sound.midi
// package.
//
// Max Hailperin
// ToneGenerator class 2009-10-19 in order to
// (1) provide a reliable way to wait for the completion of a
// synchronous tone,
// and while he was at it,
// (2) improve the efficiency of asynchronous tones by using a thread
// pool executor, and
// (3) simplify the interface by removing all the unused versions
// that provided default values for various parameters
/////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
/*
* Creates a Tone object and passes it to a thread to “play” it using MIDI.
*/
class ToneGenerator {
/**
* The default pitch value for the tone: 60 / middle C.
*/
public final static byte DEFAULT_PITCH = 60;
/**
* The default duration of the tone: 1000 milliseconds.
*/
public final static int DEFAULT_DURATION = 1000;
/**
* The default instrument of the tone: 0 / piano.
*/
public final static byte DEFAULT_INSTRUMENT = 0;
/**
* The default volume of the tone: 100 (of 127).
*/
public final static byte DEFAULT_VOLUME = 100;
private static Executor threadPool = Executors.newCachedThreadPool();
/**
* Produces a Tone with the specified pitch, duration, and instrument,
* and volume.
*
* @param pitch the desired pitch in semitones – 0-127 where 60 is
* middle C.
* @param duration the desired duration in milliseconds.
* @param instrument the desired instrument (or patch) represented
* by a positive byte value (0-127). See the general
* MIDI instrument patch map for more instruments associated with
* each value.
* @param volume the desired volume of the initial attack of the
* Tone (MIDI velocity) represented by a positive byte value (0-127).
*/
public void generateTone(byte pitch, int duration,
byte instrument, byte volume) {
Runnable tone = new Tone(pitch, duration, instrument, volume);
threadPool.execute(tone);
}
/**
* Produces a Tone with the specified pitch, duration, and instrument,
* and volume, waiting for it to finish playing.
*
* @param pitch the desired pitch in semitones – 0-127 where 60 is
* middle C.
* @param duration the desired duration in milliseconds.
* @param instrument the desired instrument (or patch) represented
* by a positive byte value (0-127). See the general
* MIDI instrument patch map for more instruments associated with
* each value.
* @param volume the desired volume of the initial attack of the
* Tone (MIDI velocity) represented by a positive byte value (0-127).
*/
public void generateToneSynchronously(byte pitch, int duration,
byte instrument, byte volume) {
Runnable tone = new Tone(pitch, duration, instrument, volume);
tone.run();
}
}
/**
* Contains important variables for a MIDI Tone: pitch, duration
* instrument (patch), and volume. The tone can be passed to a thread
* and will be played using MIDI.
*/
class Tone implements Runnable {
/**
* Tempo of the tone is in milliseconds: 1000 beats per second.
*/
public final static int TEMPO = 1000;
/**
* The default MIDI channel of the tone: 0 (channel 1).
*/
public final static int DEFAULT_CHANNEL = 0;
private byte pitch;
private int duration;
private byte instrument;
private byte volume;
/**
* Instantiates a new Tone object, initializing the tone’s pitch,
* duration, instrument (patch), and volume.
*
* @param pitch the pitch in semitones. Pitch is represented by
* a positive byte value – 0-127 where 60 is middle C.
* @param duration the duration of the tone in milliseconds.
* @param instrument a positive byte value (0-127) which represents
* the instrument (or patch) of the tone. See the general
* MIDI instrument patch map for more instruments associated with
* each value.
* @param volume a positive byte value (0-127) which represents the
* volume of the initial attack of the note (MIDI velocity). 127 being
* loud, and 0 being silent.
*/
public Tone(byte pitch, int duration, byte instrument, byte volume) {
this.pitch = pitch;
this.duration = duration;
this.instrument = instrument;
this.volume = volume;
}
/**
* Plays the tone.
*/
public void run() {
playTone();
}
/* The following lock and the code which locks and unlocks it
* around the opening of the Sequencer were added 2009-10-19 by
* Max Hailperin
* bug in Sun’s JDK which causes crashing if two threads race:
* http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6888117 .
* This routinely manifested native-code crashes when tones
* were played asynchronously, on dual-core machines with Sun’s
* JDK (but not on one core or with OpenJDK). Even when tones
* were played only synchronously, crashes sometimes occurred.
* This is likely due to the fact that Thread.sleep was used
* for synchronization, a role it cannot reliably serve. In
* any case, this one lock seems to make all the crashes go
* away, and the sleeps are being eliminated (since they can
* cause other, less severe, problems), so that case should be
* double covered. */
private static Lock openLock = new ReentrantLock();
private void playTone() {
try {
Sequencer player = null;
openLock.lock();
try {
player = MidiSystem.getSequencer();
player.open();
} finally {
openLock.unlock();
}
Sequence seq = new Sequence(Sequence.PPQ, 1);
player.setTempoInMPQ(TEMPO);
Track t = seq.createTrack();
//select instrument
ShortMessage inst = new ShortMessage();
inst.setMessage(ShortMessage.PROGRAM_CHANGE, DEFAULT_CHANNEL, instrument, 0);
MidiEvent instChange = new MidiEvent(inst, 0);
t.add(instChange);
ShortMessage on = new ShortMessage();
on.setMessage(ShortMessage.NOTE_ON, DEFAULT_CHANNEL, pitch, volume);
MidiEvent noteOn = new MidiEvent(on, 0);
t.add(noteOn);
ShortMessage off = new ShortMessage();
off.setMessage(ShortMessage.NOTE_OFF, DEFAULT_CHANNEL, pitch, volume);
MidiEvent noteOff = new MidiEvent(off, duration);
t.add(noteOff);
player.setSequence(seq);
/* The EndOfTrackListener was added 2009-10-19 by Max
* Hailperin
* awaitEndOfTrack method could be used as a more reliable
* replacement for Thread.sleep. (Given that the tone
* might not start playing right away, the sleep could end
* before the tone, clipping off the end of the tone.) */
EndOfTrackListener eot = new EndOfTrackListener();
player.addMetaEventListener(eot);
player.start();
try {
eot.awaitEndOfTrack();
}
catch (InterruptedException ex) {
}
finally {
player.close();
}
}
catch (MidiUnavailableException mue) {
mue.printStackTrace();
}
catch (InvalidMidiDataException imde) {
imde.printStackTrace();
}
}
}
class EndOfTrackListener implements javax.sound.midi.MetaEventListener {
private boolean endedYet = false;
public synchronized void meta(javax.sound.midi.MetaMessage m){
if(m.getType() == 47){
endedYet = true;
notifyAll();
}
}
public synchronized void awaitEndOfTrack() throws InterruptedException {
while(!endedYet){
wait();
}
}
}
MIPSprogram
package mars;
public synchronized class MIPSprogram {
private boolean steppedExecution;
private String filename;
private java.util.ArrayList sourceList;
private java.util.ArrayList tokenList;
private java.util.ArrayList parsedList;
private java.util.ArrayList machineList;
private simulator.BackStepper backStepper;
private assembler.SymbolTable localSymbolTable;
private assembler.MacroPool macroPool;
private java.util.ArrayList sourceLineList;
private assembler.Tokenizer tokenizer;
public void MIPSprogram();
public java.util.ArrayList getSourceList();
public void setSourceLineList(java.util.ArrayList);
public java.util.ArrayList getSourceLineList();
public String getFilename();
public java.util.ArrayList getTokenList();
public assembler.Tokenizer getTokenizer();
public java.util.ArrayList createParsedList();
public java.util.ArrayList getParsedList();
public java.util.ArrayList getMachineList();
public simulator.BackStepper getBackStepper();
public assembler.SymbolTable getLocalSymbolTable();
public boolean backSteppingEnabled();
public String getSourceLine(int);
public void readSource(String) throws ProcessingException;
public void tokenize() throws ProcessingException;
public java.util.ArrayList prepareFilesForAssembly(java.util.ArrayList, String, String) throws ProcessingException;
public ErrorList assemble(java.util.ArrayList, boolean) throws ProcessingException;
public ErrorList assemble(java.util.ArrayList, boolean, boolean) throws ProcessingException;
public boolean simulate(int[]) throws ProcessingException;
public boolean simulate(int) throws ProcessingException;
public boolean simulateFromPC(int[], int, javax.swing.AbstractAction) throws ProcessingException;
public boolean simulateStepAtPC(javax.swing.AbstractAction) throws ProcessingException;
public boolean inSteppedExecution();
public assembler.MacroPool createMacroPool();
public assembler.MacroPool getLocalMacroPool();
public void setLocalMacroPool(assembler.MacroPool);
}
mars/MIPSprogram.java
mars/MIPSprogram.java package mars;
import mars.venus.*;
import mars.assembler.*;
import mars.simulator.*;
import mars.mips.hardware.*;
import java.util.*;
import java.io.*;
import java.awt.event.*;
import javax.swing.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Internal representations of MIPS program. Connects source, tokens and machine code. Having
* all these structures available facilitates construction of good messages,
* debugging, and easy simulation.
*
* @author Pete Sanderson
* @version August 2003
**/
public class MIPSprogram {
// See explanation of method inSteppedExecution() below.
private boolean steppedExecution = false;
private String filename;
private ArrayList sourceList;
private ArrayList tokenList;
private ArrayList parsedList;
private ArrayList machineList;
private BackStepper backStepper;
private SymbolTable localSymbolTable;
private MacroPool macroPool;
private ArrayList
private Tokenizer tokenizer;
/**
* Produces list of source statements that comprise the program.
* @return ArrayList of String. Each String is one line of MIPS source code.
**/
public ArrayList getSourceList() {
return sourceList;
}
/**
* Set list of source statements that comprise the program.
* @param sourceLineList ArrayList of SourceLine.
* Each SourceLine represents one line of MIPS source code.
**/
public void setSourceLineList(ArrayList
this.sourceLineList = sourceLineList;
sourceList = new ArrayList();
for (SourceLine sl : sourceLineList) {
sourceList.add(sl.getSource());
}
}
/**
* Retrieve list of source statements that comprise the program.
* @return ArrayList of SourceLine.
* Each SourceLine represents one line of MIPS source cod
**/
public ArrayList
return this.sourceLineList;
}
/**
* Produces name of associated source code file.
* @return File name as String.
**/
public String getFilename() {
return filename;
}
/**
* Produces list of tokens that comprise the program.
* @return ArrayList of TokenList. Each TokenList is list of tokens generated by
* corresponding line of MIPS source code.
* @see TokenList
**/
public ArrayList getTokenList() {
return tokenList;
}
/**
* Retrieves Tokenizer for this program
* @return Tokenizer
**/
public Tokenizer getTokenizer() {
return tokenizer;
}
/**
* Produces new empty list to hold parsed source code statements.
* @return ArrayList of ProgramStatement. Each ProgramStatement represents a parsed
* MIPS statement.
* @see ProgramStatement
**/
public ArrayList createParsedList() {
parsedList = new ArrayList();
return parsedList;
}
/**
* Produces existing list of parsed source code statements.
* @return ArrayList of ProgramStatement. Each ProgramStatement represents a parsed
* MIPS statement.
* @see ProgramStatement
**/
public ArrayList getParsedList() {
return parsedList;
}
/**
* Produces list of machine statements that are assembled from the program.
* @return ArrayList of ProgramStatement. Each ProgramStatement represents an assembled
* basic MIPS instruction.
* @see ProgramStatement
**/
public ArrayList getMachineList() {
return machineList;
}
/**
* Returns BackStepper associated with this program. It is created upon successful assembly.
* @return BackStepper object, null if there is none.
**/
public BackStepper getBackStepper() {
return backStepper;
}
/**
* Returns SymbolTable associated with this program. It is created at assembly time,
* and stores local labels (those not declared using .globl directive).
**/
public SymbolTable getLocalSymbolTable() {
return localSymbolTable;
}
/**
* Returns status of BackStepper associated with this program.
* @return true if enabled, false if disabled or non-existant.
**/
public boolean backSteppingEnabled() {
return (backStepper!=null && backStepper.enabled());
}
/**
* Produces specified line of MIPS source program.
* @param i Line number of MIPS source program to get. Line 1 is first line.
* @return Returns specified line of MIPS source. If outside the line range,
* it returns null. Line 1 is first line.
**/
public String getSourceLine(int i) {
if ( (i >= 1) && (i <= sourceList.size()) )
return (String) sourceList.get(i-1);
else
return null;
}
/**
* Reads MIPS source code from file into structure. Will always read from file.
* It is GUI responsibility to assure that source edits are written to file
* when user selects compile or run/step options.
*
* @param file String containing name of MIPS source code file.
* @throws ProcessingException Will throw exception if there is any problem reading the file.
**/
public void readSource(String file) throws ProcessingException {
this.filename = file;
this.sourceList = new ArrayList();
ErrorList errors = null;
BufferedReader inputFile;
String line;
int lengthSoFar = 0;
try {
inputFile = new BufferedReader(new FileReader(file));
line = inputFile.readLine();
while (line != null) {
sourceList.add(line);
line = inputFile.readLine();
}
}
catch (Exception e) {
errors = new ErrorList();
errors.add(new ErrorMessage((MIPSprogram)null,0,0,e.toString()));
throw new ProcessingException(errors);
}
return;
}
/**
* Tokenizes the MIPS source program. Program must have already been read from file.
* @throws ProcessingException Will throw exception if errors occured while tokenizing.
**/
public void tokenize() throws ProcessingException {
this.tokenizer = new Tokenizer();
this.tokenList = tokenizer.tokenize(this);
this.localSymbolTable = new SymbolTable(this.filename); // prepare for assembly
return;
}
/**
* Prepares the given list of files for assembly. This involves
* reading and tokenizing all the source files. There may be only one.
* @param filenames ArrayList containing the source file name(s) in no particular order
* @param leadFilename String containing name of source file that needs to go first and
* will be represented by "this" MIPSprogram object.
* @param exceptionHandler String containing name of source file containing exception
* handler. This will be assembled first, even ahead of leadFilename, to allow it to
* include "startup" instructions loaded beginning at 0x00400000. Specify null or
* empty String to indicate there is no such designated exception handler.
* @return ArrayList containing one MIPSprogram object for each file to assemble.
* objects for any additional files (send ArrayList to assembler)
* @throws ProcessingException Will throw exception if errors occured while reading or tokenizing.
**/
public ArrayList prepareFilesForAssembly(ArrayList filenames, String leadFilename, String exceptionHandler) throws ProcessingException {
ArrayList MIPSprogramsToAssemble = new ArrayList();
int leadFilePosition = 0;
if (exceptionHandler != null && exceptionHandler.length() > 0) {
filenames.add(0, exceptionHandler);
leadFilePosition = 1;
}
for (int i=0; i
MIPSprogramsToAssemble.add(leadFilePosition,preparee);
}
else {
MIPSprogramsToAssemble.add(preparee);
}
}
return MIPSprogramsToAssemble;
}
/**
* Assembles the MIPS source program. All files comprising the program must have
* already been tokenized. Assembler warnings are not considered errors.
* @param MIPSprogramsToAssemble ArrayList of MIPSprogram objects, each representing a tokenized source file.
* @param extendedAssemblerEnabled A boolean value – true means extended (pseudo) instructions
* are permitted in source code and false means they are to be flagged as errors.
* @throws ProcessingException Will throw exception if errors occured while assembling.
* @return ErrorList containing nothing or only warnings (otherwise would have thrown exception).
**/
public ErrorList assemble(ArrayList MIPSprogramsToAssemble, boolean extendedAssemblerEnabled)
throws ProcessingException {
return assemble(MIPSprogramsToAssemble, extendedAssemblerEnabled, false);
}
/**
* Assembles the MIPS source program. All files comprising the program must have
* already been tokenized.
* @param MIPSprogramsToAssemble ArrayList of MIPSprogram objects, each representing a tokenized source file.
* @param extendedAssemblerEnabled A boolean value – true means extended (pseudo) instructions
* are permitted in source code and false means they are to be flagged as errors
* @param warningsAreErrors A boolean value – true means assembler warnings will be considered errors and terminate
the assemble; false means the assembler will produce warning message but otherwise ignore warnings.
* @throws ProcessingException Will throw exception if errors occured while assembling.
* @return ErrorList containing nothing or only warnings (otherwise would have thrown exception).
**/
public ErrorList assemble(ArrayList MIPSprogramsToAssemble, boolean extendedAssemblerEnabled,
boolean warningsAreErrors) throws ProcessingException {
this.backStepper = null;
Assembler asm = new Assembler();
this.machineList = asm.assemble(MIPSprogramsToAssemble, extendedAssemblerEnabled, warningsAreErrors);
this.backStepper = new BackStepper();
return asm.getErrorList();
}
/**
* Simulates execution of the MIPS program. Program must have already been assembled.
* Begins simulation at beginning of text segment and continues to completion.
* @param breakPoints int array of breakpoints (PC addresses). Can be null.
* @return true if execution completed and false otherwise
* @throws ProcessingException Will throw exception if errors occured while simulating.
**/
public boolean simulate(int[] breakPoints) throws ProcessingException {
return this.simulateFromPC(breakPoints, -1, null);
}
/**
* Simulates execution of the MIPS program. Program must have already been assembled.
* Begins simulation at beginning of text segment and continues to completion or
* until the specified maximum number of steps are simulated.
* @param maxSteps maximum number of steps to simulate.
* @return true if execution completed and false otherwise
* @throws ProcessingException Will throw exception if errors occured while simulating.
**/
public boolean simulate(int maxSteps) throws ProcessingException {
return this.simulateFromPC(null, maxSteps, null);
}
/**
* Simulates execution of the MIPS program. Program must have already been assembled.
* Begins simulation at current program counter address and continues until stopped,
* paused, maximum steps exceeded, or exception occurs.
* @param breakPoints int array of breakpoints (PC addresses). Can be null.
* @param maxSteps maximum number of instruction executions. Default -1 means no maximum.
* @param a the GUI component responsible for this call (GO normally). set to null if none.
* @return true if execution completed and false otherwise
* @throws ProcessingException Will throw exception if errors occured while simulating.
**/
public boolean simulateFromPC(int[] breakPoints, int maxSteps, AbstractAction a) throws ProcessingException {
steppedExecution = false;
Simulator sim = Simulator.getInstance();
return sim.simulate(this, RegisterFile.getProgramCounter(), maxSteps, breakPoints, a);
}
/**
* Simulates execution of the MIPS program. Program must have already been assembled.
* Begins simulation at current program counter address and executes one step.
* @param a the GUI component responsible for this call (STEP normally). Set to null if none.
* @return true if execution completed and false otherwise
* @throws ProcessingException Will throw exception if errors occured while simulating.
**/
public boolean simulateStepAtPC(AbstractAction a) throws ProcessingException {
steppedExecution = true;
Simulator sim = Simulator.getInstance();
boolean done = sim.simulate(this, RegisterFile.getProgramCounter(), 1, null,a);
return done;
}
/** Will be true only while in process of simulating a program statement
* in step mode (e.g. returning to GUI after each step). This is used to
* prevent spurious AccessNotices from being sent from Memory and Register
* to observers at other times (e.g. while updating the data and register
* displays, while assembling program’s data segment, etc).
*/
public boolean inSteppedExecution() {
return steppedExecution;
}
/**
* Instantiates a new {@link MacroPool} and sends reference of this
* {@link MIPSprogram} to it
*
* @return instatiated MacroPool
* @author M.H.Sekhavat
*/
public MacroPool createMacroPool() {
macroPool = new MacroPool(this);
return macroPool;
}
/**
* Gets local macro pool {@link MacroPool} for this program
* @return MacroPool
* @author M.H.Sekhavat
*/
public MacroPool getLocalMacroPool() {
return macroPool;
}
/**
* Sets local macro pool {@link MacroPool} for this program
* @param macroPool reference to MacroPool
* @author M.H.Sekhavat
*/
public void setLocalMacroPool(MacroPool macroPool) {
this.macroPool = macroPool;
}
} // MIPSprogram
ProcessingException
package mars;
public synchronized class ProcessingException extends Exception {
private ErrorList errs;
public void ProcessingException(ErrorList);
public void ProcessingException(ErrorList, mips.hardware.AddressErrorException);
public void ProcessingException(ProgramStatement, String);
public void ProcessingException(ProgramStatement, String, int);
public void ProcessingException(ProgramStatement, mips.hardware.AddressErrorException);
public void ProcessingException();
public ErrorList errors();
}
mars/ProcessingException.java
mars/ProcessingException.java package mars;
import mars.util.*;
import mars.mips.hardware.*;
import mars.mips.instructions.Instruction;
import mars.simulator.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Class to represent error that occurs while assembling or running a MIPS program.
*
* @author Pete Sanderson
* @version August 2003
**/
public class ProcessingException extends Exception {
private ErrorList errs;
/**
* Constructor for ProcessingException.
*
* @param e An ErrorList which is an ArrayList of ErrorMessage objects. Each ErrorMessage
* represents one processing error.
**/
public ProcessingException(ErrorList e) {
errs = e;
}
/**
* Constructor for ProcessingException.
*
* @param e An ErrorList which is an ArrayList of ErrorMessage objects. Each ErrorMessage
* represents one processing error.
* @param aee AddressErrorException object containing specialized error message, cause, address
**/
public ProcessingException(ErrorList e, AddressErrorException aee) {
errs = e;
Exceptions.setRegisters(aee.getType(), aee.getAddress());
}
/**
* Constructor for ProcessingException to handle runtime exceptions
*
* @param ps a ProgramStatement of statement causing runtime exception
* @param m a String containing specialized error message
**/
public ProcessingException(ProgramStatement ps, String m) {
errs = new ErrorList();
errs.add(new ErrorMessage(ps, “Runtime exception at “+
Binary.intToHexString(RegisterFile.getProgramCounter()-Instruction.INSTRUCTION_LENGTH)+
“: “+m));
// Stopped using ps.getAddress() because of pseudo-instructions. All instructions in
// the macro expansion point to the same ProgramStatement, and thus all will return the
// same value for getAddress(). But only the first such expanded instruction will
// be stored at that address. So now I use the program counter (which has already
// been incremented).
}
/**
* Constructor for ProcessingException to handle runtime exceptions
*
* @param ps a ProgramStatement of statement causing runtime exception
* @param m a String containing specialized error message
* @param cause exception cause (see Exceptions class for list)
**/
public ProcessingException(ProgramStatement ps, String m, int cause) {
this(ps,m);
Exceptions.setRegisters(cause);
}
/**
* Constructor for ProcessingException to handle address runtime exceptions
*
* @param ps a ProgramStatement of statement causing runtime exception
* @param aee AddressErrorException object containing specialized error message, cause, address
**/
public ProcessingException(ProgramStatement ps, AddressErrorException aee) {
this(ps, aee.getMessage());
Exceptions.setRegisters(aee.getType(), aee.getAddress());
}
/**
* Constructor for ProcessingException.
*
* No parameter and thus no error list. Use this for normal MIPS
* program termination (e.g. syscall 10 for exit).
**/
public ProcessingException() {
errs = null;
}
/**
* Produce the list of error messages.
*
* @return Returns ErrorList of error messages.
* @see ErrorList
* @see ErrorMessage
**/
public ErrorList errors() {
return errs;
}
}
ProgramStatement$BasicStatementList$ListElement
package mars;
synchronized class ProgramStatement$BasicStatementList$ListElement {
int type;
String sValue;
int iValue;
void ProgramStatement$BasicStatementList$ListElement(ProgramStatement$BasicStatementList, int, String, int);
}
ProgramStatement$BasicStatementList
package mars;
synchronized class ProgramStatement$BasicStatementList {
private java.util.ArrayList list;
void ProgramStatement$BasicStatementList(ProgramStatement);
void addString(String);
void addAddress(int);
void addValue(int);
public String toString();
}
ProgramStatement
package mars;
public synchronized class ProgramStatement {
private MIPSprogram sourceMIPSprogram;
private String source;
private String basicAssemblyStatement;
private String machineStatement;
private assembler.TokenList originalTokenList;
private assembler.TokenList strippedTokenList;
private ProgramStatement$BasicStatementList basicStatementList;
private int[] operands;
private int numOperands;
private mips.instructions.Instruction instruction;
private int textAddress;
private int sourceLine;
private int binaryStatement;
private boolean altered;
private static final String invalidOperator =
public void ProgramStatement(MIPSprogram, String, assembler.TokenList, assembler.TokenList, mips.instructions.Instruction, int, int);
public void ProgramStatement(int, int);
public void buildBasicStatementFromBasicInstruction(ErrorList);
public void buildMachineStatementFromBasicStatement(ErrorList);
public String toString();
public void setBasicAssemblyStatement(String);
public void setMachineStatement(String);
public void setBinaryStatement(int);
public void setSource(String);
public MIPSprogram getSourceMIPSprogram();
public String getSourceFile();
public String getSource();
public int getSourceLine();
public String getBasicAssemblyStatement();
public String getPrintableBasicAssemblyStatement();
public String getMachineStatement();
public int getBinaryStatement();
public assembler.TokenList getOriginalTokenList();
public assembler.TokenList getStrippedTokenList();
public mips.instructions.Instruction getInstruction();
public int getAddress();
public int[] getOperands();
public int getOperand(int);
private void insertBinaryCode(int, char, ErrorList);
private ProgramStatement$BasicStatementList buildBasicStatementListFromBinaryCode(int, mips.instructions.BasicInstruction, int[], int);
}
mars/ProgramStatement.java
mars/ProgramStatement.java package mars;
import mars.assembler.*;
import mars.mips.instructions.*;
import mars.mips.hardware.*;
import mars.util.*;
import java.util.*;
/*
Copyright (c) 2003-2013, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Represents one assembly/machine statement. This represents the “bare machine” level.
* Pseudo-instructions have already been processed at this point and each assembly
* statement generated by them is one of these.
*
* @author Pete Sanderson and Jason Bumgarner
* @version August 2003
*/
public class ProgramStatement {
private MIPSprogram sourceMIPSprogram;
private String source, basicAssemblyStatement, machineStatement;
private TokenList originalTokenList, strippedTokenList;
private BasicStatementList basicStatementList;
private int[] operands;
private int numOperands;
private Instruction instruction;
private int textAddress;
private int sourceLine;
private int binaryStatement;
private boolean altered;
private static final String invalidOperator = “
//////////////////////////////////////////////////////////////////////////////////
/**
* Constructor for ProgramStatement when there are links back to all source and token
* information. These can be used by a debugger later on.
* @param sourceMIPSprogram The MIPSprogram object that contains this statement
* @param source The corresponding MIPS source statement.
* @param origTokenList Complete list of Token objects (includes labels, comments, parentheses, etc)
* @param strippedTokenList List of Token objects with all but operators and operands removed.
* @param inst The Instruction object for this statement’s operator.
* @param textAddress The Text Segment address in memory where the binary machine code for this statement
* is stored.
**/
public ProgramStatement(MIPSprogram sourceMIPSprogram, String source, TokenList origTokenList, TokenList strippedTokenList,
Instruction inst, int textAddress, int sourceLine) {
this.sourceMIPSprogram = sourceMIPSprogram;
this.source = source;
this.originalTokenList = origTokenList;
this.strippedTokenList = strippedTokenList;
this.operands = new int[4];
this.numOperands = 0;
this.instruction = inst;
this.textAddress = textAddress;
this.sourceLine = sourceLine;
this.basicAssemblyStatement = null;
this.basicStatementList = new BasicStatementList();
this.machineStatement = null;
this.binaryStatement = 0; // nop, or sll $0, $0, 0 (32 bits of 0’s)
this.altered = false;
}
//////////////////////////////////////////////////////////////////////////////////
/**
* Constructor for ProgramStatement used only for writing a binary machine
* instruction with no source code to refer back to. Originally supported
* only NOP instruction (all zeroes), but extended in release 4.4 to support
* all basic instructions. This was required for the self-modifying code
* feature.
* @param binaryStatement The 32-bit machine code.
* @param textAddress The Text Segment address in memory where the binary machine code for this statement
* is stored.
**/
public ProgramStatement(int binaryStatement, int textAddress) {
this.sourceMIPSprogram = null;
this.binaryStatement = binaryStatement;
this.textAddress = textAddress;
this.originalTokenList = this.strippedTokenList = null;
this.source = “”;
this.machineStatement = this.basicAssemblyStatement = null;
BasicInstruction instr = Globals.instructionSet.findByBinaryCode(binaryStatement);
if (instr == null) {
this.operands = null;
this.numOperands = 0;
this.instruction = (binaryStatement==0) // this is a “nop” statement
? (Instruction) Globals.instructionSet.matchOperator(“nop”).get(0)
: null;
}
else {
this.operands = new int[4];
this.numOperands = 0;
this.instruction = instr;
String opandCodes = “fst”;
String fmt = instr.getOperationMask();
BasicInstructionFormat instrFormat = instr.getInstructionFormat();
int numOps = 0;
for (int i = 0; i < opandCodes.length(); i++) {
int code = opandCodes.charAt(i);
int j = fmt.indexOf(code);
if (j >= 0) {
int k0 = 31 – fmt.lastIndexOf(code);
int k1 = 31 – j;
int opand = (binaryStatement >> k0) & ((1 << (k1 - k0 + 1)) - 1);
if (instrFormat.equals(BasicInstructionFormat.I_BRANCH_FORMAT) && numOps == 2) {
opand = opand << 16 >> 16;
}
else if (instrFormat.equals(BasicInstructionFormat.J_FORMAT) && numOps == 0) {
opand |= (textAddress >> 2) & 0x3C000000;
}
this.operands[numOps] = opand;
numOps++;
}
}
this.numOperands = numOps;
}
this.altered = false;
this.basicStatementList = buildBasicStatementListFromBinaryCode(binaryStatement, instr, operands, numOperands);
}
/////////////////////////////////////////////////////////////////////////////
/**
* Given specification of BasicInstruction for this operator, build the
* corresponding assembly statement in basic assembly format (e.g. substituting
* register numbers for register names, replacing labels by values).
* @param errors The list of assembly errors encountered so far. May add to it here.
**/
public void buildBasicStatementFromBasicInstruction(ErrorList errors) {
Token token = strippedTokenList.get(0);
String basicStatementElement = token.getValue()+” “;;
String basic = basicStatementElement;
basicStatementList.addString(basicStatementElement); // the operator
TokenTypes tokenType, nextTokenType;
String tokenValue;
int registerNumber;
this.numOperands = 0;
for (int i=1; i
address = (address – (this.textAddress+Instruction.INSTRUCTION_LENGTH)) >> 2;
absoluteAddress = false;
}
}
//////////////////////////////////////////////////////////////////////
basic += address;
if (absoluteAddress) { // record as address if absolute, value if relative
basicStatementList.addAddress(address);
}
else {
basicStatementList.addValue(address);
}
this.operands[this.numOperands++] = address;
}
else if (tokenType == TokenTypes.INTEGER_5 || tokenType == TokenTypes.INTEGER_16 ||
tokenType == TokenTypes.INTEGER_16U || tokenType == TokenTypes.INTEGER_32) {
int tempNumeric = Binary.stringToInt(tokenValue);
/***************************************************************************
* MODIFICATION AND COMMENT, DPS 3-July-2008
*
* The modifications of January 2005 documented below are being rescinded.
* All hexadecimal immediate values are considered 32 bits in length and
* their classification as INTEGER_5, INTEGER_16, INTEGER_16U (new)
* or INTEGER_32 depends on their 32 bit value. So 0xFFFF will be
* equivalent to 0x0000FFFF instead of 0xFFFFFFFF. This change, along with
* the introduction of INTEGER_16U (adopted from Greg Gibeling of Berkeley),
* required extensive changes to instruction templates especially for
* pseudo-instructions.
*
* This modification also appears inbuildBasicStatementFromBasicInstruction()
* in mars.ProgramStatement.
*
* ///// Begin modification 1/4/05 KENV ///////////////////////////////////////////
* // We have decided to interpret non-signed (no + or -) 16-bit hexadecimal immediate
* // operands as signed values in the range -32768 to 32767. So 0xffff will represent
* // -1, not 65535 (bit 15 as sign bit), 0x8000 will represent -32768 not 32768.
* // NOTE: 32-bit hexadecimal immediate operands whose values fall into this range
* // will be likewise affected, but they are used only in pseudo-instructions. The
* // code in ExtendedInstruction.java to split this number into upper 16 bits for “lui”
* // and lower 16 bits for “ori” works with the original source code token, so it is
* // not affected by this tweak. 32-bit immediates in data segment directives
* // are also processed elsewhere so are not affected either.
* ////////////////////////////////////////////////////////////////////////////////
*
* if (tokenType != TokenTypes.INTEGER_16U) { // part of the Berkeley mod…
* if ( Binary.isHex(tokenValue) &&
* (tempNumeric >= 32768) &&
* (tempNumeric <= 65535) ) // Range 0x8000 ... 0xffff
* {
* // Subtract the 0xffff bias, because strings in the
* // range "0x8000" ... "0xffff" are used to represent
* // 16-bit negative numbers, not positive numbers.
* tempNumeric = tempNumeric - 65536;
* // Note: no action needed for range 0xffff8000 ... 0xffffffff
* }
* }
************************** END DPS 3-July-2008 COMMENTS *******************************/
basic += tempNumeric;
basicStatementList.addValue(tempNumeric);
this.operands[this.numOperands++] = tempNumeric;
///// End modification 1/7/05 KENV ///////////////////////////////////////////
}
else {
basicStatementElement = tokenValue;
basic += basicStatementElement;
basicStatementList.addString(basicStatementElement);
}
// add separator if not at end of token list AND neither current nor
// next token is a parenthesis
if ((i < strippedTokenList.size()-1)) {
nextTokenType = strippedTokenList.get(i+1).getType();
if (tokenType != TokenTypes.LEFT_PAREN && tokenType != TokenTypes.RIGHT_PAREN &&
nextTokenType != TokenTypes.LEFT_PAREN && nextTokenType != TokenTypes.RIGHT_PAREN)
{
basicStatementElement = ",";
basic += basicStatementElement;
basicStatementList.addString(basicStatementElement);
}
}
}
this.basicAssemblyStatement = basic;
} //buildBasicStatementFromBasicInstruction()
/////////////////////////////////////////////////////////////////////////////
/**
* Given the current statement in Basic Assembly format (see above), build the
* 32-bit binary machine code statement.
* @param errors The list of assembly errors encountered so far. May add to it here.
**/
public void buildMachineStatementFromBasicStatement(ErrorList errors) {
try {
//mask indicates bit positions for 'f'irst, 's'econd, 't'hird operand
this.machineStatement = ((BasicInstruction)instruction).getOperationMask();
} // This means the pseudo-instruction expansion generated another
// pseudo-instruction (expansion must be to all basic instructions).
// This is an error on the part of the pseudo-instruction author.
catch (ClassCastException cce) {
errors.add(new ErrorMessage(this.sourceMIPSprogram,this.sourceLine,0,
"INTERNAL ERROR: pseudo-instruction expansion contained a pseudo-instruction"));
return;
}
BasicInstructionFormat format = ((BasicInstruction)instruction).getInstructionFormat();
if (format == BasicInstructionFormat.J_FORMAT) {
if ((this.textAddress & 0xF0000000) != (this.operands[0] & 0xF0000000)) {
// attempt to jump beyond 28-bit byte (26-bit word) address range.
// SPIM flags as warning, I'll flag as error b/c MARS text segment not long enough for it to be OK.
errors.add(new ErrorMessage(this.sourceMIPSprogram, this.sourceLine, 0,
"Jump target word address beyond 26-bit range"));
return;
}
// Note the bit shift to make this a word address.
this.operands[0] = this.operands[0] >>> 2;
this.insertBinaryCode(this.operands[0], Instruction.operandMask[0], errors);
}
else if (format == BasicInstructionFormat.I_BRANCH_FORMAT) {
for (int i=0; i
**/
public int getOperand(int i) {
if (i >= 0 && i < this.numOperands) {
return operands[i];
}
else {
return -1;
}
}
//////////////////////////////////////////////////////////////////////////////
// Given operand (register or integer) and mask character ('f', 's', or 't'),
// generate the correct sequence of bits and replace the mask with them.
private void insertBinaryCode(int value, char mask, ErrorList errors) {
int startPos = this.machineStatement.indexOf(mask);
int endPos = this.machineStatement.lastIndexOf(mask);
if (startPos == -1 || endPos == -1) { // should NEVER occur
errors.add(new ErrorMessage(this.sourceMIPSprogram,this.sourceLine,0,
"INTERNAL ERROR: mismatch in number of operands in statement vs mask"));
return;
}
String bitString = Binary.intToBinaryString(value, endPos-startPos+1);
String state = this.machineStatement.substring(0, startPos) + bitString;
if (endPos < this.machineStatement.length()-1)
state = state + this.machineStatement.substring(endPos+1);
this.machineStatement = state;
return;
} // insertBinaryCode()
//////////////////////////////////////////////////////////////////////////////
/*
* Given a model BasicInstruction and the assembled (not source) operand array for a statement,
* this method will construct the corresponding basic instruction list. This method is
* used by the constructor that is given only the int address and binary code. It is not
* intended to be used when source code is available. DPS 11-July-2013
*/
private BasicStatementList buildBasicStatementListFromBinaryCode(int binary, BasicInstruction instr, int[] operands, int numOperands) {
BasicStatementList statementList = new BasicStatementList();
int tokenListCounter = 1; // index 0 is operator; operands start at index 1
if (instr == null) {
statementList.addString(invalidOperator);
return statementList;
}
else {
statementList.addString(instr.getName()+" ");
}
for (int i=0; i
}
mars/Settings.java
mars/Settings.java package mars;
import mars.*;
import mars.util.*;
import mars.venus.editors.jeditsyntax.*;
import java.io.*;
import java.util.*;
import java.util.prefs.*;
import java.awt.Color;
import java.awt.Font;
/*
Copyright (c) 2003-2013, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Contains various IDE settings. Persistent settings are maintained for the
* current user and on the current machine using
* Java’s Preference objects. Failing that, default setting values come from
* Settings.properties file. If both of those fail, default values come from
* static arrays defined in this class. The latter can can be modified prior to
* instantiating Settings object.
*
* NOTE: If the Preference objects fail due to security exceptions, changes to
* settings will not carry over from one MARS session to the next.
*
* Actual implementation of the Preference objects is platform-dependent.
* For Windows, they are stored in Registry. To see, run regedit and browse to:
* HKEY_CURRENT_USER\Software\JavaSoft\Prefs\mars
* @author Pete Sanderson
**/
public class Settings extends Observable {
/* Properties file used to hold default settings. */
private static String settingsFile = “Settings”;
///////////////////////////// PROPERTY ARRAY INDEXES /////////////////////////////
// Because MARS is programmed to Java 1.4, we cannot use an enumerated type.
// BOOLEAN SETTINGS…
/** Flag to determine whether or not program being assembled is limited to
basic MIPS instructions and formats. */
public static final int EXTENDED_ASSEMBLER_ENABLED = 0;
/** Flag to determine whether or not program being assembled is limited to
using register numbers instead of names. NOTE: Its default value is
false and the IDE provides no means to change it! */
public static final int BARE_MACHINE_ENABLED = 1;
/** Flag to determine whether or not a file is immediately and automatically assembled
upon opening. Handy when using externa editor like mipster. */
public static final int ASSEMBLE_ON_OPEN_ENABLED = 2;
/** Flag to determine whether only the current editor source file (enabled false) or
all files in its directory (enabled true) will be assembled when assembly is selected. */
public static final int ASSEMBLE_ALL_ENABLED = 3;
/** Default visibilty of label window (symbol table). Default only, dynamic status
maintained by ExecutePane */
public static final int LABEL_WINDOW_VISIBILITY = 4;
/** Default setting for displaying addresses and values in hexidecimal in the Execute
pane.*/
public static final int DISPLAY_ADDRESSES_IN_HEX = 5;
public static final int DISPLAY_VALUES_IN_HEX = 6;
/** Flag to determine whether the currently selected exception handler source file will
be included in each assembly operation. */
public static final int EXCEPTION_HANDLER_ENABLED = 7;
/** Flag to determine whether or not delayed branching is in effect at MIPS execution.
This means we simulate the pipeline and statement FOLLOWING a successful branch
is executed before branch is taken. DPS 14 June 2007.*/
public static final int DELAYED_BRANCHING_ENABLED = 8;
/** Flag to determine whether or not the editor will display line numbers. */
public static final int EDITOR_LINE_NUMBERS_DISPLAYED = 9;
/** Flag to determine whether or not assembler warnings are considered errors. */
public static final int WARNINGS_ARE_ERRORS = 10;
/** Flag to determine whether or not to display and use program arguments */
public static final int PROGRAM_ARGUMENTS = 11;
/** Flag to control whether or not highlighting is applied to data segment window */
public static final int DATA_SEGMENT_HIGHLIGHTING = 12;
/** Flag to control whether or not highlighting is applied to register windows */
public static final int REGISTERS_HIGHLIGHTING = 13;
/** Flag to control whether or not assembler automatically initializes program counter to ‘main’s address */
public static final int START_AT_MAIN = 14;
/** Flag to control whether or not editor will highlight the line currently being edited */
public static final int EDITOR_CURRENT_LINE_HIGHLIGHTING = 15;
/** Flag to control whether or not editor will provide popup instruction guidance while typing */
public static final int POPUP_INSTRUCTION_GUIDANCE = 16;
/** Flag to control whether or not simulator will use popup dialog for input syscalls */
public static final int POPUP_SYSCALL_INPUT = 17;
/** Flag to control whether or not to use generic text editor instead of language-aware styled editor */
public static final int GENERIC_TEXT_EDITOR = 18;
/** Flag to control whether or not language-aware editor will use auto-indent feature */
public static final int AUTO_INDENT = 19;
/** Flag to determine whether a program can write binary code to the text or data segment and
execute that code. */
public static final int SELF_MODIFYING_CODE_ENABLED = 20;
// NOTE: key sequence must match up with labels above which are used for array indexes!
private static String[] booleanSettingsKeys = {“ExtendedAssembler”, “BareMachine”, “AssembleOnOpen”, “AssembleAll”,
“LabelWindowVisibility”, “DisplayAddressesInHex”, “DisplayValuesInHex”,
“LoadExceptionHandler”, “DelayedBranching”, “EditorLineNumbersDisplayed”,
“WarningsAreErrors”, “ProgramArguments”, “DataSegmentHighlighting”,
“RegistersHighlighting”, “StartAtMain”, “EditorCurrentLineHighlighting”,
“PopupInstructionGuidance”, “PopupSyscallInput”, “GenericTextEditor”,
“AutoIndent”, “SelfModifyingCode” };
/** Last resort default values for boolean settings; will use only if neither
* the Preferences nor the properties file work. If you wish to change them,
* do so before instantiating the Settings object.
* Values are matched to keys by list position.
*/
public static boolean[] defaultBooleanSettingsValues = { // match the above list by position
true, false, false, false, false, true, true, false, false,
true, false, false, true, true, false, true, true, false, false, true, false };
// STRING SETTINGS. Each array position has associated name.
/** Current specified exception handler file (a MIPS assembly source file) */
public static final int EXCEPTION_HANDLER = 0;
/** Order of text segment table columns */
public static final int TEXT_COLUMN_ORDER = 1;
/** State for sorting label window display */
public static final int LABEL_SORT_STATE = 2;
/** Identifier of current memory configuration */
public static final int MEMORY_CONFIGURATION = 3;
/** Caret blink rate in milliseconds, 0 means don’t blink. */
public static final int CARET_BLINK_RATE = 4;
/** Editor tab size in characters. */
public static final int EDITOR_TAB_SIZE = 5;
/** Number of letters to be matched by editor’s instruction guide before popup generated (if popup enabled) */
public static final int EDITOR_POPUP_PREFIX_LENGTH = 6;
// Match the above by position.
private static final String[] stringSettingsKeys = { “ExceptionHandler”, “TextColumnOrder”, “LabelSortState”, “MemoryConfiguration”, “CaretBlinkRate”, “EditorTabSize”, “EditorPopupPrefixLength” };
/** Last resort default values for String settings;
* will use only if neither the Preferences nor the properties file work.
* If you wish to change, do so before instantiating the Settings object.
* Must match key by list position.
*/
private static String[] defaultStringSettingsValues = { “”, “0 1 2 3 4”, “0”, “”, “500”, “8”, “2” };
// FONT SETTINGS. Each array position has associated name.
/** Font for the text editor */
public static final int EDITOR_FONT = 0;
/** Font for table even row background (text, data, register displays) */
public static final int EVEN_ROW_FONT = 1;
/** Font for table odd row background (text, data, register displays) */
public static final int ODD_ROW_FONT = 2;
/** Font for table odd row foreground (text, data, register displays) */
public static final int TEXTSEGMENT_HIGHLIGHT_FONT = 3;
/** Font for text segment delay slot highlighted background */
public static final int TEXTSEGMENT_DELAYSLOT_HIGHLIGHT_FONT = 4;
/** Font for text segment highlighted background */
public static final int DATASEGMENT_HIGHLIGHT_FONT = 5;
/** Font for register highlighted background */
public static final int REGISTER_HIGHLIGHT_FONT = 6;
private static final String[] fontFamilySettingsKeys = { “EditorFontFamily”, “EvenRowFontFamily”,
“OddRowFontFamily”, ” TextSegmentHighlightFontFamily”, “TextSegmentDelayslotHighightFontFamily”,
“DataSegmentHighlightFontFamily”, “RegisterHighlightFontFamily”
};
private static final String[] fontStyleSettingsKeys = { “EditorFontStyle”, “EvenRowFontStyle”,
“OddRowFontStyle”, ” TextSegmentHighlightFontStyle”, “TextSegmentDelayslotHighightFontStyle”,
“DataSegmentHighlightFontStyle”, “RegisterHighlightFontStyle”
};
private static final String[] fontSizeSettingsKeys = { “EditorFontSize”, “EvenRowFontSize”,
“OddRowFontSize”, ” TextSegmentHighlightFontSize”, “TextSegmentDelayslotHighightFontSize”,
“DataSegmentHighlightFontSize”, “RegisterHighlightFontSize”
};
/** Last resort default values for Font settings;
* will use only if neither the Preferences nor the properties file work.
* If you wish to change, do so before instantiating the Settings object.
* Must match key by list position shown above.
*/
// DPS 3-Oct-2012
// Changed default font family from “Courier New” to “Monospaced” after receiving reports that Mac were not
// correctly rendering the left parenthesis character in the editor or text segment display.
// See http://www.mirthcorp.com/community/issues/browse/MIRTH-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
private static final String[] defaultFontFamilySettingsValues = { “Monospaced”,”Monospaced”,”Monospaced”,
“Monospaced”,”Monospaced”,”Monospaced”,”Monospaced”
};
private static final String[] defaultFontStyleSettingsValues = {“Plain”, “Plain”, “Plain”, “Plain”,
“Plain”, “Plain”, “Plain”
};
private static final String[] defaultFontSizeSettingsValues = {“12”, “12”, “12”, “12”, “12”, “12”, “12”,
};
// COLOR SETTINGS. Each array position has associated name.
/** RGB color for table even row background (text, data, register displays) */
public static final int EVEN_ROW_BACKGROUND = 0;
/** RGB color for table even row foreground (text, data, register displays) */
public static final int EVEN_ROW_FOREGROUND = 1;
/** RGB color for table odd row background (text, data, register displays) */
public static final int ODD_ROW_BACKGROUND = 2;
/** RGB color for table odd row foreground (text, data, register displays) */
public static final int ODD_ROW_FOREGROUND = 3;
/** RGB color for text segment highlighted background */
public static final int TEXTSEGMENT_HIGHLIGHT_BACKGROUND = 4;
/** RGB color for text segment highlighted foreground */
public static final int TEXTSEGMENT_HIGHLIGHT_FOREGROUND = 5;
/** RGB color for text segment delay slot highlighted background */
public static final int TEXTSEGMENT_DELAYSLOT_HIGHLIGHT_BACKGROUND = 6;
/** RGB color for text segment delay slot highlighted foreground */
public static final int TEXTSEGMENT_DELAYSLOT_HIGHLIGHT_FOREGROUND = 7;
/** RGB color for text segment highlighted background */
public static final int DATASEGMENT_HIGHLIGHT_BACKGROUND = 8;
/** RGB color for text segment highlighted foreground */
public static final int DATASEGMENT_HIGHLIGHT_FOREGROUND = 9;
/** RGB color for register highlighted background */
public static final int REGISTER_HIGHLIGHT_BACKGROUND = 10;
/** RGB color for register highlighted foreground */
public static final int REGISTER_HIGHLIGHT_FOREGROUND = 11;
// Match the above by position.
private static final String[] colorSettingsKeys = {
“EvenRowBackground”,”EvenRowForeground”, “OddRowBackground”, “OddRowForeground”,
“TextSegmentHighlightBackground”, “TextSegmentHighlightForeground”,
“TextSegmentDelaySlotHighlightBackground”,”TextSegmentDelaySlotHighlightForeground”,
“DataSegmentHighlightBackground”, “DataSegmentHighlightForeground”,
“RegisterHighlightBackground”, “RegisterHighlightForeground” };
/** Last resort default values for color settings;
* will use only if neither the Preferences nor the properties file work.
* If you wish to change, do so before instantiating the Settings object.
* Must match key by list position.
*/
private static String[] defaultColorSettingsValues = {
“0x00e0e0e0”, “0”, “0x00ffffff”, “0”, “0x00ffff99”, “0”, “0x0033ff00”, “0”, “0x0099ccff”, “0”, “0x0099cc55″,”0” };
private boolean[] booleanSettingsValues;
private String[] stringSettingsValues;
private String[] fontFamilySettingsValues;
private String[] fontStyleSettingsValues;
private String[] fontSizeSettingsValues;
private String[] colorSettingsValues;
private Preferences preferences;
/**
* Create Settings object and set to saved values. If saved values not found, will set
* based on defaults stored in Settings.properties file. If file problems, will set based
* on defaults stored in this class.
*/
public Settings() {
this(true);
}
/**
* Create Settings object and set to saved values. If saved values not found, will set
* based on defaults stored in Settings.properties file. If file problems, will set based
* on defaults stored in this class.
* @param gui true if running the graphical IDE, false if running from command line.
* Ignored as of release 3.6 but retained for compatability.
*/
public Settings(boolean gui) {
booleanSettingsValues = new boolean[booleanSettingsKeys.length];
stringSettingsValues = new String[stringSettingsKeys.length];
fontFamilySettingsValues = new String[fontFamilySettingsKeys.length];
fontStyleSettingsValues = new String[fontStyleSettingsKeys.length];
fontSizeSettingsValues = new String[fontSizeSettingsKeys.length];
colorSettingsValues = new String[colorSettingsKeys.length];
// This determines where the values are actually stored. Actual implementation
// is platform-dependent. For Windows, they are stored in Registry. To see,
// run regedit and browse to: HKEY_CURRENT_USER\Software\JavaSoft\Prefs\mars
preferences = Preferences.userNodeForPackage(this.getClass());
// The gui parameter, formerly passed to initialize(), is no longer needed
// because I removed (1/21/09) the call to generate the Font object for the text editor.
// Font objects are now generated only on demand so the “if (gui)” guard
// is no longer necessary. Originally added by Berkeley b/c they were running it on a
// headless server and running in command mode. The Font constructor resulted in Swing
// initialization which caused problems. Now this will only occur on demand from
// Venus, which happens only when running as GUI.
initialize();
}
/**
* Return whether backstepping is permitted at this time. Backstepping is ability to undo execution
* steps one at a time. Available only in the IDE. This is not a persistent setting and is not under
* MARS user control.
* @return true if backstepping is permitted, false otherwise.
*/
public boolean getBackSteppingEnabled() {
return (Globals.program!=null && Globals.program.getBackStepper()!=null && Globals.program.getBackStepper().enabled());
}
/**
* Reset settings to default values, as described in the constructor comments.
* @param gui true if running from GUI IDE and false if running from command mode.
* Ignored as of release 3.6 but retained for compatibility.
*/
public void reset(boolean gui) {
initialize();
}
/* **************************************************************************
This section contains all code related to syntax highlighting styles settings.
A style includes 3 components: color, bold (t/f), italic (t/f)
The fallback defaults will come not from an array here, but from the
existing static method SyntaxUtilities.getDefaultSyntaxStyles()
in the mars.venus.editors.jeditsyntax package. It returns an array
of SyntaxStyle objects.
*/
private String[] syntaxStyleColorSettingsValues;
private boolean[] syntaxStyleBoldSettingsValues;
private boolean[] syntaxStyleItalicSettingsValues;
private static final String SYNTAX_STYLE_COLOR_PREFIX = “SyntaxStyleColor_”;
private static final String SYNTAX_STYLE_BOLD_PREFIX = “SyntaxStyleBold_”;
private static final String SYNTAX_STYLE_ITALIC_PREFIX = “SyntaxStyleItalic_”;
private static String[] syntaxStyleColorSettingsKeys, syntaxStyleBoldSettingsKeys, syntaxStyleItalicSettingsKeys;
private static String[] defaultSyntaxStyleColorSettingsValues;
private static boolean[] defaultSyntaxStyleBoldSettingsValues;
private static boolean[] defaultSyntaxStyleItalicSettingsValues;
public void setEditorSyntaxStyleByPosition( int index, SyntaxStyle syntaxStyle ) {
syntaxStyleColorSettingsValues[index] = syntaxStyle.getColorAsHexString();
syntaxStyleItalicSettingsValues[index] = syntaxStyle.isItalic();
syntaxStyleBoldSettingsValues[index] = syntaxStyle.isBold();
saveEditorSyntaxStyle(index);
}
public SyntaxStyle getEditorSyntaxStyleByPosition( int index ) {
return new SyntaxStyle(getColorValueByPosition(index, syntaxStyleColorSettingsValues),
syntaxStyleItalicSettingsValues[index],
syntaxStyleBoldSettingsValues[index]);
}
public SyntaxStyle getDefaultEditorSyntaxStyleByPosition( int index ) {
return new SyntaxStyle(getColorValueByPosition(index, defaultSyntaxStyleColorSettingsValues),
defaultSyntaxStyleItalicSettingsValues[index],
defaultSyntaxStyleBoldSettingsValues[index]);
}
private void saveEditorSyntaxStyle(int index) {
try {
preferences.put(syntaxStyleColorSettingsKeys[index], syntaxStyleColorSettingsValues[index]);
preferences.putBoolean(syntaxStyleBoldSettingsKeys[index], syntaxStyleBoldSettingsValues[index]);
preferences.putBoolean(syntaxStyleItalicSettingsKeys[index], syntaxStyleItalicSettingsValues[index]);
preferences.flush();
}
catch (SecurityException se) {
// cannot write to persistent storage for security reasons
}
catch (BackingStoreException bse) {
// unable to communicate with persistent storage (strange days)
}
}
// For syntax styles, need to initialize from SyntaxUtilities defaults.
// Taking care not to explicitly create a Color object, since it may trigger
// Swing initialization (that caused problems for UC Berkeley when we
// created Font objects here). It shouldn’t, but then again Font shouldn’t
// either but they said it did. (see HeadlessException)
// On othe other hand, the first statement of this method causes Color objects
// to be created! It is possible but a real pain in the rear to avoid using
// Color objects totally. Requires new methods for the SyntaxUtilities class.
private void initializeEditorSyntaxStyles() {
SyntaxStyle syntaxStyle[] = SyntaxUtilities.getDefaultSyntaxStyles();
int tokens = syntaxStyle.length;
syntaxStyleColorSettingsKeys = new String[tokens];
syntaxStyleBoldSettingsKeys = new String[tokens];
syntaxStyleItalicSettingsKeys = new String[tokens];
defaultSyntaxStyleColorSettingsValues = new String[tokens];
defaultSyntaxStyleBoldSettingsValues = new boolean[tokens];
defaultSyntaxStyleItalicSettingsValues = new boolean[tokens];
syntaxStyleColorSettingsValues = new String[tokens];
syntaxStyleBoldSettingsValues = new boolean[tokens];
syntaxStyleItalicSettingsValues = new boolean[tokens];
for (int i=0; igetBooleanSetting(int id)
with the appropriate boolean setting ID
* (e.g. Settings.BARE_MACHINE_ENABLED
)
*/
public boolean getBareMachineEnabled() {
return booleanSettingsValues[BARE_MACHINE_ENABLED];
}
/**
* Setting for whether user programs can use pseudo-instructions or extended addressing modes
* or alternative instruction formats (all are implemented as pseudo-instructions).
* @return true if pseudo-instructions and formats permitted, false otherwise.
* @deprecated Use getBooleanSetting(int id)
with the appropriate boolean setting ID
* (e.g. Settings.EXTENDED_ASSEMBLER_ENABLED
)
*/
public boolean getExtendedAssemblerEnabled() {
return booleanSettingsValues[EXTENDED_ASSEMBLER_ENABLED];
}
/**
* Setting for whether selected program will be automatically assembled upon opening. This
* can be useful if user employs an external editor such as MIPSter.
* @return true if file is to be automatically assembled upon opening and false otherwise.
* @deprecated Use getBooleanSetting(int id)
with the appropriate boolean setting ID
* (e.g. Settings.ASSEMBLE_ON_OPEN_ENABLED
)
*/
public boolean getAssembleOnOpenEnabled() {
return booleanSettingsValues[ASSEMBLE_ON_OPEN_ENABLED];
}
/**
* Setting for whether Addresses in the Execute pane will be displayed in hexadecimal.
* @return true if addresses are displayed in hexadecimal and false otherwise (decimal).
* @deprecated Use getBooleanSetting(int id)
with the appropriate boolean setting ID
* (e.g. Settings.DISPLAY_ADDRESSES_IN_HEX
)
*/
public boolean getDisplayAddressesInHex() {
return booleanSettingsValues[DISPLAY_ADDRESSES_IN_HEX];
}
/**
* Setting for whether values in the Execute pane will be displayed in hexadecimal.
* @return true if values are displayed in hexadecimal and false otherwise (decimal).
* @deprecated Use getBooleanSetting(int id)
with the appropriate boolean setting ID
* (e.g. Settings.DISPLAY_VALUES_IN_HEX
)
*/
public boolean getDisplayValuesInHex() {
return booleanSettingsValues[DISPLAY_VALUES_IN_HEX];
}
/**
* Setting for whether the assemble operation applies only to the file currently open in
* the editor or whether it applies to all files in that file’s directory (primitive project
* capability). If the “assemble on open” setting is set, this “assemble all” setting will
* be applied as soon as the file is opened.
* @return true if all files are to be assembled, false if only the file open in editor.
* @deprecated Use getBooleanSetting(int id)
with the appropriate boolean setting ID
* (e.g. Settings.ASSEMBLE_ALL_ENABLED
)
*/
public boolean getAssembleAllEnabled() {
return booleanSettingsValues[ASSEMBLE_ALL_ENABLED];
}
/**
* Setting for whether the currently selected exception handler
* (a MIPS source file) will be automatically included in each
* assemble operation.
@return true if exception handler is to be included in assemble, false otherwise.
* @deprecated Use getBooleanSetting(int id)
with the appropriate boolean setting ID
* (e.g. Settings.EXCEPTION_HANDLER_ENABLED
)
*/
public boolean getExceptionHandlerEnabled() {
return booleanSettingsValues[EXCEPTION_HANDLER_ENABLED];
}
/**
* Setting for whether delayed branching will be applied during MIPS
* program execution. If enabled, the statement following a successful
* branch will be executed and then the branch is taken! This simulates
* pipelining and all MIPS processors do it. However it is confusing to
* assembly language students so is disabled by default. SPIM does same thing.
@return true if delayed branching is enabled, false otherwise.
* @deprecated Use getBooleanSetting(int id)
with the appropriate boolean setting ID
* (e.g. Settings.DELAYED_BRANCHING_ENABLED
)
*/
public boolean getDelayedBranchingEnabled() {
return booleanSettingsValues[DELAYED_BRANCHING_ENABLED];
}
/**
* Setting concerning whether or not to display the Labels Window — symbol table.
* @return true if label window is to be displayed, false otherwise.
* @deprecated Use getBooleanSetting(int id)
with the appropriate boolean setting ID
* (e.g. Settings.LABEL_WINDOW_VISIBILITY
)
*/
public boolean getLabelWindowVisibility() {
return booleanSettingsValues[LABEL_WINDOW_VISIBILITY];
}
/**
* Setting concerning whether or not the editor will display line numbers.
* @return true if line numbers are to be displayed, false otherwise.
* @deprecated Use getBooleanSetting(int id)
with the appropriate boolean setting ID
* (e.g. Settings.EDITOR_LINE_NUMBERS_DISPLAYED
)
*/
public boolean getEditorLineNumbersDisplayed() {
return booleanSettingsValues[EDITOR_LINE_NUMBERS_DISPLAYED];
}
/**
* Setting concerning whether or not assembler will consider warnings to be errors.
* @return true if warnings are considered errors, false otherwise.
* @deprecated Use getBooleanSetting(int id)
with the appropriate boolean setting ID
* (e.g. Settings.WARNINGS_ARE_ERRORS
)
*/
public boolean getWarningsAreErrors() {
return booleanSettingsValues[WARNINGS_ARE_ERRORS];
}
/**
* Setting concerning whether or not program arguments can be entered and used.
* @return true if program arguments can be entered/used, false otherwise.
* @deprecated Use getBooleanSetting(int id)
with the appropriate boolean setting ID
* (e.g. Settings.PROGRAM_ARGUMENTS
)
*/
public boolean getProgramArguments() {
return booleanSettingsValues[PROGRAM_ARGUMENTS];
}
/**
* Setting concerning whether or not highlighting is applied to Data Segment window.
* @return true if highlighting is to be applied, false otherwise.
* @deprecated Use getBooleanSetting(int id)
with the appropriate boolean setting ID
* (e.g. Settings.DATA_SEGMENT_HIGHLIGHTING
)
*/
public boolean getDataSegmentHighlighting() {
return booleanSettingsValues[DATA_SEGMENT_HIGHLIGHTING];
}
/**
* Setting concerning whether or not highlighting is applied to Registers,
* Coprocessor0, and Coprocessor1 windows.
* @return true if highlighting is to be applied, false otherwise.
* @deprecated Use getBooleanSetting(int id)
with the appropriate boolean setting ID
* (e.g. Settings.REGISTERS_HIGHLIGHTING
)
*/
public boolean getRegistersHighlighting() {
return booleanSettingsValues[REGISTERS_HIGHLIGHTING];
}
/**
* Setting concerning whether or not assembler will automatically initialize
* the program counter to address of statement labeled ‘main’ if defined.
* @return true if it initializes to ‘main’, false otherwise.
* @deprecated Use getBooleanSetting(int id)
with the appropriate boolean setting ID
* (e.g. Settings.START_AT_MAIN
)
*/
public boolean getStartAtMain() {
return booleanSettingsValues[START_AT_MAIN];
}
/**
* Name of currently selected exception handler file.
* @return String pathname of current exception handler file, empty if none.
*/
public String getExceptionHandler() {
return stringSettingsValues[EXCEPTION_HANDLER];
}
/**
* Returns identifier of current built-in memory configuration.
* @return String identifier of current built-in memory configuration, empty if none.
*/
public String getMemoryConfiguration() {
return stringSettingsValues[MEMORY_CONFIGURATION];
}
/**
* Current editor font. Retained for compatibility but replaced
* by: getFontByPosition(Settings.EDITOR_FONT)
* @return Font object for current editor font.
*/
public Font getEditorFont() {
return getFontByPosition(EDITOR_FONT);
}
/**
* Retrieve a Font setting
* @param fontSettingPosition constant that identifies which item
* @return Font object for given item
*/
public Font getFontByPosition(int fontSettingPosition) {
if (fontSettingPosition >=0 && fontSettingPosition < fontFamilySettingsValues.length) {
return EditorFont.createFontFromStringValues(fontFamilySettingsValues[fontSettingPosition],
fontStyleSettingsValues[fontSettingPosition],
fontSizeSettingsValues[fontSettingPosition]);
}
else {
return null;
}
}
/**
* Retrieve a default Font setting
* @param fontSettingPosition constant that identifies which item
* @return Font object for given item
*/
public Font getDefaultFontByPosition(int fontSettingPosition) {
if (fontSettingPosition >=0 && fontSettingPosition < defaultFontFamilySettingsValues.length) {
return EditorFont.createFontFromStringValues(defaultFontFamilySettingsValues[fontSettingPosition],
defaultFontStyleSettingsValues[fontSettingPosition],
defaultFontSizeSettingsValues[fontSettingPosition]);
}
else {
return null;
}
}
/**
* Order of text segment display columns (there are 5, numbered 0 to 4).
* @return Array of int indicating the order. Original order is 0 1 2 3 4.
*/
public int[] getTextColumnOrder() {
return getTextSegmentColumnOrder(stringSettingsValues[TEXT_COLUMN_ORDER]);
}
/**
* Retrieve the caret blink rate in milliseconds. Blink rate of 0 means
* do not blink.
* @return int blink rate in milliseconds
*/
public int getCaretBlinkRate() {
int rate = 500;
try {
rate = Integer.parseInt(stringSettingsValues[CARET_BLINK_RATE]);
}
catch (NumberFormatException nfe) {
rate = Integer.parseInt(defaultStringSettingsValues[CARET_BLINK_RATE]);
}
return rate;
}
/**
* Get the tab size in characters.
* @return tab size in characters.
*/
public int getEditorTabSize() {
int size = 8;
try {
size = Integer.parseInt(stringSettingsValues[EDITOR_TAB_SIZE]);
}
catch (NumberFormatException nfe) {
size = getDefaultEditorTabSize();
}
return size;
}
/**
* Get number of letters to be matched by editor's instruction guide before popup generated (if popup enabled).
* Should be 1 or 2. If 1, the popup will be generated after first letter typed, based on all matches; if 2,
* the popup will be generated after second letter typed.
* @return number of letters (should be 1 or 2).
*/
public int getEditorPopupPrefixLength() {
int length = 2;
try {
length = Integer.parseInt(stringSettingsValues[EDITOR_POPUP_PREFIX_LENGTH]);
}
catch (NumberFormatException nfe) {
}
return length;
}
/**
* Get the text editor default tab size in characters
* @return tab size in characters
*/
public int getDefaultEditorTabSize() {
return Integer.parseInt(defaultStringSettingsValues[EDITOR_TAB_SIZE]);
}
/**
* Get the saved state of the Labels Window sorting (can sort by either
* label or address and either ascending or descending order).
* Default state is 0, by ascending addresses.
* @return State value 0-7, as a String.
*/
public String getLabelSortState() {
return stringSettingsValues[LABEL_SORT_STATE];
}
/**
* Get Color object for specified settings key.
* Returns null if key is not found or its value is not a valid color encoding.
* @param key the Setting key
* @return corresponding Color, or null if key not found or value not valid color
*/
public Color getColorSettingByKey(String key) {
return getColorValueByKey(key, colorSettingsValues);
}
/**
* Get default Color value for specified settings key.
* Returns null if key is not found or its value is not a valid color encoding.
* @param key the Setting key
* @return corresponding default Color, or null if key not found or value not valid color
*/
public Color getDefaultColorSettingByKey(String key) {
return getColorValueByKey(key, defaultColorSettingsValues);
}
/**
* Get Color object for specified settings name (a static constant).
* Returns null if argument invalid or its value is not a valid color encoding.
* @param position the Setting name (see list of static constants)
* @return corresponding Color, or null if argument invalid or value not valid color
*/
public Color getColorSettingByPosition(int position) {
return getColorValueByPosition(position, colorSettingsValues);
}
/**
* Get default Color object for specified settings name (a static constant).
* Returns null if argument invalid or its value is not a valid color encoding.
* @param position the Setting name (see list of static constants)
* @return corresponding default Color, or null if argument invalid or value not valid color
*/
public Color getDefaultColorSettingByPosition(int position) {
return getColorValueByPosition(position, defaultColorSettingsValues);
}
////////////////////////////////////////////////////////////////////////
// Setting Setters
////////////////////////////////////////////////////////////////////////
/**
* Set value of a boolean setting given its id and the value.
* @param id int containing the setting's identifier (constants listed above)
* @param value boolean value to store
* @throws IllegalArgumentException if identifier is not valid.
*/
public void setBooleanSetting(int id, boolean value) {
if (id >=0 && id < booleanSettingsValues.length) {
internalSetBooleanSetting(id, value);
}
else {
throw new IllegalArgumentException("Invalid boolean setting ID");
}
}
/**
* Establish setting for whether or not pseudo-instructions and formats are permitted
* in user programs. User can change this setting via the IDE. If setting changes,
* new setting will be written to properties file.
* @param value True to permit, false otherwise.
* @deprecated Use setBooleanSetting(int id, boolean value)
with the appropriate boolean setting ID
* (e.g. Settings.EXTENDED_ASSEMBLER_ENABLED
)
*/
public void setExtendedAssemblerEnabled(boolean value) {
internalSetBooleanSetting(EXTENDED_ASSEMBLER_ENABLED, value);
}
/**
* Establish setting for whether a file will be automatically assembled as soon as it
* is opened. This is handy for those using an external text editor such as Mipster.
* If setting changes, new setting will be written to properties file.
* @param value True to automatically assemble, false otherwise.
* @deprecated Use setBooleanSetting(int id, boolean value)
with the appropriate boolean setting ID
* (e.g. Settings.ASSEMBLE_ON_OPEN_ENABLED
)
*/
public void setAssembleOnOpenEnabled(boolean value) {
internalSetBooleanSetting(ASSEMBLE_ON_OPEN_ENABLED, value);
}
/**
* Establish setting for whether a file will be assembled by itself (false) or along
* with all other files in its directory (true). This permits multi-file programs
* and a primitive “project” capability. If setting changes,
* new setting will be written to properties file.
* @param value True to assemble all, false otherwise.
* @deprecated Use setBooleanSetting(int id, boolean value)
with the appropriate boolean setting ID
* (e.g. Settings.ASSEMBLE_ALL_ENABLED
)
*/
public void setAssembleAllEnabled(boolean value) {
internalSetBooleanSetting(ASSEMBLE_ALL_ENABLED, value);
}
/**
* Establish setting for whether addresses in the Execute pane will be displayed
* in hexadecimal format.
* @param value True to display addresses in hexadecimal, false for decimal.
* @deprecated Use setBooleanSetting(int id, boolean value)
with the appropriate boolean setting ID
* (e.g. Settings.DISPLAY_ADDRESSES_IN_HEX
)
*/
public void setDisplayAddressesInHex(boolean value) {
internalSetBooleanSetting(DISPLAY_ADDRESSES_IN_HEX, value);
}
/**
* Establish setting for whether values in the Execute pane will be displayed
* in hexadecimal format.
* @param value True to display values in hexadecimal, false for decimal.
* @deprecated Use setBooleanSetting(int id, boolean value)
with the appropriate boolean setting ID
* (e.g. Settings.DISPLAY_VALUES_IN_HEX
)
*/
public void setDisplayValuesInHex(boolean value) {
internalSetBooleanSetting(DISPLAY_VALUES_IN_HEX, value);
}
/**
* Establish setting for whether the labels window (i.e. symbol table) will
* be displayed as part of the Text Segment display. If setting changes,
* new setting will be written to properties file.
* @param value True to dispay labels window, false otherwise.
* @deprecated Use setBooleanSetting(int id, boolean value)
with the appropriate boolean setting ID
* (e.g. Settings.LABEL_WINDOW_VISIBILITY
)
*/
public void setLabelWindowVisibility(boolean value) {
internalSetBooleanSetting(LABEL_WINDOW_VISIBILITY, value);
}
/**
* Establish setting for whether the currently selected exception handler
* (a MIPS source file) will be automatically included in each
* assemble operation. If setting changes, new setting will be written
* to properties file.
* @param value True to assemble exception handler, false otherwise.
* @deprecated Use setBooleanSetting(int id, boolean value)
with the appropriate boolean setting ID
* (e.g. Settings.EXCEPTION_HANDLER_ENABLED
)
*/
public void setExceptionHandlerEnabled(boolean value) {
internalSetBooleanSetting(EXCEPTION_HANDLER_ENABLED, value);
}
/**
* Establish setting for whether delayed branching will be applied during
* MIPS program execution. If enabled, the statement following a successful
* branch will be executed and then the branch is taken! This simulates
* pipelining and all MIPS processors do it. However it is confusing to
* assembly language students so is disabled by default. SPIM does same thing.
* @param value True to enable delayed branching, false otherwise.
* @deprecated Use setBooleanSetting(int id, boolean value)
with the appropriate boolean setting ID
* (e.g. Settings.DELAYED_BRANCHING_ENABLED
)
*/
public void setDelayedBranchingEnabled(boolean value) {
internalSetBooleanSetting(DELAYED_BRANCHING_ENABLED, value);
}
/**
* Establish setting for whether line numbers will be displayed by the
* text editor.
* @param value True to display line numbers, false otherwise.
* @deprecated Use setBooleanSetting(int id, boolean value)
with the appropriate boolean setting ID
* (e.g. Settings.EDITOR_LINE_NUMBERS_DISPLAYED
)
*/
public void setEditorLineNumbersDisplayed(boolean value) {
internalSetBooleanSetting(EDITOR_LINE_NUMBERS_DISPLAYED, value);
}
/**
* Establish setting for whether assembler warnings will be considered errors.
* @param value True to consider warnings to be errors, false otherwise.
* @deprecated Use setBooleanSetting(int id, boolean value)
with the appropriate boolean setting ID
* (e.g. Settings.WARNINGS_ARE_ERRORS
)
*/
public void setWarningsAreErrors(boolean value) {
internalSetBooleanSetting(WARNINGS_ARE_ERRORS, value);
}
/**
* Establish setting for whether program arguments can be ented/used.
* @param value True if program arguments can be entered/used, false otherwise.
* @deprecated Use setBooleanSetting(int id, boolean value)
with the appropriate boolean setting ID
* (e.g. Settings.PROGRAM_ARGUMENTS
)
*/
public void setProgramArguments(boolean value) {
internalSetBooleanSetting(PROGRAM_ARGUMENTS, value);
}
/**
* Establish setting for whether highlighting is to be applied to
* Data Segment window.
* @param value True if highlighting is to be applied, false otherwise.
* @deprecated Use setBooleanSetting(int id, boolean value)
with the appropriate boolean setting ID
* (e.g. Settings.DATA_SEGMENT_HIGHLIGHTING
)
*/
public void setDataSegmentHighlighting(boolean value) {
internalSetBooleanSetting(DATA_SEGMENT_HIGHLIGHTING, value);
}
/**
* Establish setting for whether highlighting is to be applied to
* Registers, Coprocessor0 and Coprocessor1 windows.
* @param value True if highlighting is to be applied, false otherwise.
* @deprecated Use setBooleanSetting(int id, boolean value)
with the appropriate boolean setting ID
* (e.g. Settings.REGISTERS_HIGHLIGHTING
)
*/
public void setRegistersHighlighting(boolean value) {
internalSetBooleanSetting(REGISTERS_HIGHLIGHTING, value);
}
/**
* Establish setting for whether assembler will automatically initialize
* program counter to address of statement labeled ‘main’ if defined.
* @param value True if PC set to address of ‘main’, false otherwise.
* @deprecated Use setBooleanSetting(int id, boolean value)
with the appropriate boolean setting ID
* (e.g. Settings.START_AT_MAIN
)
*/
public void setStartAtMain(boolean value) {
internalSetBooleanSetting(START_AT_MAIN, value);
}
/**
* Temporarily establish boolean setting. This setting will NOT be written to persisent
* store! Currently this is used only when running MARS from the command line
* @param id setting identifier. These are defined for this class as static final int.
* @param value True to enable the setting, false otherwise.
*/
public void setBooleanSettingNonPersistent(int id, boolean value) {
if (id >=0 && id < booleanSettingsValues.length) {
booleanSettingsValues[id] = value;
}
else {
throw new IllegalArgumentException("Invalid boolean setting ID");
}
}
/**
* Establish setting for whether delayed branching will be applied during
* MIPS program execution. This setting will NOT be written to persisent
* store! This method should be called only to temporarily set this
* setting -- currently this is needed only when running MARS from the
* command line.
* @param value True to enabled delayed branching, false otherwise.
* @deprecated Use setBooleanSettingNonPersistent(int id, boolean value)
with the appropriate boolean setting ID
* (e.g. Settings.DELAYED_BRANCHING_ENABLED
)
*/
public void setDelayedBranchingEnabledNonPersistent(boolean value) {
// Note: Doing assignment to array results in non-persistent
// setting (lost when MARS terminates). For persistent, use
// the internalSetBooleanSetting() method instead.
booleanSettingsValues[DELAYED_BRANCHING_ENABLED] = value;
}
/**
* Set name of exception handler file and write it to persistent storage.
* @param newFilename name of exception handler file
*/
public void setExceptionHandler(String newFilename) {
setStringSetting(EXCEPTION_HANDLER, newFilename);
}
/**
* Store the identifier of the memory configuration.
* @param config A string that identifies the current built-in memory configuration
*/
public void setMemoryConfiguration(String config) {
setStringSetting(MEMORY_CONFIGURATION, config);
}
/**
* Set the caret blinking rate in milliseconds. Rate of 0 means no blinking.
* @param rate blink rate in milliseconds
*/
public void setCaretBlinkRate(int rate) {
setStringSetting(CARET_BLINK_RATE, “”+rate);
}
/**
* Set the tab size in characters.
* @param size tab size in characters.
*/
public void setEditorTabSize(int size) {
setStringSetting(EDITOR_TAB_SIZE, “”+size);
}
/**
* Set number of letters to be matched by editor’s instruction guide before popup generated (if popup enabled).
* Should be 1 or 2. If 1, the popup will be generated after first letter typed, based on all matches; if 2,
* the popup will be generated after second letter typed.
* @param number of letters (should be 1 or 2).
*/
public void setEditorPopupPrefixLength(int length) {
setStringSetting(EDITOR_POPUP_PREFIX_LENGTH, “”+length);
}
/**
* Set editor font to the specified Font object and write it to persistent storage.
* This method retained for compatibility but replaced by:
* setFontByPosition(Settings.EDITOR_FONT, font)
* @param font Font object to be used by text editor.
*/
public void setEditorFont(Font font) {
setFontByPosition(EDITOR_FONT, font);
}
/**
* Store a Font setting
* @param fontSettingPosition Constant that identifies the item the font goes with
* @font The font to set that item to
*/
public void setFontByPosition(int fontSettingPosition, Font font) {
if (fontSettingPosition >=0 && fontSettingPosition < fontFamilySettingsValues.length) {
fontFamilySettingsValues[fontSettingPosition] = font.getFamily();
fontStyleSettingsValues[fontSettingPosition] = EditorFont.styleIntToStyleString(font.getStyle());
fontSizeSettingsValues[fontSettingPosition] = EditorFont.sizeIntToSizeString(font.getSize());
saveFontSetting(fontSettingPosition, fontFamilySettingsKeys, fontFamilySettingsValues);
saveFontSetting(fontSettingPosition, fontStyleSettingsKeys, fontStyleSettingsValues);
saveFontSetting(fontSettingPosition, fontSizeSettingsKeys, fontSizeSettingsValues);
}
if (fontSettingPosition == EDITOR_FONT) {
setChanged();
notifyObservers();
}
}
/**
* Store the current order of Text Segment window table columns, so the ordering
* can be preserved and restored.
* @param columnOrder An array of int indicating column order.
*/
public void setTextColumnOrder(int[] columnOrder) {
String stringifiedOrder = new String();
for (int i=0; i
}
mars/simulator/DelayedBranch.java
mars/simulator/DelayedBranch.javapackage mars.simulator;
/*
Copyright (c) 2003-2007, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Represents a (potential) delayed branch. Note it is necessary only when
* delayed branching is enabled. Here’s the protocol for using it:
*
* (1) When a runtime decision to branch is made (by either a branch or jump
* instruction’s simulate() method in InstructionSet), then if delayed branching
* is enabled, the register() method is called with the branch target address but
* the program counter is NOT set to the branch target address.
*
* (2) At the end of that instruction cycle, the simulate() method in Simulator
* will detect the registered branch, and set its trigger. Don’t do anything yet
* because the next instruction cycle is the delay slot and needs to complete.
*
* (3) At the end of the next (delay slot) instruction cycle, the simulate()
* method in Simulator will detect the triggered branch, set the program
* counter to its target value and clear the delayed branch.
*
* The only interesting situation is when the delay slot itself contains a
* successful branch! I tried this with SPIM (e.g. beq followed by b)
* and it treats it as if nothing was there and continues the delay slot
* into the next cycle. The eventual branch taken is the original one (as one
* would hope) but in the meantime the first statement following the sequence
* of successful branches will constitute the delay slot and will be executed!
*
* Since only one pending delayed branch can be taken at a time, everything
* here is done with statics. The class itself represents the potential branch.
*
* @author Pete Sanderson
* @version June 2007
**/
public class DelayedBranch {
// Class states.
private static final int CLEARED = 0;
private static final int REGISTERED = 1;
private static final int TRIGGERED = 2;
// Initially nothing is happening.
private static int state = CLEARED;
private static int branchTargetAddress = 0;
/**
* Register the fact that a successful branch is to occur. This is called in
* the instruction’s simulated execution (its simulate() method in InstructionSet).
* If a branch is registered but not triggered, this registration will be ignored
* (cannot happen if class usage protocol is followed). If a branch is currently
* registered and triggered, reset the state back to registered (but not triggered)
* in order to carry over the delay slot for another execution cycle. This is the
* only public member of the class.
*
* @param targetAddress The address to branch to after executing the next instruction
*/
public static void register(int targetAddress) {
// About as clean as a switch statement can be!
switch (state) {
case CLEARED : branchTargetAddress = targetAddress;
case REGISTERED :
case TRIGGERED : state = REGISTERED;
}
}
/**
* Trigger a registered branch. This is called at the end of the MIPS simulator
* instruction execution cycle (simulate method in Simulator), so a registered
* branch will be triggered right away. The next execution cycle will be the
* delay slot and at the end of THAT cycle, the trigger will be detected and the
* branch carried out. This method has package visibility.
*
* Precondition: DelayedBranch.isRegistered()
*
* Postcondition: DelayedBranch.isTriggered() && !DelayedBranch.isRegistered()
*
*/
static void trigger() {
// About as clean as a switch statement can be!
switch (state) {
case REGISTERED :
case TRIGGERED : state = TRIGGERED;
case CLEARED :
}
}
/**
* Clear the delayed branch. This must be done immediately after setting the
* program counter to the target address. This method has package visibility.
*/
static void clear() {
state = CLEARED;
branchTargetAddress = 0;
}
/**
* Return registration status. Is false initially, true after register() is called
* but becomes false after trigger() or clear() are called. This method has package
* visibility.
*
* @return true if branch is registered but not triggered, false otherwise.
*/
static boolean isRegistered() {
return state == REGISTERED;
}
/**
* Return trigger status. Is false initially, true after trigger() is called
* but becomes false after clear() is called. This method has package visibility.
*
* @return true if branch is registered but not triggered, false otherwise.
*/
static boolean isTriggered() {
return state == TRIGGERED;
}
/**
* Return branch target address. This should be retrieved only to set the program
* counter at the end of the delay slot. This method has package visibility.
*
* Precondition: DelayedBranch.isTriggered()
*
* @return Target address of the delayed branch.
*/
static int getBranchTargetAddress() {
return branchTargetAddress;
}
} // DelayedBranch
Exceptions
package mars.simulator;
public synchronized class Exceptions {
public static final int EXTERNAL_INTERRUPT_KEYBOARD = 64;
public static final int EXTERNAL_INTERRUPT_DISPLAY = 128;
public static final int ADDRESS_EXCEPTION_LOAD = 4;
public static final int ADDRESS_EXCEPTION_STORE = 5;
public static final int SYSCALL_EXCEPTION = 8;
public static final int BREAKPOINT_EXCEPTION = 9;
public static final int RESERVED_INSTRUCTION_EXCEPTION = 10;
public static final int ARITHMETIC_OVERFLOW_EXCEPTION = 12;
public static final int TRAP_EXCEPTION = 13;
public static final int DIVIDE_BY_ZERO_EXCEPTION = 15;
public static final int FLOATING_POINT_OVERFLOW = 16;
public static final int FLOATING_POINT_UNDERFLOW = 17;
public void Exceptions();
public static void setRegisters(int);
public static void setRegisters(int, int);
}
mars/simulator/Exceptions.java
mars/simulator/Exceptions.javapackage mars.simulator;
import mars.mips.hardware.*;
import mars.mips.instructions.*;
import mars.util.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Represents an error/interrupt that occurs during execution (simulation).
* @author Pete Sanderson
* @version August 2005
**/
public class Exceptions {
/** The exception number is stored in coprocessor 0 cause register ($13)
* Note: the codes for External Interrupts have been modified from MIPS
* specs in order to encode two pieces of information. According
* to spec, there is one External Interrupt code, 0. But then
* how to distinguish keyboard interrupt from display interrupt?
* The Cause register has Interupt Pending bits that can be set.
* Bit 8 represents keyboard, bit 9 represents display. Those
* bits are included into this code, but shifted right two positions
* since the interrupt code will be shifted left two positions
* for inserting cause code into bit positions 2-6 in Cause register.
* DPS 23 July 2008.
*/
public static final int EXTERNAL_INTERRUPT_KEYBOARD = 0x00000040; // see comment above.
public static final int EXTERNAL_INTERRUPT_DISPLAY = 0x00000080; // see comment above.
public static final int ADDRESS_EXCEPTION_LOAD = 4;
public static final int ADDRESS_EXCEPTION_STORE = 5;
public static final int SYSCALL_EXCEPTION = 8;
public static final int BREAKPOINT_EXCEPTION = 9;
public static final int RESERVED_INSTRUCTION_EXCEPTION = 10;
public static final int ARITHMETIC_OVERFLOW_EXCEPTION = 12;
public static final int TRAP_EXCEPTION = 13;
/* the following are from SPIM */
public static final int DIVIDE_BY_ZERO_EXCEPTION = 15;
public static final int FLOATING_POINT_OVERFLOW = 16;
public static final int FLOATING_POINT_UNDERFLOW = 17;
/**
* Given MIPS exception cause code, will place that code into
* coprocessor 0 CAUSE register ($13), set the EPC register to
* “current” program counter, and set Exception Level bit in STATUS register.
*
* @param cause The cause code (see Exceptions for a list)
*/
public static void setRegisters(int cause) {
// Set CAUSE register bits 2 thru 6 to cause value. The “& 0xFFFFFC83” will set bits 2-6 and 8-9 to 0 while
// keeping all the others. Left-shift by 2 to put cause value into position then OR it in. Bits 8-9 used to
// identify devices for External Interrupt (8=keyboard,9=display).
Coprocessor0.updateRegister(Coprocessor0.CAUSE,(Coprocessor0.getValue(Coprocessor0.CAUSE) & 0xFFFFFC83 | (cause << 2)));
// When exception occurred, PC had already been incremented so need to subtract 4 here.
Coprocessor0.updateRegister(Coprocessor0.EPC, RegisterFile.getProgramCounter()-Instruction.INSTRUCTION_LENGTH);
// Set EXL (Exception Level) bit, bit position 1, in STATUS register to 1.
Coprocessor0.updateRegister(Coprocessor0.STATUS, Binary.setBit(Coprocessor0.getValue(Coprocessor0.STATUS), Coprocessor0.EXCEPTION_LEVEL));
}
/**
* Given MIPS exception cause code and bad address, place the bad address into VADDR
* register ($8) then call overloaded setRegisters with the cause code to do the rest.
*
* @param cause The cause code (see Exceptions for a list). Should be address exception.
* @param addr The address that caused the exception.
*/
public static void setRegisters(int cause, int addr) {
Coprocessor0.updateRegister(Coprocessor0.VADDR,addr);
setRegisters(cause);
}
} // Exceptions
ProgramArgumentList
package mars.simulator;
public synchronized class ProgramArgumentList {
java.util.ArrayList programArgumentList;
public void ProgramArgumentList(String);
public void ProgramArgumentList(String[]);
public void ProgramArgumentList(String[], int);
public void ProgramArgumentList(java.util.ArrayList);
public void ProgramArgumentList(java.util.ArrayList, int);
public void storeProgramArguments();
}
mars/simulator/ProgramArgumentList.java
mars/simulator/ProgramArgumentList.java package mars.simulator;
import mars.*;
import mars.venus.*;
import mars.util.*;
import mars.mips.hardware.*;
import mars.mips.instructions.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Models Program Arguments, one or more strings provided to the MIPS
* program at runtime. Equivalent to C's main(int argc, char **argv) or
* Java's main(String[] args).
* @author Pete Sanderson
* @version July 2008
**/
public class ProgramArgumentList {
ArrayList programArgumentList;
/**
* Constructor that parses string to produce list. Delimiters
* are the default Java StringTokenizer delimiters (space, tab,
* newline, return, formfeed)
*
* @param args String containing delimiter-separated arguments
*/
public ProgramArgumentList(String args) {
StringTokenizer st = new StringTokenizer(args);
programArgumentList = new ArrayList(st.countTokens());
while (st.hasMoreTokens()) {
programArgumentList.add(st.nextToken());
}
}
/**
* Constructor that gets list from String array, one argument per element.
*
* @param list Array of String, each element containing one argument
*/
public ProgramArgumentList(String[] list) {
this(list, 0);
}
/**
* Constructor that gets list from section of String array, one
* argument per element.
*
* @param args Array of String, each element containing one argument
* @param startPosition Index of array element containing the first argument; all remaining
* elements are assumed to contain an argument.
*/
public ProgramArgumentList(String[] list, int startPosition) {
programArgumentList = new ArrayList(list.length-startPosition);
for (int i=startPosition; i
Globals.memory.set(highAddress, programArgument.charAt(j), 1);
highAddress–;
}
argStartAddress[i] = highAddress+1;
}
// now place a null word, the arg starting addresses, and arg count onto stack.
int stackAddress = Memory.stackPointer; // base address for runtime stack.
if (highAddress < Memory.stackPointer) {
// Based on current values for stackBaseAddress and stackPointer, this will
// only happen if the combined lengths of program arguments is greater than
// 0x7ffffffc - 0x7fffeffc = 0x00001000 = 4096 bytes. In this case, set
// stackAddress to next lower word boundary minus 4 for clearance (since every
// byte from highAddress+1 is filled).
stackAddress = highAddress - (highAddress % Memory.WORD_LENGTH_BYTES) - Memory.WORD_LENGTH_BYTES;
}
Globals.memory.set(stackAddress, 0, Memory.WORD_LENGTH_BYTES); // null word for end of argv array
stackAddress -= Memory.WORD_LENGTH_BYTES;
for (int i=argStartAddress.length-1; i >= 0; i–) {
Globals.memory.set(stackAddress, argStartAddress[i], Memory.WORD_LENGTH_BYTES);
stackAddress -= Memory.WORD_LENGTH_BYTES;
}
Globals.memory.set(stackAddress, argStartAddress.length, Memory.WORD_LENGTH_BYTES); // argc
stackAddress -= Memory.WORD_LENGTH_BYTES;
// Need to set $sp register to stack address, $a0 to argc, $a1 to argv
// Need to by-pass the backstepping mechanism so go directly to Register instead of RegisterFile
Register[] registers = RegisterFile.getRegisters();
RegisterFile.getUserRegister(“$sp”).setValue(stackAddress+Memory.WORD_LENGTH_BYTES);
RegisterFile.getUserRegister(“$a0”).setValue(argStartAddress.length); // argc
RegisterFile.getUserRegister(“$a1”).setValue(stackAddress+Memory.WORD_LENGTH_BYTES+Memory.WORD_LENGTH_BYTES); // argv
//RegisterFile.updateRegister(“$sp”,stackAddress+Memory.WORD_LENGTH_BYTES);
//RegisterFile.updateRegister(“$a0”,argStartAddress.length); // argc
//RegisterFile.updateRegister(“$a1”,stackAddress+Memory.WORD_LENGTH_BYTES+Memory.WORD_LENGTH_BYTES); // argv
}
catch (AddressErrorException aee) {
System.out.println(“Internal Error: Memory write error occurred while storing program arguments! “+aee);
System.exit(0);
}
return;
}
}
Simulator$1
package mars.simulator;
synchronized class Simulator$1 {
}
Simulator$SimThread
package mars.simulator;
synchronized class Simulator$SimThread extends SwingWorker {
private mars.MIPSprogram p;
private int pc;
private int maxSteps;
private int[] breakPoints;
private boolean done;
private mars.ProcessingException pe;
private volatile boolean stop;
private volatile javax.swing.AbstractAction stopper;
private javax.swing.AbstractAction starter;
private int constructReturnReason;
void Simulator$SimThread(Simulator, mars.MIPSprogram, int, int, int[], javax.swing.AbstractAction);
public void setStop(javax.swing.AbstractAction);
public Object construct();
public void finished();
}
Simulator$StopListener
package mars.simulator;
public abstract interface Simulator$StopListener {
public abstract void stopped(Simulator);
}
Simulator$UpdateGUI
package mars.simulator;
synchronized class Simulator$UpdateGUI implements Runnable {
private void Simulator$UpdateGUI(Simulator);
public void run();
}
Simulator
package mars.simulator;
public synchronized class Simulator extends java.util.Observable {
private Simulator$SimThread simulatorThread;
private static Simulator simulator;
private static Runnable interactiveGUIUpdater;
public static final int NO_DEVICE = 0;
public static volatile int externalInterruptingDevice;
public static final int BREAKPOINT = 1;
public static final int EXCEPTION = 2;
public static final int MAX_STEPS = 3;
public static final int NORMAL_TERMINATION = 4;
public static final int CLIFF_TERMINATION = 5;
public static final int PAUSE_OR_STOP = 6;
private java.util.ArrayList stopListeners;
public static Simulator getInstance();
private void Simulator();
public static boolean inDelaySlot();
public boolean simulate(mars.MIPSprogram, int, int, int[], javax.swing.AbstractAction) throws mars.ProcessingException;
public void stopExecution(javax.swing.AbstractAction);
public void addStopListener(Simulator$StopListener);
public void removeStopListener(Simulator$StopListener);
private void notifyObserversOfExecutionStart(int, int);
private void notifyObserversOfExecutionStop(int, int);
static void
}
mars/simulator/Simulator.java
mars/simulator/Simulator.java package mars.simulator;
import mars.*;
import mars.venus.*;
import mars.util.*;
import mars.mips.hardware.*;
import mars.mips.instructions.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
/*
Copyright (c) 2003-2010, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Used to simulate the execution of an assembled MIPS program.
* @author Pete Sanderson
* @version August 2005
**/
public class Simulator extends Observable {
private SimThread simulatorThread;
private static Simulator simulator = null; // Singleton object
private static Runnable interactiveGUIUpdater = null;
// Others can set this true to indicate external interrupt. Initially used
// to simulate keyboard and display interrupts. The device is identified
// by the address of its MMIO control register. keyboard 0xFFFF0000 and
// display 0xFFFF0008. DPS 23 July 2008.
public static final int NO_DEVICE = 0;
public static volatile int externalInterruptingDevice = NO_DEVICE;
/** various reasons for simulate to end… */
public static final int BREAKPOINT = 1;
public static final int EXCEPTION = 2;
public static final int MAX_STEPS = 3; // includes step mode (where maxSteps is 1)
public static final int NORMAL_TERMINATION = 4;
public static final int CLIFF_TERMINATION = 5; // run off bottom of program
public static final int PAUSE_OR_STOP = 6;
/**
* Returns the Simulator object
*
* @return the Simulator object in use
*/
public static Simulator getInstance() {
// Do NOT change this to create the Simulator at load time (in declaration above)!
// Its constructor looks for the GUI, which at load time is not created yet,
// and incorrectly leaves interactiveGUIUpdater null! This causes runtime
// exceptions while running in timed mode.
if (simulator==null) {
simulator = new Simulator();
}
return simulator;
}
private Simulator() {
simulatorThread = null;
if (Globals.getGui() != null) {
interactiveGUIUpdater = new UpdateGUI();
}
}
/**
* Determine whether or not the next instruction to be executed is in a
* “delay slot”. This means delayed branching is enabled, the branch
* condition has evaluated true, and the next instruction executed will
* be the one following the branch. It is said to occupy the “delay slot.”
* Normally programmers put a nop instruction here but it can be anything.
*
* @return true if next instruction is in delay slot, false otherwise.
*/
public static boolean inDelaySlot() {
return DelayedBranch.isTriggered();
}
/**
* Simulate execution of given MIPS program. It must have already been assembled.
* @param p The MIPSprogram to be simulated.
* @param pc address of first instruction to simulate; this goes into program counter
* @param maxSteps maximum number of steps to perform before returning false (0 or less means no max)
* @param breakPoints array of breakpoint program counter values, use null if none
* @param actor the GUI component responsible for this call, usually GO or STEP. null if none.
* @return true if execution completed, false otherwise
* @throws ProcessingException Throws exception if run-time exception occurs.
**/
public boolean simulate(MIPSprogram p, int pc, int maxSteps, int[] breakPoints, AbstractAction actor) throws ProcessingException {
simulatorThread = new SimThread(p,pc,maxSteps,breakPoints,actor);
simulatorThread.start();
// Condition should only be true if run from command-line instead of GUI.
// If so, just stick around until execution thread is finished.
if (actor == null) {
Object dun = simulatorThread.get(); // this should emulate join()
ProcessingException pe = simulatorThread.pe;
boolean done = simulatorThread.done;
if (done) SystemIO.resetFiles(); // close any files opened in MIPS progra
this.simulatorThread = null;
if (pe != null) {
throw pe;
}
return done;
}
return true;
}
/**
* Set the volatile stop boolean variable checked by the execution
* thread at the end of each MIPS instruction execution. If variable
* is found to be true, the execution thread will depart
* gracefully so the main thread handling the GUI can take over.
* This is used by both STOP and PAUSE features.
*/
public void stopExecution(AbstractAction actor) {
if (simulatorThread != null) {
simulatorThread.setStop(actor);
for (StopListener l : stopListeners) {
l.stopped(this);
}
simulatorThread = null;
}
}
/* This interface is required by the Asker class in MassagesPane
* to be notified about the fact that the user has requested to
* stop the execution. When that happens, it must unblock the
* simulator thread. */
public interface StopListener {
void stopped(Simulator s);
}
private ArrayList
public void addStopListener(StopListener l) {
stopListeners.add(l);
}
public void removeStopListener(StopListener l) {
stopListeners.remove(l);
}
// The Simthread object will call this method when it enters and returns from
// its construct() method. These signal start and stop, respectively, of
// simulation execution. The observer can then adjust its own state depending
// on the execution state. Note that “stop” and “done” are not the same thing.
// “stop” just means it is leaving execution state; this could be triggered
// by Stop button, by Pause button, by Step button, by runtime exception, by
// instruction count limit, by breakpoint, or by end of simulation (truly done).
private void notifyObserversOfExecutionStart(int maxSteps, int programCounter) {
this.setChanged();
this.notifyObservers(new SimulatorNotice(SimulatorNotice.SIMULATOR_START,
maxSteps, RunSpeedPanel.getInstance().getRunSpeed(), programCounter) );
}
private void notifyObserversOfExecutionStop(int maxSteps, int programCounter) {
this.setChanged();
this.notifyObservers(new SimulatorNotice(SimulatorNotice.SIMULATOR_STOP,
maxSteps, RunSpeedPanel.getInstance().getRunSpeed(), programCounter) );
}
/**
* SwingWorker subclass to perform the simulated execution in background thread.
* It is “interrupted” when main thread sets the “stop” variable to true.
* The variable is tested before the next MIPS instruction is simulated. Thus
* interruption occurs in a tightly controlled fashion.
*
* See SwingWorker.java for more details on its functionality and usage. It is
* provided by Sun Microsystems for download and is not part of the Swing library.
*/
class SimThread extends SwingWorker {
private MIPSprogram p;
private int pc, maxSteps;
private int[] breakPoints;
private boolean done;
private ProcessingException pe;
private volatile boolean stop = false;
private volatile AbstractAction stopper;
private AbstractAction starter;
private int constructReturnReason;
/**
* SimThread constructor. Receives all the information it needs to simulate execution.
*
* @param p the MIPSprogram to be simulated
* @param pc address in text segment of first instruction to simulate
* @param maxSteps maximum number of instruction steps to simulate. Default of -1 means no maximum
* @param breakPoints array of breakpoints (instruction addresses) specified by user
* @param starter the GUI component responsible for this call, usually GO or STEP. null if none.
*/
SimThread(MIPSprogram p, int pc, int maxSteps, int[] breakPoints, AbstractAction starter) {
super(Globals.getGui()!=null);
this.p = p;
this.pc = pc;
this.maxSteps = maxSteps;
this.breakPoints = breakPoints;
this.done = false;
this.pe = null;
this.starter = starter;
this.stopper = null;
}
/**
* Sets to “true” the volatile boolean variable that is tested after each
* MIPS instruction is executed. After calling this method, the next test
* will yield “true” and “construct” will return.
*
* @param actor the Swing component responsible for this call.
*/
public void setStop(AbstractAction actor) {
stop = true;
stopper = actor;
}
/**
* This is comparable to the Runnable “run” method (it is called by
* SwingWorker’s “run” method). It simulates the program
* execution in the backgorund.
*
* @return boolean value true if execution done, false otherwise
*/
public Object construct() {
// The next two statements are necessary for GUI to be consistently updated
// before the simulation gets underway. Without them, this happens only intermittently,
// with a consequence that some simulations are interruptable using PAUSE/STOP and others
// are not (because one or the other or both is not yet enabled).
Thread.currentThread().setPriority(Thread.NORM_PRIORITY-1);
Thread.yield(); // let the main thread run a bit to finish updating the GUI
if (breakPoints == null || breakPoints.length == 0) {
breakPoints = null;
}
else {
Arrays.sort(breakPoints); // must be pre-sorted for binary search
}
Simulator.getInstance().notifyObserversOfExecutionStart(maxSteps, pc);
RegisterFile.initializeProgramCounter(pc);
ProgramStatement statement = null;
try {
statement = Globals.memory.getStatement(RegisterFile.getProgramCounter());
}
catch (AddressErrorException e) {
ErrorList el = new ErrorList();
el.add(new ErrorMessage((MIPSprogram)null,0,0,”invalid program counter value: “+Binary.intToHexString(RegisterFile.getProgramCounter())));
this.pe = new ProcessingException(el, e);
// Next statement is a hack. Previous statement sets EPC register to ProgramCounter-4
// because it assumes the bad address comes from an operand so the ProgramCounter has already been
// incremented. In this case, bad address is the instruction fetch itself so Program Counter has
// not yet been incremented. We’ll set the EPC directly here. DPS 8-July-2013
Coprocessor0.updateRegister(Coprocessor0.EPC, RegisterFile.getProgramCounter());
this.constructReturnReason = EXCEPTION;
this.done = true;
SystemIO.resetFiles(); // close any files opened in MIPS program
Simulator.getInstance().notifyObserversOfExecutionStop(maxSteps, pc);
return new Boolean(done);
}
int steps = 0;
// ******************* PS addition 26 July 2006 **********************
// A couple statements below were added for the purpose of assuring that when
// “back stepping” is enabled, every instruction will have at least one entry
// on the back-stepping stack. Most instructions will because they write either
// to a register or memory. But “nop” and branches not taken do not. When the
// user is stepping backward through the program, the stack is popped and if
// an instruction has no entry it will be skipped over in the process. This has
// no effect on the correctness of the mechanism but the visual jerkiness when
// instruction highlighting skips such instrutions is disruptive. Current solution
// is to add a “do nothing” stack entry for instructions that do no write anything.
// To keep this invisible to the “simulate()” method writer, we
// will push such an entry onto the stack here if there is none for this instruction
// by the time it has completed simulating. This is done by the IF statement
// just after the call to the simulate method itself. The BackStepper method does
// the aforementioned check and decides whether to push or not. The result
// is a a smoother interaction experience. But it comes at the cost of slowing
// simulation speed for flat-out runs, for every MIPS instruction executed even
// though very few will require the “do nothing” stack entry. For stepped or
// timed execution the slower execution speed is not noticeable.
//
// To avoid this cost I tried a different technique: back-fill with “do nothings”
// during the backstepping itself when this situation is recognized. Problem
// was in recognizing all possible situations in which the stack contained such
// a “gap”. It became a morass of special cases and it seemed every weird test
// case revealed another one. In addition, when a program
// begins with one or more such instructions (“nop” and branches not taken),
// the backstep button is not enabled until a “real” instruction is executed.
// This is noticeable in stepped mode.
// *********************************************************************
int pc = 0; // added: 7/26/06 (explanation above)
while (statement != null) {
pc = RegisterFile.getProgramCounter(); // added: 7/26/06 (explanation above)
RegisterFile.incrementPC();
// Perform the MIPS instruction in synchronized block. If external threads agree
// to access MIPS memory and registers only through synchronized blocks on same
// lock variable, then full (albeit heavy-handed) protection of MIPS memory and
// registers is assured. Not as critical for reading from those resources.
synchronized (Globals.memoryAndRegistersLock) {
try {
if (Simulator.externalInterruptingDevice != NO_DEVICE) {
int deviceInterruptCode = externalInterruptingDevice;
Simulator.externalInterruptingDevice = NO_DEVICE;
throw new ProcessingException(statement, “External Interrupt”, deviceInterruptCode);
}
BasicInstruction instruction = (BasicInstruction)statement.getInstruction();
if (instruction == null) {
throw new ProcessingException(statement,
“undefined instruction (“+Binary.intToHexString(statement.getBinaryStatement())+”)”,
Exceptions.RESERVED_INSTRUCTION_EXCEPTION);
}
// THIS IS WHERE THE INSTRUCTION EXECUTION IS ACTUALLY SIMULATED!
instruction.getSimulationCode().simulate(statement);
// IF statement added 7/26/06 (explanation above)
if (Globals.getSettings().getBackSteppingEnabled()) {
Globals.program.getBackStepper().addDoNothing(pc);
}
}
catch (ProcessingException pe) {
if (pe.errors() == null) {
this.constructReturnReason = NORMAL_TERMINATION;
this.done = true;
SystemIO.resetFiles(); // close any files opened in MIPS program
Simulator.getInstance().notifyObserversOfExecutionStop(maxSteps, pc);
return new Boolean(done); // execution completed without error.
}
else {
// See if an exception handler is present. Assume this is the case
// if and only if memory location Memory.exceptionHandlerAddress
// (e.g. 0x80000180) contains an instruction. If so, then set the
// program counter there and continue. Otherwise terminate the
// MIPS program with appropriate error message.
ProgramStatement exceptionHandler = null;
try {
exceptionHandler = Globals.memory.getStatement(Memory.exceptionHandlerAddress);
}
catch (AddressErrorException aee) { } // will not occur with this well-known addres
if (exceptionHandler != null) {
RegisterFile.setProgramCounter(Memory.exceptionHandlerAddress);
}
else {
this.constructReturnReason = EXCEPTION;
this.pe = pe;
this.done = true;
SystemIO.resetFiles(); // close any files opened in MIPS program
Simulator.getInstance().notifyObserversOfExecutionStop(maxSteps, pc);
return new Boolean(done);
}
}
}
}// end synchronized block
///////// DPS 15 June 2007. Handle delayed branching if it occurs./////
if (DelayedBranch.isTriggered()) {
RegisterFile.setProgramCounter(DelayedBranch.getBranchTargetAddress());
DelayedBranch.clear();
}
else if (DelayedBranch.isRegistered()) {
DelayedBranch.trigger();
}//////////////////////////////////////////////////////////////////////
// Volatile variable initialized false but can be set true by the main thread.
// Used to stop or pause a running MIPS program. See stopSimulation() above.
if (stop == true) {
this.constructReturnReason = PAUSE_OR_STOP;
this.done = false;
Simulator.getInstance().notifyObserversOfExecutionStop(maxSteps, pc);
return new Boolean(done);
}
// Return if we’ve reached a breakpoint.
if((breakPoints != null) &&
(Arrays.binarySearch(breakPoints,RegisterFile.getProgramCounter()) >= 0)) {
this.constructReturnReason = BREAKPOINT;
this.done = false;
Simulator.getInstance().notifyObserversOfExecutionStop(maxSteps, pc);
return new Boolean(done); // false;
}
// Check number of MIPS instructions executed. Return if at limit (-1 is no limit).
if (maxSteps > 0) {
steps++;
if (steps >= maxSteps) {
this.constructReturnReason = MAX_STEPS;
this.done = false;
Simulator.getInstance().notifyObserversOfExecutionStop(maxSteps, pc);
return new Boolean(done);// false;
}
}
// schedule GUI update only if: there is in fact a GUI! AND
// using Run, not Step (maxSteps > 1) AND
// running slowly enough for GUI to keep up
//if (Globals.getGui() != null && maxSteps != 1 &&
if (interactiveGUIUpdater != null && maxSteps != 1 &&
RunSpeedPanel.getInstance().getRunSpeed() < RunSpeedPanel.UNLIMITED_SPEED) {
SwingUtilities.invokeLater(interactiveGUIUpdater);
}
if (Globals.getGui() != null || Globals.runSpeedPanelExists) { // OR added by DPS 24 July 2008 to enable speed control by stand-alone tool
if (maxSteps != 1 &&
RunSpeedPanel.getInstance().getRunSpeed() < RunSpeedPanel.UNLIMITED_SPEED) {
try { Thread.sleep((int)(1000/RunSpeedPanel.getInstance().getRunSpeed())); // make sure it's never zero!
}
catch (InterruptedException e) {}
}
}
// Get next instruction in preparation for next iteration.
try {
statement = Globals.memory.getStatement(RegisterFile.getProgramCounter());
}
catch (AddressErrorException e) {
ErrorList el = new ErrorList();
el.add(new ErrorMessage((MIPSprogram)null,0,0,"invalid program counter value: "+Binary.intToHexString(RegisterFile.getProgramCounter())));
this.pe = new ProcessingException(el,e);
// Next statement is a hack. Previous statement sets EPC register to ProgramCounter-4
// because it assumes the bad address comes from an operand so the ProgramCounter has already been
// incremented. In this case, bad address is the instruction fetch itself so Program Counter has
// not yet been incremented. We'll set the EPC directly here. DPS 8-July-2013
Coprocessor0.updateRegister(Coprocessor0.EPC, RegisterFile.getProgramCounter());
this.constructReturnReason = EXCEPTION;
this.done = true;
SystemIO.resetFiles(); // close any files opened in MIPS program
Simulator.getInstance().notifyObserversOfExecutionStop(maxSteps, pc);
return new Boolean(done);
}
}
// DPS July 2007. This "if" statement is needed for correct program
// termination if delayed branching on and last statement in
// program is a branch/jump. Program will terminate rather than branch,
// because that's what MARS does when execution drops off the bottom.
if (DelayedBranch.isTriggered() || DelayedBranch.isRegistered()) {
DelayedBranch.clear();
}
// If we got here it was due to null statement, which means program
// counter "fell off the end" of the program. NOTE: Assumes the
// "while" loop contains no "break;" statements.
this.constructReturnReason = CLIFF_TERMINATION;
this.done = true;
SystemIO.resetFiles(); // close any files opened in MIPS program
Simulator.getInstance().notifyObserversOfExecutionStop(maxSteps, pc);
return new Boolean(done); // true; // execution completed
}
/**
* This method is invoked by the SwingWorker when the "construct" method returns.
* It will update the GUI appropriately. According to Sun's documentation, it
* is run in the main thread so should work OK with Swing components (which are
* not thread-safe).
*
* Its action depends on what caused the return from construct() and what
* action led to the call of construct() in the first place.
*/
public void finished() {
// If running from the command-line, then there is no GUI to update.
if (Globals.getGui() == null) {
return;
}
String starterName = (String) starter.getValue(AbstractAction.NAME);
if (starterName.equals("Step")) {
((RunStepAction)starter).stepped(done,constructReturnReason,pe);
}
if (starterName.equals("Go")) {
if (done) {
((RunGoAction)starter).stopped(pe,constructReturnReason);
}
else if (constructReturnReason == BREAKPOINT) {
((RunGoAction)starter).paused(done,constructReturnReason,pe);
}
else {
String stopperName = (String) stopper.getValue(AbstractAction.NAME);
if ("Pause".equals(stopperName)) {
((RunGoAction)starter).paused(done,constructReturnReason,pe);
}
else if ("Stop".equals(stopperName)) {
((RunGoAction)starter).stopped(pe,constructReturnReason);
}
}
}
return;
}
}
private class UpdateGUI implements Runnable {
public void run() {
if (Globals.getGui().getRegistersPane().getSelectedComponent() ==
Globals.getGui().getMainPane().getExecutePane().getRegistersWindow()) {
Globals.getGui().getMainPane().getExecutePane().getRegistersWindow().updateRegisters();
}
else {
Globals.getGui().getMainPane().getExecutePane().getCoprocessor1Window().updateRegisters();
}
Globals.getGui().getMainPane().getExecutePane().getDataSegmentWindow().updateValues();
Globals.getGui().getMainPane().getExecutePane().getTextSegmentWindow().setCodeHighlighting(true);
Globals.getGui().getMainPane().getExecutePane().getTextSegmentWindow().highlightStepAtPC();
}
}
}
SimulatorNotice
package mars.simulator;
public synchronized class SimulatorNotice {
private int action;
private int maxSteps;
private double runSpeed;
private int programCounter;
public static final int SIMULATOR_START = 0;
public static final int SIMULATOR_STOP = 1;
public void SimulatorNotice(int, int, double, int);
public int getAction();
public int getMaxSteps();
public double getRunSpeed();
public int getProgramCounter();
public String toString();
}
mars/simulator/SimulatorNotice.java
mars/simulator/SimulatorNotice.javapackage mars.simulator;
/*
Copyright (c) 2003-2009, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Object provided to Observers of the Simulator.
* They are notified at important phases of the runtime simulator,
* such as start and stop of simulation.
*
* @author Pete Sanderson
* @version January 2009
*/
public class SimulatorNotice {
private int action;
private int maxSteps;
private double runSpeed;
private int programCounter;
public static final int SIMULATOR_START = 0;
public static final int SIMULATOR_STOP = 1;
/** Constructor will be called only within this package, so assume
* address and length are in valid ranges.
*/
public SimulatorNotice(int action, int maxSteps, double runSpeed, int programCounter) {
this.action = action;
this.maxSteps = maxSteps;
this.runSpeed = runSpeed;
this.programCounter = programCounter;
}
/** Fetch the memory address that was accessed. */
public int getAction() {
return this.action;
}
/** Fetch the length in bytes of the access operation (4,2,1). */
public int getMaxSteps() {
return this.maxSteps;
}
/** Fetch the value of the access operation (the value read or written). */
public double getRunSpeed() {
return this.runSpeed;
}
/** Fetch the value of the access operation (the value read or written). */
public int getProgramCounter() {
return this.programCounter;
}
/** String representation indicates access type, address and length in bytes */
public String toString() {
return ((this.getAction()==SIMULATOR_START) ? "START " : "STOP ") +
"Max Steps " + this.maxSteps + " " +
"Speed "+ ((this.runSpeed==mars.venus.RunSpeedPanel.UNLIMITED_SPEED)? "unlimited " : ""+this.runSpeed+" inst/sec") +
"Prog Ctr "+this.programCounter;
}
}
SwingWorker$1
package mars.simulator;
synchronized class SwingWorker$1 implements Runnable {
void SwingWorker$1(SwingWorker);
public void run();
}
SwingWorker$2
package mars.simulator;
synchronized class SwingWorker$2 implements Runnable {
void SwingWorker$2(SwingWorker, boolean, Runnable);
public void run();
}
SwingWorker$ThreadVar
package mars.simulator;
synchronized class SwingWorker$ThreadVar {
private Thread thread;
void SwingWorker$ThreadVar(Thread);
synchronized Thread get();
synchronized void clear();
}
SwingWorker
package mars.simulator;
public abstract synchronized class SwingWorker {
private Object value;
private SwingWorker$ThreadVar threadVar;
protected synchronized Object getValue();
private synchronized void setValue(Object);
public abstract Object construct();
public void finished();
public void interrupt();
public Object get();
public void SwingWorker(boolean);
public void start();
}
mars/simulator/SwingWorker.java
mars/simulator/SwingWorker.javapackage mars.simulator;
import javax.swing.SwingUtilities;
/*-----------------------------------------------------
* This file downloaded from the Sun Microsystems URL given below.
*
* I will subclass it to create worker thread for running
* MIPS simulated execution.
*/
/**
* This is the 3rd version of SwingWorker (also known as
* SwingWorker 3), an abstract class that you subclass to
* perform GUI-related work in a dedicated thread. For
* instructions on and examples of using this class, see:
*
* http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
*
* Note that the API changed slightly in the 3rd version:
* You must now invoke start() on the SwingWorker after
* creating it.
*/
public abstract class SwingWorker {
private Object value; // see getValue(), setValue()
/**
* Class to maintain reference to current worker thread
* under separate synchronization control.
*/
private static class ThreadVar {
private Thread thread;
ThreadVar(Thread t) { thread = t; }
synchronized Thread get() { return thread; }
synchronized void clear() { thread = null; }
}
private ThreadVar threadVar;
/**
* Get the value produced by the worker thread, or null if it
* hasn't been constructed yet.
*/
protected synchronized Object getValue() {
return value;
}
/**
* Set the value produced by worker thread
*/
private synchronized void setValue(Object x) {
value = x;
}
/**
* Compute the value to be returned by the get
method.
*/
public abstract Object construct();
/**
* Called on the event dispatching thread (not on the worker thread)
* after the construct
method has returned.
*/
public void finished() {
}
/**
* A new method that interrupts the worker thread. Call this method
* to force the worker to stop what it’s doing.
*/
public void interrupt() {
Thread t = threadVar.get();
if (t != null) {
t.interrupt();
}
threadVar.clear();
}
/**
* Return the value created by the construct
method.
* Returns null if either the constructing thread or the current
* thread was interrupted before a value was produced.
*
* @return the value created by the construct
method
*/
public Object get() {
while (true) {
Thread t = threadVar.get();
if (t == null) {
return getValue();
}
try {
t.join();
}
catch (InterruptedException e) {
Thread.currentThread().interrupt(); // propagate
return null;
}
}
}
/**
* Start a thread that will call the construct
method
* and then exit.
* @param useSwing Set true if MARS is running from GUI, false otherwise.
*/
public SwingWorker(final boolean useSwing) {
final Runnable doFinished = new Runnable() {
public void run() { finished(); }
};
Runnable doConstruct = new Runnable() {
public void run() {
try {
setValue(construct());
}
finally {
threadVar.clear();
}
if (useSwing) SwingUtilities.invokeLater(doFinished);
else doFinished.run();
}
};
// Thread that represents executing MIPS program…
Thread t = new Thread(doConstruct, “MIPS”);
//t.setPriority(Thread.NORM_PRIORITY-1);//******************
threadVar = new ThreadVar(t);
}
/**
* Start the worker thread.
*/
public void start() {
Thread t = threadVar.get();
if (t != null) {
t.start();
}
}
}
AbstractMarsToolAndApplication$1
package mars.tools;
synchronized class AbstractMarsToolAndApplication$1 extends java.awt.event.WindowAdapter {
void AbstractMarsToolAndApplication$1(AbstractMarsToolAndApplication);
public void windowClosing(java.awt.event.WindowEvent);
}
AbstractMarsToolAndApplication$10
package mars.tools;
synchronized class AbstractMarsToolAndApplication$10 implements java.awt.event.ActionListener {
void AbstractMarsToolAndApplication$10(AbstractMarsToolAndApplication);
public void actionPerformed(java.awt.event.ActionEvent);
}
AbstractMarsToolAndApplication$2
package mars.tools;
synchronized class AbstractMarsToolAndApplication$2 extends java.awt.event.WindowAdapter {
void AbstractMarsToolAndApplication$2(AbstractMarsToolAndApplication);
public void windowClosing(java.awt.event.WindowEvent);
}
AbstractMarsToolAndApplication$3
package mars.tools;
synchronized class AbstractMarsToolAndApplication$3 implements java.awt.event.ActionListener {
void AbstractMarsToolAndApplication$3(AbstractMarsToolAndApplication);
public void actionPerformed(java.awt.event.ActionEvent);
}
AbstractMarsToolAndApplication$4
package mars.tools;
synchronized class AbstractMarsToolAndApplication$4 implements java.awt.event.ActionListener {
void AbstractMarsToolAndApplication$4(AbstractMarsToolAndApplication);
public void actionPerformed(java.awt.event.ActionEvent);
}
AbstractMarsToolAndApplication$5
package mars.tools;
synchronized class AbstractMarsToolAndApplication$5 implements java.awt.event.ActionListener {
void AbstractMarsToolAndApplication$5(AbstractMarsToolAndApplication);
public void actionPerformed(java.awt.event.ActionEvent);
}
AbstractMarsToolAndApplication$6
package mars.tools;
synchronized class AbstractMarsToolAndApplication$6 implements java.awt.event.ActionListener {
void AbstractMarsToolAndApplication$6(AbstractMarsToolAndApplication);
public void actionPerformed(java.awt.event.ActionEvent);
}
AbstractMarsToolAndApplication$7
package mars.tools;
synchronized class AbstractMarsToolAndApplication$7 implements java.awt.event.ActionListener {
void AbstractMarsToolAndApplication$7(AbstractMarsToolAndApplication);
public void actionPerformed(java.awt.event.ActionEvent);
}
AbstractMarsToolAndApplication$8
package mars.tools;
synchronized class AbstractMarsToolAndApplication$8 implements java.awt.event.ActionListener {
void AbstractMarsToolAndApplication$8(AbstractMarsToolAndApplication);
public void actionPerformed(java.awt.event.ActionEvent);
}
AbstractMarsToolAndApplication$9
package mars.tools;
synchronized class AbstractMarsToolAndApplication$9 implements java.awt.event.ActionListener {
void AbstractMarsToolAndApplication$9(AbstractMarsToolAndApplication);
public void actionPerformed(java.awt.event.ActionEvent);
}
AbstractMarsToolAndApplication$ConnectButton
package mars.tools;
public synchronized class AbstractMarsToolAndApplication$ConnectButton extends javax.swing.JButton {
private static final String connectText = Connect to MIPS;
private static final String disconnectText = Disconnect from MIPS;
public void AbstractMarsToolAndApplication$ConnectButton(AbstractMarsToolAndApplication);
public void connect();
public void disconnect();
public boolean isConnected();
}
AbstractMarsToolAndApplication$CreateAssembleRunMIPSprogram
package mars.tools;
synchronized class AbstractMarsToolAndApplication$CreateAssembleRunMIPSprogram implements Runnable {
private void AbstractMarsToolAndApplication$CreateAssembleRunMIPSprogram(AbstractMarsToolAndApplication);
public void run();
}
AbstractMarsToolAndApplication$EnterKeyListener
package mars.tools;
public synchronized class AbstractMarsToolAndApplication$EnterKeyListener extends java.awt.event.KeyAdapter {
javax.swing.AbstractButton myButton;
public void AbstractMarsToolAndApplication$EnterKeyListener(AbstractMarsToolAndApplication, javax.swing.AbstractButton);
public void keyPressed(java.awt.event.KeyEvent);
}
AbstractMarsToolAndApplication$GUIUpdater
package mars.tools;
synchronized class AbstractMarsToolAndApplication$GUIUpdater implements Runnable {
private void AbstractMarsToolAndApplication$GUIUpdater(AbstractMarsToolAndApplication);
public void run();
}
AbstractMarsToolAndApplication$MessageField$MessageWriter
package mars.tools;
synchronized class AbstractMarsToolAndApplication$MessageField$MessageWriter implements Runnable {
private String text;
private boolean terminatingMessage;
public void AbstractMarsToolAndApplication$MessageField$MessageWriter(AbstractMarsToolAndApplication$MessageField, String, boolean);
public void run();
}
AbstractMarsToolAndApplication$MessageField
package mars.tools;
synchronized class AbstractMarsToolAndApplication$MessageField extends javax.swing.JTextField {
public void AbstractMarsToolAndApplication$MessageField(AbstractMarsToolAndApplication, String);
private void displayTerminatingMessage(String);
private void displayNonTerminatingMessage(String);
private void displayMessage(String, boolean);
}
AbstractMarsToolAndApplication
package mars.tools;
public abstract synchronized class AbstractMarsToolAndApplication extends javax.swing.JFrame implements MarsTool, java.util.Observer {
protected boolean isBeingUsedAsAMarsTool;
protected AbstractMarsToolAndApplication thisMarsApp;
private javax.swing.JDialog dialog;
protected java.awt.Window theWindow;
javax.swing.JLabel headingLabel;
private String title;
private String heading;
private javax.swing.border.EmptyBorder emptyBorder;
private java.awt.Color backgroundColor;
private int lowMemoryAddress;
private int highMemoryAddress;
private volatile boolean observing;
private java.io.File mostRecentlyOpenedFile;
private Runnable interactiveGUIUpdater;
private AbstractMarsToolAndApplication$MessageField operationStatusMessages;
private javax.swing.JButton openFileButton;
private javax.swing.JButton assembleRunButton;
private javax.swing.JButton stopButton;
private boolean multiFileAssemble;
protected AbstractMarsToolAndApplication$ConnectButton connectButton;
protected void AbstractMarsToolAndApplication(String, String);
public abstract String getName();
protected abstract javax.swing.JComponent buildMainDisplayArea();
public void go();
public void action();
protected void initializePreGUI();
protected void initializePostGUI();
protected void reset();
protected javax.swing.JComponent buildHeadingArea();
protected javax.swing.JComponent buildButtonAreaMarsTool();
protected javax.swing.JComponent buildButtonAreaStandAlone();
public void update(java.util.Observable, Object);
protected void processMIPSUpdate(java.util.Observable, mars.mips.hardware.AccessNotice);
protected void performSpecialClosingDuties();
protected void addAsObserver();
protected void addAsObserver(int, int);
protected void addAsObserver(mars.mips.hardware.Register);
protected void deleteAsObserver();
protected void deleteAsObserver(mars.mips.hardware.Register);
protected boolean isObserving();
protected void updateDisplay();
protected javax.swing.JComponent getHelpComponent();
private void performToolClosingDuties();
private void performAppClosingDuties();
}
mars/tools/AbstractMarsToolAndApplication.java
mars/tools/AbstractMarsToolAndApplication.java package mars.tools;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.filechooser.FileFilter;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import mars.*;
import mars.util.*;
import mars.tools.*;
import mars.mips.hardware.*;
/*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* An abstract class that provides generic components to facilitate implementation of
* a MarsTool and/or stand-alone Mars-based application. Provides default definitions
* of both the action() method required to implement MarsTool and the go() method
* conventionally used to launch a Mars-based stand-alone application. It also provides
* generic definitions for interactively controlling the application. The generic controls
* for MarsTools are 3 buttons: connect/disconnect to MIPS resource (memory and/or
* registers), reset, and close (exit). The generic controls for stand-alone Mars apps
* include: button that triggers a file open dialog, a text field to display status
* messages, the run-speed slider to control execution rate when running a MIPS program,
* a button that assembles and runs the current MIPS program, a button to interrupt
* the running MIPS program, a reset button, and an exit button.
* Pete Sanderson, 14 November 2006.
*/
public abstract class AbstractMarsToolAndApplication extends JFrame implements MarsTool, Observer {
protected boolean isBeingUsedAsAMarsTool = false; // can use to determine whether invoked as MarsTool or stand-alone.
protected AbstractMarsToolAndApplication thisMarsApp;
private JDialog dialog; // used only for MarsTool use. This is the pop-up dialog that appears when menu item selected.
protected Window theWindow; // highest level GUI component (a JFrame for app, a JDialog for MarsTool)
// Major GUI components
JLabel headingLabel;
private String title; // descriptive title for title bar provided to constructor.
private String heading; // Text to be displayed in the top portion of the main window.
// Some GUI settings
private EmptyBorder emptyBorder = new EmptyBorder(4,4,4,4);
private Color backgroundColor = Color.WHITE;
private int lowMemoryAddress = Memory.dataSegmentBaseAddress;
private int highMemoryAddress = Memory.stackBaseAddress;
// For MarsTool, is set true when “Connect” clicked, false when “Disconnect” clicked.
// For app, is set true when “Assemble and Run” clicked, false when program terminates.
private volatile boolean observing = false;
// Several structures required for stand-alone use only (not MarsTool use)
private File mostRecentlyOpenedFile = null;
private Runnable interactiveGUIUpdater = new GUIUpdater();
private MessageField operationStatusMessages;
private JButton openFileButton, assembleRunButton, stopButton;
private boolean multiFileAssemble = false;
// Structure required for MarsTool use only (not stand-alone use). Want subclasses to have access.
protected ConnectButton connectButton;
/**
* Simple constructor
* @param title String containing title bar text
*/
protected AbstractMarsToolAndApplication(String title,String heading) {
thisMarsApp = this;
this.title = title;
this.heading = heading;
}
//////////////////////////////////////////////////////////////////////////////////////
////////////////////////////// ABSTRACT METHODS ///////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
/**
* Required MarsTool method to return Tool name. Must be defined by subclass.
* @return Tool name. MARS will display this in menu item.
*/
public abstract String getName();
/**
* Abstract method that must be instantiated by subclass to build the main display area
* of the GUI. It will be placed in the CENTER area of a BorderLayout. The title
* is in the NORTH area, and the controls are in the SOUTH area.
*/
protected abstract JComponent buildMainDisplayArea();
//////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// METHODS WITH DEFAULT IMPLEMENTATIONS //////////////////
//////////////////////////////////////////////////////////////////////////////////////
/**
* Run the simulator as stand-alone application. For this default implementation,
* the user-defined main display of the user interface is identical for both stand-alone
* and MARS Tools menu use, but the control buttons are different because the stand-alone
* must include a mechansim for controlling the opening, assembling, and executing of
* an underlying MIPS program. The generic controls include: a button that triggers a
* file open dialog, a text field to display status messages, the run-speed slider
* to control execution rate when running a MIPS program, a button that assembles and
* runs the current MIPS program, a reset button, and an exit button.
* This method calls 3 methods that can be defined/overriden in the subclass: initializePreGUI()
* for any special initialization that must be completed before building the user
* interface (e.g. data structures whose properties determine default GUI settings),
* initializePostGUI() for any special initialization that cannot be
* completed until after the building the user interface (e.g. data structure whose
* properties are determined by default GUI settings), and buildMainDisplayArea()
* to contain application-specific displays of parameters and results.
*/
public void go() {
theWindow = this;
this.isBeingUsedAsAMarsTool = false;
thisMarsApp.setTitle(this.title);
mars.Globals.initialize(true);
// assure the dialog goes away if user clicks the X
thisMarsApp.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
performAppClosingDuties();
}
});
initializePreGUI();
JPanel contentPane = new JPanel(new BorderLayout(5,5));
contentPane.setBorder(emptyBorder);
contentPane.setOpaque(true);
contentPane.add(buildHeadingArea(), BorderLayout.NORTH);
contentPane.add(buildMainDisplayArea(), BorderLayout.CENTER);
contentPane.add(buildButtonAreaStandAlone(), BorderLayout.SOUTH);
thisMarsApp.setContentPane(contentPane);
thisMarsApp.pack();
thisMarsApp.setLocationRelativeTo(null); // center on screen
thisMarsApp.setVisible(true);
initializePostGUI();
}
/**
* Required MarsTool method to carry out Tool functions. It is invoked when MARS
* user selects this tool from the Tools menu. This default implementation provides
* generic definitions for interactively controlling the tool. The generic controls
* for MarsTools are 3 buttons: connect/disconnect to MIPS resource (memory and/or
* registers), reset, and close (exit). Like “go()” above, this default version
* calls 3 methods that can be defined/overriden in the subclass: initializePreGUI()
* for any special initialization that must be completed before building the user
* interface (e.g. data structures whose properties determine default GUI settings),
* initializePostGUI() for any special initialization that cannot be
* completed until after the building the user interface (e.g. data structure whose
* properties are determined by default GUI settings), and buildMainDisplayArea()
* to contain application-specific displays of parameters and results.
*/
public void action() {
this.isBeingUsedAsAMarsTool = true;
dialog = new JDialog(Globals.getGui(), this.title);
// assure the dialog goes away if user clicks the X
dialog.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
performToolClosingDuties();
}
});
theWindow = dialog;
initializePreGUI();
JPanel contentPane = new JPanel(new BorderLayout(5,5));
contentPane.setBorder(emptyBorder);
contentPane.setOpaque(true);
contentPane.add(buildHeadingArea(), BorderLayout.NORTH);
contentPane.add(buildMainDisplayArea(),BorderLayout.CENTER);
contentPane.add(buildButtonAreaMarsTool(), BorderLayout.SOUTH);
initializePostGUI();
dialog.setContentPane(contentPane);
dialog.pack();
dialog.setLocationRelativeTo(Globals.getGui());
dialog.setVisible(true);
}
/**
* Method that will be called once just before the GUI is constructed in the go() and action()
* methods. Use it to initialize any data structures needed for the application whose values
* will be needed to determine the initial state of GUI components. By default it does nothing.
*/
protected void initializePreGUI() {
}
/**
* Method that will be called once just after the GUI is constructed in the go() and action()
* methods. Use it to initialize data structures needed for the application whose values
* may depend on the initial state of GUI components. By default it does nothing.
*/
protected void initializePostGUI() {
}
/**
* Method that will be called each time the default Reset button is clicked.
* Use it to reset any data structures and/or GUI components. By default it does nothing.
*/
protected void reset() {
}
/**
* Constructs GUI header as label with default positioning and font. May be overridden.
*/
protected JComponent buildHeadingArea() {
// OVERALL STRUCTURE OF MESSAGE (TOP)
headingLabel = new JLabel();
Box headingPanel = Box.createHorizontalBox();//new JPanel(new BorderLayout());
headingPanel.add(Box.createHorizontalGlue());
headingPanel.add(headingLabel);
headingPanel.add(Box.createHorizontalGlue());
// Details for heading area (top)
headingLabel.setText(heading);
headingLabel.setHorizontalTextPosition(JLabel.CENTER);
headingLabel.setFont(new Font(headingLabel.getFont().getFontName(),Font.PLAIN,18));
return headingPanel;
}
/**
* The MarsTool default set of controls has one row of 3 buttons. It includes a dual-purpose button to
* attach or detach simulator to MIPS memory, a button to reset the cache, and one to close the tool.
*/
protected JComponent buildButtonAreaMarsTool() {
Box buttonArea = Box.createHorizontalBox();
TitledBorder tc =new TitledBorder(“Tool Control”);
tc.setTitleJustification(TitledBorder.CENTER);
buttonArea.setBorder(tc);
connectButton = new ConnectButton();
connectButton.setToolTipText(“Control whether tool will respond to running MIPS program”);
connectButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (connectButton.isConnected()) {
connectButton.disconnect();
}
else {
connectButton.connect();
}
}
});
connectButton.addKeyListener(new EnterKeyListener(connectButton));
JButton resetButton = new JButton(“Reset”);
resetButton.setToolTipText(“Reset all counters and other structures”);
resetButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
reset();
}
});
resetButton.addKeyListener(new EnterKeyListener(resetButton));
JButton closeButton = new JButton(“Close”);
closeButton.setToolTipText(“Close (exit) this tool”);
closeButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
performToolClosingDuties();
}
});
closeButton.addKeyListener(new EnterKeyListener(closeButton));
// Add all the buttons…
buttonArea.add(connectButton);
buttonArea.add(Box.createHorizontalGlue());
buttonArea.add(resetButton);
buttonArea.add(Box.createHorizontalGlue());
JComponent helpComponent = getHelpComponent();
if (helpComponent != null) {
buttonArea.add(helpComponent);
buttonArea.add(Box.createHorizontalGlue());
}
buttonArea.add(closeButton);
return buttonArea;
}
/**
* The Mars stand-alone app default set of controls has two rows of controls. It includes a text field for
* displaying status messages, a button to trigger an open file dialog, the MARS run speed slider
* to control timed execution, a button to assemble and run the program, a reset button
* whose action is determined by the subclass reset() method, and an exit button.
*/
protected JComponent buildButtonAreaStandAlone() {
// Overall structure of control area (two rows).
Box operationArea = Box.createVerticalBox();
Box fileControlArea = Box.createHorizontalBox();
Box buttonArea = Box.createHorizontalBox();
operationArea.add(fileControlArea);
operationArea.add(Box.createVerticalStrut(5));
operationArea.add(buttonArea);
TitledBorder ac =new TitledBorder(“Application Control”);
ac.setTitleJustification(TitledBorder.CENTER);
operationArea.setBorder(ac);
// Top row of controls consists of button to launch file open operation,
// text field to show filename, and run speed slider.
openFileButton = new JButton(“Open MIPS program…”);
openFileButton.setToolTipText(“Select MIPS program file to assemble and run”);
openFileButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
JCheckBox multiFileAssembleChoose = new JCheckBox(“Assemble all in selected file’s directory”,multiFileAssemble);
multiFileAssembleChoose.setToolTipText(“If checked, selected file will be assembled first and all other assembly files in directory will be assembled also.”);
fileChooser.setAccessory(multiFileAssembleChoose);
if (mostRecentlyOpenedFile != null) {
fileChooser.setSelectedFile(mostRecentlyOpenedFile);
}
// DPS 13 June 2007. The next 4 lines add file filter to file chooser.
FileFilter defaultFileFilter = FilenameFinder.getFileFilter(Globals.fileExtensions, “Assembler Files”, true);
fileChooser.addChoosableFileFilter(defaultFileFilter);
fileChooser.addChoosableFileFilter(fileChooser.getAcceptAllFileFilter());
fileChooser.setFileFilter(defaultFileFilter);
if (fileChooser.showOpenDialog(thisMarsApp) == JFileChooser.APPROVE_OPTION) {
multiFileAssemble = multiFileAssembleChoose.isSelected();
File theFile = fileChooser.getSelectedFile();
try {
theFile = theFile.getCanonicalFile();
}
catch (IOException ioe) {
// nothing to do, theFile will keep current value
}
String currentFilePath = theFile.getPath();
mostRecentlyOpenedFile = theFile;
operationStatusMessages.setText(“File: “+currentFilePath);
operationStatusMessages.setCaretPosition(0);
assembleRunButton.setEnabled(true);
}
}
});
openFileButton.addKeyListener(new EnterKeyListener(openFileButton));
operationStatusMessages = new MessageField(“No file open.”);
operationStatusMessages.setColumns(40);
operationStatusMessages.setMargin(new Insets(0, 3, 0, 3)); //(top, left, bottom, right)
operationStatusMessages.setBackground(backgroundColor);
operationStatusMessages.setFocusable(false);
operationStatusMessages.setToolTipText(“Display operation status messages”);
mars.venus.RunSpeedPanel speed = mars.venus.RunSpeedPanel.getInstance();
// Bottom row of controls consists of the three buttons defined here.
assembleRunButton = new JButton(“Assemble and Run”);
assembleRunButton.setToolTipText(“Assemble and run the currently selected MIPS program”);
assembleRunButton.setEnabled(false);
assembleRunButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
assembleRunButton.setEnabled(false);
openFileButton.setEnabled(false);
stopButton.setEnabled(true);
new Thread(new CreateAssembleRunMIPSprogram()).start();
}
});
assembleRunButton.addKeyListener(new EnterKeyListener(assembleRunButton));
stopButton = new JButton(“Stop”);
stopButton.setToolTipText(“Terminate MIPS program execution”);
stopButton.setEnabled(false);
stopButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
mars.simulator.Simulator.getInstance().stopExecution(null);
}
});
stopButton.addKeyListener(new EnterKeyListener(stopButton));
JButton resetButton = new JButton(“Reset”);
resetButton.setToolTipText(“Reset all counters and other structures”);
resetButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
reset();
}
});
resetButton.addKeyListener(new EnterKeyListener(resetButton));
JButton closeButton = new JButton(“Exit”);
closeButton.setToolTipText(“Exit this application”);
closeButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
performAppClosingDuties();
}
});
closeButton.addKeyListener(new EnterKeyListener(closeButton));
// Add top row of controls…
//fileControlArea.add(Box.createHorizontalStrut(5));
Box fileDisplayBox = Box.createVerticalBox();
fileDisplayBox.add(Box.createVerticalStrut(8));
fileDisplayBox.add(operationStatusMessages);
fileDisplayBox.add(Box.createVerticalStrut(8));
fileControlArea.add(fileDisplayBox);
fileControlArea.add(Box.createHorizontalGlue());
fileControlArea.add(speed);
// Add bottom row of buttons…
buttonArea.add(openFileButton);
buttonArea.add(Box.createHorizontalGlue());
buttonArea.add(assembleRunButton);
buttonArea.add(Box.createHorizontalGlue());
buttonArea.add(stopButton);
buttonArea.add(Box.createHorizontalGlue());
buttonArea.add(resetButton);
buttonArea.add(Box.createHorizontalGlue());
JComponent helpComponent = getHelpComponent();
if (helpComponent != null) {
buttonArea.add(helpComponent);
buttonArea.add(Box.createHorizontalGlue());
}
buttonArea.add(closeButton);
return operationArea;
}
//////////////////////////////////////////////////////////////////////////////////////
// Rest of the methods. Some are used by stand-alone (JFrame-based) only, some are
// used by MarsTool (JDialog-based) only, others are used by both.
//////////////////////////////////////////////////////////////////////////////////////
/**
* Called when receiving notice of access to MIPS memory or registers. Default
* implementation of method required by Observer interface. This method will filter out
* notices originating from the MARS GUI or from direct user editing of memory or register
* displays. Only notices arising from MIPS program access are allowed in.
* It then calls two methods to be overridden by the subclass (since they do
* nothing by default): processMIPSUpdate() then updateDisplay().
* @param resource the attached MIPS resource
* @param accessNotice AccessNotice information provided by the resource
*/
public void update(Observable resource, Object accessNotice) {
if (((AccessNotice)accessNotice).accessIsFromMIPS()) {
processMIPSUpdate(resource, (AccessNotice)accessNotice);
updateDisplay();
}
}
/**
* Override this method to process a received notice from MIPS Observable (memory or register)
* It will only be called if the notice was generated as the result of MIPS instruction execution.
* By default it does nothing. After this method is complete, the updateDisplay() method will be
* invoked automatically.
*/
protected void processMIPSUpdate(Observable resource, AccessNotice notice) {
}
/**
* This method is called when tool/app is exited either through the close/exit button or the window’s X box.
* Override it to perform any special housecleaning needed. By default it does nothing.
*/
protected void performSpecialClosingDuties() {
}
/**
* Add this app/tool as an Observer of desired MIPS Observables (memory and registers).
* By default, will add as an Observer of the entire Data Segment in memory.
* Override if you want something different. Note that the Memory methods to add an
* Observer to memory are flexible (you can register for a range of addresses) but
* may throw an AddressErrorException that you need to catch.
* This method is called whenever the default “Connect” button on a MarsTool or the
* default “Assemble and run” on a stand-alone Mars app is selected. The corresponding
* NOTE: if you do not want to register as an Observer of the entire data segment
* (starts at address 0x10000000) then override this to either do some alternative
* or nothing at all. This method is also overloaded to allow arbitrary memory
* subrange.
*/
protected void addAsObserver() {
addAsObserver(lowMemoryAddress, highMemoryAddress);
}
/**
* Add this app/tool as an Observer of the specified subrange of MIPS memory. Note
* that this method is not invoked automatically like the no-argument version, but
* if you use this method, you can still take advantage of provided default deleteAsObserver()
* since it will remove the app as a memory observer regardless of the subrange
* or number of subranges it is registered for.
* @param lowEnd low end of memory address range.
* @param highEnd high end of memory address range; must be >= lowEnd
*/
protected void addAsObserver(int lowEnd, int highEnd) {
String errorMessage = “Error connecting to MIPS memory”;
try {
Globals.memory.addObserver(thisMarsApp,lowEnd, highEnd);
}
catch (AddressErrorException aee) {
if (this.isBeingUsedAsAMarsTool) {
headingLabel.setText(errorMessage);
}
else {
operationStatusMessages.displayTerminatingMessage(errorMessage);
}
}
}
/**
* Add this app/tool as an Observer of the specified MIPS register.
*/
protected void addAsObserver(Register reg) {
if (reg != null) {
reg.addObserver(thisMarsApp);
}
}
/**
* Delete this app/tool as an Observer of MIPS Observables (memory and registers).
* By default, will delete as an Observer of memory.
* Override if you want something different.
* 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).
*/
protected void deleteAsObserver() {
Globals.memory.deleteObserver(thisMarsApp);
}
/**
* Delete this app/tool as an Observer of the specified MIPS register
*/
protected void deleteAsObserver(Register reg) {
if (reg != null) {
reg.deleteObserver(thisMarsApp);
}
}
/**
* Query method to let you know if the tool/app is (or could be) currently
* “observing” any MIPS resources. When running as a MarsTool, this
* will be true by default after clicking the “Connect to MIPS” button until “Disconnect
* from MIPS” is clicked. When running as a stand-alone app, this will be
* true by default after clicking the “Assemble and Run” button until until
* program execution has terminated either normally or by clicking the “Stop”
* button. The phrase “or could be” was added above because depending on how
* the tool/app operates, it may be possible to run the MIPS program without
* first registering as an Observer — i.e. addAsObserver() is overridden and
* takes no action.
* @return true if tool/app is (or could be) currently active as an Observer.
*/
protected boolean isObserving() {
return observing;
}
/**
* Override this method to implement updating of GUI after each MIPS instruction is executed,
* while running in “timed” mode (user specifies execution speed on the slider control).
* Does nothing by default.
*/
protected void updateDisplay() {
}
/**
* Override this method to provide a JComponent (probably a JButton) of your choice
* to be placed just left of the Close/Exit button. Its anticipated use is for a
* “help” button that launches a help message or dialog. But it can be any valid
* JComponent that doesn’t mind co-existing among a bunch of JButtons.
*/
protected JComponent getHelpComponent() {
return null;
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////// PRIVATE HELPER METHODS //////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// Closing duties for MarsTool only.
private void performToolClosingDuties() {
performSpecialClosingDuties();
if (connectButton.isConnected()) {
connectButton.disconnect();
}
dialog.setVisible(false);
dialog.dispose();
}
// Closing duties for stand-alone application only.
private void performAppClosingDuties() {
performSpecialClosingDuties();
thisMarsApp.setVisible(false);
System.exit(0);
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////// PRIVATE HELPER CLASSES //////////////////////////////////
// Specialized inner classes. Either used by stand-alone (JFrame-based) only //
// or used by MarsTool (JDialog-based) only. //
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// Little class for this dual-purpose button. It is used only by the MarsTool
// (not by the stand-alone app).
protected class ConnectButton extends JButton {
private static final String connectText = “Connect to MIPS”;
private static final String disconnectText = “Disconnect from MIPS”;
public ConnectButton() {
super();
disconnect();
}
public void connect() {
observing = true;
synchronized (Globals.memoryAndRegistersLock) {// DPS 23 July 2008
addAsObserver();
}
setText(disconnectText);
}
public void disconnect() {
synchronized (Globals.memoryAndRegistersLock) {// DPS 23 July 2008
deleteAsObserver();
}
observing = false;
setText(connectText);
}
public boolean isConnected() {
return observing;
}
}
///////////////////////////////////////////////////////////////////////
// Every control button will get one of these so when it has focus
// the Enter key can be used instead of a mouse click to perform
// its associated action. It will do nothing if no action listeners
// are attached to the button at the time of the call. Otherwise,
// it will call actionPerformed for the first action listener in the
// button’s list.
protected class EnterKeyListener extends KeyAdapter {
AbstractButton myButton;
public EnterKeyListener(AbstractButton who) {
myButton = who;
}
public void keyPressed(KeyEvent e) {
if (e.getKeyChar()== KeyEvent.VK_ENTER) {
e.consume();
try {
myButton.getActionListeners()[0].actionPerformed(new ActionEvent(myButton, 0, myButton.getText()));
}
catch (ArrayIndexOutOfBoundsException oob) {
// do nothing, since there is no action listener.
}
}
}
}
/////////////////////////////////////////////////////////////////////////////////
// called when the Assemble and Run button is pressed. Used only by stand-alone app.
private class CreateAssembleRunMIPSprogram implements Runnable {
public void run() {
String noSupportForExceptionHandler = null; // no auto-loaded exception handlers.
// boolean extendedAssemblerEnabled = true; // In this context, no reason to constrain.
// boolean warningsAreErrors = false; // Ditto.
String exceptionHandler = null;
if (Globals.getSettings().getExceptionHandlerEnabled() &&
Globals.getSettings().getExceptionHandler() != null &&
Globals.getSettings().getExceptionHandler().length() > 0) {
exceptionHandler = Globals.getSettings().getExceptionHandler();
}
Thread.currentThread().setPriority(Thread.NORM_PRIORITY-1);
Thread.yield();
MIPSprogram program = new MIPSprogram();
mars.Globals.program = program; // Shouldn’t have to do this…
String fileToAssemble = mostRecentlyOpenedFile.getPath();
ArrayList filesToAssemble = null;
if (multiFileAssemble) {// setting (check box in file open dialog) calls for multiple file assembly
filesToAssemble = FilenameFinder.getFilenameList(
new File(fileToAssemble).getParent(), Globals.fileExtensions);
}
else {
filesToAssemble = new ArrayList();
filesToAssemble.add(fileToAssemble);
}
ArrayList programsToAssemble = null;
try {
operationStatusMessages.displayNonTerminatingMessage(“Assembling “+fileToAssemble);
programsToAssemble = program.prepareFilesForAssembly(filesToAssemble, fileToAssemble, exceptionHandler);
}
catch (mars.ProcessingException pe) {
operationStatusMessages.displayTerminatingMessage(“Error reading file(s): “+fileToAssemble);
return;
}
try {
program.assemble(programsToAssemble, Globals.getSettings().getExtendedAssemblerEnabled(), Globals.getSettings().getWarningsAreErrors());
}
catch (mars.ProcessingException pe) {
operationStatusMessages.displayTerminatingMessage(“Assembly Error: “+fileToAssemble);
return;
}
// Moved these three register resets from before the try block to after it. 17-Dec-09 DPS.
RegisterFile.resetRegisters();
Coprocessor1.resetRegisters();
Coprocessor0.resetRegisters();
addAsObserver();
observing = true;
String terminatingMessage = “Normal termination: “;
try {
operationStatusMessages.displayNonTerminatingMessage(“Running “+fileToAssemble);
program.simulate(-1); // unlimited steps
}
catch (NullPointerException npe) {
// This will occur if program execution is interrupted by Stop button.
terminatingMessage = “User interrupt: “;
}
catch (mars.ProcessingException pe) {
terminatingMessage = “Runtime error: “;
}
finally {
deleteAsObserver();
observing = false;
operationStatusMessages.displayTerminatingMessage(terminatingMessage+fileToAssemble);
}
return;
}
}
//////////////////////////////////////////////////////////////////////////
// Class for text message field used to update operation status when
// assembling and running MIPS programs.
private class MessageField extends JTextField {
public MessageField(String text) {
super(text);
}
private void displayTerminatingMessage(String text) {
displayMessage(text, true);
}
private void displayNonTerminatingMessage(String text) {
displayMessage(text, false);
}
private void displayMessage(String text, boolean terminating) {
SwingUtilities.invokeLater(new MessageWriter(text, terminating));
}
/////////////////////////////////////////////////////////////////////////////////
// Little inner-inner class to display processing error message on AWT thread.
// Used only by stand-alone app.
private class MessageWriter implements Runnable {
private String text;
private boolean terminatingMessage;
public MessageWriter(String text, boolean terminating) {
this.text = text;
this.terminatingMessage = terminating;
}
public void run() {
if (text!=null) {
operationStatusMessages.setText(text);
operationStatusMessages.setCaretPosition(0);
}
if (terminatingMessage) {
assembleRunButton.setEnabled(true);
openFileButton.setEnabled(true);
stopButton.setEnabled(false);
}
}
}
}
//////////////////////////////////////////////////////////////////////
// For scheduling GUI update on timed runs…used only by stand-alone app.
private class GUIUpdater implements Runnable {
public void run() {
updateDisplay();
}
}
}
BHTableModel
package mars.tools;
public synchronized class BHTableModel extends javax.swing.table.AbstractTableModel {
private java.util.Vector m_entries;
private int m_entryCnt;
private int m_historySize;
private String[] m_columnNames;
private Class[] m_columnClasses;
public void BHTableModel(int, int, boolean);
public String getColumnName(int);
public Class getColumnClass(int);
public int getColumnCount();
public int getRowCount();
public Object getValueAt(int, int);
public void initBHT(int, int, boolean);
public int getIdxForAddress(int);
public boolean getPredictionAtIdx(int);
public void updatePredictionAtIdx(int, boolean);
}
mars/tools/BHTableModel.java
mars/tools/BHTableModel.java/*
Copyright (c) 2009, Ingo Kofler, ITEC, Klagenfurt University, Austria
Developed by Ingo Kofler (ingo.kofler@itec.uni-klu.ac.at)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
package mars.tools;//.bhtsim;
import java.util.Vector;
import javax.swing.table.AbstractTableModel;
/**
* Simulates the actual functionality of a Branch History Table (BHT).
*
* The BHT consists of a number of BHT entries which are used to perform branch prediction.
* The entries of the BHT are stored as a Vector of BHTEntry objects.
* The number of entries is configurable but has to be a power of 2.
* The history kept by each BHT entry is also configurable during run-time.
* A change of the configuration however causes a complete reset of the BHT.
*
* The typical interaction is as follows:
*
-
*
- Construction of a BHT with a certain number of entries with a given history size.
- When encountering a branch instruction the index of the relevant BHT entry is calculated via the {@link BHTableModel#getIdxForAddress(int)} method.
- The current prediction of the BHT entry at the calculated index is obtained via the {@link BHTableModel#getPredictionAtIdx(int)} method.
- After detecting if the branch was really taken or not, this feedback is provided to the BHT by the {@link BHTableModel#updatePredictionAtIdx(int, boolean)} method.
*
*
*
*
*
* Additionally it serves as TableModel that can be directly used to render the state of the BHT in a JTable.
* Feedback provided to the BHT causes a change of the internal state and a repaint of the table(s) associated to this model.
*
* @author ingo.kofler@itec.uni-klu.ac.at
*/
//@SuppressWarnings(“serial”)
public class BHTableModel extends AbstractTableModel {
/** vector holding the entries of the BHT */
private Vector m_entries;
/** number of entries in the BHT */
private int m_entryCnt;
/** number of past branch events to remember */
private int m_historySize;
/** name of the table columns */
private String m_columnNames[] = { “Index”, “History”, “Prediction”, “Correct”, “Incorrect”, “Precision”};
/** type of the table columns */
//@SuppressWarnings(“unchecked”)
private Class m_columnClasses[] = { Integer.class, String.class, String.class, Integer.class, Integer.class, Double.class};
/**
* Constructs a new BHT with given number of entries and history size.
*
* @param numEntries number of entries in the BHT
* @param historySize size of the history (in bits/number of past branches)
*/
public BHTableModel (int numEntries, int historySize, boolean initVal) {
initBHT(numEntries, historySize, initVal);
}
/**
* Returns the name of the i-th column of the table.
* Required by the TableModel interface.
*
* @param i the index of the column
* @return name of the i-th column
*/
public String getColumnName(int i) {
if (i < 0 || i > m_columnNames.length)
throw new IllegalArgumentException(“Illegal column index ” + i + ” (must be in range 0..” + (m_columnNames.length-1) + “)”);
return m_columnNames[i];
}
/**
* Returns the class/type of the i-th column of the table.
* Required by the TableModel interface.
*
* @param i the index of the column
* @return class representing the type of the i-th column
*/
public Class getColumnClass(int i) {
if (i < 0 || i > m_columnClasses.length)
throw new IllegalArgumentException(“Illegal column index ” + i + ” (must be in range 0..” + (m_columnClasses.length-1) + “)”);
return m_columnClasses[i];
}
/**
* Returns the number of columns.
* Required by the TableModel interface.
*
* @return currently the constant 6
*/
public int getColumnCount() {
return 6;
}
/**
* Returns the number of entries of the BHT.
* Required by the TableModel interface.
*
* @return number of rows / entries of the BHT
*/
public int getRowCount() {
return m_entryCnt;
}
/**
* Returns the value of the cell at the given row and column
* Required by the TableModel interface.
*
* @param row the row index
* @param col the column index
* @return the value of the cell
*/
public Object getValueAt(int row, int col) {
BHTEntry e = (BHTEntry) m_entries.elementAt(row);
if (e==null) return “”;
if (col==0) return new Integer(row);
if (col==1) return e.getHistoryAsStr();
if (col==2) return e.getPredictionAsStr();
if (col==3) return new Integer(e.getStatsPredCorrect());
if (col==4) return new Integer(e.getStatsPredIncorrect());
if (col==5) return new Double(e.getStatsPredPrecision());
return “”;
}
/**
* Initializes the BHT with the given size and history.
* All previous data like the BHT entries’ history and statistics will get lost.
* A refresh of the table that use this BHT as model will be triggered.
*
* @param numEntries number of entries in the BHT (has to be a power of 2)
* @param historySize size of the history to consider
* @param initVal initial value for each entry (true means take branch, false do not take branch)
*/
public void initBHT(int numEntries, int historySize, boolean initVal) {
if (numEntries <= 0 || (numEntries & (numEntries-1)) != 0)
throw new IllegalArgumentException("Number of entries must be a positive power of 2.");
if (historySize < 1 || historySize > 2)
throw new IllegalArgumentException(“Only history sizes of 1 or 2 supported.”);
m_entryCnt = numEntries;
m_historySize = historySize;
m_entries = new Vector();
for (int i=0; i < m_entryCnt; i++) {
m_entries.add(new BHTEntry(m_historySize, initVal));
}
// refresh the table(s)
fireTableStructureChanged();
}
/**
* Returns the index into the BHT for a given branch instruction address.
* A simple direct mapping is used.
*
* @param address the address of the branch instruction
* @return the index into the BHT
*/
public int getIdxForAddress(int address) {
if (address < 0)
throw new IllegalArgumentException("No negative addresses supported");
return (address >> 2) % m_entryCnt;
}
/**
* Retrieve the prediction for the i-th BHT entry.
*
* @param index the index of the entry in the BHT
* @return the prediction to take (true) or do not take (false) the branch
*/
public boolean getPredictionAtIdx(int index) {
if (index < 0 || index > m_entryCnt)
throw new IllegalArgumentException(“Only indexes in the range 0 to ” + (m_entryCnt-1) + ” allowed”);
return ((BHTEntry) m_entries.elementAt(index)).getPrediction();
}
/**
* Updates the BHT entry with the outcome of the branch instruction.
* This causes a change in the model and signals to update the connected table(s).
*
* @param index the index of the entry in the BHT
* @param branchTaken
*/
public void updatePredictionAtIdx(int index, boolean branchTaken) {
if (index < 0 || index > m_entryCnt)
throw new IllegalArgumentException(“Only indexes in the range 0 to ” + (m_entryCnt-1) + ” allowed”);
((BHTEntry) m_entries.elementAt(index)).updatePrediction(branchTaken);
fireTableRowsUpdated(index, index);
}
}
BHTEntry
package mars.tools;
public synchronized class BHTEntry {
private boolean[] m_history;
private boolean m_prediction;
private int m_incorrect;
private int m_correct;
public void BHTEntry(int, boolean);
public boolean getPrediction();
public void updatePrediction(boolean);
public int getStatsPredIncorrect();
public int getStatsPredCorrect();
public double getStatsPredPrecision();
public String getHistoryAsStr();
public String getPredictionAsStr();
}
mars/tools/BHTEntry.java
mars/tools/BHTEntry.java/*
Copyright (c) 2009, Ingo Kofler, ITEC, Klagenfurt University, Austria
Developed by Ingo Kofler (ingo.kofler@itec.uni-klu.ac.at)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
package mars.tools;//.bhtsim;
/**
* Represents a single entry of the Branch History Table.
*
* The entry holds the information about former branch predictions and outcomes.
* The number of past branch outcomes can be configured and is called the history.
* The semantics of the history of size n is as follows.
* The entry will change its prediction, if it mispredicts the branch n times in series.
* The prediction of the entry can be obtained by the {@link BHTEntry#getPrediction()} method.
* Feedback of taken or not taken branches is provided to the entry via the {@link BHTEntry#updatePrediction(boolean)} method.
* This causes the history and the prediction to be updated.
*
* Additionally the entry keeps track about how many times the prediction was correct or incorrect.
* The statistics can be obtained by the methods {@link BHTEntry#getStatsPredCorrect()}, {@link BHTEntry#getStatsPredIncorrect()} and {@link BHTEntry#getStatsPredPrecision()}.
*
* @author ingo.kofler@itec.uni-klu.ac.at
*/
public class BHTEntry {
/** the history of the BHT entry. Each boolean value signals if the branch was taken or not. The value at index n-1 represents the most recent branch outcome. */
private boolean m_history[];
/** the current prediction */
private boolean m_prediction;
/** absolute number of incorrect predictions */
private int m_incorrect;
/** absolute number of correct predictions */
private int m_correct;
/**
* Constructs a BHT entry with a given history size.
*
* The size of the history can only be set via the constructor and cannot be changed afterwards.
*
* @param historySize number of past branch outcomes to remember
* @param initVal the initial value of the entry (take or do not take)
*/
public BHTEntry(int historySize, boolean initVal) {
m_prediction = initVal;
m_history = new boolean[historySize];
for (int i=0; i < historySize; i++) {
m_history[i] = initVal;
}
m_correct = m_incorrect = 0;
}
/**
* Returns the branch prediction based on the history.
*
* @return true if prediction is to take the branch, false otherwise
*/
public boolean getPrediction() {
return m_prediction;
}
/**
* Updates the entry's history and prediction.
* This method provides feedback for a prediction.
* The history and the statistics are updated accordingly.
* Based on the updated history a new prediction is calculated
*
* @param branchTaken signals if the branch was taken (true) or not (false)
*/
public void updatePrediction(boolean branchTaken) {
// update history
for (int i=0; i < m_history.length-1; i++) {
m_history[i] = m_history[i+1];
}
m_history[m_history.length-1] = branchTaken;
// if the prediction was correct, update stats and keep prediction
if (branchTaken == m_prediction) {
m_correct ++;
}
else {
m_incorrect ++;
// check if the prediction should change
boolean changePrediction = true;
for (int i=0; i < m_history.length; i++) {
if (m_history[i] != branchTaken)
changePrediction = false;
}
if (changePrediction)
m_prediction = !m_prediction;
}
}
/**
* Get the absolute number of mispredictions.
*
* @return number of incorrect predictions (mispredictions)
*/
public int getStatsPredIncorrect() {
return m_incorrect;
}
/**
* Get the absolute number of correct predictions.
*
* @return number of correct predictions
*/
public int getStatsPredCorrect() {
return m_correct;
}
/**
* Get the percentage of correct predictions.
*
* @return the percentage of correct predictions
*/
public double getStatsPredPrecision() {
int sum = m_incorrect + m_correct;
return (sum==0) ? 0 : m_correct * 100.0 / sum;
}
/***
* Builds a string representation of the BHT entry's history.
* The history is a sequence of flags that signal if the branch was taken (T) or not taken (NT).
*
* @return a string representation of the BHT entry's history
*/
public String getHistoryAsStr() {
String result = "";
for (int i=0; i
result += m_history[i] ? “T” : “NT”;
}
return result;
}
/***
* Returns a string representation of the BHT entry’s current prediction.
* The prediction can be either to TAKE or do NOT TAKE the branch.
*
* @return a string representation of the BHT entry’s current prediction
*/
public String getPredictionAsStr() {
return m_prediction ? “TAKE” : “NOT TAKE”;
}
}
BHTSimGUI$1
package mars.tools;
synchronized class BHTSimGUI$1 extends javax.swing.table.DefaultTableCellRenderer {
private java.text.DecimalFormat formatter;
void BHTSimGUI$1(BHTSimGUI);
public void setValue(Object);
}
BHTSimGUI
package mars.tools;
public synchronized class BHTSimGUI extends javax.swing.JPanel {
private javax.swing.JTextField m_tfInstruction;
private javax.swing.JTextField m_tfAddress;
private javax.swing.JTextField m_tfIndex;
private javax.swing.JComboBox m_cbBHTentries;
private javax.swing.JComboBox m_cbBHThistory;
private javax.swing.JComboBox m_cbBHTinitVal;
private javax.swing.JTable m_tabBHT;
private javax.swing.JTextArea m_taLog;
public static final java.awt.Color COLOR_PREPREDICTION;
public static final java.awt.Color COLOR_PREDICTION_CORRECT;
public static final java.awt.Color COLOR_PREDICTION_INCORRECT;
public static final String BHT_TAKE_BRANCH = TAKE;
public static final String BHT_DO_NOT_TAKE_BRANCH = NOT TAKE;
public void BHTSimGUI();
private javax.swing.JTable createAndInitTable();
private javax.swing.JPanel buildInfoPanel();
private javax.swing.JPanel buildConfigPanel();
private javax.swing.JPanel buildLogPanel();
public javax.swing.JComboBox getCbBHTentries();
public javax.swing.JComboBox getCbBHThistory();
public javax.swing.JComboBox getCbBHTinitVal();
public javax.swing.JTable getTabBHT();
public javax.swing.JTextArea getTaLog();
public javax.swing.JTextField getTfInstruction();
public javax.swing.JTextField getTfAddress();
public javax.swing.JTextField getTfIndex();
static void
}
mars/tools/BHTSimGUI.java
mars/tools/BHTSimGUI.java/*
Copyright (c) 2009, Ingo Kofler, ITEC, Klagenfurt University, Austria
Developed by Ingo Kofler (ingo.kofler@itec.uni-klu.ac.at)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
package mars.tools;//.bhtsim;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.text.DecimalFormat;
import java.util.Vector;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;
/**
* Represents the GUI of the BHT Simulator Tool.
*
*
* The GUI consists of mainly four parts:
*
-
*
- A configuration panel to select the number of entries and the history size
* - A information panel that displays the most recent branch instruction including its address and BHT index
* - A table representing the BHT with all entries and their internal state and statistics
* - A log panel that summarizes the predictions in a textual form
*
*
* @author ingo.kofler@itec.uni-klu.ac.at
*/
//@SuppressWarnings(“serial”)
public class BHTSimGUI extends JPanel {
/** text field presenting the most recent branch instruction */
private JTextField m_tfInstruction;
/** text field representing the address of the most recent branch instruction */
private JTextField m_tfAddress;
/** text field representing the resulting BHT index of the branch instruction */
private JTextField m_tfIndex;
/** combo box for selecting the number of BHT entries */
private JComboBox m_cbBHTentries;
/** combo box for selecting the history size */
private JComboBox m_cbBHThistory;
/** combo box for selecting the initial value */
private JComboBox m_cbBHTinitVal;
/** the table representing the BHT */
private JTable m_tabBHT;
/** text field for log output */
private JTextArea m_taLog;
/** constant for the color that highlights the current BHT entry */
public final static Color COLOR_PREPREDICTION = Color.yellow;
/** constant for the color to signal a correct prediction */
public final static Color COLOR_PREDICTION_CORRECT = Color.green;
/** constant for the color to signal a misprediction */
public final static Color COLOR_PREDICTION_INCORRECT = Color.red;
/** constant for the String representing “take the branch” */
public final static String BHT_TAKE_BRANCH = “TAKE”;
/** constant for the String representing “do not take the branch” */
public final static String BHT_DO_NOT_TAKE_BRANCH = “NOT TAKE”;
/**
* Creates the GUI components of the BHT Simulator
* The GUI is a subclass of JPanel which is integrated in the GUI of the MARS tool
*/
public BHTSimGUI() {
BorderLayout layout = new BorderLayout();
layout.setVgap(10);
layout.setHgap(10);
setLayout(layout);
m_tabBHT = createAndInitTable();
add(buildConfigPanel(), BorderLayout.NORTH);
add(buildInfoPanel(), BorderLayout.WEST);
add(new JScrollPane(m_tabBHT), BorderLayout.CENTER);
add(buildLogPanel(), BorderLayout.SOUTH);
}
/**
* Creates and initializes the JTable representing the BHT.
*
* @return the JTable representing the BHT
*/
private JTable createAndInitTable() {
// create the table
JTable theTable = new JTable();
// create a default renderer for double values (percentage)
DefaultTableCellRenderer doubleRenderer = new DefaultTableCellRenderer() {
private DecimalFormat formatter = new DecimalFormat(“##0.00”);
public void setValue(Object value) {
setText((value == null) ? “” : formatter.format(value));
}
};
doubleRenderer.setHorizontalAlignment(SwingConstants.CENTER);
// create a default renderer for all other values with center alignment
DefaultTableCellRenderer defRenderer = new DefaultTableCellRenderer();
defRenderer.setHorizontalAlignment(SwingConstants.CENTER);
theTable.setDefaultRenderer(Double.class, doubleRenderer);
theTable.setDefaultRenderer(Integer.class, defRenderer);
theTable.setDefaultRenderer(String.class, defRenderer);
theTable.setSelectionBackground(BHTSimGUI.COLOR_PREPREDICTION);
theTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
return theTable;
}
/**
* Creates and initializes the panel holding the instruction, address and index text fields.
*
* @return the info panel
*/
private JPanel buildInfoPanel() {
m_tfInstruction = new JTextField();
m_tfAddress = new JTextField();
m_tfIndex = new JTextField();
m_tfInstruction.setColumns(10);
m_tfInstruction.setEditable(false);
m_tfInstruction.setHorizontalAlignment(JTextField.CENTER);
m_tfAddress.setColumns(10);
m_tfAddress.setEditable(false);
m_tfAddress.setHorizontalAlignment(JTextField.CENTER);
m_tfIndex.setColumns(10);
m_tfIndex.setEditable(false);
m_tfIndex.setHorizontalAlignment(JTextField.CENTER);
JPanel panel = new JPanel();
JPanel outerPanel = new JPanel();
outerPanel.setLayout(new BorderLayout());
GridBagLayout gbl = new GridBagLayout();
panel.setLayout(gbl);
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(5, 5, 2, 5);
c.gridx = 1;
c.gridy = 1;
panel.add(new JLabel(“Instruction”), c);
c.gridy++;
panel.add(m_tfInstruction, c);
c.gridy++;
panel.add(new JLabel(“@ Address”), c);
c.gridy++;
panel.add(m_tfAddress, c);
c.gridy++;
panel.add(new JLabel(“-> Index”), c);
c.gridy++;
panel.add(m_tfIndex, c);
outerPanel.add(panel, BorderLayout.NORTH);
return outerPanel;
}
/**
* Creates and initializes the panel for the configuration of the tool
* The panel contains two combo boxes for selecting the number of BHT entries and the history size.
*
* @return a panel for the configuration
*/
private JPanel buildConfigPanel() {
JPanel panel = new JPanel();
Vector sizes = new Vector();
sizes.add(new Integer(8));
sizes.add(new Integer(16));
sizes.add(new Integer(32));
Vector bits = new Vector();
bits.add(new Integer(1));
bits.add(new Integer(2));
Vector initVals = new Vector();
initVals.add(BHTSimGUI.BHT_DO_NOT_TAKE_BRANCH);
initVals.add(BHTSimGUI.BHT_TAKE_BRANCH);
m_cbBHTentries = new JComboBox(sizes);
m_cbBHThistory = new JComboBox(bits);
m_cbBHTinitVal = new JComboBox(initVals);
panel.add(new JLabel(“# of BHT entries”));
panel.add(m_cbBHTentries);
panel.add(new JLabel(“BHT history size”));
panel.add(m_cbBHThistory);
panel.add(new JLabel(“Initial value”));
panel.add(m_cbBHTinitVal);
return panel;
}
/**
* Creates and initializes the panel containing the log text area.
*
* @return the panel for the logging output
*/
private JPanel buildLogPanel() {
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
m_taLog = new JTextArea();
m_taLog.setRows(6);
m_taLog.setEditable(false);
panel.add(new JLabel(“Log”), BorderLayout.NORTH);
panel.add(new JScrollPane(m_taLog), BorderLayout.CENTER);
return panel;
}
/***
* Returns the combo box for selecting the number of BHT entries.
*
* @return the reference to the combo box
*/
public JComboBox getCbBHTentries() {
return m_cbBHTentries;
}
/***
* Returns the combo box for selecting the size of the BHT history.
*
* @return the reference to the combo box
*/
public JComboBox getCbBHThistory() {
return m_cbBHThistory;
}
/***
* Returns the combo box for selecting the initial value of the BHT
*
* @return the reference to the combo box
*/
public JComboBox getCbBHTinitVal() {
return m_cbBHTinitVal;
}
/***
* Returns the table representing the BHT.
*
* @return the reference to the table
*/
public JTable getTabBHT() {
return m_tabBHT;
}
/***
* Returns the text area for log purposes.
*
* @return the reference to the text area
*/
public JTextArea getTaLog() {
return m_taLog;
}
/***
* Returns the text field for displaying the most recent branch instruction
*
* @return the reference to the text field
*/
public JTextField getTfInstruction() {
return m_tfInstruction;
}
/***
* Returns the text field for displaying the address of the most recent branch instruction
*
* @return the reference to the text field
*/
public JTextField getTfAddress() {
return m_tfAddress;
}
/***
* Returns the text field for displaying the corresponding index into the BHT
*
* @return the reference to the text field
*/
public JTextField getTfIndex() {
return m_tfIndex;
}
}
BHTSimulator
package mars.tools;
public synchronized class BHTSimulator extends AbstractMarsToolAndApplication implements java.awt.event.ActionListener {
public static final int BHT_DEFAULT_SIZE = 16;
public static final int BHT_DEFAULT_HISTORY = 1;
public static final boolean BHT_DEFAULT_INITVAL = 0;
public static final String BHT_NAME = BHT Simulator;
public static final String BHT_VERSION = Version 1.0 (Ingo Kofler);
public static final String BHT_HEADING = Branch History Table Simulator;
private BHTSimGUI m_gui;
private BHTableModel m_bhtModel;
private int m_pendingBranchInstAddress;
private boolean m_lastBranchTaken;
public void BHTSimulator();
protected void addAsObserver();
protected javax.swing.JComponent buildMainDisplayArea();
public String getName();
protected void reset();
public void actionPerformed(java.awt.event.ActionEvent);
protected void resetSimulator();
protected void handlePreBranchInst(mars.ProgramStatement);
protected void handleExecBranchInst(int, boolean);
protected static boolean isBranchInstruction(mars.ProgramStatement);
protected static boolean willBranch(mars.ProgramStatement);
protected static int extractBranchAddress(mars.ProgramStatement);
protected void processMIPSUpdate(java.util.Observable, mars.mips.hardware.AccessNotice);
}
mars/tools/BHTSimulator.java
mars/tools/BHTSimulator.java/*
Copyright (c) 2009, Ingo Kofler, ITEC, Klagenfurt University, Austria
Developed by Ingo Kofler (ingo.kofler@itec.uni-klu.ac.at)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
package mars.tools;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Observable;
import javax.swing.JComponent;
import mars.ProgramStatement;
import mars.mips.hardware.AccessNotice;
import mars.mips.hardware.AddressErrorException;
import mars.mips.hardware.Memory;
import mars.mips.hardware.MemoryAccessNotice;
import mars.mips.hardware.RegisterFile;
//import mars.tools.bhtsim.BHTSimGUI;
//import mars.tools.bhtsim.BHTableModel;
/**
* A MARS tool for simulating branch prediction with a Branch History Table (BHT)
*
* The simulation is based on observing the access to the instruction memory area (text segment).
* If a branch instruction is encountered, a prediction based on a BHT is performed.
* The outcome of the branch is compared with the prediction and the prediction is updated accordingly.
* Statistics about the correct and incorrect number of predictions can be obtained for each BHT entry.
* The number of entries in the BHT and the history that is considered for each prediction can be configured interactively.
* A change of the configuration however causes a re-initialization of the BHT.
*
* The tool can be used to show how branch prediction works in case of loops and how effective such simple methods are.
* In case of nested loops the difference of BHT with 1 or 2 Bit history can be explored and visualized.
*
* @author ingo.kofler@itec.uni-klu.ac.at
*/
//@SuppressWarnings(“serial”)
public class BHTSimulator extends AbstractMarsToolAndApplication implements ActionListener {
/** constant for the default size of the BHT */
public static final int BHT_DEFAULT_SIZE = 16;
/** constant for the default history size */
public static final int BHT_DEFAULT_HISTORY = 1;
/** constant for the default inital value */
public static final boolean BHT_DEFAULT_INITVAL = false;
/** the name of the tool */
public static final String BHT_NAME = “BHT Simulator”;
/** the version of the tool */
public static final String BHT_VERSION = “Version 1.0 (Ingo Kofler)”;
/** the heading of the tool */
public static final String BHT_HEADING = “Branch History Table Simulator”;
/** the GUI of the BHT simulator */
private BHTSimGUI m_gui;
/** the model of the BHT */
private BHTableModel m_bhtModel;
/** state variable that indicates that the last instruction was a branch instruction (if address != 0) or not (address == 0) */
private int m_pendingBranchInstAddress;
/** state variable that signals if the last branch was taken */
private boolean m_lastBranchTaken;
/**
* Creates a BHT Simulator with given name and heading.
*/
public BHTSimulator() {
super(BHTSimulator.BHT_NAME+”, “+BHTSimulator.BHT_VERSION, BHTSimulator.BHT_HEADING);
}
/**
* Adds BHTSimulator as observer of the text segment.
*/
protected void addAsObserver() {
addAsObserver(Memory.textBaseAddress, Memory.textLimitAddress);
addAsObserver(RegisterFile.getProgramCounterRegister());
}
/**
* Creates a GUI and initialize the GUI with the default values.
*/
protected JComponent buildMainDisplayArea() {
m_gui = new BHTSimGUI();
m_bhtModel = new BHTableModel(BHTSimulator.BHT_DEFAULT_SIZE, BHTSimulator.BHT_DEFAULT_HISTORY, BHT_DEFAULT_INITVAL);
m_gui.getTabBHT().setModel(m_bhtModel);
m_gui.getCbBHThistory().setSelectedItem(new Integer(BHTSimulator.BHT_DEFAULT_HISTORY));
m_gui.getCbBHTentries().setSelectedItem(new Integer(BHTSimulator.BHT_DEFAULT_SIZE));
m_gui.getCbBHTentries().addActionListener(this);
m_gui.getCbBHThistory().addActionListener(this);
m_gui.getCbBHTinitVal().addActionListener(this);
return m_gui;
}
/**
* Returns the name of the tool.
* @return the tool’s name as String
*/
public String getName() {
return BHTSimulator.BHT_NAME;
}
/**
* Performs a reset of the simulator.
* This causes the BHT to be reseted and the log messages to be cleared.
*/
protected void reset() {
resetSimulator();
}
/**
* Handles the actions when selecting another value in one of the two combo boxes.
* Selecting a different BHT size or history causes a reset of the simulator.
*/
public void actionPerformed(ActionEvent event) {
// change of the BHT size or BHT bit configuration
// resets the simulator
if (event.getSource() == m_gui.getCbBHTentries() || event.getSource() == m_gui.getCbBHThistory() || event.getSource() == m_gui.getCbBHTinitVal()) {
resetSimulator();
}
}
/**
* Resets the simulator by clearing the GUI elements and resetting the BHT.
*/
protected void resetSimulator() {
m_gui.getTfInstruction().setText(“”);
m_gui.getTfAddress().setText(“”);
m_gui.getTfIndex().setText(“”);
m_gui.getTaLog().setText(“”);
m_bhtModel.initBHT(((Integer)m_gui.getCbBHTentries().getSelectedItem()).intValue(),
((Integer)m_gui.getCbBHThistory().getSelectedItem()).intValue(),
((String)m_gui.getCbBHTinitVal().getSelectedItem()).equals(BHTSimGUI.BHT_TAKE_BRANCH));
m_pendingBranchInstAddress = 0;
m_lastBranchTaken = false;
}
/**
* Handles the execution branch instruction.
* This method is called each time a branch instruction is executed.
* Based on the address of the instruction the corresponding index into the BHT is calculated.
* The prediction is obtained from the BHT at the calculated index and is visualized appropriately.
*
* @param stmt the branch statement that is executed
*/
protected void handlePreBranchInst(ProgramStatement stmt) {
String strStmt = stmt.getBasicAssemblyStatement();
int address = stmt.getAddress();
int idx = m_bhtModel.getIdxForAddress(address);
// update the GUI
m_gui.getTfInstruction().setText(strStmt);
m_gui.getTfAddress().setText(“0x” + Integer.toHexString(address));
m_gui.getTfIndex().setText(“” + idx);
// mark the affected BHT row
m_gui.getTabBHT().setSelectionBackground(BHTSimGUI.COLOR_PREPREDICTION);
m_gui.getTabBHT().addRowSelectionInterval(idx, idx);
// add output to log
m_gui.getTaLog().append(“instruction ” + strStmt + ” at address 0x” + Integer.toHexString(address) + “, maps to index ” + idx + “\n”);
m_gui.getTaLog().append(“branches to address 0x” + BHTSimulator.extractBranchAddress(stmt) + “\n”);
m_gui.getTaLog().append(“prediction is: ” + (m_bhtModel.getPredictionAtIdx(idx) ? “take” : “do not take”) + “…\n”);
m_gui.getTaLog().setCaretPosition(m_gui.getTaLog().getDocument().getLength());
}
/**
* Handles the execution of the branch instruction.
* The correctness of the prediction is visualized in both the table and the log message area.
* The BHT is updated based on the information if the branch instruction was taken or not.
*
* @param branchInstAddr the address of the branch instruction
* @param branchTaken the information if the branch is taken or not (determined in a step before)
*/
protected void handleExecBranchInst(int branchInstAddr, boolean branchTaken) {
// determine the index in the BHT for the branch instruction
int idx = m_bhtModel.getIdxForAddress(branchInstAddr);
// check if the prediction is correct
boolean correctPrediction = m_bhtModel.getPredictionAtIdx(idx) == branchTaken;
m_gui.getTabBHT().setSelectionBackground(correctPrediction ? BHTSimGUI.COLOR_PREDICTION_CORRECT: BHTSimGUI.COLOR_PREDICTION_INCORRECT);
// add some output at the log
m_gui.getTaLog().append(“branch ” + (branchTaken ? “taken” : “not taken”) + “, prediction was ” + ( correctPrediction ? “correct” : “incorrect”) + “\n\n”);
m_gui.getTaLog().setCaretPosition(m_gui.getTaLog().getDocument().getLength());
// update the BHT -> causes refresh of the table
m_bhtModel.updatePredictionAtIdx(idx, branchTaken);
}
/**
* Determines if the instruction is a branch instruction or not.
*
* @param stmt the statement to investigate
* @return true, if stmt is a branch instruction, otherwise false
*/
protected static boolean isBranchInstruction(ProgramStatement stmt) {
int opCode = stmt.getBinaryStatement() >>> (32-6);
int funct = stmt.getBinaryStatement() & 0x1F;
if (opCode == 0x01) {
if (0x00 <= funct && funct <= 0x07) return true; // bltz, bgez, bltzl, bgezl
if (0x10 <= funct && funct <= 0x13) return true; // bltzal, bgezal, bltzall, bgczall
}
if (0x04 <= opCode && opCode <= 0x07) return true; // beq, bne, blez, bgtz
if (0x14 <= opCode && opCode <= 0x17) return true; // beql, bnel, blezl, bgtzl
return false;
}
/**
* Checks if the branch instruction delivered as parameter will branch or not.
*
* @param stmt the branch instruction to be investigated
* @return true if the branch will be taken, otherwise false
*/
protected static boolean willBranch(ProgramStatement stmt) {
int opCode = stmt.getBinaryStatement() >>> (32-6);
int funct = stmt.getBinaryStatement() & 0x1F;
int rs = stmt.getBinaryStatement() >>> (32-6-5) & 0x1F;
int rt = stmt.getBinaryStatement() >>> (32-6-5-5) & 0x1F;
int valRS = RegisterFile.getRegisters()[rs].getValue();
int valRT = RegisterFile.getRegisters()[rt].getValue();
if (opCode == 0x01) {
switch (funct) {
case 0x00: return valRS < 0; // bltz
case 0x01: return valRS >= 0; // bgez
case 0x02: return valRS < 0; // bltzl
case 0x03: return valRS >= 0; // bgezl
}
}
switch (opCode) {
case 0x04: return valRS == valRT;
case 0x05: return valRS != valRT;
case 0x06: return valRS <= 0;
case 0x07: return valRS >= 0;
case 0x14: return valRS == valRT;
case 0x15: return valRS != valRT;
case 0x16: return valRS <= 0;
case 0x17: return valRS >= 0;
}
return true;
}
/**
* Extracts the target address of the branch.
*
* In MIPS the target address is encoded as 16-bit value.
* The target address is encoded relative to the address of the instruction after the branch instruction
*
* @param stmt the branch instruction
* @return the address of the instruction that is executed if the branch is taken
*/
protected static int extractBranchAddress(ProgramStatement stmt) {
short offset = (short)(stmt.getBinaryStatement() & 0xFFFF);
return stmt.getAddress() + (offset<<2) + 4;
}
/**
* Callback for text segment access by the MIPS simulator.
*
* The method is called each time the text segment is accessed to fetch the next instruction.
* If the next instruction to execute was a branch instruction, the branch prediction is performed and visualized.
* In case the last instruction was a branch instruction, the outcome of the branch prediction is analyzed and visualized.
*
* @param resource the observed resource
* @param notice signals the type of access (memory, register etc.)
*/
protected void processMIPSUpdate(Observable resource, AccessNotice notice) {
if (!notice.accessIsFromMIPS()) return;
if (notice.getAccessType() == AccessNotice.READ && notice instanceof MemoryAccessNotice) {
// now it is safe to make a cast of the notice
MemoryAccessNotice memAccNotice = (MemoryAccessNotice) notice;
try {
// access the statement in the text segment without notifying other tools etc.
ProgramStatement stmt = Memory.getInstance().getStatementNoNotify(memAccNotice.getAddress());
// necessary to handle possible null pointers at the end of the program
// (e.g., if the simulator tries to execute the next instruction after the last instruction in the text segment)
if (stmt != null) {
boolean clearTextFields = true;
// first, check if there's a pending branch to handle
if (m_pendingBranchInstAddress != 0) {
handleExecBranchInst(m_pendingBranchInstAddress, m_lastBranchTaken);
clearTextFields = false;
m_pendingBranchInstAddress = 0;
}
// if current instruction is branch instruction
if (BHTSimulator.isBranchInstruction(stmt)) {
handlePreBranchInst(stmt);
m_lastBranchTaken = willBranch(stmt);
m_pendingBranchInstAddress = stmt.getAddress();
clearTextFields = false;
}
// clear text fields and selection
if (clearTextFields) {
m_gui.getTfInstruction().setText("");
m_gui.getTfAddress().setText("");
m_gui.getTfIndex().setText("");
m_gui.getTabBHT().clearSelection();
}
}
else {
// check if there's a pending branch to handle
if (m_pendingBranchInstAddress != 0) {
handleExecBranchInst(m_pendingBranchInstAddress, m_lastBranchTaken);
m_pendingBranchInstAddress = 0;
}
}
}
catch (AddressErrorException e) {
// silently ignore these exceptions
}
}
}
}
BitmapDisplay$1
package mars.tools;
synchronized class BitmapDisplay$1 implements java.awt.event.ActionListener {
void BitmapDisplay$1(BitmapDisplay);
public void actionPerformed(java.awt.event.ActionEvent);
}
BitmapDisplay$2
package mars.tools;
synchronized class BitmapDisplay$2 implements java.awt.event.ActionListener {
void BitmapDisplay$2(BitmapDisplay);
public void actionPerformed(java.awt.event.ActionEvent);
}
BitmapDisplay$3
package mars.tools;
synchronized class BitmapDisplay$3 implements java.awt.event.ActionListener {
void BitmapDisplay$3(BitmapDisplay);
public void actionPerformed(java.awt.event.ActionEvent);
}
BitmapDisplay$4
package mars.tools;
synchronized class BitmapDisplay$4 implements java.awt.event.ActionListener {
void BitmapDisplay$4(BitmapDisplay);
public void actionPerformed(java.awt.event.ActionEvent);
}
BitmapDisplay$5
package mars.tools;
synchronized class BitmapDisplay$5 implements java.awt.event.ActionListener {
void BitmapDisplay$5(BitmapDisplay);
public void actionPerformed(java.awt.event.ActionEvent);
}
BitmapDisplay$6
package mars.tools;
synchronized class BitmapDisplay$6 implements java.awt.event.ActionListener {
void BitmapDisplay$6(BitmapDisplay);
public void actionPerformed(java.awt.event.ActionEvent);
}
BitmapDisplay$GraphicsPanel
package mars.tools;
synchronized class BitmapDisplay$GraphicsPanel extends javax.swing.JPanel {
private void BitmapDisplay$GraphicsPanel(BitmapDisplay);
public void paint(java.awt.Graphics);
private void paintGrid(java.awt.Graphics, BitmapDisplay$Grid);
}
BitmapDisplay$Grid
package mars.tools;
synchronized class BitmapDisplay$Grid {
java.awt.Color[][] grid;
int rows;
int columns;
private void BitmapDisplay$Grid(BitmapDisplay, int, int);
private int getRows();
private int getColumns();
private java.awt.Color getElement(int, int);
private java.awt.Color getElementFast(int, int);
private void setElement(int, int, int);
private void setElement(int, int, java.awt.Color);
private void reset();
}
BitmapDisplay
package mars.tools;
public synchronized class BitmapDisplay extends AbstractMarsToolAndApplication {
private static String version;
private static String heading;
private javax.swing.JComboBox visualizationUnitPixelWidthSelector;
private javax.swing.JComboBox visualizationUnitPixelHeightSelector;
private javax.swing.JComboBox visualizationPixelWidthSelector;
private javax.swing.JComboBox visualizationPixelHeightSelector;
private javax.swing.JComboBox displayBaseAddressSelector;
private java.awt.Graphics drawingArea;
private javax.swing.JPanel canvas;
private javax.swing.JPanel results;
private javax.swing.border.EmptyBorder emptyBorder;
private java.awt.Font countFonts;
private java.awt.Color backgroundColor;
private final String[] visualizationUnitPixelWidthChoices;
private final int defaultVisualizationUnitPixelWidthIndex;
private final String[] visualizationUnitPixelHeightChoices;
private final int defaultVisualizationUnitPixelHeightIndex;
private final String[] displayAreaPixelWidthChoices;
private final int defaultDisplayWidthIndex;
private final String[] displayAreaPixelHeightChoices;
private final int defaultDisplayHeightIndex;
private int unitPixelWidth;
private int unitPixelHeight;
private int displayAreaWidthInPixels;
private int displayAreaHeightInPixels;
private String[] displayBaseAddressChoices;
private int[] displayBaseAddresses;
private int defaultBaseAddressIndex;
private int baseAddress;
private BitmapDisplay$Grid theGrid;
public void BitmapDisplay(String, String);
public void BitmapDisplay();
public static void main(String[]);
public String getName();
protected void addAsObserver();
protected javax.swing.JComponent buildMainDisplayArea();
protected void processMIPSUpdate(java.util.Observable, mars.mips.hardware.AccessNotice);
protected void initializePreGUI();
protected void initializePostGUI();
protected void reset();
protected void updateDisplay();
protected javax.swing.JComponent getHelpComponent();
private javax.swing.JComponent buildOrganizationArea();
private javax.swing.JComponent buildVisualizationArea();
private void initializeDisplayBaseChoices();
private void updateBaseAddress();
private java.awt.Dimension getDisplayAreaDimension();
private void resetCounts();
private int getIntComboBoxSelection(javax.swing.JComboBox);
private javax.swing.JPanel getPanelWithBorderLayout();
private BitmapDisplay$Grid createNewGrid();
private void updateColorForAddress(mars.mips.hardware.MemoryAccessNotice);
static void
}
mars/tools/BitmapDisplay.java
mars/tools/BitmapDisplay.java package mars.tools;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import mars.tools.*;
import mars.mips.hardware.*;
/*
Copyright (c) 2010-2011, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Bitmapp display simulator. It can be run either as a stand-alone Java application having
* access to the mars package, or through MARS as an item in its Tools menu. It makes
* maximum use of methods inherited from its abstract superclass AbstractMarsToolAndApplication.
* Pete Sanderson, verison 1.0, 23 December 2010.
*/
public class BitmapDisplay extends AbstractMarsToolAndApplication {
private static String version = “Version 1.0”;
private static String heading = “Bitmap Display”;
// Major GUI components
private JComboBox visualizationUnitPixelWidthSelector, visualizationUnitPixelHeightSelector,
visualizationPixelWidthSelector, visualizationPixelHeightSelector, displayBaseAddressSelector;
private Graphics drawingArea;
private JPanel canvas;
private JPanel results;
// Some GUI settings
private EmptyBorder emptyBorder = new EmptyBorder(4,4,4,4);
private Font countFonts = new Font(“Times”, Font.BOLD,12);
private Color backgroundColor = Color.WHITE;
// Values for Combo Boxes
private final String[] visualizationUnitPixelWidthChoices = {“1″,”2″,”4″,”8″,”16″,”32”};
private final int defaultVisualizationUnitPixelWidthIndex = 0;
private final String[] visualizationUnitPixelHeightChoices = {“1″,”2″,”4″,”8″,”16″,”32”};
private final int defaultVisualizationUnitPixelHeightIndex = 0;
private final String[] displayAreaPixelWidthChoices = {“64″,”128″,”256″,”512″,”1024”};
private final int defaultDisplayWidthIndex = 3;
private final String[] displayAreaPixelHeightChoices = {“64″,”128″,”256″,”512″,”1024”};
private final int defaultDisplayHeightIndex = 2;
// Values for display canvas. Note their initialization uses the identifiers just above.
private int unitPixelWidth = Integer.parseInt(visualizationUnitPixelWidthChoices[defaultVisualizationUnitPixelWidthIndex]);
private int unitPixelHeight = Integer.parseInt(visualizationUnitPixelHeightChoices[defaultVisualizationUnitPixelHeightIndex]);
private int displayAreaWidthInPixels = Integer.parseInt(displayAreaPixelWidthChoices[defaultDisplayWidthIndex]);
private int displayAreaHeightInPixels = Integer.parseInt(displayAreaPixelHeightChoices[defaultDisplayHeightIndex]);
// The next four are initialized dynamically in initializeDisplayBaseChoices()
private String[] displayBaseAddressChoices;
private int[] displayBaseAddresses;
private int defaultBaseAddressIndex;
private int baseAddress;
private Grid theGrid;
/**
* Simple constructor, likely used to run a stand-alone bitmap display tool.
* @param title String containing title for title bar
* @param heading String containing text for heading shown in upper part of window.
*/
public BitmapDisplay(String title, String heading) {
super(title,heading);
}
/**
* Simple constructor, likely used by the MARS Tools menu mechanism
*/
public BitmapDisplay() {
super (“Bitmap Display, “+version, heading);
}
/**
* Main provided for pure stand-alone use. Recommended stand-alone use is to write a
* driver program that instantiates a Bitmap object then invokes its go() method.
* “stand-alone” means it is not invoked from the MARS Tools menu. “Pure” means there
* is no driver program to invoke the application.
*/
public static void main(String[] args) {
new BitmapDisplay(“Bitmap Display stand-alone, “+version,heading).go();
}
/**
* Required MarsTool method to return Tool name.
* @return Tool name. MARS will display this in menu item.
*/
public String getName() {
return “Bitmap Display”;
}
/**
* 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
* the memory range as selected by the base address combo box and capacity of the visualization display
* (number of visualization elements times the number of memory words each one represents).
* It does so by calling the inherited 2-parameter overload of this method.
* 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.
*/
protected void addAsObserver() {
int highAddress = baseAddress+theGrid.getRows()*theGrid.getColumns()*Memory.WORD_LENGTH_BYTES;
// Special case: baseAddress<0 means we're in kernel memory (0x80000000 and up) and most likely
// in memory map address space (0xffff0000 and up). In this case, we need to make sure the high address
// does not drop off the high end of 32 bit address space. Highest allowable word address is 0xfffffffc,
// which is interpreted in Java int as -4.
if (baseAddress < 0 && highAddress > -4) {
highAddress = -4;
}
addAsObserver(baseAddress, highAddress);
}
/**
* Method that constructs the main display area. It is organized vertically
* into two major components: the display configuration which an be modified
* using combo boxes, and the visualization display which is updated as the
* attached MIPS program executes.
* @return the GUI component containing these two areas
*/
protected JComponent buildMainDisplayArea() {
results = new JPanel();
results.add(buildOrganizationArea());
results.add(buildVisualizationArea());
return results;
}
//////////////////////////////////////////////////////////////////////////////////////
// Rest of the protected methods. These override do-nothing methods inherited from
// the abstract superclass.
//////////////////////////////////////////////////////////////////////////////////////
/**
* Update display when connected MIPS program accesses (data) memory.
* @param memory the attached memory
* @param accessNotice information provided by memory in MemoryAccessNotice object
*/
protected void processMIPSUpdate(Observable memory, AccessNotice accessNotice) {
if (accessNotice.getAccessType() == AccessNotice.WRITE) {
updateColorForAddress((MemoryAccessNotice)accessNotice);
}
}
/**
* Initialize all JComboBox choice structures not already initialized at declaration.
* Overrides inherited method that does nothing.
*/
protected void initializePreGUI() {
initializeDisplayBaseChoices();
// NOTE: Can’t call “createNewGrid()” here because it uses settings from
// several combo boxes that have not been created yet. But a default grid
// needs to be allocated for initial canvas display.
theGrid = new Grid(displayAreaHeightInPixels/unitPixelHeight,
displayAreaWidthInPixels/unitPixelWidth);
}
/**
* The only post-GUI initialization is to create the initial Grid object based on the default settings
* of the various combo boxes. Overrides inherited method that does nothing.
*/
protected void initializePostGUI() {
theGrid = createNewGrid();
updateBaseAddress();
}
/**
* Method to reset counters and display when the Reset button selected.
* Overrides inherited method that does nothing.
*/
protected void reset() {
resetCounts();
updateDisplay();
}
/**
* Updates display immediately after each update (AccessNotice) is processed, after
* display configuration changes as needed, and after each execution step when Mars
* is running in timed mode. Overrides inherited method that does nothing.
*/
protected void updateDisplay() {
canvas.repaint();
}
/**
* Overrides default method, to provide a Help button for this tool/app.
*/
protected JComponent getHelpComponent() {
final String helpContent =
“Use this program to simulate a basic bitmap display where\n”+
“each memory word in a specified address space corresponds to\n”+
“one display pixel in row-major order starting at the upper left\n”+
“corner of the display. This tool may be run either from the\n”+
“MARS Tools menu or as a stand-alone application.\n”+
“\n”+
“You can easily learn to use this small program by playing with\n”+
“it! Each rectangular unit on the display represents one memory\n”+
“word in a contiguous address space starting with the specified\n”+
“base address. The value stored in that word will be interpreted\n”+
“as a 24-bit RGB color value with the red component in bits 16-23,\n”+
“the green component in bits 8-15, and the blue component in bits 0-7.\n”+
“Each time a memory word within the display address space is written\n”+
“by the MIPS program, its position in the display will be rendered\n”+
“in the color that its value represents.\n”+
“\n”+
“Version 1.0 is very basic and was constructed from the Memory\n”+
“Reference Visualization tool’s code. Feel free to improve it and\n”+
“send me your code for consideration in the next MARS release.\n”+
“\n”+
“Contact Pete Sanderson at psanderson@otterbein.edu with\n”+
“questions or comments.\n”;
JButton help = new JButton(“Help”);
help.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(theWindow, helpContent);
}
});
return help;
}
//////////////////////////////////////////////////////////////////////////////////////
// Private methods defined to support the above.
//////////////////////////////////////////////////////////////////////////////////////
// UI components and layout for left half of GUI, where settings are specified.
private JComponent buildOrganizationArea() {
JPanel organization = new JPanel(new GridLayout(8,1));
visualizationUnitPixelWidthSelector = new JComboBox(visualizationUnitPixelWidthChoices);
visualizationUnitPixelWidthSelector.setEditable(false);
visualizationUnitPixelWidthSelector.setBackground(backgroundColor);
visualizationUnitPixelWidthSelector.setSelectedIndex(defaultVisualizationUnitPixelWidthIndex);
visualizationUnitPixelWidthSelector.setToolTipText(“Width in pixels of rectangle representing memory word”);
visualizationUnitPixelWidthSelector.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
unitPixelWidth = getIntComboBoxSelection(visualizationUnitPixelWidthSelector);
theGrid = createNewGrid();
updateDisplay();
}
});
visualizationUnitPixelHeightSelector = new JComboBox(visualizationUnitPixelHeightChoices);
visualizationUnitPixelHeightSelector.setEditable(false);
visualizationUnitPixelHeightSelector.setBackground(backgroundColor);
visualizationUnitPixelHeightSelector.setSelectedIndex(defaultVisualizationUnitPixelHeightIndex);
visualizationUnitPixelHeightSelector.setToolTipText(“Height in pixels of rectangle representing memory word”);
visualizationUnitPixelHeightSelector.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
unitPixelHeight = getIntComboBoxSelection(visualizationUnitPixelHeightSelector);
theGrid = createNewGrid();
updateDisplay();
}
});
visualizationPixelWidthSelector = new JComboBox(displayAreaPixelWidthChoices);
visualizationPixelWidthSelector.setEditable(false);
visualizationPixelWidthSelector.setBackground(backgroundColor);
visualizationPixelWidthSelector.setSelectedIndex(defaultDisplayWidthIndex);
visualizationPixelWidthSelector.setToolTipText(“Total width in pixels of display area”);
visualizationPixelWidthSelector.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
displayAreaWidthInPixels = getIntComboBoxSelection(visualizationPixelWidthSelector);
canvas.setPreferredSize(getDisplayAreaDimension());
canvas.setSize(getDisplayAreaDimension());
theGrid = createNewGrid();
updateDisplay();
}
});
visualizationPixelHeightSelector = new JComboBox(displayAreaPixelHeightChoices);
visualizationPixelHeightSelector.setEditable(false);
visualizationPixelHeightSelector.setBackground(backgroundColor);
visualizationPixelHeightSelector.setSelectedIndex(defaultDisplayHeightIndex);
visualizationPixelHeightSelector.setToolTipText(“Total height in pixels of display area”);
visualizationPixelHeightSelector.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
displayAreaHeightInPixels = getIntComboBoxSelection(visualizationPixelHeightSelector);
canvas.setPreferredSize(getDisplayAreaDimension());
canvas.setSize(getDisplayAreaDimension());
theGrid = createNewGrid();
updateDisplay();
}
});
displayBaseAddressSelector = new JComboBox(displayBaseAddressChoices);
displayBaseAddressSelector.setEditable(false);
displayBaseAddressSelector.setBackground(backgroundColor);
displayBaseAddressSelector.setSelectedIndex(defaultBaseAddressIndex);
displayBaseAddressSelector.setToolTipText(“Base address for display area (upper left corner)”);
displayBaseAddressSelector.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
// This may also affect what address range we should be registered as an Observer
// for. The default (inherited) address range is the MIPS static data segment
// starting at 0x10010000. To change this requires override of
// AbstractMarsToolAndApplication.addAsObserver(). The no-argument version of
// that method is called automatically when “Connect” button is clicked for MarsTool
// and when “Assemble and Run” button is clicked for Mars application.
updateBaseAddress();
// If display base address is changed while connected to MIPS (this can only occur
// when being used as a MarsTool), we have to delete ourselves as an observer and re-register.
if (connectButton != null && connectButton.isConnected()) {
deleteAsObserver();
addAsObserver();
}
theGrid = createNewGrid();
updateDisplay();
}
});
// ALL COMPONENTS FOR “ORGANIZATION” SECTION
JPanel unitWidthInPixelsRow = getPanelWithBorderLayout();
unitWidthInPixelsRow.setBorder(emptyBorder);
unitWidthInPixelsRow.add(new JLabel(“Unit Width in Pixels “),BorderLayout.WEST);
unitWidthInPixelsRow.add(visualizationUnitPixelWidthSelector, BorderLayout.EAST);
JPanel unitHeightInPixelsRow = getPanelWithBorderLayout();
unitHeightInPixelsRow.setBorder(emptyBorder);
unitHeightInPixelsRow.add(new JLabel(“Unit Height in Pixels “),BorderLayout.WEST);
unitHeightInPixelsRow.add(visualizationUnitPixelHeightSelector,BorderLayout.EAST);
JPanel widthInPixelsRow = getPanelWithBorderLayout();
widthInPixelsRow.setBorder(emptyBorder);
widthInPixelsRow.add(new JLabel(“Display Width in Pixels “),BorderLayout.WEST);
widthInPixelsRow.add(visualizationPixelWidthSelector, BorderLayout.EAST);
JPanel heightInPixelsRow = getPanelWithBorderLayout();
heightInPixelsRow.setBorder(emptyBorder);
heightInPixelsRow.add(new JLabel(“Display Height in Pixels “),BorderLayout.WEST);
heightInPixelsRow.add(visualizationPixelHeightSelector,BorderLayout.EAST);
JPanel baseAddressRow = getPanelWithBorderLayout();
baseAddressRow.setBorder(emptyBorder);
baseAddressRow.add(new JLabel(“Base address for display “),BorderLayout.WEST);
baseAddressRow.add(displayBaseAddressSelector,BorderLayout.EAST);
// Lay ’em out in the grid…
organization.add(unitWidthInPixelsRow);
organization.add(unitHeightInPixelsRow);
organization.add(widthInPixelsRow);
organization.add(heightInPixelsRow);
organization.add(baseAddressRow);
return organization;
}
// UI components and layout for right half of GUI, the visualization display area.
private JComponent buildVisualizationArea() {
canvas = new GraphicsPanel();
canvas.setPreferredSize(getDisplayAreaDimension());
canvas.setToolTipText(“Bitmap display area”);
return canvas;
}
// For greatest flexibility, initialize the display base choices directly from
// the constants defined in the Memory class. This method called prior to
// building the GUI. Here are current values from Memory.java:
//dataSegmentBaseAddress=0x10000000, globalPointer=0x10008000
//dataBaseAddress=0x10010000, heapBaseAddress=0x10040000, memoryMapBaseAddress=0xffff0000
private void initializeDisplayBaseChoices() {
int[] displayBaseAddressArray = {Memory.dataSegmentBaseAddress, Memory.globalPointer, Memory.dataBaseAddress,
Memory.heapBaseAddress, Memory.memoryMapBaseAddress };
// Must agree with above in number and order…
String[] descriptions = { ” (global data)”, ” ($gp)”, ” (static data)”, ” (heap)”, ” (memory map)” };
displayBaseAddresses = displayBaseAddressArray;
displayBaseAddressChoices = new String[displayBaseAddressArray.length];
for (int i=0; i
10 and apply Integer.parseInt() to it to get custom base address.
*/
}
// Returns Dimension object with current width and height of display area as determined
// by current settings of respective combo boxes.
private Dimension getDisplayAreaDimension() {
return new Dimension(displayAreaWidthInPixels, displayAreaHeightInPixels);
}
// reset all counters in the Grid.
private void resetCounts() {
theGrid.reset();
}
// Will return int equivalent of specified combo box’s current selection.
// The selection must be a String that parses to an int.
private int getIntComboBoxSelection(JComboBox comboBox) {
try {
return Integer.parseInt((String)comboBox.getSelectedItem());
}
catch (NumberFormatException nfe) {
// Can occur only if initialization list contains badly formatted numbers. This
// is a developer’s error, not a user error, and better be caught before release.
return 1;
}
}
// Use this for consistent results.
private JPanel getPanelWithBorderLayout() {
return new JPanel(new BorderLayout(2,2));
}
// Method to determine grid dimensions based on current control settings.
// Each grid element corresponds to one visualization unit.
private Grid createNewGrid() {
int rows = displayAreaHeightInPixels/unitPixelHeight;
int columns = displayAreaWidthInPixels/unitPixelWidth;
return new Grid(rows,columns);
}
// Given memory address, update color for the corresponding grid element.
private void updateColorForAddress(MemoryAccessNotice notice) {
int address = notice.getAddress();
int value = notice.getValue();
int offset = (address – baseAddress)/Memory.WORD_LENGTH_BYTES;
try {
theGrid.setElement(offset / theGrid.getColumns(), offset % theGrid.getColumns(), value);
}
catch (IndexOutOfBoundsException e) {
// If address is out of range for display, do nothing.
}
}
//////////////////////////////////////////////////////////////////////////////////////
// Specialized inner classes for modeling and animation.
//////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Class that represents the panel for visualizing and animating memory reference
// patterns.
private class GraphicsPanel extends JPanel {
// override default paint method to assure display updated correctly every time
// the panel is repainted.
public void paint(Graphics g) {
paintGrid(g, theGrid);
}
// Paint the color codes.
private void paintGrid(Graphics g, Grid grid) {
int upperLeftX = 0, upperLeftY = 0;
for (int i=0; i
}
mars/tools/CacheSimulator.java
mars/tools/CacheSimulator.java package mars.tools;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import mars.util.*;
import mars.tools.*;
import mars.mips.hardware.*;
/*
Copyright (c) 2003-2011, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* A data cache simulator. It can be run either as a stand-alone Java application having
* access to the mars package, or through MARS as an item in its Tools menu. It makes
* maximum use of methods inherited from its abstract superclass AbstractMarsToolOrApp.
* Pete Sanderson, v 1.0: 16-18 October 2006, v 1.1: 7 November 2006. v 1.2: 23 December 2010.
*
Version 1.2 fixes a bug in the hit/miss animator under full or N-way set associative. It was
* animating the block of initial access (first block of set). Now it animates the block
* of final access (where address found or stored). Also added log display to GUI (previously System.out).
*/
public class CacheSimulator extends AbstractMarsToolAndApplication {
private static boolean debug = false; // controls display of debugging info
private static String version = “Version 1.2”;
private static String heading = “Simulate and illustrate data cache performance”;
// Major GUI components
private JComboBox cacheBlockSizeSelector, cacheBlockCountSelector,
cachePlacementSelector, cacheReplacementSelector,
cacheSetSizeSelector;
private JTextField memoryAccessCountDisplay, cacheHitCountDisplay, cacheMissCountDisplay,
replacementPolicyDisplay,cachableAddressesDisplay,
cacheSizeDisplay;
private JProgressBar cacheHitRateDisplay;
private Animation animations;
private JPanel logPanel;
private JScrollPane logScroll;
private JTextArea logText;
private JCheckBox logShow;
// Some GUI settings
private EmptyBorder emptyBorder = new EmptyBorder(4,4,4,4);
private Font countFonts = new Font(“Times”, Font.BOLD,12);
private Color backgroundColor = Color.WHITE;
// Values for Combo Boxes
private int[] cacheBlockSizeChoicesInt, cacheBlockCountChoicesInt;
private String[] cacheBlockSizeChoices = {“1″,”2″,”4″,”8″,”16″,”32″,”64″,”128″,”256″,”512″,”1024″,”2048”};
private String[] cacheBlockCountChoices = {“1″,”2″,”4″,”8″,”16″,”32″,”64″,”128″,”256″,”512″,”1024″,”2048”};
private String[] placementPolicyChoices = {“Direct Mapping”, “Fully Associative”, “N-way Set Associative” };
private final int DIRECT = 0, FULL = 1, SET = 2; // NOTE: these have to match placementPolicyChoices order!
private String[] replacementPolicyChoices = {“LRU”,”Random”};
private final int LRU = 0, RANDOM = 1; // NOTE: these have to match replacementPolicyChoices order!
private String[] cacheSetSizeChoices; // will change dynamically based on the other selections
private int defaultCacheBlockSizeIndex = 2;
private int defaultCacheBlockCountIndex = 3;
private int defaultPlacementPolicyIndex = DIRECT;
private int defaultReplacementPolicyIndex = LRU;
private int defaultCacheSetSizeIndex = 0;
// Cache-related data structures
private AbstractCache theCache;
private int memoryAccessCount, cacheHitCount, cacheMissCount;
private double cacheHitRate;
// RNG used for random replacement policy. For testing, set seed for reproducible stream
private Random randu = new Random(0);
/**
* Simple constructor, likely used to run a stand-alone cache simulator.
* @param title String containing title for title bar
* @param heading String containing text for heading shown in upper part of window.
*/
public CacheSimulator(String title, String heading) {
super(title,heading);
}
/**
* Simple constructor, likely used by the MARS Tools menu mechanism
*/
public CacheSimulator() {
super (“Data Cache Simulation Tool, “+version, heading);
}
/**
* Main provided for pure stand-alone use. Recommended stand-alone use is to write a
* driver program that instantiates a CacheSimulator object then invokes its go() method.
* “stand-alone” means it is not invoked from the MARS Tools menu. “Pure” means there
* is no driver program to invoke the Cache Simulator.
*/
public static void main(String[] args) {
new CacheSimulator(“Data Cache Simulator stand-alone, “+version,heading).go();
}
/**
* Required MarsTool method to return Tool name.
* @return Tool name. MARS will display this in menu item.
*/
public String getName() {
return “Data Cache Simulator”;
}
/**
* Method that constructs the main cache simulator display area. It is organized vertically
* into three major components: the cache configuration which an be modified
* using combo boxes, the cache performance which is updated as the
* attached MIPS program executes, and the runtime log which is optionally used
* to display log of each cache access.
* @return the GUI component containing these three areas
*/
protected JComponent buildMainDisplayArea() {
// OVERALL STRUCTURE OF MAIN UI (CENTER)
Box results = Box.createVerticalBox();
results.add(buildOrganizationArea());
results.add(buildPerformanceArea());
results.add(buildLogArea());
return results;
}
////////////////////////////////////////////////////////////////////////////
private JComponent buildLogArea() {
logPanel = new JPanel();
TitledBorder ltb =new TitledBorder(“Runtime Log”);
ltb.setTitleJustification(TitledBorder.CENTER);
logPanel.setBorder(ltb);
logShow = new JCheckBox(“Enabled”,debug);
logShow.addItemListener(
new ItemListener() {
public void itemStateChanged(ItemEvent e) {
debug = e.getStateChange() == ItemEvent.SELECTED;
resetLogDisplay();
logText.setEnabled(debug);
logText.setBackground( debug ? Color.WHITE : logPanel.getBackground() );
}
});
logPanel.add(logShow);
logText = new JTextArea(5,70);
logText.setEnabled(debug);
logText.setBackground( debug ? Color.WHITE : logPanel.getBackground() );
logText.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
logText.setToolTipText(“Displays cache activity log if enabled”);
logScroll = new JScrollPane(logText,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
logPanel.add(logScroll);
return logPanel;
}
////////////////////////////////////////////////////////////////////////////
private JComponent buildOrganizationArea() {
JPanel organization = new JPanel(new GridLayout(3,2));
TitledBorder otb =new TitledBorder(“Cache Organization”);
otb.setTitleJustification(TitledBorder.CENTER);
organization.setBorder(otb);
cachePlacementSelector = new JComboBox(placementPolicyChoices);
cachePlacementSelector.setEditable(false);
cachePlacementSelector.setBackground(backgroundColor);
cachePlacementSelector.setSelectedIndex(defaultPlacementPolicyIndex);
cachePlacementSelector.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
updateCacheSetSizeSelector();
reset();
}
});
cacheReplacementSelector = new JComboBox(replacementPolicyChoices);
cacheReplacementSelector.setEditable(false);
cacheReplacementSelector.setBackground(backgroundColor);
cacheReplacementSelector.setSelectedIndex(defaultReplacementPolicyIndex);
cacheBlockSizeSelector = new JComboBox(cacheBlockSizeChoices);
cacheBlockSizeSelector.setEditable(false);
cacheBlockSizeSelector.setBackground(backgroundColor);
cacheBlockSizeSelector.setSelectedIndex(defaultCacheBlockSizeIndex);
cacheBlockSizeSelector.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
updateCacheSizeDisplay();
reset();
}
});
cacheBlockCountSelector = new JComboBox(cacheBlockCountChoices);
cacheBlockCountSelector.setEditable(false);
cacheBlockCountSelector.setBackground(backgroundColor);
cacheBlockCountSelector.setSelectedIndex(defaultCacheBlockCountIndex);
cacheBlockCountSelector.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
updateCacheSetSizeSelector();
theCache = createNewCache();
resetCounts();
updateDisplay();
updateCacheSizeDisplay();
animations.fillAnimationBoxWithCacheBlocks();
}
});
cacheSetSizeSelector = new JComboBox(cacheSetSizeChoices);
cacheSetSizeSelector.setEditable(false);
cacheSetSizeSelector.setBackground(backgroundColor);
cacheSetSizeSelector.setSelectedIndex(defaultCacheSetSizeIndex);
cacheSetSizeSelector.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
reset();
}
});
// ALL COMPONENTS FOR “CACHE ORGANIZATION” SECTION
JPanel placementPolicyRow = getPanelWithBorderLayout();
placementPolicyRow.setBorder(emptyBorder);
placementPolicyRow.add(new JLabel(“Placement Policy “),BorderLayout.WEST);
placementPolicyRow.add(cachePlacementSelector,BorderLayout.EAST);
JPanel replacementPolicyRow = getPanelWithBorderLayout();
replacementPolicyRow.setBorder(emptyBorder);
replacementPolicyRow.add(new JLabel(“Block Replacement Policy “),BorderLayout.WEST);
/* replacementPolicyDisplay = new JTextField(“N/A”,6);
replacementPolicyDisplay.setEditable(false);
replacementPolicyDisplay.setBackground(backgroundColor);
replacementPolicyDisplay.setHorizontalAlignment(JTextField.RIGHT); */
replacementPolicyRow.add(cacheReplacementSelector, BorderLayout.EAST);
JPanel cacheSetSizeRow = getPanelWithBorderLayout();
cacheSetSizeRow.setBorder(emptyBorder);
cacheSetSizeRow.add(new JLabel(“Set size (blocks) “),BorderLayout.WEST);
cacheSetSizeRow.add(cacheSetSizeSelector,BorderLayout.EAST);
// Cachable address range “selection” removed for now…
/*
JPanel cachableAddressesRow = getPanelWithBorderLayout();
cachableAddressesRow.setBorder(emptyBorder);
cachableAddressesRow.add(new JLabel(“Cachable Addresses “),BorderLayout.WEST);
cachableAddressesDisplay = new JTextField(“all data segment”);
cachableAddressesDisplay.setEditable(false);
cachableAddressesDisplay.setBackground(backgroundColor);
cachableAddressesDisplay.setHorizontalAlignment(JTextField.RIGHT);
cachableAddressesRow.add(cachableAddressesDisplay, BorderLayout.EAST);
*/
JPanel cacheNumberBlocksRow = getPanelWithBorderLayout();
cacheNumberBlocksRow.setBorder(emptyBorder);
cacheNumberBlocksRow.add(new JLabel(“Number of blocks “), BorderLayout.WEST);
cacheNumberBlocksRow.add(cacheBlockCountSelector, BorderLayout.EAST);
JPanel cacheBlockSizeRow = getPanelWithBorderLayout();
cacheBlockSizeRow.setBorder(emptyBorder);
cacheBlockSizeRow.add(new JLabel(“Cache block size (words) “), BorderLayout.WEST);
cacheBlockSizeRow.add(cacheBlockSizeSelector, BorderLayout.EAST);
JPanel cacheTotalSizeRow = getPanelWithBorderLayout();
cacheTotalSizeRow.setBorder(emptyBorder);
cacheTotalSizeRow.add(new JLabel(“Cache size (bytes) “), BorderLayout.WEST);
cacheSizeDisplay = new JTextField(8);
cacheSizeDisplay.setHorizontalAlignment(JTextField.RIGHT);
cacheSizeDisplay.setEditable(false);
cacheSizeDisplay.setBackground(backgroundColor);
cacheSizeDisplay.setFont(countFonts);
cacheTotalSizeRow.add(cacheSizeDisplay, BorderLayout.EAST);
updateCacheSizeDisplay();
// Lay ’em out in the grid…
organization.add(placementPolicyRow);
organization.add(cacheNumberBlocksRow);
organization.add(replacementPolicyRow);
organization.add(cacheBlockSizeRow);
//organization.add(cachableAddressesRow);
organization.add(cacheSetSizeRow);
organization.add(cacheTotalSizeRow);
return organization;
}
////////////////////////////////////////////////////////////////////////////
private JComponent buildPerformanceArea() {
JPanel performance = new JPanel(new GridLayout(1,2));
TitledBorder ptb =new TitledBorder(“Cache Performance”);
ptb.setTitleJustification(TitledBorder.CENTER);
performance.setBorder(ptb);
JPanel memoryAccessCountRow = getPanelWithBorderLayout();
memoryAccessCountRow.setBorder(emptyBorder);
memoryAccessCountRow.add(new JLabel(“Memory Access Count “), BorderLayout.WEST);
memoryAccessCountDisplay = new JTextField(10);
memoryAccessCountDisplay.setHorizontalAlignment(JTextField.RIGHT);
memoryAccessCountDisplay.setEditable(false);
memoryAccessCountDisplay.setBackground(backgroundColor);
memoryAccessCountDisplay.setFont(countFonts);
memoryAccessCountRow.add(memoryAccessCountDisplay, BorderLayout.EAST);
JPanel cacheHitCountRow = getPanelWithBorderLayout();
cacheHitCountRow.setBorder(emptyBorder);
cacheHitCountRow.add(new JLabel(“Cache Hit Count “), BorderLayout.WEST);
cacheHitCountDisplay = new JTextField(10);
cacheHitCountDisplay.setHorizontalAlignment(JTextField.RIGHT);
cacheHitCountDisplay.setEditable(false);
cacheHitCountDisplay.setBackground(backgroundColor);
cacheHitCountDisplay.setFont(countFonts);
cacheHitCountRow.add(cacheHitCountDisplay, BorderLayout.EAST);
JPanel cacheMissCountRow = getPanelWithBorderLayout();
cacheMissCountRow.setBorder(emptyBorder);
cacheMissCountRow.add(new JLabel(“Cache Miss Count “), BorderLayout.WEST);
cacheMissCountDisplay = new JTextField(10);
cacheMissCountDisplay.setHorizontalAlignment(JTextField.RIGHT);
cacheMissCountDisplay.setEditable(false);
cacheMissCountDisplay.setBackground(backgroundColor);
cacheMissCountDisplay.setFont(countFonts);
cacheMissCountRow.add(cacheMissCountDisplay, BorderLayout.EAST);
JPanel cacheHitRateRow = getPanelWithBorderLayout();
cacheHitRateRow.setBorder(emptyBorder);
cacheHitRateRow.add(new JLabel(“Cache Hit Rate “), BorderLayout.WEST);
cacheHitRateDisplay = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
cacheHitRateDisplay.setStringPainted(true);
cacheHitRateDisplay.setForeground(Color.BLUE);
cacheHitRateDisplay.setBackground(backgroundColor);
cacheHitRateDisplay.setFont(countFonts);
cacheHitRateRow.add(cacheHitRateDisplay, BorderLayout.EAST);
resetCounts();
updateDisplay();
// Vertically align these 4 measures in a grid, then add to left column of main grid.
JPanel performanceMeasures = new JPanel(new GridLayout(4,1));
performanceMeasures.add(memoryAccessCountRow);
performanceMeasures.add(cacheHitCountRow);
performanceMeasures.add(cacheMissCountRow);
performanceMeasures.add(cacheHitRateRow);
performance.add(performanceMeasures);
// LET’S TRY SOME ANIMATION ON THE RIGHT SIDE…
animations = new Animation();
animations.fillAnimationBoxWithCacheBlocks();
JPanel animationsPanel = new JPanel(new GridLayout(1,2));
Box animationsLabel = Box.createVerticalBox();
JPanel tableTitle1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
JPanel tableTitle2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
tableTitle1.add(new JLabel(“Cache Block Table”));
tableTitle2.add(new JLabel(“(block 0 at top)”));
animationsLabel.add(tableTitle1);
animationsLabel.add(tableTitle2);
Dimension colorKeyBoxSize = new Dimension(8,8);
JPanel emptyKey = new JPanel(new FlowLayout(FlowLayout.LEFT));
JPanel emptyBox = new JPanel();
emptyBox.setSize(colorKeyBoxSize);
emptyBox.setBackground(animations.defaultColor);
emptyBox.setBorder(BorderFactory.createLineBorder(Color.BLACK));
emptyKey.add(emptyBox);
emptyKey.add(new JLabel(” = empty”));
JPanel missBox = new JPanel();
JPanel missKey = new JPanel(new FlowLayout(FlowLayout.LEFT));
missBox.setSize(colorKeyBoxSize);
missBox.setBackground(animations.missColor);
missBox.setBorder(BorderFactory.createLineBorder(Color.BLACK));
missKey.add(missBox);
missKey.add(new JLabel(” = miss”));
JPanel hitKey = new JPanel(new FlowLayout(FlowLayout.LEFT));
JPanel hitBox = new JPanel();
hitBox.setSize(colorKeyBoxSize);
hitBox.setBackground(animations.hitColor);
hitBox.setBorder(BorderFactory.createLineBorder(Color.BLACK));
hitKey.add(hitBox);
hitKey.add(new JLabel(” = hit”));
animationsLabel.add(emptyKey);
animationsLabel.add(hitKey);
animationsLabel.add(missKey);
animationsLabel.add(Box.createVerticalGlue());
animationsPanel.add(animationsLabel);
animationsPanel.add(animations.getAnimationBox());
performance.add(animationsPanel);
return performance;
}
//////////////////////////////////////////////////////////////////////////////////////
// Rest of the protected methods. These override do-nothing methods inherited from
// the abstract superclass.
//////////////////////////////////////////////////////////////////////////////////////
/**
* Apply caching policies and update display when connected MIPS program accesses (data) memory.
* @param memory the attached memory
* @param accessNotice information provided by memory in MemoryAccessNotice object
*/
protected void processMIPSUpdate(Observable memory, AccessNotice accessNotice) {
MemoryAccessNotice notice = (MemoryAccessNotice) accessNotice;
memoryAccessCount++;
CacheAccessResult cacheAccessResult = theCache.isItAHitThenReadOnMiss(notice.getAddress());
if (cacheAccessResult.isHit()) {
cacheHitCount++;
animations.showHit(cacheAccessResult.getBlock());
}
else {
cacheMissCount++;
animations.showMiss(cacheAccessResult.getBlock());
}
cacheHitRate = cacheHitCount / (double)memoryAccessCount;
}
/**
* Initialize all JComboBox choice structures not already initialized at declaration.
* Also creates initial default cache object. Overrides inherited method that does nothing.
*/
protected void initializePreGUI() {
cacheBlockSizeChoicesInt = new int[cacheBlockSizeChoices.length];
for (int i=0; i
int blockPixelWidth = 40;
Dimension blockDimension = new Dimension(blockPixelWidth, blockPixelHeight);
blocks = new JTextField[numberOfBlocks];
for (int i=0; i
}
mars/tools/DigitalLabSim.java
mars/tools/DigitalLabSim.javapackage mars.tools;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.Timer;
import mars.Globals;
import mars.mips.hardware.AddressErrorException;
import mars.mips.hardware.Coprocessor0;
import mars.mips.hardware.Memory;
import mars.mips.hardware.MemoryAccessNotice;
import mars.simulator.Exceptions;
@SuppressWarnings(“serial”)
/* Add these two lines in exceptions.java file
* public static final int EXTERNAL_INTERRUPT_TIMER = 0x00000100; //Add for digital Lab Sim
* public static final int EXTERNAL_INTERRUPT_HEXA_KEYBOARD = 0x00000200;// Add for digital Lab Sim
*/
/*
* Didier Teifreto LIFC Université de franche-Comté www.lifc.univ-fcomte.fr/~teifreto
* didier.teifreto@univ-fcomte.fr
*/
public class DigitalLabSim extends AbstractMarsToolAndApplication {
private static String heading = “Digital Lab Sim”;
private static String version = ” Version 1.0 (Didier Teifreto)”;
private static final int IN_ADRESS_DISPLAY_1=Memory.memoryMapBaseAddress+0x10;
private static final int IN_ADRESS_DISPLAY_2=Memory.memoryMapBaseAddress+0x11;
private static final int IN_ADRESS_HEXA_KEYBOARD=Memory.memoryMapBaseAddress+0x12;
private static final int IN_ADRESS_COUNTER=Memory.memoryMapBaseAddress+0x13;
private static final int OUT_ADRESS_HEXA_KEYBOARD=Memory.memoryMapBaseAddress+0x14;
public static final int EXTERNAL_INTERRUPT_TIMER = 0x00000100; //Add for digital Lab Sim
public static final int EXTERNAL_INTERRUPT_HEXA_KEYBOARD = 0x00000200;// Add for digital Lab Sim
// GUI Interface.
private static JPanel panelTools;
// Seven Segment display
private SevenSegmentPanel sevenSegPanel;
// Keyboard
private static int KeyBoardValueButtonClick=-1; // -1 no button click
private HexaKeyboard hexaKeyPanel;
private static boolean KeyboardInterruptOnOff=false;
// Counter
private static int CounterValueMax=30;
private static int CounterValue=CounterValueMax;
private static boolean CounterInterruptOnOff=false;
private static OneSecondCounter SecondCounter;
public DigitalLabSim(String title, String heading) {
super(title,heading);
}
public DigitalLabSim() {
super (heading+”, “+version, heading);
}
public static void main(String[] args) {
new DigitalLabSim(heading+”, “+version,heading).go();
}
public String getName() {
return “Digital Lab Sim”;
}
protected void addAsObserver(){
addAsObserver(IN_ADRESS_DISPLAY_1, IN_ADRESS_DISPLAY_1);
addAsObserver(Memory.textBaseAddress, Memory.textLimitAddress);
}
public void update(Observable ressource, Object accessNotice){
MemoryAccessNotice notice = (MemoryAccessNotice) accessNotice;
int address=notice.getAddress();
char value=(char)notice.getValue();
if(address == IN_ADRESS_DISPLAY_1)
updateSevenSegment(1, value);
else
if (address == IN_ADRESS_DISPLAY_2)
updateSevenSegment(0, value);
else
if (address == IN_ADRESS_HEXA_KEYBOARD)
updateHexaKeyboard(value);
else
if (address == IN_ADRESS_COUNTER)
updateOneSecondCounter(value);
if (CounterInterruptOnOff)
if (CounterValue >0){
CounterValue–;
}
else{
CounterValue=CounterValueMax;
if((Coprocessor0.getValue(Coprocessor0.STATUS) & 2)==0){
mars.simulator.Simulator.externalInterruptingDevice = /*Exceptions.*/EXTERNAL_INTERRUPT_TIMER;
}
}
}
protected void reset(){
sevenSegPanel.resetSevenSegment();
hexaKeyPanel.resetHexaKeyboard();
SecondCounter.resetOneSecondCounter();
}
protected JComponent buildMainDisplayArea() {
panelTools=new JPanel(new GridLayout(1,2));
sevenSegPanel=new SevenSegmentPanel();
panelTools.add(sevenSegPanel);
hexaKeyPanel = new HexaKeyboard();
panelTools.add(hexaKeyPanel);
SecondCounter= new OneSecondCounter();
return panelTools;
}
private synchronized void updateMMIOControlAndData(int dataAddr, int dataValue) {
if (!this.isBeingUsedAsAMarsTool || (this.isBeingUsedAsAMarsTool && connectButton.isConnected())) {
synchronized (Globals.memoryAndRegistersLock) {
try {
Globals.memory.setByte(dataAddr, dataValue);
}
catch (AddressErrorException aee) {
System.out.println(“Tool author specified incorrect MMIO address!”+aee);
System.exit(0);
}
}
if (Globals.getGui() != null && Globals.getGui().getMainPane().getExecutePane().getTextSegmentWindow().getCodeHighlighting() ) {
Globals.getGui().getMainPane().getExecutePane().getDataSegmentWindow().updateValues();
}
}
}
protected JComponent getHelpComponent() {
final String helpContent =
” This tool is composed of 3 parts : two seven-segment displays, an hexadecimal keyboard and counter \n”+
“Seven segment display\n”+
” Byte value at address 0xFFFF0010 : command right seven segment display \n “+
” Byte value at address 0xFFFF0011 : command left seven segment display \n “+
” Each bit of these two bytes are connected to segments (bit 0 for a segment, 1 for b segment and 7 for point \n \n”+
“Hexadecimal keyboard\n”+
” Byte value at address 0xFFFF0012 : command row number of hexadecimal keyboard (bit 0 to 3) and enable keyboard interrupt (bit 7) \n” +
” Byte value at address 0xFFFF0014 : receive row and column of the key pressed, 0 if not key pressed \n”+
” The mips program have to scan, one by one, each row (send 1,2,4,8…)”+
” and then observe if a key is pressed (that mean byte value at adresse 0xFFFF0014 is different from zero). “+
” This byte value is composed of row number (4 left bits) and column number (4 right bits)”+
” Here you’ll find the code for each key : 0x11,0x21,0x41,0x81,0x12,0x22,0x42,0x82,0x14,0x24,0x44,0x84,0x18,0x28,0x48,0x88. \n”+
” For exemple key number 2 return 0x41, that mean the key is on column 3 and row 1. \n”+
” If keyboard interruption is enable, an exception is started, with cause register bit number 11 set.\n \n”+
“Counter\n”+
” Byte value at address 0xFFFF0013 : If one bit of this byte is set, the counter interruption is enable.\n”+
” If counter interruption is enable, every 30 instructions, an exception is started with cause register bit number 10.\n” +
” (contributed by Didier Teifreto, dteifreto@lifc.univ-fcomte.fr)”
;
JButton help = new JButton(“Help”);
help.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
JTextArea ja = new JTextArea(helpContent);
ja.setRows(20);
ja.setColumns(60);
ja.setLineWrap(true);
ja.setWrapStyleWord(true);
JOptionPane.showMessageDialog(theWindow, new JScrollPane(ja),
“Simulating the Hexa Keyboard and Seven segment display”, JOptionPane.INFORMATION_MESSAGE);
}
});
return help;
}/* ………………..Seven Segment display start here…………………………….. */
/* ………………………Seven segment display start here …………………………*/
public void updateSevenSegment(int number,char value) {
sevenSegPanel.display[number].modifyDisplay(value);
}
public class SevenSegmentDisplay extends JComponent {
public char aff;
public SevenSegmentDisplay(char aff){
this.aff=aff;
this.setPreferredSize(new Dimension(60,80));
}
public void modifyDisplay(char val){
aff=val;
this.repaint();
}
public void SwitchSegment(Graphics g,char segment){
switch(segment){
case ‘a’: //a segment
int[]pxa1={12,9,12};
int[]pxa2={36,39,36};
int[]pya={5,8,11};
g.fillPolygon(pxa1,pya, 3);
g.fillPolygon(pxa2,pya, 3);
g.fillRect(12,5,24,6);
break;
case ‘b’: //b segment
int[]pxb={37,40,43};
int[]pyb1={12,9,12};
int[]pyb2={36,39,36};
g.fillPolygon(pxb,pyb1, 3);
g.fillPolygon(pxb,pyb2, 3);
g.fillRect(37,12,6,24);
break;
case ‘c’: // c segment
int[]pxc={37,40,43};
int[]pyc1={44,41,44};
int[]pyc2={68,71,68};
g.fillPolygon(pxc,pyc1, 3);
g.fillPolygon(pxc,pyc2, 3);
g.fillRect(37,44,6,24);
break;
case ‘d’: // d segment
int[]pxd1={12,9,12};
int[]pxd2={36,39,36};
int[]pyd={69,72,75};
g.fillPolygon(pxd1,pyd, 3);
g.fillPolygon(pxd2,pyd, 3);
g.fillRect(12,69,24,6);
break;
case ‘e’: // e segment
int[]pxe={5,8,11};
int[]pye1={44,41,44};
int[]pye2={68,71,68};
g.fillPolygon(pxe,pye1, 3);
g.fillPolygon(pxe,pye2, 3);
g.fillRect(5,44,6,24);
break;
case ‘f’: // f segment
int[]pxf={5,8,11};
int[]pyf1={12,9,12};
int[]pyf2={36,39,36};
g.fillPolygon(pxf,pyf1, 3);
g.fillPolygon(pxf,pyf2, 3);
g.fillRect(5,12,6,24);
break;
case ‘g’: // g segment
int[]pxg1={12,9,12};
int[]pxg2={36,39,36};
int[]pyg={37,40,43};
g.fillPolygon(pxg1,pyg, 3);
g.fillPolygon(pxg2,pyg, 3);
g.fillRect(12,37,24,6);
break;
case ‘h’: // decimal point
g.fillOval(49,68,8,8);
break;
}
}
public void paint(Graphics g) {
char c=’a’;
while(c<='h'){
if ((aff & 0x1) == 1)
g.setColor(Color.RED);
else
g.setColor(Color.LIGHT_GRAY);
SwitchSegment(g,c);
aff = (char)(aff >>>1);
c++;
}
}
}
public class SevenSegmentPanel extends JPanel {
public SevenSegmentDisplay[] display;
public SevenSegmentPanel(){
int i;
FlowLayout fl= new FlowLayout();
this.setLayout(fl);
display= new SevenSegmentDisplay[2];
for (i=0;i<2;i++){
display[i]= new SevenSegmentDisplay((char)(0));
this.add(display[i]);
}
}
public void modifyDisplay(int num,char val){
display[num].modifyDisplay(val);
display[num].repaint();
}
public void resetSevenSegment() {
int i;
for (i=0;i<2;i++)
modifyDisplay(i, (char)0);
}
}
/* ...........................Seven segment display end here ..............................*/
/* ....................Hexa Keyboard start here................................... */
public void updateHexaKeyboard(char row) {
int key = KeyBoardValueButtonClick;
if ((key !=-1)&& ((1 << (key / 4))==(row & 0xF))){
updateMMIOControlAndData(OUT_ADRESS_HEXA_KEYBOARD,
(char)(1 << (key / 4)) | (1 << (4+(key%4))));
}
else{
updateMMIOControlAndData(OUT_ADRESS_HEXA_KEYBOARD, 0);
}
if ((row & 0xF0) != 0)
KeyboardInterruptOnOff = true;
else
KeyboardInterruptOnOff = false;
}
public class HexaKeyboard extends JPanel{
public JButton[] button;
public HexaKeyboard(){
int i;
GridLayout layout = new GridLayout(4,4);
this.setLayout(layout);
button = new JButton[16];
for (i=0;i<16;i++){
button[i]= new JButton(Integer.toHexString(i));
button[i].setBackground(Color.WHITE);
button[i].setMargin(new Insets(10,10,10,10));
button[i].addMouseListener(new EcouteurClick(i));
this.add(button[i]);
}
}
public void resetHexaKeyboard(){
int i;
KeyBoardValueButtonClick=-1;
for(i=0;i<16;i++){
button[i].setBackground(Color.WHITE);
}
}
public class EcouteurClick implements MouseListener{
private int buttonValue;
public EcouteurClick(int val){
buttonValue=val;
}
public void mouseEntered(MouseEvent arg0) { }
public void mouseExited(MouseEvent arg0) {}
public void mousePressed(MouseEvent arg0) {}
public void mouseReleased(MouseEvent arg0) {}
public void mouseClicked(MouseEvent arg0) {
int i;
if(KeyBoardValueButtonClick!=-1){//Button already pressed -> now realease
KeyBoardValueButtonClick = -1;
updateMMIOControlAndData(OUT_ADRESS_HEXA_KEYBOARD,0);
for(i=0;i<16;i++)
button[i].setBackground(Color.WHITE);
}
else{ // new button pressed
KeyBoardValueButtonClick = buttonValue;
button[KeyBoardValueButtonClick].setBackground(Color.GREEN);
if( KeyboardInterruptOnOff && (Coprocessor0.getValue(Coprocessor0.STATUS) & 2)==0){
mars.simulator.Simulator.externalInterruptingDevice = /*Exceptions.*/EXTERNAL_INTERRUPT_HEXA_KEYBOARD;
}
}
}
}
}
/* ....................Hexa Keyboard end here................................... */
/* ....................Timer start here................................... */
public void updateOneSecondCounter(char value) {
if (value !=0){
CounterInterruptOnOff=true;
CounterValue=CounterValueMax;
}
else{
CounterInterruptOnOff=false;
}
}
public class OneSecondCounter{
public OneSecondCounter(){
CounterInterruptOnOff=false;
}
public void resetOneSecondCounter(){
CounterInterruptOnOff=false;
CounterValue=CounterValueMax;
}
}
}
FloatRepresentation$1
package mars.tools;
synchronized class FloatRepresentation$1 implements java.awt.event.ActionListener {
void FloatRepresentation$1(FloatRepresentation);
public void actionPerformed(java.awt.event.ActionEvent);
}
FloatRepresentation$BinaryDisplayKeystrokeListener
package mars.tools;
synchronized class FloatRepresentation$BinaryDisplayKeystrokeListener extends java.awt.event.KeyAdapter {
private int bitLength;
public void FloatRepresentation$BinaryDisplayKeystrokeListener(FloatRepresentation, int);
public void keyTyped(java.awt.event.KeyEvent);
public void keyPressed(java.awt.event.KeyEvent);
private boolean isBinaryDigit(char);
}
FloatRepresentation$BinaryFractionDisplayTextField
package mars.tools;
synchronized class FloatRepresentation$BinaryFractionDisplayTextField extends javax.swing.JTextField {
public void FloatRepresentation$BinaryFractionDisplayTextField(FloatRepresentation, String, int);
public void paintComponent(java.awt.Graphics);
}
FloatRepresentation$BinaryToDecimalFormulaGraphic
package mars.tools;
synchronized class FloatRepresentation$BinaryToDecimalFormulaGraphic extends javax.swing.JPanel {
final String subtractLabelTrailer;
final int arrowHeadOffset;
final int lowerY;
final int upperY;
int centerX;
int exponentCenterX;
int subtractLabelWidth;
int subtractLabelHeight;
int centerY;
int upperYArrowHead;
int currentExponent;
void FloatRepresentation$BinaryToDecimalFormulaGraphic(FloatRepresentation);
public void paintComponent(java.awt.Graphics);
public void drawSubtractLabel(int);
private void drawSubtractLabel(java.awt.Graphics, String);
private String buildSubtractLabel(int);
}
FloatRepresentation$DecimalDisplayKeystokeListenter
package mars.tools;
synchronized class FloatRepresentation$DecimalDisplayKeystokeListenter extends java.awt.event.KeyAdapter {
private void FloatRepresentation$DecimalDisplayKeystokeListenter(FloatRepresentation);
public void keyTyped(java.awt.event.KeyEvent);
public void keyPressed(java.awt.event.KeyEvent);
private boolean isDecimalFloatDigit(char);
}
FloatRepresentation$FlavorsOfFloat
package mars.tools;
synchronized class FloatRepresentation$FlavorsOfFloat {
String hexString;
String binaryString;
String decimalString;
String expansionString;
int intValue;
private void FloatRepresentation$FlavorsOfFloat(FloatRepresentation);
public FloatRepresentation$FlavorsOfFloat buildOneFromHexString(String);
private FloatRepresentation$FlavorsOfFloat buildOneFromBinaryString();
private FloatRepresentation$FlavorsOfFloat buildOneFromDecimalString(String);
private FloatRepresentation$FlavorsOfFloat buildOneFromInt(int);
public String buildExpansionFromBinaryString(String);
private String getFullBinaryStringFromDisplays();
private String addLeadingZeroes(String, int);
}
FloatRepresentation$HexDisplayKeystrokeListener
package mars.tools;
synchronized class FloatRepresentation$HexDisplayKeystrokeListener extends java.awt.event.KeyAdapter {
private int digitLength;
public void FloatRepresentation$HexDisplayKeystrokeListener(FloatRepresentation, int);
public void keyTyped(java.awt.event.KeyEvent);
public void keyPressed(java.awt.event.KeyEvent);
private boolean isHexDigit(char);
}
FloatRepresentation$HexToBinaryGraphicPanel
package mars.tools;
synchronized class FloatRepresentation$HexToBinaryGraphicPanel extends javax.swing.JPanel {
void FloatRepresentation$HexToBinaryGraphicPanel(FloatRepresentation);
public void paintComponent(java.awt.Graphics);
}
FloatRepresentation$InstructionsPane
package mars.tools;
synchronized class FloatRepresentation$InstructionsPane extends javax.swing.JLabel {
void FloatRepresentation$InstructionsPane(FloatRepresentation, java.awt.Component);
public void setText(String);
}
FloatRepresentation
package mars.tools;
public synchronized class FloatRepresentation extends AbstractMarsToolAndApplication {
private static String version;
private static String heading;
private static final String title = Floating Point Representation, ;
private static final String defaultHex = 00000000;
private static final String defaultDecimal = 0.0;
private static final String defaultBinarySign = 0;
private static final String defaultBinaryExponent = 00000000;
private static final String defaultBinaryFraction = 00000000000000000000000;
private static final int maxLengthHex = 8;
private static final int maxLengthBinarySign = 1;
private static final int maxLengthBinaryExponent = 8;
private static final int maxLengthBinaryFraction = 23;
private static final int maxLengthBinaryTotal = 32;
private static final int maxLengthDecimal = 20;
private static final String denormalizedLabel = significand (denormalized - no 'hidden bit');
private static final String normalizedLabel = significand ('hidden bit' underlined) ;
private static final java.awt.Font instructionsFont;
private static final java.awt.Font hexDisplayFont;
private static final java.awt.Font binaryDisplayFont;
private static final java.awt.Font decimalDisplayFont;
private static final java.awt.Color hexDisplayColor;
private static final java.awt.Color binaryDisplayColor;
private static final java.awt.Color decimalDisplayColor;
private static final String expansionFontTag = ;
private static final String instructionFontTag = ;
private static final int exponentBias = 127;
private mars.mips.hardware.Register attachedRegister;
private mars.mips.hardware.Register[] fpRegisters;
private FloatRepresentation thisFloatTool;
private javax.swing.JPanel binarySignDecoratedDisplay;
private javax.swing.JPanel binaryExponentDecoratedDisplay;
private javax.swing.JPanel binaryFractionDecoratedDisplay;
private javax.swing.JTextField hexDisplay;
private javax.swing.JTextField decimalDisplay;
private javax.swing.JTextField binarySignDisplay;
private javax.swing.JTextField binaryExponentDisplay;
private javax.swing.JTextField binaryFractionDisplay;
private javax.swing.JLabel expansionDisplay;
private javax.swing.JLabel significandLabel;
private FloatRepresentation$BinaryToDecimalFormulaGraphic binaryToDecimalFormulaGraphic;
private FloatRepresentation$InstructionsPane instructions;
private String defaultInstructions;
private static final String zeroes = 0000000000000000000000000000000000000000000000000000000000000000;
private static final String HTMLspaces = ;
public void FloatRepresentation(String, String);
public void FloatRepresentation();
public static void main(String[]);
public String getName();
protected void addAsObserver();
protected void deleteAsObserver();
protected javax.swing.JComponent buildMainDisplayArea();
public void update(java.util.Observable, Object);
protected void reset();
protected javax.swing.JComponent buildDisplayArea();
private synchronized void updateAnyAttachedRegister(int);
private void updateDisplays(FloatRepresentation$FlavorsOfFloat);
private void updateDisplaysAndRegister(FloatRepresentation$FlavorsOfFloat);
private void updateSignificandLabel(FloatRepresentation$FlavorsOfFloat);
static void
}
mars/tools/FloatRepresentation.java
mars/tools/FloatRepresentation.java package mars.tools;
import mars.*;
import mars.util.*;
import mars.assembler.*;
import mars.mips.instructions.*;
import mars.mips.hardware.*;
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import javax.swing.text.html.*;
/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Developed by Pete Sanderson (psanderson@otterbein.edu)
and Kenneth Vollmar (kenvollmar@missouristate.edu)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT license, http://www.opensource.org/licenses/mit-license.html)
*/
/**
* Tool to help students learn about IEEE 754 representation of 32 bit
* floating point values. This representation is used by MIPS “float”
* directive and instructions and also the Java (and most other languages)
* “float” data type. As written, it can ALMOST be adapted to 64 bit by
* changing a few constants.
*/
public class FloatRepresentation extends AbstractMarsToolAndApplication {
private static String version = “Version 1.1”;
private static String heading = “32-bit IEEE 754 Floating Point Representation”;
private static final String title = “Floating Point Representation, “;
private static final String defaultHex = “00000000”;
private static final String defaultDecimal = “0.0”;
private static final String defaultBinarySign = “0”;
private static final String defaultBinaryExponent = “00000000”;
private static final String defaultBinaryFraction = “00000000000000000000000”;
private static final int maxLengthHex = 8;
private static final int maxLengthBinarySign = 1;
private static final int maxLengthBinaryExponent = 8;
private static final int maxLengthBinaryFraction = 23;
private static final int maxLengthBinaryTotal = maxLengthBinarySign+maxLengthBinaryExponent+maxLengthBinaryFraction;
private static final int maxLengthDecimal = 20;
private static final String denormalizedLabel = ” significand (denormalized – no ‘hidden bit’)”;
private static final String normalizedLabel = ” significand (‘hidden bit’ underlined) “;
private static final Font instructionsFont = new Font(“Arial”,Font.PLAIN,14);
private static final Font hexDisplayFont = new Font(“Courier”,Font.PLAIN,32);
private static final Font binaryDisplayFont = new Font(“Courier”,Font.PLAIN,18);
private static final Font decimalDisplayFont = new Font(“Courier”,Font.PLAIN,18);
private static final Color hexDisplayColor = Color.red;
private static final Color binaryDisplayColor = Color.black;
private static final Color decimalDisplayColor = Color.blue;
private static final String expansionFontTag = ““;
private static final String instructionFontTag = ““;
private static final int exponentBias = 127; // 32 bit floating point exponent bias
private Register attachedRegister = null;
private Register[] fpRegisters;
private FloatRepresentation thisFloatTool;
// Panels to hold binary displays and decorations (labels, arrows)
private JPanel binarySignDecoratedDisplay,
binaryExponentDecoratedDisplay, binaryFractionDecoratedDisplay;
// Editable fields for the hex, binary and decimal representations.
private JTextField hexDisplay, decimalDisplay,
binarySignDisplay, binaryExponentDisplay, binaryFractionDisplay;
// Non-editable fields to display formula translating binary to decimal.
private JLabel expansionDisplay;
private JLabel significandLabel = new JLabel(denormalizedLabel, JLabel.CENTER);
private BinaryToDecimalFormulaGraphic binaryToDecimalFormulaGraphic;
// Non-editable field to display instructions
private InstructionsPane instructions;
private String defaultInstructions = “Modify any value then press the Enter key to update all values.”;
/**
* Simple constructor, likely used to run a stand-alone memory reference visualizer.
* @param title String containing title for title bar
* @param heading String containing text for heading shown in upper part of window.
*/
public FloatRepresentation(String title, String heading) {
super(title,heading);
thisFloatTool = this;
}
/**
* Simple constructor, likely used by the MARS Tools menu mechanism
*/
public FloatRepresentation() {
this(title+version, heading);
}
/**
* Main provided for pure stand-alone use. Recommended stand-alone use is to write a
* driver program that instantiates a FloatRepresentation object then invokes its go() method.
* “stand-alone” means it is not invoked from the MARS Tools menu. “Pure” means there
* is no driver program to invoke the application.
*/
public static void main(String[] args) {
new FloatRepresentation(title+version,heading).go();
}
/**
* Fetch tool name (for display in MARS Tools menu)
* @return String containing tool name
*/
public String getName() {
return “Floating Point Representation”;
}
/**
* 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.
*/
protected void addAsObserver() {
addAsObserver(attachedRegister);
}
/**
* 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).
*/
protected void deleteAsObserver() {
deleteAsObserver(attachedRegister);
}
/**
* 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.
* @return the GUI component containing the application/tool-specific part of the user interface
*/
protected JComponent buildMainDisplayArea() {
return buildDisplayArea();
}
/**
* Override inherited update() to update display when “attached” register is modified
* either by MIPS program or by user editing it on the MARS user interface.
* The latter is the reason for overriding the inherited update() method.
* The inherited method will filter out notices triggered by the MARS GUI or the user.
* @param register the attached register
* @param accessNotice information provided by register in RegisterAccessNotice object
*/
public void update(Observable register, Object accessNotice) {
if (((AccessNotice)accessNotice).getAccessType()==AccessNotice.WRITE) {
updateDisplays(new FlavorsOfFloat().buildOneFromInt(attachedRegister.getValue()));
}
}
/**
* 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.
*/
protected void reset() {
instructions.setText(defaultInstructions);
updateDisplaysAndRegister(new FlavorsOfFloat());
}
//////////////////////////////////////////////////////////////////////////////////////
// Private methods defined to support the above.
protected JComponent buildDisplayArea() {
// Panel to hold all floating point dislay and editing components
Box mainPanel = Box.createVerticalBox();
JPanel leftPanel = new JPanel(new GridLayout(5,1,0,0));
JPanel rightPanel = new JPanel(new GridLayout(5,1,0,0));
Box subMainPanel = Box.createHorizontalBox();
subMainPanel.add(leftPanel);
subMainPanel.add(rightPanel);
mainPanel.add(subMainPanel);
// Editable display for hexadecimal version of the float value
hexDisplay = new JTextField(defaultHex, maxLengthHex+1);
hexDisplay.setFont(hexDisplayFont);
hexDisplay.setForeground(hexDisplayColor);
hexDisplay.setHorizontalAlignment(JTextField.RIGHT);
hexDisplay.setToolTipText(“”+maxLengthHex+”-digit hexadecimal (base 16) display”);
hexDisplay.setEditable(true);
hexDisplay.revalidate();
hexDisplay.addKeyListener(new HexDisplayKeystrokeListener(8));
JPanel hexPanel = new JPanel();
hexPanel.add(hexDisplay);
//################ Grid Row : Hexadecimal ##################################
leftPanel.add(hexPanel);
HexToBinaryGraphicPanel hexToBinaryGraphic = new HexToBinaryGraphicPanel();
//################ Grid Row : Hex-to-binary graphic ########################
leftPanel.add(hexToBinaryGraphic);
// Editable display for binary version of float value.
// It is split into 3 separately editable components (sign,exponent,fraction)
binarySignDisplay = new JTextField(defaultBinarySign, maxLengthBinarySign+1);
binarySignDisplay.setFont(binaryDisplayFont);
binarySignDisplay.setForeground(binaryDisplayColor);
binarySignDisplay.setHorizontalAlignment(JTextField.RIGHT);
binarySignDisplay.setToolTipText(“The sign bit”);
binarySignDisplay.setEditable(true);
binarySignDisplay.revalidate();
binaryExponentDisplay = new JTextField(defaultBinaryExponent, maxLengthBinaryExponent+1);
binaryExponentDisplay.setFont(binaryDisplayFont);
binaryExponentDisplay.setForeground(binaryDisplayColor);
binaryExponentDisplay.setHorizontalAlignment(JTextField.RIGHT);
binaryExponentDisplay.setToolTipText(“”+maxLengthBinaryExponent+”-bit exponent”);
binaryExponentDisplay.setEditable(true);
binaryExponentDisplay.revalidate();
binaryFractionDisplay = new BinaryFractionDisplayTextField(defaultBinaryFraction, maxLengthBinaryFraction+1);
binaryFractionDisplay.setFont(binaryDisplayFont);
binaryFractionDisplay.setForeground(binaryDisplayColor);
binaryFractionDisplay.setHorizontalAlignment(JTextField.RIGHT);
binaryFractionDisplay.setToolTipText(“”+maxLengthBinaryFraction+”-bit fraction”);
binaryFractionDisplay.setEditable(true);
binaryFractionDisplay.revalidate();
binarySignDisplay.addKeyListener(new BinaryDisplayKeystrokeListener(maxLengthBinarySign));
binaryExponentDisplay.addKeyListener(new BinaryDisplayKeystrokeListener(maxLengthBinaryExponent));
binaryFractionDisplay.addKeyListener(new BinaryDisplayKeystrokeListener(maxLengthBinaryFraction));
JPanel binaryPanel = new JPanel();
binarySignDecoratedDisplay = new JPanel(new BorderLayout());
binaryExponentDecoratedDisplay = new JPanel(new BorderLayout());
binaryFractionDecoratedDisplay = new JPanel(new BorderLayout());
binarySignDecoratedDisplay.add(binarySignDisplay,BorderLayout.CENTER);
binarySignDecoratedDisplay.add(new JLabel(“sign”,JLabel.CENTER),BorderLayout.SOUTH);
binaryExponentDecoratedDisplay.add(binaryExponentDisplay,BorderLayout.CENTER);
binaryExponentDecoratedDisplay.add(new JLabel(“exponent”,JLabel.CENTER),BorderLayout.SOUTH);
binaryFractionDecoratedDisplay.add(binaryFractionDisplay,BorderLayout.CENTER);
binaryFractionDecoratedDisplay.add(new JLabel(“fraction”,JLabel.CENTER),BorderLayout.SOUTH);
binaryPanel.add(binarySignDecoratedDisplay);
binaryPanel.add(binaryExponentDecoratedDisplay);
binaryPanel.add(binaryFractionDecoratedDisplay);
//################ Grid Row : Binary ##################################
leftPanel.add(binaryPanel);
//################ Grid Row : Binary to decimal formula arrows ##########
binaryToDecimalFormulaGraphic = new BinaryToDecimalFormulaGraphic();
binaryToDecimalFormulaGraphic.setBackground(leftPanel.getBackground());
leftPanel.add(binaryToDecimalFormulaGraphic);
// Non-Editable display for expansion of binary representation
expansionDisplay = new JLabel(new FlavorsOfFloat().expansionString);
expansionDisplay.setFont(new Font(“Monospaced”,Font.PLAIN,12));
expansionDisplay.setFocusable(false); // causes it to be skipped in “tab sequence”.
expansionDisplay.setBackground(leftPanel.getBackground());
JPanel expansionDisplayBox = new JPanel(new GridLayout(2,1));
expansionDisplayBox.add(expansionDisplay);
expansionDisplayBox.add(significandLabel); // initialized at top
//################ Grid Row : Formula mapping binary to decimal ########
leftPanel.add(expansionDisplayBox);
// Editable display for decimal version of float value.
decimalDisplay = new JTextField(defaultDecimal, maxLengthDecimal+1);
decimalDisplay.setFont(decimalDisplayFont);
decimalDisplay.setForeground(decimalDisplayColor);
decimalDisplay.setHorizontalAlignment(JTextField.RIGHT);
decimalDisplay.setToolTipText(“Decimal floating point value”);
decimalDisplay.setMargin(new Insets(0,0,0,0));
decimalDisplay.setEditable(true);
decimalDisplay.revalidate();
decimalDisplay.addKeyListener(new DecimalDisplayKeystokeListenter());
Box decimalDisplayBox = Box.createVerticalBox();
decimalDisplayBox.add(Box.createVerticalStrut(5));
decimalDisplayBox.add(decimalDisplay);
decimalDisplayBox.add(Box.createVerticalStrut(15));
FlowLayout rightPanelLayout = new FlowLayout(FlowLayout.LEFT);
JPanel place1 = new JPanel(rightPanelLayout);
JPanel place2 = new JPanel(rightPanelLayout);
JPanel place3 = new JPanel(rightPanelLayout);
JPanel place4 = new JPanel(rightPanelLayout);
JEditorPane hexExplain = new JEditorPane(“text/html”,expansionFontTag+”< Hexadecimal representation”+”“);
hexExplain.setEditable(false);
hexExplain.setFocusable(false);
hexExplain.setForeground(Color.black);
hexExplain.setBackground(place1.getBackground());
JEditorPane hexToBinExplain = new JEditorPane(“text/html”,expansionFontTag+”< Each hex digit represents 4 bits”+”“);
hexToBinExplain.setEditable(false);
hexToBinExplain.setFocusable(false);
hexToBinExplain.setBackground(place2.getBackground());
JEditorPane binExplain = new JEditorPane(“text/html”,expansionFontTag+”< Binary representation”+”“);
binExplain.setEditable(false);
binExplain.setFocusable(false);
binExplain.setBackground(place3.getBackground());
JEditorPane binToDecExplain = new JEditorPane(“text/html”,expansionFontTag+”< Binary-to-decimal conversion”+”“);
binToDecExplain.setEditable(false);
binToDecExplain.setFocusable(false);
binToDecExplain.setBackground(place4.getBackground());
place1.add(hexExplain);
place2.add(hexToBinExplain);
place3.add(binExplain);
place4.add(binToDecExplain);
//################ 4 Grid Rows : Explanations #########################
rightPanel.add(place1);
rightPanel.add(place2);
rightPanel.add(place3);
rightPanel.add(place4);
//################ Grid Row : Decimal ##################################
rightPanel.add(decimalDisplayBox);
//######## mainPanel is vertical box, instructions get a row #################
JPanel instructionsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
instructions = new InstructionsPane(instructionsPanel);
instructionsPanel.add(instructions);
instructionsPanel.setBorder(new TitledBorder(“Instructions”));
mainPanel.add(instructionsPanel);
// Means of selecting and deselecting an attached floating point register
fpRegisters = Coprocessor1.getRegisters();
String[] registerList = new String[fpRegisters.length+1];
registerList[0] = “None”;
for (int i=0; i
+ “-1“+binaryString.substring(0,maxLengthBinarySign)+” * 2”
+ stringExponent + HTMLspaces.substring(0, (5-stringExponent.length())*6)
+ “ * ”
+ ((biasedExponent==0) ? ” .” : “1.”)
+ binaryString.substring(maxLengthBinarySign+maxLengthBinaryExponent, maxLengthBinaryTotal)
+ ” =