diff options
| author | Camille Mougey <commial@gmail.com> | 2015-02-20 14:16:55 +0100 |
|---|---|---|
| committer | Camille Mougey <commial@gmail.com> | 2015-02-20 14:16:55 +0100 |
| commit | f1966ac767894b4fe954613d2134f87cdc3697ca (patch) | |
| tree | 878c5e56046c920e58548fd522140fa73b3bed0e /miasm2/jitter/vm_mngr.c | |
| parent | 736befb2b6fab02e601eae392a9969ac91f2caa3 (diff) | |
| parent | c166f6cf0eb5d8dd697f03cb89c2703db1554b2b (diff) | |
| download | miasm-f1966ac767894b4fe954613d2134f87cdc3697ca.tar.gz miasm-f1966ac767894b4fe954613d2134f87cdc3697ca.zip | |
Merge pull request #80 from serpilliere/fix_bsr_bsf
Fix bsr bsf
Diffstat (limited to 'miasm2/jitter/vm_mngr.c')
| -rw-r--r-- | miasm2/jitter/vm_mngr.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/miasm2/jitter/vm_mngr.c b/miasm2/jitter/vm_mngr.c index 188f0372..057c10be 100644 --- a/miasm2/jitter/vm_mngr.c +++ b/miasm2/jitter/vm_mngr.c @@ -915,26 +915,29 @@ int rcr_cf_op(unsigned int size, unsigned int a, unsigned int b, unsigned int cf { return rcl_cf_op(size, a, size+1-b, cf); } -unsigned int my_bsr(unsigned int a, unsigned int b) + +unsigned int x86_bsr(uint64_t src, unsigned int size) { int i; - for (i=31; i>=0; i--){ - if (b & (1<<i)) + for (i=size-1; i>=0; i--){ + if (src & (1<<i)) return i; } - return a; + fprintf(stderr, "sanity check error bsr\n"); + exit(0); } -unsigned int my_bsf(unsigned int a, unsigned int b) +unsigned int x86_bsf(uint64_t src, unsigned int size) { int i; - for (i=0; i<32; i++){ - if (b & (1<<i)) + for (i=0; i<size; i++){ + if (src & (1<<i)) return i; } - return a; + fprintf(stderr, "sanity check error bsf\n"); + exit(0); } |