Skip to content

Commit

Permalink
fix BH..
Browse files Browse the repository at this point in the history
  • Loading branch information
lenawanel committed Apr 20, 2024
1 parent 9f02ea3 commit b55b343
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/emu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,12 @@ impl Emu {
} else {
// we're the high part of an register
// so first mask off the unused bits
self.registers[register as usize - 31] &= !0xff_00;
self.registers
[register as usize - self.registers.len() - self.simd_registers.len() + 1] &=
!0xff_00;
// then set it to it's new value
self.registers[register as usize - 31] |=
self.registers
[register as usize - self.registers.len() - self.simd_registers.len() + 1] |=
TryInto::<u16>::try_into(val).unwrap().overflowing_shl(8).0 as u64;
}
}
Expand All @@ -179,7 +182,14 @@ impl Emu {
.unwrap()
} else {
// we're the high part of a 16 bit lower register
T::try_from(((self.registers[register as usize - 31] as u16) & 0xff_00) >> 8).unwrap()
T::try_from(
((self.registers
[register as usize - self.registers.len() - self.simd_registers.len() + 1]
as u16)
& 0xff_00)
>> 8,
)
.unwrap()
}
}

Expand Down Expand Up @@ -1857,14 +1867,14 @@ pub enum Register {
/// 16 bit hight bytes of `EAX`
AH,
/// general purpose register
/// 16 bit hight bytes of `EBX`
BH,
/// general purpose register
/// 16 bit hight bytes of `ECX`
CH,
/// general purpose register
/// 16 bit hight bytes of `EDX`
DH,
/// general purpose register
/// 16 bit hight bytes of `EBX`
BH,
}

#[derive(Clone, Copy)]
Expand Down

0 comments on commit b55b343

Please sign in to comment.