From: Julian Seward Date: Sun, 2 Jun 2002 00:04:00 +0000 (+0000) Subject: Implement CLC and STC (Pascal Massimino ). X-Git-Tag: svn/VALGRIND_1_0_3~114 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5162912b134511f41571608dd45449d846bb3710;p=thirdparty%2Fvalgrind.git Implement CLC and STC (Pascal Massimino ). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@353 --- diff --git a/coregrind/vg_helpers.S b/coregrind/vg_helpers.S index b2654bbfff..82627377d6 100644 --- a/coregrind/vg_helpers.S +++ b/coregrind/vg_helpers.S @@ -392,7 +392,16 @@ VG_(helper_STD): std ret - +/* Clear/set the carry flag. */ +.global VG_(helper_CLC) +VG_(helper_CLC): + clc + ret + +.global VG_(helper_STC) +VG_(helper_STC): + stc + ret /* Signed 32-to-64 multiply. */ .globl VG_(helper_imul_32_64) diff --git a/coregrind/vg_include.h b/coregrind/vg_include.h index 1472e63844..2310050d0c 100644 --- a/coregrind/vg_include.h +++ b/coregrind/vg_include.h @@ -1744,6 +1744,9 @@ extern void VG_(helper_CLD); extern void VG_(helper_STD); extern void VG_(helper_get_dirflag); +extern void VG_(helper_CLC); +extern void VG_(helper_STC); + extern void VG_(helper_shldl); extern void VG_(helper_shldw); extern void VG_(helper_shrdl); @@ -1887,6 +1890,9 @@ extern Int VGOFF_(helper_CLD); extern Int VGOFF_(helper_STD); extern Int VGOFF_(helper_get_dirflag); +extern Int VGOFF_(helper_CLC); +extern Int VGOFF_(helper_STC); + extern Int VGOFF_(helper_shldl); extern Int VGOFF_(helper_shldw); extern Int VGOFF_(helper_shrdl); diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index 399291d682..986ddf32a6 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -77,6 +77,8 @@ Int VGOFF_(helper_mul_8_16) = INVALID_OFFSET; Int VGOFF_(helper_CLD) = INVALID_OFFSET; Int VGOFF_(helper_STD) = INVALID_OFFSET; Int VGOFF_(helper_get_dirflag) = INVALID_OFFSET; +Int VGOFF_(helper_CLC) = INVALID_OFFSET; +Int VGOFF_(helper_STC) = INVALID_OFFSET; Int VGOFF_(helper_shldl) = INVALID_OFFSET; Int VGOFF_(helper_shldw) = INVALID_OFFSET; Int VGOFF_(helper_shrdl) = INVALID_OFFSET; @@ -269,6 +271,11 @@ static void vg_init_baseBlock ( void ) VGOFF_(helper_get_dirflag) = alloc_BaB_1_set( (Addr) & VG_(helper_get_dirflag) ); + VGOFF_(helper_CLC) + = alloc_BaB_1_set( (Addr) & VG_(helper_CLC) ); + VGOFF_(helper_STC) + = alloc_BaB_1_set( (Addr) & VG_(helper_STC) ); + VGOFF_(helper_shldl) = alloc_BaB_1_set( (Addr) & VG_(helper_shldl) ); VGOFF_(helper_shldw) diff --git a/coregrind/vg_to_ucode.c b/coregrind/vg_to_ucode.c index da2871c3f1..9230236fab 100644 --- a/coregrind/vg_to_ucode.c +++ b/coregrind/vg_to_ucode.c @@ -4051,6 +4051,22 @@ static Addr disInstr ( UCodeBlock* cb, Addr eip, Bool* isEnd ) if (dis) VG_(printf)("std\n"); break; + case 0xF8: /* CLC */ + uInstr0(cb, CALLM_S, 0); + uInstr1(cb, CALLM, 0, Lit16, VGOFF_(helper_CLC)); + uFlagsRWU(cb, FlagsEmpty, FlagC, FlagsOSZAP); + uInstr0(cb, CALLM_E, 0); + if (dis) VG_(printf)("clc\n"); + break; + + case 0xF9: /* STC */ + uInstr0(cb, CALLM_S, 0); + uInstr1(cb, CALLM, 0, Lit16, VGOFF_(helper_STC)); + uFlagsRWU(cb, FlagsEmpty, FlagC, FlagsOSZCP); + uInstr0(cb, CALLM_E, 0); + if (dis) VG_(printf)("stc\n"); + break; + case 0xF2: { /* REPNE prefix insn */ Addr eip_orig = eip - 1; abyte = getUChar(eip); eip++; diff --git a/vg_helpers.S b/vg_helpers.S index b2654bbfff..82627377d6 100644 --- a/vg_helpers.S +++ b/vg_helpers.S @@ -392,7 +392,16 @@ VG_(helper_STD): std ret - +/* Clear/set the carry flag. */ +.global VG_(helper_CLC) +VG_(helper_CLC): + clc + ret + +.global VG_(helper_STC) +VG_(helper_STC): + stc + ret /* Signed 32-to-64 multiply. */ .globl VG_(helper_imul_32_64) diff --git a/vg_include.h b/vg_include.h index 1472e63844..2310050d0c 100644 --- a/vg_include.h +++ b/vg_include.h @@ -1744,6 +1744,9 @@ extern void VG_(helper_CLD); extern void VG_(helper_STD); extern void VG_(helper_get_dirflag); +extern void VG_(helper_CLC); +extern void VG_(helper_STC); + extern void VG_(helper_shldl); extern void VG_(helper_shldw); extern void VG_(helper_shrdl); @@ -1887,6 +1890,9 @@ extern Int VGOFF_(helper_CLD); extern Int VGOFF_(helper_STD); extern Int VGOFF_(helper_get_dirflag); +extern Int VGOFF_(helper_CLC); +extern Int VGOFF_(helper_STC); + extern Int VGOFF_(helper_shldl); extern Int VGOFF_(helper_shldw); extern Int VGOFF_(helper_shrdl); diff --git a/vg_main.c b/vg_main.c index 399291d682..986ddf32a6 100644 --- a/vg_main.c +++ b/vg_main.c @@ -77,6 +77,8 @@ Int VGOFF_(helper_mul_8_16) = INVALID_OFFSET; Int VGOFF_(helper_CLD) = INVALID_OFFSET; Int VGOFF_(helper_STD) = INVALID_OFFSET; Int VGOFF_(helper_get_dirflag) = INVALID_OFFSET; +Int VGOFF_(helper_CLC) = INVALID_OFFSET; +Int VGOFF_(helper_STC) = INVALID_OFFSET; Int VGOFF_(helper_shldl) = INVALID_OFFSET; Int VGOFF_(helper_shldw) = INVALID_OFFSET; Int VGOFF_(helper_shrdl) = INVALID_OFFSET; @@ -269,6 +271,11 @@ static void vg_init_baseBlock ( void ) VGOFF_(helper_get_dirflag) = alloc_BaB_1_set( (Addr) & VG_(helper_get_dirflag) ); + VGOFF_(helper_CLC) + = alloc_BaB_1_set( (Addr) & VG_(helper_CLC) ); + VGOFF_(helper_STC) + = alloc_BaB_1_set( (Addr) & VG_(helper_STC) ); + VGOFF_(helper_shldl) = alloc_BaB_1_set( (Addr) & VG_(helper_shldl) ); VGOFF_(helper_shldw) diff --git a/vg_to_ucode.c b/vg_to_ucode.c index da2871c3f1..9230236fab 100644 --- a/vg_to_ucode.c +++ b/vg_to_ucode.c @@ -4051,6 +4051,22 @@ static Addr disInstr ( UCodeBlock* cb, Addr eip, Bool* isEnd ) if (dis) VG_(printf)("std\n"); break; + case 0xF8: /* CLC */ + uInstr0(cb, CALLM_S, 0); + uInstr1(cb, CALLM, 0, Lit16, VGOFF_(helper_CLC)); + uFlagsRWU(cb, FlagsEmpty, FlagC, FlagsOSZAP); + uInstr0(cb, CALLM_E, 0); + if (dis) VG_(printf)("clc\n"); + break; + + case 0xF9: /* STC */ + uInstr0(cb, CALLM_S, 0); + uInstr1(cb, CALLM, 0, Lit16, VGOFF_(helper_STC)); + uFlagsRWU(cb, FlagsEmpty, FlagC, FlagsOSZCP); + uInstr0(cb, CALLM_E, 0); + if (dis) VG_(printf)("stc\n"); + break; + case 0xF2: { /* REPNE prefix insn */ Addr eip_orig = eip - 1; abyte = getUChar(eip); eip++;