-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/li/cil/tis3d/common/module/execution/target/PcTargetInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package li.cil.tis3d.common.module.execution.target; | ||
|
||
import li.cil.tis3d.common.module.execution.Machine; | ||
|
||
/** | ||
* Interface for the {@link Target#PC} target. | ||
* <p> | ||
* Provides instant read and write on the program counter | ||
*/ | ||
public final class PcTargetInterface extends AbstractTargetInterface { | ||
public PcTargetInterface(final Machine machine) { | ||
super(machine); | ||
} | ||
|
||
// --------------------------------------------------------------------- // | ||
// TargetInterface | ||
|
||
@Override | ||
public boolean beginWrite(final short value) { | ||
getState().pc = value; | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isWriting() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void beginRead() { | ||
} | ||
|
||
@Override | ||
public boolean isReading() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean canTransfer() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public short read() { | ||
return (short) getState().pc; | ||
} | ||
|
||
// --------------------------------------------------------------------- // | ||
// Object | ||
|
||
@Override | ||
public String toString() { | ||
return "PC"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
* Valid sources and sinks for move operations. | ||
*/ | ||
public enum Target { | ||
PC, | ||
ACC, | ||
BAK, | ||
NIL, | ||
|