mirror of
https://codeberg.org/sethm/symon.git
synced 2026-11-07 19:12:23 +00:00
There is already an existing project (albeit defunct) named j6502. Name changed to lm6502.
This commit is contained in:
1 parent
316d0feac6
commit
061eeba85c
8 files changed
+19
-22
No files matched your search
@@ -0,0 +1,73 @@
|
||||
package com.loomcom.lm6502;
|
||||
|
||||
/**
|
||||
* Main 6502 CPU Simulation.
|
||||
*/
|
||||
public class Cpu {
|
||||
|
||||
/**
|
||||
* The Program Counter.
|
||||
*/
|
||||
private int m_pc;
|
||||
|
||||
/**
|
||||
* The system stack pointer.
|
||||
*/
|
||||
private int m_sp;
|
||||
|
||||
/**
|
||||
* Reference to the simulator
|
||||
*/
|
||||
private Simulator m_sim;
|
||||
|
||||
public Cpu(Simulator sim) {
|
||||
reset();
|
||||
this.m_sim = sim;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the CPU to known initial values.
|
||||
*/
|
||||
public void reset() {
|
||||
m_sp = 0x01ff;
|
||||
/* locations fffc and fffd hold the reset vector address */
|
||||
m_pc = 0xfffc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger a maskable interrupt.
|
||||
*/
|
||||
public void interrupt() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger a nonmaskable interrupt.
|
||||
*/
|
||||
public void nmiInterrupt() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An address specified by the two bytes immediately following the
|
||||
* Program Counter.
|
||||
*/
|
||||
private int readAddress() {
|
||||
return readAddress(m_pc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the two bytes located at <tt>addr</tt> and <tt>addr + 1</tt>,
|
||||
* and return the address held there.
|
||||
*
|
||||
* @param address
|
||||
* @return The address specified in the two bytes at location <tt>addr</tt>
|
||||
*/
|
||||
private int readAddress(int address) {
|
||||
return (m_sim.read(address)<<8 & m_sim.read(address+1));
|
||||
}
|
||||
|
||||
public Simulator getSimulator() {
|
||||
return m_sim;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user