summaryrefslogtreecommitdiff
path: root/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/DevTools/UserspaceEmulator/SoftCPU.cpp')
-rw-r--r--Userland/DevTools/UserspaceEmulator/SoftCPU.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp b/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp
index f39c6e8d7f..0ee6bb338e 100644
--- a/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp
+++ b/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp
@@ -2153,8 +2153,24 @@ void SoftCPU::MOV_reg8_imm8(const X86::Instruction& insn)
gpr8(insn.reg8()) = shadow_wrap_as_initialized(insn.imm8());
}
-void SoftCPU::MOV_seg_RM16(const X86::Instruction&) { TODO_INSN(); }
-void SoftCPU::MOV_seg_RM32(const X86::Instruction&) { TODO_INSN(); }
+void SoftCPU::write_segment_register(X86::SegmentRegister segment_register, ValueWithShadow<u16> value)
+{
+ // FIXME: Validate the segment selector and raise exception if necessary.
+ // FIXME: Complain if uninitialized data is moved into a segment register.
+ m_segment[to_underlying(segment_register)] = value.value();
+}
+
+void SoftCPU::MOV_seg_RM16(X86::Instruction const& insn)
+{
+ write_segment_register(insn.segment_register(), insn.modrm().read16(*this, insn));
+}
+
+void SoftCPU::MOV_seg_RM32(X86::Instruction const& insn)
+{
+ // NOTE: This instruction performs a 32-bit read but only the bottom 16 bits are used since segment registers are 16-bit.
+ auto value = insn.modrm().read32(*this, insn);
+ write_segment_register(insn.segment_register(), ValueWithShadow<u16>(value.value(), value.shadow_as_value()));
+}
void SoftCPU::MUL_RM16(const X86::Instruction& insn)
{