mirror of
https://codeberg.org/sethm/symon.git
synced 2026-11-07 19:12:23 +00:00
Instruction Table interface.
This commit is contained in:
1 parent
8df561d292
commit
d18c1c7f82
3 files changed
+250
-8
No files matched your search
@@ -3,20 +3,20 @@ package com.loomcom.lm6502;
|
||||
/**
|
||||
* Main 6502 CPU Simulation.
|
||||
*/
|
||||
public class Cpu {
|
||||
public class Cpu implements InstructionTable {
|
||||
|
||||
/* The Bus */
|
||||
private Bus bus;
|
||||
|
||||
/* User Registers */
|
||||
private int a; // Accumulator
|
||||
private int x; // X index register
|
||||
private int y; // Y index register
|
||||
private int a; // Accumulator
|
||||
private int x; // X index register
|
||||
private int y; // Y index register
|
||||
|
||||
/* Internal Registers */
|
||||
private int pc; // Program Counter register
|
||||
private int sp; // Stack Pointer register
|
||||
private int ir; // Instruction register
|
||||
private int pc; // Program Counter register
|
||||
private int sp; // Stack Pointer register
|
||||
private int ir; // Instruction register
|
||||
|
||||
/**
|
||||
* Construct a new CPU.
|
||||
@@ -48,5 +48,29 @@ public class Cpu {
|
||||
ir = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an individual machine cycle.
|
||||
*/
|
||||
public void step() {
|
||||
// 1. Fetch memory
|
||||
ir = bus.read(pc);
|
||||
|
||||
// 2. Decode the instruction and execute.
|
||||
|
||||
// x. Increment PC
|
||||
incProgramCounter();
|
||||
}
|
||||
|
||||
/*
|
||||
* Increment the PC, rolling over if necessary.
|
||||
*/
|
||||
private void incProgramCounter() {
|
||||
if (pc == 0xffff) {
|
||||
pc = 0;
|
||||
} else {
|
||||
++pc;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user