-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
324 additions
and
259 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
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 super::*; | ||
|
||
/// Performs math using the A register along with some other value. | ||
#[derive(Debug, Clone, Copy)] | ||
pub enum BinaryOp { | ||
/// `adc` | ||
AddCarry, | ||
|
||
/// `add` | ||
Add, | ||
|
||
/// `and` | ||
BitAnd, | ||
|
||
/// `cp` | ||
Compare, | ||
|
||
/// `or` | ||
BitOr, | ||
|
||
/// `sbc` | ||
SubCarry, | ||
|
||
/// `sub` | ||
Sub, | ||
|
||
/// `xor` | ||
BitXor, | ||
} | ||
impl core::fmt::Display for BinaryOp { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!( | ||
f, | ||
"{}", | ||
match self { | ||
BinaryOp::AddCarry => "adc", | ||
BinaryOp::Add => "add", | ||
BinaryOp::BitAnd => "and", | ||
BinaryOp::Compare => "cp", | ||
BinaryOp::BitOr => "or", | ||
BinaryOp::SubCarry => "sbc", | ||
BinaryOp::Sub => "sub", | ||
BinaryOp::BitXor => "xor", | ||
} | ||
) | ||
} | ||
} |
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,35 @@ | ||
use super::*; | ||
|
||
/// The conditions for calls and jumps | ||
#[derive(Debug, Clone, Copy)] | ||
pub enum Condition { | ||
/// `c,` | ||
Carry, | ||
|
||
/// `nc,` | ||
NoCarry, | ||
|
||
/// `z,` | ||
Zero, | ||
|
||
/// `nz,` | ||
NonZero, | ||
|
||
/// The "always" condition doesn't get written down in assembly output. | ||
Always, | ||
} | ||
impl core::fmt::Display for Condition { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!( | ||
f, | ||
"{}", | ||
match self { | ||
Condition::Carry => "c, ", | ||
Condition::NoCarry => "nc, ", | ||
Condition::Zero => "z, ", | ||
Condition::NonZero => "nz, ", | ||
Condition::Always => "", | ||
} | ||
) | ||
} | ||
} |
Oops, something went wrong.