From a536cfec133b7d6695a559d74f848c052034b08b Mon Sep 17 00:00:00 2001 From: Krusty/Benediction Date: Tue, 19 Nov 2024 21:20:51 +0100 Subject: [PATCH] [cpclib-asm] Add STEP parameter to breakpoint as in EdouardBERGE/rasm@7bd50f0fa3827dc3d71deeba12e42493ccc02a25 --- cpclib-asm/src/assembler/mod.rs | 11 ++++- cpclib-asm/src/parser/obtained.rs | 3 +- cpclib-asm/src/parser/parser.rs | 45 ++++++++++++++----- cpclib-basm/tests/asm/good_breakpoint.asm | 3 +- .../tests/asm/rasm_comparison/breakpoint.asm | 3 +- cpclib-sna/src/chunks/remu.rs | 14 ++++-- cpclib-tokens/src/tokens/instructions.rs | 3 +- 7 files changed, 62 insertions(+), 20 deletions(-) diff --git a/cpclib-asm/src/assembler/mod.rs b/cpclib-asm/src/assembler/mod.rs index f61631bb..84f60649 100644 --- a/cpclib-asm/src/assembler/mod.rs +++ b/cpclib-asm/src/assembler/mod.rs @@ -1942,6 +1942,7 @@ impl Env { value_mask: Option<&E>, condition: Option<&E>, name: Option<&E>, + step: Option<&E>, span: Option<&Z80Span> ) -> Result<(), AssemblerError> { let brk = if r#type.is_none() @@ -1953,6 +1954,7 @@ impl Env { && value_mask.is_none() && condition.is_none() && name.is_none() + && step.is_none() { // here we manipulate a very simple breakpoint let (current_address, page): (u16, u8) = if let Some(exp) = address { @@ -2040,6 +2042,11 @@ impl Env { .resolve_expr_may_fail_in_first_pass(value_mask)? .int()? as u8; } + if let Some(step) = step { + brk.step = Some(self + .resolve_expr_may_fail_in_first_pass(step)? + .int()? as _); + } if let Some(condition) = condition { let cond = self.resolve_expr_may_fail_in_first_pass(condition)?; let cond = cond.string()?; @@ -3474,7 +3481,8 @@ macro_rules! visit_token_impl { value, value_mask, condition, - name + name, + step } => { $env.visit_breakpoint( address.as_ref(), @@ -3487,6 +3495,7 @@ macro_rules! visit_token_impl { value_mask.as_ref(), condition.as_ref(), name.as_ref(), + step.as_ref(), $span ) }, diff --git a/cpclib-asm/src/parser/obtained.rs b/cpclib-asm/src/parser/obtained.rs index 0207718d..31c917e1 100644 --- a/cpclib-asm/src/parser/obtained.rs +++ b/cpclib-asm/src/parser/obtained.rs @@ -938,7 +938,8 @@ pub enum LocatedTokenInner { value: Option, value_mask: Option, condition: Option, - name: Option + name: Option, + step: Option }, BuildCpr, BuildSna(Option), diff --git a/cpclib-asm/src/parser/parser.rs b/cpclib-asm/src/parser/parser.rs index 1be02ba7..14020297 100644 --- a/cpclib-asm/src/parser/parser.rs +++ b/cpclib-asm/src/parser/parser.rs @@ -2837,6 +2837,7 @@ pub fn parse_breakpoint(input: &mut InnerZ80Span) -> PResult PResult { let mut address = address.borrow_mut(); let address = address.deref_mut(); - if let Some(address) = address { + if address.is_some() { false } else { @@ -2862,7 +2863,7 @@ pub fn parse_breakpoint(input: &mut InnerZ80Span) -> PResult { let mut r#type = r#type.borrow_mut(); let r#type = r#type.deref_mut(); - if let Some(r#type) = r#type { + if r#type.is_some() { false } else { @@ -2874,7 +2875,7 @@ pub fn parse_breakpoint(input: &mut InnerZ80Span) -> PResult { let mut access = access.borrow_mut(); let access = access.deref_mut(); - if let Some(access) = access { + if access.is_some() { false } else { @@ -2886,7 +2887,7 @@ pub fn parse_breakpoint(input: &mut InnerZ80Span) -> PResult { let mut run = run.borrow_mut(); let run = run.deref_mut(); - if let Some(run) = run { + if run.is_some() { false } else { @@ -2898,7 +2899,7 @@ pub fn parse_breakpoint(input: &mut InnerZ80Span) -> PResult { let mut item = mask.borrow_mut(); let item = item.deref_mut(); - if let Some(item) = item { + if item.is_some() { false } else { @@ -2910,7 +2911,7 @@ pub fn parse_breakpoint(input: &mut InnerZ80Span) -> PResult { let mut item = size.borrow_mut(); let item = item.deref_mut(); - if let Some(item) = item { + if item.is_some() { false } else { @@ -2922,7 +2923,7 @@ pub fn parse_breakpoint(input: &mut InnerZ80Span) -> PResult { let mut item = value.borrow_mut(); let item = item.deref_mut(); - if let Some(item) = item { + if item.is_some() { false } else { @@ -2934,7 +2935,7 @@ pub fn parse_breakpoint(input: &mut InnerZ80Span) -> PResult { let mut item = value_mask.borrow_mut(); let item = item.deref_mut(); - if let Some(item) = item { + if item.is_some() { false } else { @@ -2946,7 +2947,7 @@ pub fn parse_breakpoint(input: &mut InnerZ80Span) -> PResult { let mut item = name.borrow_mut(); let item = item.deref_mut(); - if let Some(item) = item { + if item.is_some() { false } else { @@ -2958,7 +2959,7 @@ pub fn parse_breakpoint(input: &mut InnerZ80Span) -> PResult { let mut item = condition.borrow_mut(); let item = item.deref_mut(); - if let Some(item) = item { + if item.is_some() { false } else { @@ -2966,6 +2967,18 @@ pub fn parse_breakpoint(input: &mut InnerZ80Span) -> PResult { + let mut item = step.borrow_mut(); + let item = item.deref_mut(); + if item.is_some() { + false + } else { + item.replace((*arg, value.clone())); + true + } + }, + _ => true // TODO implement the tests } } @@ -2997,7 +3010,8 @@ pub fn parse_breakpoint(input: &mut InnerZ80Span) -> PResult, - pub name: Option + pub name: Option, + pub step: Option } impl Default for AdvancedRemuBreakPoint { @@ -80,7 +81,8 @@ impl Default for AdvancedRemuBreakPoint { value: 0, val_mask: 0, condition: None, - name: None + name: None, + step: None } } } @@ -90,7 +92,7 @@ impl Display for AdvancedRemuBreakPoint { let brk = self; write!( f, - "{},{},{},addr={},mask={},size={},value={},valmask={},name={},condition={}", + "{},{},{},addr={},mask={},size={},value={},valmask={},name={},condition={},step={}", <&RemuBreakPointType as Into<&'static str>>::into(&brk.brk_type), <&RemuBreakPointAccessMode as Into<&'static str>>::into(&brk.access_mode), <&RemuBreakPointRunMode as Into<&'static str>>::into(&brk.run_mode), @@ -106,7 +108,11 @@ impl Display for AdvancedRemuBreakPoint { brk.condition .as_ref() .map(|s| format!("\"{}\"", s.as_ref())) - .unwrap_or("".to_owned()) + .unwrap_or("".to_owned()), + brk.step + .as_ref() + .map(|s| format!("{s}")) + .unwrap_or("".to_owned()), ) } } diff --git a/cpclib-tokens/src/tokens/instructions.rs b/cpclib-tokens/src/tokens/instructions.rs index 65e8544a..be43afa4 100644 --- a/cpclib-tokens/src/tokens/instructions.rs +++ b/cpclib-tokens/src/tokens/instructions.rs @@ -590,7 +590,8 @@ pub enum Token { value: Option, value_mask: Option, condition: Option, - name: Option + name: Option, + step: Option }, BuildCpr, BuildSna(Option),