Skip to content

Commit

Permalink
Add getter/setter for PC and SP registers
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexodia committed Dec 24, 2024
1 parent ae409c8 commit a228304
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/icicle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ def exception_value(self) -> int: ...

icount_limit: int

pc: int

sp: int

# TODO: API to get memory information?

def mem_map(self, address: int, size: int, protection: MemoryProtection): ...
Expand Down
20 changes: 20 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,26 @@ impl Icicle {
self.architecture.to_string()
}

#[getter]
pub fn get_pc(&self) -> u64 {
self.vm.cpu.read_pc()
}

#[setter]
pub fn set_pc(&mut self, address: u64) {
self.vm.cpu.write_pc(address)
}

#[getter]
pub fn get_sp(&mut self) -> u64 {
self.vm.cpu.read_reg(self.vm.cpu.arch.reg_sp)
}

#[setter]
pub fn set_sp(&mut self, address: u64) {
self.vm.cpu.write_reg(self.vm.cpu.arch.reg_sp, address)
}

#[new]
#[pyo3(signature = (
architecture,
Expand Down

0 comments on commit a228304

Please sign in to comment.