From: Julian Seward Date: Sun, 24 Mar 2002 11:54:07 +0000 (+0000) Subject: Implement DAA as well as DAS. Byrial Jensen X-Git-Tag: svn/VALGRIND_1_0_3~424 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13c77e7c761d7b6b840f5935607668d456e72ccb;p=thirdparty%2Fvalgrind.git Implement DAA as well as DAS. Byrial Jensen git-svn-id: svn://svn.valgrind.org/valgrind/trunk@22 --- diff --git a/ChangeLog b/ChangeLog index 24988037e6..26312081cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2002-03-24 Julian Seward + * vg_to_ucode.c (disInstr): Implement DAA as well as DAS. + Byrial Jensen + * 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 diff --git a/coregrind/vg_helpers.S b/coregrind/vg_helpers.S index f86f6f96a1..3431111ee7 100644 --- a/coregrind/vg_helpers.S +++ b/coregrind/vg_helpers.S @@ -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: diff --git a/coregrind/vg_include.h b/coregrind/vg_include.h index 73befe245c..91ca2c03d9 100644 --- a/coregrind/vg_include.h +++ b/coregrind/vg_include.h @@ -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); diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index 7665d86dc5..cf2f636aca 100644 --- a/coregrind/vg_main.c +++ b/coregrind/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) ); diff --git a/coregrind/vg_to_ucode.c b/coregrind/vg_to_ucode.c index c03f5817d2..ebce94fda8 100644 --- a/coregrind/vg_to_ucode.c +++ b/coregrind/vg_to_ucode.c @@ -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 index 0000000000..0435ba4e4a --- /dev/null +++ b/tests/dastest.s @@ -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 index 0000000000..b491992137 --- /dev/null +++ b/tests/dastest_c.c @@ -0,0 +1,13 @@ + +#include + +// 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; +} diff --git a/vg_helpers.S b/vg_helpers.S index f86f6f96a1..3431111ee7 100644 --- a/vg_helpers.S +++ b/vg_helpers.S @@ -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: diff --git a/vg_include.h b/vg_include.h index 73befe245c..91ca2c03d9 100644 --- a/vg_include.h +++ b/vg_include.h @@ -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); diff --git a/vg_main.c b/vg_main.c index 7665d86dc5..cf2f636aca 100644 --- 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) ); diff --git a/vg_to_ucode.c b/vg_to_ucode.c index c03f5817d2..ebce94fda8 100644 --- a/vg_to_ucode.c +++ b/vg_to_ucode.c @@ -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 -------------------- */