comparison decoder.c @ 14:ebf344d11bde src

Some improvements to decoder.c Registers should be updated correctly now, but still needs checking.
author jcdutton
date Wed, 10 Apr 2002 13:09:40 +0000
parents de00f8362634
children 74aee0b81da0
comparison
equal deleted inserted replaced
13:de00f8362634 14:ebf344d11bde
46 46
47 static uint32_t new_bits(command_t *command, int32_t start, int32_t count) { 47 static uint32_t new_bits(command_t *command, int32_t start, int32_t count) {
48 uint64_t result = 0; 48 uint64_t result = 0;
49 uint64_t bit_mask=0xffffffffffffffff; /* I could put -1 instead */ 49 uint64_t bit_mask=0xffffffffffffffff; /* I could put -1 instead */
50 uint64_t examining = 0; 50 uint64_t examining = 0;
51 int32_t bits;
51 if (count == 0) return 0; 52 if (count == 0) return 0;
52 53
53 if ( ((count+start) > 64) || 54 if ( ((count+start) > 64) ||
54 (count > 32) || 55 (count > 32) ||
55 (start > 63) || 56 (start > 63) ||
57 (start < 0) ){ 58 (start < 0) ){
58 fprintf(stderr, "Bad call to new_bits. Parameter out of range\n"); 59 fprintf(stderr, "Bad call to new_bits. Parameter out of range\n");
59 assert(0); 60 assert(0);
60 } 61 }
61 bit_mask >>= start; 62 bit_mask >>= start;
62 examining = ((bit_mask >> (64-count-start)) << (64-count-start) ); 63 bits = 64-count-start;
64 examining = ((bit_mask >> bits) << bits );
63 command->examined |= examining; 65 command->examined |= examining;
64 result = (command->instruction & bit_mask) >> (64-count-start); 66 result = (command->instruction & bit_mask) >> bits;
65 return (uint32_t) result; 67 return (uint32_t) result;
66 } 68 }
67 69
68 /* Eval register code, can either be system or general register. 70 /* Eval register code, can either be system or general register.
69 SXXX_XXXX, where S is 1 if it is system register. */ 71 SXXX_XXXX, where S is 1 if it is system register. */