-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor VideoDevice into its own module * Implement showing debug info for the CPU * Refactor stack and opcodes into their own modules * Implement push opcode * Add PUSH and DEO opcodes and implement system/debug deo
- Loading branch information
1 parent
cb899b7
commit 9ddc0fe
Showing
11 changed files
with
302 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub const BRK: u8 = 0x00; | ||
pub const DEO: u8 = 0x17; | ||
pub const PUSH: u8 = 0x80; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use core::fmt; | ||
|
||
#[derive(Debug)] | ||
pub struct Stack { | ||
data: [u8; 0x100], | ||
index: u8, | ||
} | ||
|
||
impl Stack { | ||
pub fn new() -> Self { | ||
Self { | ||
data: [0_u8; 0x100], | ||
index: u8::MAX, | ||
} | ||
} | ||
|
||
pub fn len(&self) -> usize { | ||
self.index.wrapping_add(1) as usize | ||
} | ||
|
||
pub fn push_byte(&mut self, x: u8) { | ||
self.index = self.index.wrapping_add(1); | ||
self.data[self.index as usize] = x; | ||
} | ||
|
||
pub fn pop_byte(&mut self) -> u8 { | ||
let res = self.data[self.index as usize]; | ||
self.index = self.index.wrapping_sub(1); | ||
res | ||
} | ||
|
||
pub fn byte_at(&self, i: u8) -> u8 { | ||
return self.data[i as usize]; | ||
} | ||
} | ||
|
||
impl fmt::Display for Stack { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
for i in self.len().saturating_sub(8)..self.len() { | ||
write!(f, "{:02x}", self.byte_at(i as u8))?; | ||
if i < self.len() - 1 { | ||
write!(f, " ")?; | ||
} | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.