diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-07-15 08:55:57 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-12-12 07:31:52 +0100 |
| commit | c6c9aa4e5f3e5a01fcb9ccabf6dbd2f6da277650 (patch) | |
| tree | 55f205062606664d3f17ff762e475a7895ceefee /lib/xixanta/src/instruction.rs | |
| parent | 587dd5bb80364688419bb43aba4afc044ac0ef48 (diff) | |
| download | tools.nes-c6c9aa4e5f3e5a01fcb9ccabf6dbd2f6da277650.tar.gz tools.nes-c6c9aa4e5f3e5a01fcb9ccabf6dbd2f6da277650.zip | |
Add the notion of mapping
Mappings and segments are fundamental blocks on how code is distributed
both on the actual ROM File and in the memory layout.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta/src/instruction.rs')
| -rw-r--r-- | lib/xixanta/src/instruction.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/xixanta/src/instruction.rs b/lib/xixanta/src/instruction.rs index fac6d8e..227a3e1 100644 --- a/lib/xixanta/src/instruction.rs +++ b/lib/xixanta/src/instruction.rs @@ -268,10 +268,50 @@ impl Encodable for Literal { } } +#[derive(Debug, Clone, Eq, Ord, PartialEq, PartialOrd)] +pub struct Fill { + pub value: u8, +} + +impl Encodable for Fill { + fn size(&self) -> u8 { + 1 + } + + fn to_hex(&self) -> Vec<String> { + let mut ret = vec![]; + ret.push(format!("{:02X}", self.value)); + + ret + } + + fn to_bytes(&self) -> [u8; 3] { + [self.value, 0, 0] + } + + fn to_human(&self) -> String { + format!("${:02X}", self.value) + } + + fn to_verbose(&self) -> String { + format!("{:#?}", self) + } +} + #[derive(Debug, Clone, PartialEq)] pub enum Node { Generic(Generic), Instruction(Instruction), Scoped(Scoped), Literal(Literal), + Fill(Fill), +} + +impl Node { + pub fn is_encodeable(&self) -> bool { + matches!( + self, + &Node::Instruction(_) | &Node::Literal(_) | &Node::Fill(_) + ) + } } |
