aboutsummaryrefslogtreecommitdiffstats
path: root/tools/tests
diff options
context:
space:
mode:
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2005-12-21 14:29:23 +0100
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2005-12-21 14:29:23 +0100
commitc19d7d74307693cd3c7e21ffe13747e1cd021066 (patch)
treefcb063df0fc6481980ad73bd754faca8a8fb29e9 /tools/tests
parent2eb236c17e09007ca172219cebeb9c16a73cc3b2 (diff)
downloadxen-c19d7d74307693cd3c7e21ffe13747e1cd021066.tar.gz
xen-c19d7d74307693cd3c7e21ffe13747e1cd021066.tar.bz2
xen-c19d7d74307693cd3c7e21ffe13747e1cd021066.zip
Add support for MOVSX/MOVSXD/MOVZX (move-with-extend)
instructions to the generic x86 emulator. Also add preliminary support for 16-bit addressing: decode the ModR/M byte properly but still need to access and update implicit memory operands (esp,esi,edi) with correct width. Work is also needed to support real-mode addressing. Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'tools/tests')
-rw-r--r--tools/tests/Makefile2
-rw-r--r--tools/tests/test_x86_emulator.c30
2 files changed, 32 insertions, 0 deletions
diff --git a/tools/tests/Makefile b/tools/tests/Makefile
index 3e8962a714..015e8ae256 100644
--- a/tools/tests/Makefile
+++ b/tools/tests/Makefile
@@ -7,6 +7,8 @@ TARGET := test_x86_emulator
CC := gcc
CFLAGS := -O2 -Wall -Werror -D__TEST_HARNESS__
+all: $(TARGET)
+
$(TARGET): x86_emulate.o test_x86_emulator.o
$(CC) -o $@ $^
diff --git a/tools/tests/test_x86_emulator.c b/tools/tests/test_x86_emulator.c
index 69989bc776..f1c1a51583 100644
--- a/tools/tests/test_x86_emulator.c
+++ b/tools/tests/test_x86_emulator.c
@@ -254,6 +254,36 @@ int main(int argc, char **argv)
goto fail;
printf("okay\n");
+ printf("%-40s", "Testing movsxbd (%%eax),%%ecx...");
+ instr[0] = 0x0f; instr[1] = 0xbe; instr[2] = 0x08;
+ regs.eip = (unsigned long)&instr[0];
+ regs.ecx = 0x12345678;
+ cr2 = (unsigned long)&res;
+ res = 0x82;
+ rc = x86_emulate_memop(&regs, cr2, &emulops, 4);
+ if ( (rc != 0) ||
+ (res != 0x82) ||
+ (regs.ecx != 0xFFFFFF82) ||
+ ((regs.eflags&0x240) != 0x200) ||
+ (regs.eip != (unsigned long)&instr[3]) )
+ goto fail;
+ printf("okay\n");
+
+ printf("%-40s", "Testing movzxwd (%%eax),%%ecx...");
+ instr[0] = 0x0f; instr[1] = 0xb7; instr[2] = 0x08;
+ regs.eip = (unsigned long)&instr[0];
+ regs.ecx = 0x12345678;
+ cr2 = (unsigned long)&res;
+ res = 0x1234aa82;
+ rc = x86_emulate_memop(&regs, cr2, &emulops, 4);
+ if ( (rc != 0) ||
+ (res != 0x1234aa82) ||
+ (regs.ecx != 0xaa82) ||
+ ((regs.eflags&0x240) != 0x200) ||
+ (regs.eip != (unsigned long)&instr[3]) )
+ goto fail;
+ printf("okay\n");
+
return 0;
fail: