|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcomputer.Memory
public class Memory
A dense array-like structure representing the memory of a toy computer. The memory may hold cells of type Code, either Data cells or Instruction cells.
Field Summary | |
---|---|
private apcsGeneric.jbergin.DenseList<Code> |
storage
|
Constructor Summary | |
---|---|
Memory()
Create a memory of size 1K or 1024 cells. |
Method Summary | |
---|---|
Instruction |
getInstruction(int cell)
Retrieve an instruction cell from the memory. |
Data |
getValue(int cell)
Retrieve a data cell from the memory. |
void |
put(Code code,
int cell)
Insert a cell into the memory at a fixed address |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private apcsGeneric.jbergin.DenseList<Code> storage
Constructor Detail |
---|
public Memory()
Method Detail |
---|
public void put(Code code, int cell)
code
- the cell to be inserted. It may be Data or
Instructioncell
- the address at which to put the item in
range: 0..1023public Data getValue(int cell)
cell
- the address of the desired cell
java.lang.ClassCastException
- if the cell has the wrong typepublic Instruction getInstruction(int cell)
cell
- the address of the desired cell
java.lang.ClassCastException
- if the cell has the wrong type
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |