From 363dc47755c1ab4f8d8d5358cfe561dbffe54f89 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 7 Jun 2022 19:30:29 +0200 Subject: [PATCH] Format code --- .gitignore | 1 + examples/euclidean_algo.rs | 33 ++++++++++++------------- examples/mos6502.rs | 50 +++++++------------------------------- src/cpu.rs | 10 ++++---- src/lib.rs | 1 - src/registers.rs | 4 +-- 6 files changed, 33 insertions(+), 66 deletions(-) diff --git a/.gitignore b/.gitignore index 0fe8ab9..53c030a 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,4 @@ TAGS.vi \#*\# src/.DS_Store tmp.*.rs +.vscode diff --git a/examples/euclidean_algo.rs b/examples/euclidean_algo.rs index 2344ccd..f43e616 100644 --- a/examples/euclidean_algo.rs +++ b/examples/euclidean_algo.rs @@ -14,24 +14,23 @@ fn main() { .collect::>(); 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 ]; diff --git a/examples/mos6502.rs b/examples/mos6502.rs index f8c4612..04c163b 100644 --- a/examples/mos6502.rs +++ b/examples/mos6502.rs @@ -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); diff --git a/src/cpu.rs b/src/cpu.rs index 711feef..d6767e2 100644 --- a/src/cpu.rs +++ b/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(); } } diff --git a/src/lib.rs b/src/lib.rs index 64e8035..9e12bbb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,4 +40,3 @@ pub mod cpu; pub mod instruction; pub mod memory; pub mod registers; - diff --git a/src/registers.rs b/src/registers.rs index d0f976e..c861d41 100644 --- a/src/registers.rs +++ b/src/registers.rs @@ -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); } }