Arch.Y86.Machine
Class MainMemory
java.lang.Object
java.util.Observable
Util.AbstractDataModel
Machine.AbstractMainMemory
Arch.Y86.Machine.MainMemory
- All Implemented Interfaces:
- DataModel
public class MainMemory
- extends AbstractMainMemory
Methods inherited from class Machine.AbstractMainMemory |
getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, read, readInteger, readIntegerUnaligned, readUnaligned, setValueAt, setValueAt, setValueAtByUser, setValueAtByUser, write, writeInteger, writeIntegerUnaligned, writeUnaligned |
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 |
MainMemory
public MainMemory(int byteCapacity)
isAccessAligned
protected boolean isAccessAligned(int address,
int length)
- Description copied from class:
AbstractMainMemory
- Determine whether specified address and length represent an ALIGNED access. Protected method called
by public read and write methods.
An address is aligned if and only if the address modulo value.length is 0 (i.e., the low order log 2
(length) bits are 0. Aligned memory access is faster than unaligned access and so compilers should
attempt to used aligned access whenever possible. It is sometimes not possible, however, particularlly
for reading instructions in architectures that support variable instruction lengths such as SM213 and Y86,
for example.
- Specified by:
isAccessAligned
in class AbstractMainMemory
- Returns:
- true iff access to address of length bytes is an aligned access
bytesToInteger
public int bytesToInteger(UnsignedByte byteAtAddrPlus0,
UnsignedByte byteAtAddrPlus1,
UnsignedByte byteAtAddrPlus2,
UnsignedByte byteAtAddrPlus3)
- Description copied from class:
AbstractMainMemory
- Convert a byte array to an integer.
- Specified by:
bytesToInteger
in class AbstractMainMemory
- Parameters:
byteAtAddrPlus0
- value of byte at some memory address addrbyteAtAddrPlus1
- value of byte at some memory address addr + 1byteAtAddrPlus2
- value of byte at some memory address addr + 2byteAtAddrPlus3
- value of byte at some memory address addr + 3
- Returns:
- integer comprised of this four bytes organized according to the Endianness of the target ISA
integerToBytes
public UnsignedByte[] integerToBytes(int i)
- Description copied from class:
AbstractMainMemory
- Convert an integer to a byte array.
- Specified by:
integerToBytes
in class AbstractMainMemory
- Parameters:
i
- an 32-bit integer value
- Returns:
- an array of bytes that comprise the integer in address order according to the Endianness of the target ISA
get
protected UnsignedByte[] get(int address,
int length)
throws AbstractMainMemory.InvalidAddressException
- Description copied from class:
AbstractMainMemory
- Read a sequence of bytes from memory. Protected method called by public read method.
- Specified by:
get
in class AbstractMainMemory
- Parameters:
address
- byte address of first byte to read.length
- number of bytes to read.
- Throws:
AbstractMainMemory.InvalidAddressException
- if address is out of range.
set
protected void set(int address,
UnsignedByte[] value)
throws AbstractMainMemory.InvalidAddressException
- Description copied from class:
AbstractMainMemory
- Write a sequence of bytes to memory. Protected method called by public write method.
- Specified by:
set
in class AbstractMainMemory
- Parameters:
address
- byte address of first byte to write.value
- array of unsigned bytes to write to memory at this address.
- Throws:
AbstractMainMemory.InvalidAddressException
- if address is out of range.
length
public int length()
- Specified by:
length
in class AbstractMainMemory