aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/xixanta/src')
-rw-r--r--lib/xixanta/src/assembler.rs13
-rw-r--r--lib/xixanta/src/parser.rs20
2 files changed, 33 insertions, 0 deletions
diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs
index 2f0292e..54ba4c3 100644
--- a/lib/xixanta/src/assembler.rs
+++ b/lib/xixanta/src/assembler.rs
@@ -4630,6 +4630,19 @@ JAL procedure
}
#[test]
+ fn lobyte_with_arithmetic() {
+ let res = just_bundles(
+ r#"lda #.lobyte(@address - 1)
+@address:
+nop
+ "#,
+ );
+
+ assert_eq!(res[0].bytes[0], 0xA9);
+ assert_eq!(res[0].bytes[1], 0x01);
+ }
+
+ #[test]
fn warnings_on_empty_proc_scope_macro() {
let res = just_assemble(
r#".proc Proc
diff --git a/lib/xixanta/src/parser.rs b/lib/xixanta/src/parser.rs
index 9f8ffc7..10340c4 100644
--- a/lib/xixanta/src/parser.rs
+++ b/lib/xixanta/src/parser.rs
@@ -1194,6 +1194,12 @@ impl Parser {
// Skip any possible whitespace before the optional opening paren.
self.skip_whitespace(line);
+ // If arguments are wrapped in a parenthesis, and the look ahead index
+ // is larger than zero, then the following code will temporarily
+ // subtract it. This is in a similar fashion as what we do in
+ // extract_paren_expression().
+ let mut la_subtracted = false;
+
// Scope the end of the argument list. If the arguments are enclosed on
// parenthesis, take that into account, otherwise we will parse until
// the end of the cleaned line.
@@ -1203,6 +1209,14 @@ impl Parser {
self.next();
self.skip_whitespace(line);
+ // Arguments are in a parenthesis and we were looking
+ // ahead. Temporarily decrease the index and change 'la_subtracted'
+ // so we increase it back at the end.
+ if self.look_ahead_index > 0 {
+ self.look_ahead_index -= 1;
+ la_subtracted = true;
+ }
+
// If there is a parenthesis it might be either that the command
// enclosed its arguments into parenthesis, or that the first
// argument is using parenthesis to disambiguate with an
@@ -1282,6 +1296,12 @@ impl Parser {
}
}
+ // Was the look ahead index subtracted temporarily? If so now it's time
+ // to increase it again.
+ if la_subtracted {
+ self.look_ahead_index += 1;
+ }
+
Ok(args)
}