Fixed PPCContext::cr() returning incorrectly shifted state.

This commit is contained in:
gibbed 2017-05-13 23:44:02 -05:00
parent 6e2bf0b4b1
commit eff9ba31d2
1 changed files with 13 additions and 6 deletions

View File

@ -22,12 +22,19 @@ namespace ppc {
uint64_t PPCContext::cr() const { uint64_t PPCContext::cr() const {
uint64_t final_bits = 0; uint64_t final_bits = 0;
for (int i = 0; i < 8; ++i) { for (int i = 0; i < 8; ++i) {
uint32_t crf = *(&cr0.value + i); union {
uint64_t bits = (crf & 0x1) << (4 * (7 - i) + 3) | uint32_t value;
((crf >> 8) & 0x1) << (4 * (7 - i) + 2) | struct {
((crf >> 16) & 0x1) << (4 * (7 - i) + 1) | uint8_t lt;
((crf >> 24) & 0x1) << (4 * (7 - i) + 0); uint8_t gt;
final_bits |= bits << (i * 4); uint8_t eq;
uint8_t so;
};
} crf;
crf.value = *(&cr0.value + i);
uint64_t bits = (crf.lt & 0x1) << 3 | (crf.gt & 0x1) << 2 |
(crf.eq & 0x1) << 1 | (crf.so & 0x1) << 0;
final_bits |= bits << ((7 - i) * 4);
} }
return final_bits; return final_bits;
} }