1
0
mirror of https://github.com/mre/mos6502.git synced 2024-11-28 07:49:19 +00:00

Rename machine to cpu and the crate to mos6502

This commit is contained in:
Matthias Endler 2017-11-13 23:34:31 +01:00
parent aa30ea6300
commit 6a9ce4e12e
5 changed files with 546 additions and 1860 deletions

View File

@ -26,17 +26,17 @@
# POSSIBILITY OF SUCH DAMAGE.
[package]
name = "emu6502"
name = "mos6502"
version = "0.0.1"
authors = ["The 6502-rs Developers"]
[lib]
# This will look in src/lib.rs
name = "emu6502"
name = "mos6502"
[[bin]]
# This will look in src/bin/emu6502.rs
name = "emu6502"
# This will look in src/bin/mos6502.rs
name = "mos6502"
[dependencies]
bitflags = "0.9.1"

View File

@ -25,17 +25,17 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
extern crate emu6502;
extern crate mos6502;
#[cfg(not(test))]
use emu6502::machine;
use mos6502::cpu;
#[cfg(not(test))]
use emu6502::address::Address;
use mos6502::address::Address;
#[cfg(not(test))]
fn main() {
let mut machine = machine::Machine::new();
let mut cpu = cpu::CPU::new();
// "Load" a program
@ -67,51 +67,36 @@ fn main() {
// Code start
0xA9, // LDA Immediate
0x01, // Immediate operand
0x69, // ADC Immediate
0x07, // Immediate operand
0x65, // ADC ZeroPage
0x01, // ZeroPage operand
0xA2, // LDX Immediate
0x01, // Immediate operand
0x75, // ADC ZeroPageX
0x02, // ZeroPageX operand
0x6D, // ADC Absolute
0x01, // Absolute operand
0x80, // Absolute operand
0xA2, // LDX immediate
0x08, // Immediate operand
0x7D, // ADC AbsoluteX
0x00, // AbsoluteX operand
0x80, // AbsoluteX operand
0xA0, // LDY immediate
0x04, // Immediate operand
0x79, // ADC AbsoluteY
0x00, // AbsoluteY operand
0x80, // AbsoluteY operand
0xA2, // LDX immediate
0x05, // Immediate operand
0x61, // ADC IndexedIndirectX
0x03, // IndexedIndirectX operand
0xA0, // LDY immediate
0x10, // Immediate operand
0x71, // ADC IndirectIndexedY
0x0F, // IndirectIndexedY operand
0xEA, // NOP :)
0xFF, // Something invalid -- the end!
];
@ -143,14 +128,13 @@ fn main() {
0x06, // ADC IndirectIndexedY target
];
machine.memory.set_bytes(Address(0x0000), &zero_page_data);
machine.memory.set_bytes(Address(0x4000), &program);
machine.memory.set_bytes(Address(0x8000), &data);
cpu.memory.set_bytes(Address(0x0000), &zero_page_data);
cpu.memory.set_bytes(Address(0x4000), &program);
cpu.memory.set_bytes(Address(0x8000), &data);
machine.registers.program_counter = Address(0x4000);
cpu.registers.program_counter = Address(0x4000);
machine.run();
cpu.run();
println!("{:?}", machine);
println!("{:?}", cpu);
}

View File

@ -27,7 +27,7 @@
use address::Address;
use address::AddressDiff;
use machine::Machine;
use cpu::CPU;
// Abbreviations
//
@ -163,21 +163,19 @@ impl AddressingMode {
AddressDiff(x)
}
pub fn process(self, machine: &Machine, arr: &[u8]) -> OpInput {
pub fn process(self, cpu: &CPU, arr: &[u8]) -> OpInput {
debug_assert!({
let AddressDiff(x) = self.extra_bytes();
arr.len() == x as usize
});
let x = machine.registers.index_x as u8;
let y = machine.registers.index_y as u8;
let x = cpu.registers.index_x as u8;
let y = cpu.registers.index_y as u8;
let memory = &machine.memory;
let memory = &cpu.memory;
match self {
AddressingMode::Accumulator |
AddressingMode::Implied => {
AddressingMode::Accumulator | AddressingMode::Implied => {
// Always the same -- no input
OpInput::UseImplied
}
@ -254,8 +252,7 @@ impl AddressingMode {
pub type DecodedInstr = (Instruction, OpInput);
pub static OPCODES: [Option<(Instruction, AddressingMode)>; 256] =
[
pub static OPCODES: [Option<(Instruction, AddressingMode)>; 256] = [
/*0x00*/
Some((Instruction::BRK, AddressingMode::Implied)),
/*0x01*/

View File

@ -36,6 +36,6 @@ extern crate bitflags;
pub mod address;
pub mod instruction;
pub mod machine;
pub mod cpu;
pub mod memory;
pub mod registers;

File diff suppressed because it is too large Load Diff