aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-02-11 17:15:31 +0100
committerMiquel Sabaté Solà <mssola@mssola.com>2026-02-11 17:15:31 +0100
commitd10d4fd6e6ed2c6939b5504a7de576fa5d4e5317 (patch)
tree8f9fd99e719e4df1fd9bf949975c020b3a21145a /lib/xixanta
parent394ccffc5a3f7a6fb791eaa87767cf1bba34199c (diff)
downloadtools.nes-d10d4fd6e6ed2c6939b5504a7de576fa5d4e5317.tar.gz
tools.nes-d10d4fd6e6ed2c6939b5504a7de576fa5d4e5317.zip
Allow using a byte for indirect jumps
They should be expanded to a 16-bit address from the zero-page. The fact that the assembler was complaining about it was simply erroneous. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'lib/xixanta')
-rw-r--r--lib/xixanta/src/assembler.rs23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs
index d5dc5fa..11a9409 100644
--- a/lib/xixanta/src/assembler.rs
+++ b/lib/xixanta/src/assembler.rs
@@ -2739,16 +2739,17 @@ impl<'a> Assembler<'a> {
}
None => {
let evaluated_node = left.left.as_ref().unwrap();
- let val = self.evaluate_node(evaluated_node)?;
- if val.size != 2 {
- return Err(Error {
- message: "expecting a full 16-bit address".to_string(),
- line: node.value.line,
- source: self.source_for(node),
- global: false,
- expanded_from: self.macro_context.clone(),
- });
- }
+ let mut val = self.evaluate_node(evaluated_node)?;
+
+ // If this is a valid pure indirect addressing, then we know
+ // for sure we are in a 'jmp' instruction. In this case, if
+ // a zero-page address was being used, expand it to an
+ // absolute address. We do this unconditionally just to be
+ // sure, just as like we set the high byte of the address to
+ // $00 just to sanitize things.
+ val.size = 3;
+ val.bytes[2] = 0x00;
+
self.asan_check_arm(evaluated_node, &val)?;
Ok((AddressingMode::Indirect, val))
}
@@ -3677,7 +3678,6 @@ cpx #(4 * var2)"#,
false,
"only the Y index is allowed on indirect Y addressing",
);
- assert_error("jmp ($20)", 1, false, "expecting a full 16-bit address");
assert_error("adc $20, z", 1, false, "can only use X and Y as indices");
assert_error(
"adc ($2000)",
@@ -3829,6 +3829,7 @@ cpx #(4 * var2)"#,
assert_instruction("jmp $2002", &[0x4C, 0x02, 0x20]);
assert_instruction("jmp ($2002)", &[0x6C, 0x02, 0x20]);
+ assert_instruction("jmp ($20)", &[0x6C, 0x20, 0x00]);
}
#[test]