Package mars.mips.hardware
Class Memory.TextRegion
java.lang.Object
mars.mips.hardware.Memory.TextRegion
- Enclosing class:
- Memory
Class representing an arbitrary contiguous region of memory which contains text.
This uses a very similar structure to Memory.DataRegion
. The primary difference is that DataRegion
contains raw memory words at the innermost level, whereas this contains references to
BasicStatement
objects instead. While less space-efficient, it is much more time-efficient
for the Simulator
as it reads the code in the text segment.
(Especially since the current code to construct a BasicStatement
from its binary data
isn't too great, which is certainly on the to-do list to improve.)
-
Constructor Summary
ConstructorsConstructorDescriptionTextRegion
(int firstAddress, int lastAddress) Allocate a new region of memory containing text. -
Method Summary
Modifier and TypeMethodDescriptionfetchStatement
(int address) Fetch a statement from the region at a given address.storeStatement
(int address, BasicStatement statement) Store a statement in the region at a given address.
-
Constructor Details
-
TextRegion
public TextRegion(int firstAddress, int lastAddress) Allocate a new region of memory containing text.- Parameters:
firstAddress
- The lowest address this region is required to contain.lastAddress
- The highest address this region is required to contain.
-
-
Method Details
-
storeStatement
Store a statement in the region at a given address. The caller is responsible for ensuring that the address is word-aligned and falls within this region, as no checking will be done.- Parameters:
address
- The address to store the statement at.statement
- The statement to store at the given address.- Returns:
- The previous statement which was overwritten (defaults to null).
-
fetchStatement
Fetch a statement from the region at a given address. The caller is responsible for ensuring that the address is word-aligned and falls within this region, as no checking will be done.- Parameters:
address
- The address of the statement to fetch.- Returns:
- The statement stored at the given address (defaults to null).
-