Format code

This commit is contained in:
Matthias 2022-06-07 19:30:29 +02:00
parent e829122a5a
commit 363dc47755
6 changed files with 33 additions and 66 deletions

1
.gitignore vendored
View File

@ -65,3 +65,4 @@ TAGS.vi
\#*\# \#*\#
src/.DS_Store src/.DS_Store
tmp.*.rs tmp.*.rs
.vscode

View File

@ -14,24 +14,23 @@ fn main() {
.collect::<Vec<u8>>(); .collect::<Vec<u8>>();
let program = [ let program = [
// (F)irst | (S)econd // (F)irst | (S)econd
// .algo // .algo
0xa5, 0x00, // Load from F to A 0xa5, 0x00, // Load from F to A
// .algo_ // .algo_
0x38, // Set carry flag 0x38, // Set carry flag
0xe5, 0x01, // Substract S from number in A (from F) 0xe5, 0x01, // Substract S from number in A (from F)
0xf0, 0x07, // Jump to .end if diff is zero 0xf0, 0x07, // Jump to .end if diff is zero
0x30, 0x08, // Jump to .swap if diff is negative 0x30, 0x08, // Jump to .swap if diff is negative
0x85, 0x00, // Load A to F 0x85, 0x00, // Load A to F
0x4c, 0x12, 0x00, // Jump to .algo_ 0x4c, 0x12, 0x00, // Jump to .algo_
// .end // .end
0xa5, 0x00, // Load from S to A 0xa5, 0x00, // Load from S to A
0xff, 0xff, // .swap
// .swap 0xa6, 0x00, // load F to X
0xa6, 0x00, // load F to X 0xa4, 0x01, // load S to Y
0xa4, 0x01, // load S to Y 0x86, 0x01, // Store X to F
0x86, 0x01, // Store X to F 0x84, 0x00, // Store Y to S
0x84, 0x00, // Store Y to S
0x4c, 0x10, 0x00, // Jump to .algo 0x4c, 0x10, 0x00, // Jump to .algo
]; ];

View File

@ -39,25 +39,13 @@ fn main() {
// "Load" a program // "Load" a program
let zero_page_data = [ let zero_page_data = [
// ZeroPage data start // ZeroPage data start
0x00, 0x00, 0x02, // ADC ZeroPage target
0x02, // ADC ZeroPage target 0x00, 0x04, // ADC ZeroPageX target
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // ADC IndexedIndirectX address
0x04, // ADC ZeroPageX target
0x00,
0x00,
0x00,
0x00,
0x10, // ADC IndexedIndirectX address
0x80, // ADC IndexedIndirectX address 0x80, // ADC IndexedIndirectX address
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, // ADC IndirectIndexedY address
0x00,
0x00,
0x00,
0x00,
0x08, // ADC IndirectIndexedY address
0x80, // ADC IndirectIndexedY address 0x80, // ADC IndirectIndexedY address
]; ];
@ -99,31 +87,11 @@ fn main() {
]; ];
let data = [ let data = [
0x00, 0x00, 0x09, // ADC Absolute target
0x09, // ADC Absolute target 0x00, 0x00, 0x40, // ADC AbsoluteY target
0x00, 0x00, 0x00, 0x00, 0x11, // ADC AbsoluteX target
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, // ADC IndexedIndirectX target
0x40, // ADC AbsoluteY target 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, // ADC IndirectIndexedY 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); cpu.memory.set_bytes(Address(0x0000), &zero_page_data);

View File

@ -1366,11 +1366,11 @@ mod tests {
} }
} }
} }
} }
#[test] #[test]
fn stack_underflow() { fn stack_underflow() {
let mut cpu = CPU::new(); let mut cpu = CPU::new();
let _val: u8 = cpu.pull_from_stack(); let _val: u8 = cpu.pull_from_stack();
} }
} }

View File

@ -40,4 +40,3 @@ pub mod cpu;
pub mod instruction; pub mod instruction;
pub mod memory; pub mod memory;
pub mod registers; pub mod registers;

View File

@ -152,11 +152,11 @@ impl StackPointer {
} }
pub fn decrement(&mut self) { pub fn decrement(&mut self) {
self.0 = self.0.wrapping_sub(1); self.0 = self.0.wrapping_sub(1);
} }
pub fn increment(&mut self) { pub fn increment(&mut self) {
self.0 = self.0.wrapping_add(1); self.0 = self.0.wrapping_add(1);
} }
} }