File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff 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 ): ...
Original file line number Diff line number Diff 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,
@@ -455,7 +475,13 @@ impl Icicle {
455475 }
456476
457477 pub fn reg_write ( & mut self , name : & str , value : u64 ) -> PyResult < ( ) > {
458- Ok ( self . vm . cpu . write_reg ( reg_find ( self , name) ?. var , value) )
478+ let var = reg_find ( self , name) ?. var ;
479+ if var == self . vm . cpu . arch . reg_pc {
480+ self . vm . cpu . write_pc ( value) ;
481+ } else {
482+ self . vm . cpu . write_reg ( var, value) ;
483+ }
484+ Ok ( ( ) )
459485 }
460486
461487 pub fn reset ( & mut self ) {
You can’t perform that action at this time.
0 commit comments