mirror of
https://github.com/icicle-emu/icicle-python
synced 2026-06-21 13:53:41 +00:00
Merge pull request #14 from icicle-emu/write-reg-sp
Fix bug where `reg_write("rip", ...)` would not work after stepping
This commit is contained in:
@@ -100,6 +100,10 @@ class Icicle:
|
||||
|
||||
icount_limit: int
|
||||
|
||||
pc: int
|
||||
|
||||
sp: int
|
||||
|
||||
# TODO: API to get memory information?
|
||||
|
||||
def mem_map(self, address: int, size: int, protection: MemoryProtection): ...
|
||||
|
||||
+27
-1
@@ -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,
|
||||
@@ -455,7 +475,13 @@ impl Icicle {
|
||||
}
|
||||
|
||||
pub fn reg_write(&mut self, name: &str, value: u64) -> PyResult<()> {
|
||||
Ok(self.vm.cpu.write_reg(reg_find(self, name)?.var, value))
|
||||
let var = reg_find(self, name)?.var;
|
||||
if var == self.vm.cpu.arch.reg_pc {
|
||||
self.vm.cpu.write_pc(value);
|
||||
} else {
|
||||
self.vm.cpu.write_reg(var, value);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn reset(&mut self) {
|
||||
|
||||
Reference in New Issue
Block a user