diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-05-17 18:44:58 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-05-17 18:44:58 +0000 |
commit | 6191b05901ef1a85c64383e34406024daa4eda12 (patch) | |
tree | d0a4405b885c0999c3dcdfbe6af47a02452df8c9 /target-i386/helper.c | |
parent | 7c6ce4baedfcd0c39250f313926ef61dcb47d74c (diff) |
BSR/BSF TCG conversion
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4477 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'target-i386/helper.c')
-rw-r--r-- | target-i386/helper.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/target-i386/helper.c b/target-i386/helper.c index ce99c957d2..d888eaf9c3 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -5240,6 +5240,37 @@ void helper_movq(uint64_t *d, uint64_t *s) #endif +/* bit operations */ +target_ulong helper_bsf(target_ulong t0) +{ + int count; + target_ulong res; + + res = t0; + count = 0; + while ((res & 1) == 0) { + count++; + res >>= 1; + } + return count; +} + +target_ulong helper_bsr(target_ulong t0) +{ + int count; + target_ulong res, mask; + + res = t0; + count = TARGET_LONG_BITS - 1; + mask = (target_ulong)1 << (TARGET_LONG_BITS - 1); + while ((res & mask) == 0) { + count--; + res <<= 1; + } + return count; +} + + static int compute_all_eflags(void) { return CC_SRC; |