Package mars.util
Class MemoryDump
java.lang.Object
mars.util.MemoryDump
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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[]
Get the names of segments available for memory dump.
-
Constructor Details
-
MemoryDump
public MemoryDump()
-
-
Method Details
-
getSegmentBounds
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
Get the names of segments available for memory dump.- Returns:
- array of Strings, each string is segment name (e.g. ".text", ".data")
-
getBaseAddresses
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
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 AddressErrorExceptionLook 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 pointlimitAddress
- 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
-