int shift = 0;
int offs = 0;
if (spec.offset != NULL && spec.reg != 2) { // XXX HACK on spec.reg != 2
- int nbytes = xlen / bitwidth;
+ int nbytes = width / bitwidth;
+ if (nbytes == 0) {
+ nbytes = 1;
+ }
offs = *spec.offset;
shift = offs % nbytes;
offs /= nbytes;
reg += offs;
}
uint64_t data = _insn->p->get_state()->XPR[reg];
- uint64_t ndata = data;
- if (xlen != bitwidth)
+ uint64_t ndata = data; // + (int64_t)imm;
+ if (((uint64_t)xlen) != ((uint64_t)bitwidth))
{
ndata = data >> (shift*bitwidth); // gets element within the reg-block
ndata &= ((1UL<<bitwidth)-1UL); // masks off the right bits