diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2016-04-26 16:35:59 +0200 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2016-05-09 18:52:19 +0200 |
| commit | 7923da056511ef8ac865beb44871c29b5a910285 (patch) | |
| tree | d3b1d3abcb2a62b310c8ff7563d9d559ad1185f2 | |
| parent | 8e41c7845c9164d94f12f7d73f12bb8804f3e196 (diff) | |
| download | miasm-7923da056511ef8ac865beb44871c29b5a910285.tar.gz miasm-7923da056511ef8ac865beb44871c29b5a910285.zip | |
Jitter: parity lookup table
| -rw-r--r-- | miasm2/jitter/vm_mngr.c | 55 | ||||
| -rw-r--r-- | miasm2/jitter/vm_mngr.h | 6 |
2 files changed, 40 insertions, 21 deletions
diff --git a/miasm2/jitter/vm_mngr.c b/miasm2/jitter/vm_mngr.c index 1bb58a17..f5c83b8b 100644 --- a/miasm2/jitter/vm_mngr.c +++ b/miasm2/jitter/vm_mngr.c @@ -41,6 +41,41 @@ #define MAX(a,b) (((a)>(b))?(a):(b)) +const uint8_t parity_table[256] = { + CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, + 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, + 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, + CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, + 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, + CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, + CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, + 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, + 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, + CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, + CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, + 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, + CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, + 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, + 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, + CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, + 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, + CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, + CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, + 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, + CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, + 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, + 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, + CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, + CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, + 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, + 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, + CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, + 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, + CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, + CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, + 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, +}; + //#define DEBUG_MIASM_AUTOMOD_CODE @@ -527,26 +562,6 @@ int is_mapped(vm_mngr_t* vm_mngr, uint64_t addr, uint64_t size) return 1; } - - -unsigned int parity(unsigned int a) -{ -#if defined(__builtin_parity) - return __builtin_parity(a); -#else - unsigned int tmp, cpt; - - tmp = a&0xFF; - cpt = 1; - while (tmp!=0){ - cpt^=tmp&1; - tmp>>=1; - } - return cpt; -#endif -} - - int shift_right_arith(unsigned int size, int a, unsigned int b) { int i32_a; diff --git a/miasm2/jitter/vm_mngr.h b/miasm2/jitter/vm_mngr.h index eb972392..76b1c0dd 100644 --- a/miasm2/jitter/vm_mngr.h +++ b/miasm2/jitter/vm_mngr.h @@ -174,8 +174,12 @@ uint64_t MEM_LOOKUP_64_PASSTHROUGH(uint64_t addr); int vm_read_mem(vm_mngr_t* vm_mngr, uint64_t addr, char** buffer_ptr, uint64_t size); int vm_write_mem(vm_mngr_t* vm_mngr, uint64_t addr, char *buffer, uint64_t size); +#define CC_P 1 + +extern const uint8_t parity_table[256]; + +#define parity(a) (parity_table[(a) & 0xFF]) -unsigned int parity(unsigned int a); unsigned int my_imul08(unsigned int a, unsigned int b); int is_mapped(vm_mngr_t* vm_mngr, uint64_t addr, uint64_t size); |