mirror of
https://github.com/mre/mos6502.git
synced 2025-02-16 10:33:17 +00:00
Format code
This commit is contained in:
parent
e829122a5a
commit
363dc47755
1
.gitignore
vendored
1
.gitignore
vendored
@ -65,3 +65,4 @@ TAGS.vi
|
||||
\#*\#
|
||||
src/.DS_Store
|
||||
tmp.*.rs
|
||||
.vscode
|
||||
|
@ -14,24 +14,23 @@ fn main() {
|
||||
.collect::<Vec<u8>>();
|
||||
|
||||
let program = [
|
||||
// (F)irst | (S)econd
|
||||
// .algo
|
||||
0xa5, 0x00, // Load from F to A
|
||||
// .algo_
|
||||
0x38, // Set carry flag
|
||||
0xe5, 0x01, // Substract S from number in A (from F)
|
||||
0xf0, 0x07, // Jump to .end if diff is zero
|
||||
0x30, 0x08, // Jump to .swap if diff is negative
|
||||
0x85, 0x00, // Load A to F
|
||||
// (F)irst | (S)econd
|
||||
// .algo
|
||||
0xa5, 0x00, // Load from F to A
|
||||
// .algo_
|
||||
0x38, // Set carry flag
|
||||
0xe5, 0x01, // Substract S from number in A (from F)
|
||||
0xf0, 0x07, // Jump to .end if diff is zero
|
||||
0x30, 0x08, // Jump to .swap if diff is negative
|
||||
0x85, 0x00, // Load A to F
|
||||
0x4c, 0x12, 0x00, // Jump to .algo_
|
||||
// .end
|
||||
0xa5, 0x00, // Load from S to A
|
||||
0xff,
|
||||
// .swap
|
||||
0xa6, 0x00, // load F to X
|
||||
0xa4, 0x01, // load S to Y
|
||||
0x86, 0x01, // Store X to F
|
||||
0x84, 0x00, // Store Y to S
|
||||
// .end
|
||||
0xa5, 0x00, // Load from S to A
|
||||
0xff, // .swap
|
||||
0xa6, 0x00, // load F to X
|
||||
0xa4, 0x01, // load S to Y
|
||||
0x86, 0x01, // Store X to F
|
||||
0x84, 0x00, // Store Y to S
|
||||
0x4c, 0x10, 0x00, // Jump to .algo
|
||||
];
|
||||
|
||||
|
@ -39,25 +39,13 @@ fn main() {
|
||||
|
||||
// "Load" a program
|
||||
|
||||
|
||||
let zero_page_data = [
|
||||
// ZeroPage data start
|
||||
0x00,
|
||||
0x02, // ADC ZeroPage target
|
||||
0x00,
|
||||
0x04, // ADC ZeroPageX target
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x10, // ADC IndexedIndirectX address
|
||||
0x00, 0x02, // ADC ZeroPage target
|
||||
0x00, 0x04, // ADC ZeroPageX target
|
||||
0x00, 0x00, 0x00, 0x00, 0x10, // ADC IndexedIndirectX address
|
||||
0x80, // ADC IndexedIndirectX address
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x08, // ADC IndirectIndexedY address
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, // ADC IndirectIndexedY address
|
||||
0x80, // ADC IndirectIndexedY address
|
||||
];
|
||||
|
||||
@ -99,31 +87,11 @@ fn main() {
|
||||
];
|
||||
|
||||
let data = [
|
||||
0x00,
|
||||
0x09, // ADC Absolute target
|
||||
0x00,
|
||||
0x00,
|
||||
0x40, // ADC AbsoluteY target
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x11, // ADC AbsoluteX target
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x12, // ADC IndexedIndirectX target
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x06, // ADC IndirectIndexedY target
|
||||
0x00, 0x09, // ADC Absolute target
|
||||
0x00, 0x00, 0x40, // ADC AbsoluteY target
|
||||
0x00, 0x00, 0x00, 0x11, // ADC AbsoluteX target
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, // ADC IndexedIndirectX target
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, // ADC IndirectIndexedY target
|
||||
];
|
||||
|
||||
cpu.memory.set_bytes(Address(0x0000), &zero_page_data);
|
||||
|
10
src/cpu.rs
10
src/cpu.rs
@ -1366,11 +1366,11 @@ mod tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stack_underflow() {
|
||||
let mut cpu = CPU::new();
|
||||
let _val: u8 = cpu.pull_from_stack();
|
||||
#[test]
|
||||
fn stack_underflow() {
|
||||
let mut cpu = CPU::new();
|
||||
let _val: u8 = cpu.pull_from_stack();
|
||||
}
|
||||
}
|
||||
|
@ -40,4 +40,3 @@ pub mod cpu;
|
||||
pub mod instruction;
|
||||
pub mod memory;
|
||||
pub mod registers;
|
||||
|
||||
|
@ -152,11 +152,11 @@ impl StackPointer {
|
||||
}
|
||||
|
||||
pub fn decrement(&mut self) {
|
||||
self.0 = self.0.wrapping_sub(1);
|
||||
self.0 = self.0.wrapping_sub(1);
|
||||
}
|
||||
|
||||
pub fn increment(&mut self) {
|
||||
self.0 = self.0.wrapping_add(1);
|
||||
self.0 = self.0.wrapping_add(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user