From: Julian Seward Date: Mon, 20 Mar 2006 12:05:42 +0000 (+0000) Subject: Add a function to set/clear the x86 carry flag. (untested) X-Git-Tag: svn/VALGRIND_3_2_3^2~77 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6433bc76f3c4e46a2efdae74ba40844b5984651f;p=thirdparty%2Fvalgrind.git Add a function to set/clear the x86 carry flag. (untested) git-svn-id: svn://svn.valgrind.org/vex/trunk@1601 --- diff --git a/VEX/priv/guest-x86/ghelpers.c b/VEX/priv/guest-x86/ghelpers.c index 8921331b34..e27223da50 100644 --- a/VEX/priv/guest-x86/ghelpers.c +++ b/VEX/priv/guest-x86/ghelpers.c @@ -743,6 +743,28 @@ UInt LibVEX_GuestX86_get_eflags ( /*IN*/VexGuestX86State* vex_state ) return eflags; } +/* VISIBLE TO LIBVEX CLIENT */ +void +LibVEX_GuestX86_put_eflag_c ( UInt new_carry_flag, + /*MOD*/VexGuestX86State* vex_state ) +{ + UInt oszacp = x86g_calculate_eflags_all_WRK( + vex_state->guest_CC_OP, + vex_state->guest_CC_DEP1, + vex_state->guest_CC_DEP2, + vex_state->guest_CC_NDEP + ); + if (new_carry_flag & 1) { + oszacp |= X86G_CC_MASK_C; + } else { + oszacp &= ~X86G_CC_MASK_C; + } + vex_state->guest_CC_OP = X86G_CC_OP_COPY; + vex_state->guest_CC_DEP1 = oszacp; + vex_state->guest_CC_DEP2 = 0; + vex_state->guest_CC_NDEP = 0; +} + /*---------------------------------------------------------------*/ /*--- %eflags translation-time function specialisers. ---*/ diff --git a/VEX/pub/libvex_guest_x86.h b/VEX/pub/libvex_guest_x86.h index e78afd3bda..94d3736850 100644 --- a/VEX/pub/libvex_guest_x86.h +++ b/VEX/pub/libvex_guest_x86.h @@ -279,7 +279,12 @@ void LibVEX_GuestX86_initialise ( /*OUT*/VexGuestX86State* vex_state ); extern UInt LibVEX_GuestX86_get_eflags ( /*IN*/VexGuestX86State* vex_state ); - +/* Set the carry flag in the given state to 'new_carry_flag', which + should be zero or one. */ +extern +void +LibVEX_GuestX86_put_eflag_c ( UInt new_carry_flag, + /*MOD*/VexGuestX86State* vex_state ); #endif /* ndef __LIBVEX_PUB_GUEST_X86_H */