aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta/src/instruction.rs
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2024-07-16 11:12:26 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2024-12-12 07:32:52 +0100
commit7822c00e8689c99ded0a360026f4e7ace1f2c87f (patch)
treee2bc22aeea0a172ee7aee5e4a2a4b603a495b9b8 /lib/xixanta/src/instruction.rs
parentc6c9aa4e5f3e5a01fcb9ccabf6dbd2f6da277650 (diff)
downloadtools.nes-7822c00e8689c99ded0a360026f4e7ace1f2c87f.tar.gz
tools.nes-7822c00e8689c99ded0a360026f4e7ace1f2c87f.zip
Add support for branching
This is a bare bones implementation of it, and there's a lot of nuance that it's being missed, but at least the fundamentals have been implemented already. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta/src/instruction.rs')
-rw-r--r--lib/xixanta/src/instruction.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/xixanta/src/instruction.rs b/lib/xixanta/src/instruction.rs
index 227a3e1..c635644 100644
--- a/lib/xixanta/src/instruction.rs
+++ b/lib/xixanta/src/instruction.rs
@@ -112,8 +112,10 @@ pub struct Instruction {
pub left: Option<PString>,
pub right: Option<PString>,
pub mode: AddressingMode,
- pub cycles: u8,
- pub affected_on_page: bool,
+ pub cycles: u8, // NOTE: relative addressing makes this runtime-dependant (if branch is taken, then +1 cycle to the base cycle here).
+ pub affected_on_page: bool, // TODO: needed?
+ pub address: u16,
+ pub resolved: bool,
}
impl Instruction {
@@ -128,6 +130,8 @@ impl Instruction {
mode: AddressingMode::Unknown,
cycles: 0,
affected_on_page: false,
+ address: 0,
+ resolved: true,
}
}
@@ -142,6 +146,8 @@ impl Instruction {
mode: AddressingMode::Unknown,
cycles: 0,
affected_on_page: false,
+ address: 0,
+ resolved: true,
}
}
}
@@ -299,12 +305,18 @@ impl Encodable for Fill {
}
#[derive(Debug, Clone, PartialEq)]
+pub struct Label {
+ pub value: String,
+}
+
+#[derive(Debug, Clone, PartialEq)]
pub enum Node {
Generic(Generic),
Instruction(Instruction),
Scoped(Scoped),
Literal(Literal),
Fill(Fill),
+ Label(Label),
}
impl Node {