Implement writing memory

This commit is contained in:
2025-01-18 01:03:22 -05:00
parent 0fff4d427f
commit 5ce39fb70e
4 changed files with 77 additions and 14 deletions
+10
View File
@@ -166,6 +166,8 @@ extern "C" {
fn vb_set_write_callback(sim: *mut VB, callback: Option<OnWrite>) -> Option<OnWrite>;
#[link_name = "vbSizeOf"]
fn vb_size_of() -> usize;
#[link_name = "vbWrite"]
fn vb_write(sim: *mut VB, address: u32, _type: VBDataType, value: i32) -> i32;
}
extern "C" fn on_frame(sim: *mut VB) -> c_int {
@@ -476,6 +478,14 @@ impl Sim {
}
}
pub fn write_memory(&mut self, start: u32, buffer: &[u8]) {
let mut address = start;
for byte in buffer {
unsafe { vb_write(self.sim, address, VBDataType::U8, *byte as i32) };
address = address.wrapping_add(1);
}
}
pub fn add_breakpoint(&mut self, address: u32) {
let data = self.get_state();
if let Err(index) = data.breakpoints.binary_search(&address) {