Skip to content

Commit

Permalink
feat: support pc offset arguments for get and set
Browse files Browse the repository at this point in the history
  • Loading branch information
dxrcy committed Dec 20, 2024
1 parent 13934c7 commit 66524cf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
5 changes: 0 additions & 5 deletions src/debugger/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,12 @@ impl fmt::Display for CommandName {
}

/// Register or memory location.
/// `Location::Memory(MemoryLocation::PC)` is valid, but should not be
/// constructed, as it would imply using `get`/`set` with the PC, which is not
/// possible.
#[derive(Debug)]
pub enum Location {
Register(Register),
Memory(MemoryLocation),
}

// TODO(feat): Offset from PC. Eg. `~3`, `~-x3`. Useful for `jump`

#[derive(Debug)]
pub enum MemoryLocation {
PCOffset(i16),
Expand Down
11 changes: 3 additions & 8 deletions src/debugger/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,9 @@ impl<'a> CommandIter<'a> {

Some(Argument::Label(label)) => Ok(Location::Memory(MemoryLocation::Label(label))),

// TODO(feat): Accept pc offset arguments ?
Some(value) => Err(ArgumentError::InvalidValue {
argument_name,
error: ValueError::MismatchedType {
expected_type: "register, address, or label",
actual_type: value.kind(),
},
}),
Some(Argument::PCOffset(offset)) => {
Ok(Location::Memory(MemoryLocation::PCOffset(offset)))
}

None => Err(ArgumentError::MissingArgument {
argument_name,
Expand Down

0 comments on commit 66524cf

Please sign in to comment.