Implement DAA as well as DAS. Byrial Jensen <byrial@image.dk>

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@22
This commit is contained in:
Julian Seward 2002-03-24 11:54:07 +00:00
parent e53f9abd92
commit 13c77e7c76
11 changed files with 77 additions and 4 deletions

View File

@ -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

View 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:

View 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);

View 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) );

View 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 -------------------- */

21
tests/dastest.s Normal file
View File

@ -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)"

13
tests/dastest_c.c Normal file
View File

@ -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;
}

View 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:

View 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);

View 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) );

View 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 -------------------- */