8000 pop was missing a write · sha0coder/libscemu@beec066 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit beec066

Browse files
committed
pop was missing a write
1 parent 854e19c commit beec066

File tree

1 file changed

+43
-9
lines changed

1 file changed

+43
-9
lines changed

src/emu.rs

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,22 +1261,39 @@ impl Emu {
12611261
*/
12621262

12631263
if self.cfg.trace_mem {
1264+
// Record the read from stack memory
12641265
let name = match self.maps.get_addr_name(self.regs.get_esp()) {
12651266
Some(n) => n,
12661267
None => "not mapped".to_string(),
12671268
};
1268-
let memory_operation = MemoryOperation {
1269+
let read_operation = MemoryOperation {
12691270
pos: self.pos,
12701271
rip: self.regs.rip,
12711272
op: "read".to_string(),
12721273
bits: 32,
12731274
address: self.regs.get_esp(),
1274-
old_value: 0, // not needed for read?
1275+
old_value: 0, // not needed for read
12751276
new_value: value as u64,
12761277
name: name.clone(),
12771278
};
1278-
self.memory_operations.push(memory_operation);
1279-
println!("\tmem_trace: pos = {} rip = {:x} op = read bits = {} address = 0x{:x} value = 0x{:x} name = '{}'", self.pos, self.regs.rip, 32, self.regs.get_esp(), value, name);
1279+
self.memory_operations.push(read_operation);
1280+
println!("\tmem_trace: pos = {} rip = {:x} op = read bits = {} address = 0x{:x} value = 0x{:x} name = '{}'",
1281+
self.pos, self.regs.rip, 32, self.regs.get_esp(), value, name);
1282+
1283+
// Record the write to register
1284+
let write_operation = MemoryOperation {
1285+
pos: self.pos,
1286+
rip: self.regs.rip,
1287+
op: "write".to_string(),
1288+
bits: 32,
1289+
address: self.regs.get_esp(),
1290+
old_value: self.maps.read_dword(self.regs.get_esp()).unwrap_or(0) as u64,
1291+
new_value: value as u64, // new value being written
1292+
name: "register".to_string(),
1293+
};
1294+
self.memory_operations.push(write_operation);
1295+
println!("\tmem_trace: pos = {} rip = {:x} op = write bits = {} address = 0x{:x} value = 0x{:x} name = 'register'",
1296+
self.pos, self.regs.rip, 32, self.regs.get_esp(), value);
12801297
}
12811298

12821299
self.regs.set_esp(self.regs.get_esp() + 4);
@@ -1324,22 +1341,39 @@ impl Emu {
13241341
};
13251342

13261343
if self.cfg.trace_mem {
1344+
// Record the read from stack memory
13271345
let name = match self.maps.get_addr_name(self.regs.rsp) {
13281346
Some(n) => n,
13291347
None => "not mapped".to_string(),
13301348
};
1331-
let memory_operation = MemoryOperation {
1349+
let read_operation = MemoryOperation {
13321350
pos: self.pos,
13331351
rip: self.regs.rip,
13341352
op: "read".to_string(),
1335-
bits: 32,
1353+
bits: 64, // Changed from 32 to 64 for 64-bit operations
13361354
address: self.regs.rsp,
1337-
old_value: 0, // not needed for read?
1355+
old_value: 0, // not needed for read
13381356
new_value: value as u64,
13391357
name: name.clone(),
13401358
};
1341-
self.memory_operations.push(memory_operation);
1342-
println!("\tmem_trace: pos = {} rip = {:x} op = read bits = {} address = 0x{:x} value = 0x{:x} name = '{}'", self.pos, self.regs.rip, 32, self.regs.rsp, value, name);
1359+
self.memory_operations.push(read_operation);
1360+
println!("\tmem_trace: pos = {} rip = {:x} op = read bits = {} address = 0x{:x} value = 0x{:x} name = '{}'",
1361+
self.pos, self.regs.rip, 64, self.regs.rsp, value, name);
1362+
1363+
// Record the write to register
1364+
let write_operation = MemoryOperation {
1365+
pos: self.pos,
1366+
rip: self.regs.rip,
1367+
op: "write".to_string(),
1368+
bits: 64, // Changed from 32 to 64 for 64-bit operations
1369+
address: self.regs.rsp,
1370+
old_value: self.maps.read_qword(self.regs.rsp).unwrap_or(0) as u64,
1371+
new_value: value as u64, // new value being written
1372+
name: "register".to_string(),
1373+
};
1374+
self.memory_operations.push(write_operation);
1375+
println!("\tmem_trace: pos = {} rip = {:x} op = write bits = {} address = 0x{:x} value = 0x{:x} name = 'register'",
1376+
self.pos, self.regs.rip, 64, self.regs.rsp, value);
13431377
}
13441378

13451379
self.regs.rsp += 8;

0 commit comments

Comments
 (0)
0