diff --git a/decode.c b/decode.c index a8a8df7..9aa2cdb 100644 --- a/decode.c +++ b/decode.c @@ -24,7 +24,8 @@ static uint64_t immlogical(unsigned sf, unsigned N, unsigned immr, unsigned esize = 1 << len; uint64_t welem = ((uint64_t)1 << (s + 1)) - 1; // ROR(welem, r) as bits(esize) - welem = (welem >> r) | (welem << (esize - r)); + if (r) + welem = (welem >> r) | (welem << (esize - r)); if (esize < 64) welem &= ((uint64_t)1 << esize) - 1; // Replicate(ROR(welem, r)) diff --git a/parse.py b/parse.py index 4918522..51ea0cc 100644 --- a/parse.py +++ b/parse.py @@ -548,10 +548,10 @@ def add_mnem(self, grp: str, name: str, grpdesc: Desc, descmask: MaskedVal, ops: # use XOR s.t. immadd can toggle between add and sub. buildexprs = ["(" + "^".join([f"{descmask.val:#x}"] + grandExpansions) + ")"] for de in grpdesc: - bitmask = ((1 << de.size) - 1) << de.idx + bitmask = (1 << de.size) - 1 if de.name in assignments: - buildexprs.append(f"(({assignments[de.name]})<<{de.idx}&{bitmask:#x})") - elif descmask.mask & bitmask != bitmask: + buildexprs.append(f"((({assignments[de.name]})&{bitmask:#x})<<{de.idx})") + elif descmask.mask & (bitmask << de.idx) != (bitmask << de.idx): print("Encode desc missing for", grp, name, de.name, assignments) return expr = "|".join(buildexprs)