diff options
| -rw-r--r-- | lib/xixanta/src/assembler.rs | 8 | ||||
| -rw-r--r-- | lib/xixanta/src/object.rs | 3 | ||||
| -rw-r--r-- | tests/variable_names.s | 13 |
3 files changed, 19 insertions, 5 deletions
diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs index 3dc0577..d624c7e 100644 --- a/lib/xixanta/src/assembler.rs +++ b/lib/xixanta/src/assembler.rs @@ -1313,7 +1313,7 @@ impl<'a> Assembler<'a> { node: Some(arg.clone()), mapping: self.current_mapping, segment: self.current_segment, - object_type: ObjectType::Value, + object_type: ObjectType::Argument, asan_ignore: false, asan_reserve: 1, accessed: 0, @@ -2926,7 +2926,7 @@ impl<'a> Assembler<'a> { // let it be (e.g. 'lda palettes, x'; where 'palettes' is a // legitimate name even if not 'is_asan_friendly_name'). if let Ok(var) = self.context.get_variable(&node.value, &self.mappings) { - if matches!(var.object_type, ObjectType::Address) { + if matches!(var.object_type, ObjectType::Address | ObjectType::Argument) { return Ok(()); } } @@ -2957,12 +2957,12 @@ impl<'a> Assembler<'a> { // If everything failed but because it was an address // (e.g. 'lda palettes + 1, x'), then return early. if let Ok(var) = self.context.get_variable(left_name, &self.mappings) { - if matches!(var.object_type, ObjectType::Address) { + if matches!(var.object_type, ObjectType::Address | ObjectType::Argument) { return Ok(()); } } if let Ok(var) = self.context.get_variable(right_name, &self.mappings) { - if matches!(var.object_type, ObjectType::Address) { + if matches!(var.object_type, ObjectType::Address | ObjectType::Argument) { return Ok(()); } } diff --git a/lib/xixanta/src/object.rs b/lib/xixanta/src/object.rs index c70afb7..c16ddb0 100644 --- a/lib/xixanta/src/object.rs +++ b/lib/xixanta/src/object.rs @@ -119,6 +119,7 @@ impl Bundle { pub enum ObjectType { Address, Value, + Argument, } /// Bundle and metadata which is stored on the context table for a given @@ -241,7 +242,7 @@ impl Context { match self.map.get_mut(scope_name) { Some(scope) => match scope.get_mut(var_name) { Some(var) => match var.object_type { - ObjectType::Value => { + ObjectType::Value | ObjectType::Argument => { var.accessed += 1; Ok(var.clone()) } diff --git a/tests/variable_names.s b/tests/variable_names.s index 0859473..beda2b8 100644 --- a/tests/variable_names.s +++ b/tests/variable_names.s @@ -23,3 +23,16 @@ lda m_good lda wr_bad lda wr_good lda wr_out + +.macro INC_MOVEMENT_X ADDR + .ifdef PAL + lda ADDR, x + clc + adc Enemies::zp_movement_arg + sta ADDR, x + .else + inc ADDR, x + .endif +.endmacro + +INC_MOVEMENT_X zp_good + 1 |
