8000 move emu to mod and fix rep vs repe · sha0coder/libscemu@25df7f6 · 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 25df7f6

Browse files
committed
move emu to mod and fix rep vs repe
1 parent cdf854b commit 25df7f6

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ documentation = "https://docs.rs/libscemu/0.4.15/libscemu/"
1010
repository = "https://github.com/sha0coder/libscemu"
1111
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1212

13-
1413
[dependencies]
1514
iced-x86 = "1.19.0"
1615
uint = "0.9.5"

src/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub struct Config {
1818
pub console2: bool,
1919
pub console_addr: u64,
2020
pub entry_point: u64,
21+
pub exit_position: u64,
2122
pub code_base_addr: u64,
2223
pub is_64bits: bool, // 64bits mode
2324
pub stack_trace: bool,
@@ -50,6 +51,7 @@ impl Config {
5051
console2: false,
5152
console_addr: 0,
5253
entry_point: 0x3c0000,
54+
exit_position: 0,
5355
code_base_addr: 0x3c0000,
5456
is_64bits: false,
5557
stack_trace: false,

src/emu.rs renamed to src/emu/mod.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4671,11 +4671,31 @@ impl Emu {
46714671
self.rep = Some(rep_count + 1);
46724672
}
46734673
}
4674-
if ins.has_repe_prefix() && !self.flags.f_zf {
4675-
self.rep = None;
4676-
}
4677-
if ins.has_repne_prefix() && self.flags.f_zf {
4678-
self.rep = None;
4674+
4675+
let is_string_movement = matches!(
4676+
ins.mnemonic(),
4677+
Mnemonic::Movsb | Mnemonic::Movsw | Mnemonic::Movsd | Mnemonic::Movsq |
4678+
Mnemonic::Stosb | Mnemonic::Stosw | Mnemonic::Stosd | Mnemonic::Stosq |
4679+
Mnemonic::Lodsb | Mnemonic::Lodsw | Mnemonic::Lodsd | Mnemonic::Lodsq
4680+
);
4681+
4682+
let is_string_comparison = matches!(
4683+
ins.mnemonic(),
4684+
Mnemonic::Cmpsb | Mnemonic::Cmpsw | Mnemonic::Cmpsd | Mnemonic::Cmpsq |
4685+
Mnemonic::Scasb | Mnemonic::Scasw | Mnemonic::Scasd | Mnemonic::Scasq
4686+
);
4687+
4688+
if is_string_movement {
4689+
4690+
} else if is_string_comparison {
4691+
if ins.has_repe_prefix() && !self.flags.f_zf {
4692+
self.rep = None;
4693+
}
4694+
if ins.has_repne_prefix() && self.flags.f_zf {
4695+
self.rep = None;
4696+
}
4697+
} else {
4698+
unimplemented!("string instruction not supported");
46794699
}
46804700
}
46814701

0 commit comments

Comments
 (0)
0