mirror of
https://github.com/mre/mos6502.git
synced 2024-11-28 22:51:26 +00:00
formatting
This commit is contained in:
parent
97d6b3fd89
commit
ad622bc930
26
src/cpu.rs
26
src/cpu.rs
@ -32,7 +32,6 @@ use crate::Variant;
|
|||||||
use crate::registers::{Registers, StackPointer, Status, StatusArgs};
|
use crate::registers::{Registers, StackPointer, Status, StatusArgs};
|
||||||
|
|
||||||
fn address_from_bytes(lo: u8, hi: u8) -> u16 {
|
fn address_from_bytes(lo: u8, hi: u8) -> u16 {
|
||||||
|
|
||||||
u16::from(lo) + (u16::from(hi) << 8usize)
|
u16::from(lo) + (u16::from(hi) << 8usize)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,12 +139,16 @@ impl<M: Bus, V: Variant> CPU<M, V> {
|
|||||||
AddressingMode::AbsoluteX => {
|
AddressingMode::AbsoluteX => {
|
||||||
// Use [u8, ..2] from instruction as address, add X
|
// Use [u8, ..2] from instruction as address, add X
|
||||||
// (Output: a 16-bit address)
|
// (Output: a 16-bit address)
|
||||||
OpInput::UseAddress(address_from_bytes(slice[0], slice[1]).wrapping_add(x.into()))
|
OpInput::UseAddress(
|
||||||
|
address_from_bytes(slice[0], slice[1]).wrapping_add(x.into()),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
AddressingMode::AbsoluteY => {
|
AddressingMode::AbsoluteY => {
|
||||||
// Use [u8, ..2] from instruction as address, add Y
|
// Use [u8, ..2] from instruction as address, add Y
|
||||||
// (Output: a 16-bit address)
|
// (Output: a 16-bit address)
|
||||||
OpInput::UseAddress(address_from_bytes(slice[0], slice[1]).wrapping_add(y.into()))
|
OpInput::UseAddress(
|
||||||
|
address_from_bytes(slice[0], slice[1]).wrapping_add(y.into()),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
AddressingMode::IndirectWithFix => {
|
AddressingMode::IndirectWithFix => {
|
||||||
// Use [u8, ..2] from instruction as an address. Interpret the
|
// Use [u8, ..2] from instruction as an address. Interpret the
|
||||||
@ -165,11 +168,18 @@ impl<M: Bus, V: Variant> CPU<M, V> {
|
|||||||
|
|
||||||
let low_byte_of_target = memory.get_byte(pointer);
|
let low_byte_of_target = memory.get_byte(pointer);
|
||||||
|
|
||||||
let low_byte_of_incremented_pointer = pointer.to_le_bytes()[0].wrapping_add(1);
|
let low_byte_of_incremented_pointer =
|
||||||
let incremented_pointer = u16::from_le_bytes([low_byte_of_incremented_pointer, pointer.to_le_bytes()[1]]);
|
pointer.to_le_bytes()[0].wrapping_add(1);
|
||||||
|
let incremented_pointer = u16::from_le_bytes([
|
||||||
|
low_byte_of_incremented_pointer,
|
||||||
|
pointer.to_le_bytes()[1],
|
||||||
|
]);
|
||||||
|
|
||||||
let high_byte_of_target = memory.get_byte(incremented_pointer);
|
let high_byte_of_target = memory.get_byte(incremented_pointer);
|
||||||
OpInput::UseAddress(address_from_bytes(low_byte_of_target, high_byte_of_target))
|
OpInput::UseAddress(address_from_bytes(
|
||||||
|
low_byte_of_target,
|
||||||
|
high_byte_of_target,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
AddressingMode::IndexedIndirectX => {
|
AddressingMode::IndexedIndirectX => {
|
||||||
// Use [u8, ..1] from instruction
|
// Use [u8, ..1] from instruction
|
||||||
@ -187,7 +197,9 @@ impl<M: Bus, V: Variant> CPU<M, V> {
|
|||||||
// (Output: a 16-bit address)
|
// (Output: a 16-bit address)
|
||||||
let start = slice[0];
|
let start = slice[0];
|
||||||
let slice = read_address(memory, u16::from(start));
|
let slice = read_address(memory, u16::from(start));
|
||||||
OpInput::UseAddress(address_from_bytes(slice[0], slice[1]).wrapping_add(y.into()))
|
OpInput::UseAddress(
|
||||||
|
address_from_bytes(slice[0], slice[1]).wrapping_add(y.into()),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user