Skip to content

Commit a228304

Browse files
committed
Add getter/setter for PC and SP registers
1 parent ae409c8 commit a228304

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

python/icicle/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ def exception_value(self) -> int: ...
100100

101101
icount_limit: int
102102

103+
pc: int
104+
105+
sp: int
106+
103107
# TODO: API to get memory information?
104108

105109
def mem_map(self, address: int, size: int, protection: MemoryProtection): ...

src/lib.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,26 @@ impl Icicle {
276276
self.architecture.to_string()
277277
}
278278

279+
#[getter]
280+
pub fn get_pc(&self) -> u64 {
281+
self.vm.cpu.read_pc()
282+
}
283+
284+
#[setter]
285+
pub fn set_pc(&mut self, address: u64) {
286+
self.vm.cpu.write_pc(address)
287+
}
288+
289+
#[getter]
290+
pub fn get_sp(&mut self) -> u64 {
291+
self.vm.cpu.read_reg(self.vm.cpu.arch.reg_sp)
292+
}
293+
294+
#[setter]
295+
pub fn set_sp(&mut self, address: u64) {
296+
self.vm.cpu.write_reg(self.vm.cpu.arch.reg_sp, address)
297+
}
298+
279299
#[new]
280300
#[pyo3(signature = (
281301
architecture,

0 commit comments

Comments
 (0)