Commit d77a2507 authored by Nitin A Kamble's avatar Nitin A Kamble Committed by Avi Kivity

KVM: x86 emulator: Implement emulation of instruction: inc & dec

Instructions:
	inc r16/r32 (opcode 0x40-0x47)
	dec r16/r32 (opcode 0x48-0x4f)
Signed-off-by: default avatarNitin A Kamble <nitin.a.kamble@intel.com>
Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
parent 3176bc3e
...@@ -96,8 +96,12 @@ static u8 opcode_table[256] = { ...@@ -96,8 +96,12 @@ static u8 opcode_table[256] = {
ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM, ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM,
ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM, ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
0, 0, 0, 0, 0, 0, 0, 0,
/* 0x40 - 0x4F */ /* 0x40 - 0x47 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps,
ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps,
/* 0x48 - 0x4F */
ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps,
ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps,
/* 0x50 - 0x57 */ /* 0x50 - 0x57 */
ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps,
ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps,
...@@ -1376,6 +1380,18 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) ...@@ -1376,6 +1380,18 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
if (c->twobyte) if (c->twobyte)
goto twobyte_special_insn; goto twobyte_special_insn;
switch (c->b) { switch (c->b) {
case 0x40 ... 0x47: /* inc r16/r32 */
c->dst.bytes = c->op_bytes;
c->dst.ptr = (unsigned long *)&c->regs[c->b & 0x7];
c->dst.val = *c->dst.ptr;
emulate_1op("inc", c->dst, ctxt->eflags);
break;
case 0x48 ... 0x4f: /* dec r16/r32 */
c->dst.bytes = c->op_bytes;
c->dst.ptr = (unsigned long *)&c->regs[c->b & 0x7];
c->dst.val = *c->dst.ptr;
emulate_1op("dec", c->dst, ctxt->eflags);
break;
case 0x50 ... 0x57: /* push reg */ case 0x50 ... 0x57: /* push reg */
if (c->op_bytes == 2) if (c->op_bytes == 2)
c->src.val = (u16) c->regs[c->b & 0x7]; c->src.val = (u16) c->regs[c->b & 0x7];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment