summaryrefslogtreecommitdiff
path: root/DevTools
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-07-12 00:36:07 +0200
committerAndreas Kling <kling@serenityos.org>2020-07-12 01:36:45 +0200
commitdf95e25eaa618ae83d0ff0c3d6a2d6a22821f5ec (patch)
treecf6dede2a348e1bd7164c4cfbf91fcda17926340 /DevTools
parentaa13183615449cf8d90c3073059f7ffb0ccace92 (diff)
downloadserenity-df95e25eaa618ae83d0ff0c3d6a2d6a22821f5ec.zip
UserspaceEmulator: Implement the NEG instruction
Per the Intel manuals, NEG is equivalent to subtracting a value from 0.
Diffstat (limited to 'DevTools')
-rw-r--r--DevTools/UserspaceEmulator/SoftCPU.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/DevTools/UserspaceEmulator/SoftCPU.cpp b/DevTools/UserspaceEmulator/SoftCPU.cpp
index 9508ec1f95..1547b26239 100644
--- a/DevTools/UserspaceEmulator/SoftCPU.cpp
+++ b/DevTools/UserspaceEmulator/SoftCPU.cpp
@@ -998,9 +998,22 @@ void SoftCPU::MOV_seg_RM32(const X86::Instruction&) { TODO(); }
void SoftCPU::MUL_RM16(const X86::Instruction&) { TODO(); }
void SoftCPU::MUL_RM32(const X86::Instruction&) { TODO(); }
void SoftCPU::MUL_RM8(const X86::Instruction&) { TODO(); }
-void SoftCPU::NEG_RM16(const X86::Instruction&) { TODO(); }
-void SoftCPU::NEG_RM32(const X86::Instruction&) { TODO(); }
-void SoftCPU::NEG_RM8(const X86::Instruction&) { TODO(); }
+
+void SoftCPU::NEG_RM16(const X86::Instruction& insn)
+{
+ insn.modrm().write16(*this, insn, op_sub<u16>(*this, 0, insn.modrm().read16(*this, insn)));
+}
+
+void SoftCPU::NEG_RM32(const X86::Instruction& insn)
+{
+ insn.modrm().write32(*this, insn, op_sub<u32>(*this, 0, insn.modrm().read32(*this, insn)));
+}
+
+void SoftCPU::NEG_RM8(const X86::Instruction& insn)
+{
+ insn.modrm().write8(*this, insn, op_sub<u8>(*this, 0, insn.modrm().read8(*this, insn)));
+}
+
void SoftCPU::NOP(const X86::Instruction&) { TODO(); }
void SoftCPU::NOT_RM16(const X86::Instruction&) { TODO(); }
void SoftCPU::NOT_RM32(const X86::Instruction&) { TODO(); }