]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Implement DAA as well as DAS. Byrial Jensen <byrial@image.dk>
authorJulian Seward <jseward@acm.org>
Sun, 24 Mar 2002 11:54:07 +0000 (11:54 +0000)
committerJulian Seward <jseward@acm.org>
Sun, 24 Mar 2002 11:54:07 +0000 (11:54 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@22

ChangeLog
coregrind/vg_helpers.S
coregrind/vg_include.h
coregrind/vg_main.c
coregrind/vg_to_ucode.c
tests/dastest.s [new file with mode: 0644]
tests/dastest_c.c [new file with mode: 0644]
vg_helpers.S
vg_include.h
vg_main.c
vg_to_ucode.c

index 24988037e6dd0d08714858a1f2851a9ea5aac6db..26312081cdc33b751e3d07188e6cacc3300e93cd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2002-03-24  Julian Seward  <sewardj@localhost.localdomain>
 
+       * vg_to_ucode.c (disInstr): Implement DAA as well as DAS.
+         Byrial Jensen <byrial@image.dk>
+
        * vg_errcontext.c (pp_ErrContext): Change message "Use of
        uninitialized CPU condition code" to "Conditional jump or move
        depends on uninitialised value(s)", since that will be more
index f86f6f96a1d2247574633d29790f5f9955abb24a..3431111ee7ec3f1e5e3342b815298762cc49bfe6 100644 (file)
@@ -309,6 +309,16 @@ VG_(helper_DAS):
        ret
 
 
+/* Similarly, do %al = DAA(%al). */
+.global VG_(helper_DAA)
+VG_(helper_DAA):
+       pushl   %eax
+       movl    8(%esp), %eax
+       daa
+       movl    %eax, 8(%esp)
+       popl    %eax
+       ret
+       
 
 /* Bit scan forwards/reverse.  Sets flags (??).
    On entry:
index 73befe245c639dbd29abb392adebf910891f8b6a..91ca2c03d9a6a8f7ce4af0d6d5590814d01202ab 100644 (file)
@@ -1294,6 +1294,7 @@ extern void VG_(helper_bsr);
 extern void VG_(helper_fstsw_AX);
 extern void VG_(helper_SAHF);
 extern void VG_(helper_DAS);
+extern void VG_(helper_DAA);
 
 extern void VG_(helper_value_check4_fail);
 extern void VG_(helper_value_check2_fail);
@@ -1423,6 +1424,7 @@ extern Int VGOFF_(helper_bsr);
 extern Int VGOFF_(helper_fstsw_AX);
 extern Int VGOFF_(helper_SAHF);
 extern Int VGOFF_(helper_DAS);
+extern Int VGOFF_(helper_DAA);
 
 extern Int VGOFF_(helper_value_check4_fail);
 extern Int VGOFF_(helper_value_check2_fail);
index 7665d86dc5cf1cbfef2dac0f2973adb42ed4adec..cf2f636acacd64d2cba75acbdc71153bf1ba89ec 100644 (file)
@@ -95,6 +95,7 @@ Int VGOFF_(helper_bsr) = INVALID_OFFSET;
 Int VGOFF_(helper_fstsw_AX) = INVALID_OFFSET;
 Int VGOFF_(helper_SAHF) = INVALID_OFFSET;
 Int VGOFF_(helper_DAS) = INVALID_OFFSET;
+Int VGOFF_(helper_DAA) = INVALID_OFFSET;
 Int VGOFF_(helper_value_check4_fail) = INVALID_OFFSET;
 Int VGOFF_(helper_value_check2_fail) = INVALID_OFFSET;
 Int VGOFF_(helper_value_check1_fail) = INVALID_OFFSET;
@@ -303,6 +304,8 @@ static void vg_init_baseBlock ( void )
       = alloc_BaB_1_set( (Addr) & VG_(helper_SAHF) );
    VGOFF_(helper_DAS)
       = alloc_BaB_1_set( (Addr) & VG_(helper_DAS) );
+   VGOFF_(helper_DAA)
+      = alloc_BaB_1_set( (Addr) & VG_(helper_DAA) );
 
    VGOFF_(helper_request_normal_exit)
       = alloc_BaB_1_set( (Addr) & VG_(helper_request_normal_exit) );
index c03f5817d2f4368554e97e8ec983e7c51759e980..ebce94fda83c21bb9251f218699155f5435ace6c 100644 (file)
@@ -3035,6 +3035,7 @@ static Addr disInstr ( UCodeBlock* cb, Addr eip, Bool* isEnd )
 
    /* ---------------- Misc wierd-ass insns --------------- */
 
+   case 0x27: /* DAA */
    case 0x2F: /* DAS */
       t1 = newTemp(cb);
       uInstr2(cb, GET, 1, ArchReg, R_AL, TempReg, t1);
@@ -3044,12 +3045,14 @@ static Addr disInstr ( UCodeBlock* cb, Addr eip, Bool* isEnd )
       LAST_UINSTR(cb).signed_widen = False;
       uInstr0(cb, CALLM_S, 0);
       uInstr1(cb, PUSH, 4, TempReg, t1);
-      uInstr1(cb, CALLM, 0, Lit16, VGOFF_(helper_DAS) );
+      uInstr1(cb, CALLM, 0, Lit16, 
+                  opc == 0x27 ? VGOFF_(helper_DAA) : VGOFF_(helper_DAS) );
       uFlagsRWU(cb, FlagsAC, FlagsOSZACP, FlagsEmpty);
       uInstr1(cb, POP, 4, TempReg, t1);
       uInstr0(cb, CALLM_E, 0);
       uInstr2(cb, PUT, 1, TempReg, t1, ArchReg, R_AL);
-      if (dis) VG_(printf)("das\n");
+      if (dis) VG_(printf)(opc == 0x27 ? "daa\n" : "das\n");
+      break;
 
    /* ------------------------ CWD/CDQ -------------------- */
 
diff --git a/tests/dastest.s b/tests/dastest.s
new file mode 100644 (file)
index 0000000..0435ba4
--- /dev/null
@@ -0,0 +1,21 @@
+
+/* general simple function to use as a template for assembly hacks */
+
+       .file   "oneparam.c"
+       .version        "01.01"
+gcc2_compiled.:
+.text
+       .align 4
+.globl dastest
+       .type    dastest,@function
+dastest:
+       pushl   %ebp
+       movl    %esp, %ebp
+       movl    8(%ebp), %eax
+        das
+       daa
+       popl    %ebp
+       ret
+.Lfe1:
+       .size    dastest,.Lfe1-dastest
+       .ident  "GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)"
diff --git a/tests/dastest_c.c b/tests/dastest_c.c
new file mode 100644 (file)
index 0000000..b491992
--- /dev/null
@@ -0,0 +1,13 @@
+
+#include <stdio.h>
+
+// dastest.s
+extern int dastest ( int );
+
+int main ( void )
+{
+   int x = 49;
+   printf("dastest: x = %d\n", x);
+   printf("dastest: das(x) = %d\n", dastest(x));
+   return 0;
+}
index f86f6f96a1d2247574633d29790f5f9955abb24a..3431111ee7ec3f1e5e3342b815298762cc49bfe6 100644 (file)
@@ -309,6 +309,16 @@ VG_(helper_DAS):
        ret
 
 
+/* Similarly, do %al = DAA(%al). */
+.global VG_(helper_DAA)
+VG_(helper_DAA):
+       pushl   %eax
+       movl    8(%esp), %eax
+       daa
+       movl    %eax, 8(%esp)
+       popl    %eax
+       ret
+       
 
 /* Bit scan forwards/reverse.  Sets flags (??).
    On entry:
index 73befe245c639dbd29abb392adebf910891f8b6a..91ca2c03d9a6a8f7ce4af0d6d5590814d01202ab 100644 (file)
@@ -1294,6 +1294,7 @@ extern void VG_(helper_bsr);
 extern void VG_(helper_fstsw_AX);
 extern void VG_(helper_SAHF);
 extern void VG_(helper_DAS);
+extern void VG_(helper_DAA);
 
 extern void VG_(helper_value_check4_fail);
 extern void VG_(helper_value_check2_fail);
@@ -1423,6 +1424,7 @@ extern Int VGOFF_(helper_bsr);
 extern Int VGOFF_(helper_fstsw_AX);
 extern Int VGOFF_(helper_SAHF);
 extern Int VGOFF_(helper_DAS);
+extern Int VGOFF_(helper_DAA);
 
 extern Int VGOFF_(helper_value_check4_fail);
 extern Int VGOFF_(helper_value_check2_fail);
index 7665d86dc5cf1cbfef2dac0f2973adb42ed4adec..cf2f636acacd64d2cba75acbdc71153bf1ba89ec 100644 (file)
--- a/vg_main.c
+++ b/vg_main.c
@@ -95,6 +95,7 @@ Int VGOFF_(helper_bsr) = INVALID_OFFSET;
 Int VGOFF_(helper_fstsw_AX) = INVALID_OFFSET;
 Int VGOFF_(helper_SAHF) = INVALID_OFFSET;
 Int VGOFF_(helper_DAS) = INVALID_OFFSET;
+Int VGOFF_(helper_DAA) = INVALID_OFFSET;
 Int VGOFF_(helper_value_check4_fail) = INVALID_OFFSET;
 Int VGOFF_(helper_value_check2_fail) = INVALID_OFFSET;
 Int VGOFF_(helper_value_check1_fail) = INVALID_OFFSET;
@@ -303,6 +304,8 @@ static void vg_init_baseBlock ( void )
       = alloc_BaB_1_set( (Addr) & VG_(helper_SAHF) );
    VGOFF_(helper_DAS)
       = alloc_BaB_1_set( (Addr) & VG_(helper_DAS) );
+   VGOFF_(helper_DAA)
+      = alloc_BaB_1_set( (Addr) & VG_(helper_DAA) );
 
    VGOFF_(helper_request_normal_exit)
       = alloc_BaB_1_set( (Addr) & VG_(helper_request_normal_exit) );
index c03f5817d2f4368554e97e8ec983e7c51759e980..ebce94fda83c21bb9251f218699155f5435ace6c 100644 (file)
@@ -3035,6 +3035,7 @@ static Addr disInstr ( UCodeBlock* cb, Addr eip, Bool* isEnd )
 
    /* ---------------- Misc wierd-ass insns --------------- */
 
+   case 0x27: /* DAA */
    case 0x2F: /* DAS */
       t1 = newTemp(cb);
       uInstr2(cb, GET, 1, ArchReg, R_AL, TempReg, t1);
@@ -3044,12 +3045,14 @@ static Addr disInstr ( UCodeBlock* cb, Addr eip, Bool* isEnd )
       LAST_UINSTR(cb).signed_widen = False;
       uInstr0(cb, CALLM_S, 0);
       uInstr1(cb, PUSH, 4, TempReg, t1);
-      uInstr1(cb, CALLM, 0, Lit16, VGOFF_(helper_DAS) );
+      uInstr1(cb, CALLM, 0, Lit16, 
+                  opc == 0x27 ? VGOFF_(helper_DAA) : VGOFF_(helper_DAS) );
       uFlagsRWU(cb, FlagsAC, FlagsOSZACP, FlagsEmpty);
       uInstr1(cb, POP, 4, TempReg, t1);
       uInstr0(cb, CALLM_E, 0);
       uInstr2(cb, PUT, 1, TempReg, t1, ArchReg, R_AL);
-      if (dis) VG_(printf)("das\n");
+      if (dis) VG_(printf)(opc == 0x27 ? "daa\n" : "das\n");
+      break;
 
    /* ------------------------ CWD/CDQ -------------------- */