}
int result = 0;
for (int i = 0; i < sz; i++) {
RegisterSpec one = regs.get(i);
result += one.getCategory();
/*
* The check below adds (category - 1) to the register, to
* account for the fact that the second half of a
* category-2 register has to be represented explicitly in
* the result.
*/
if (!unsignedFitsInNibble(one.getReg() + one.getCategory() - 1)) {
return -1;
}
}
return (result <= MAX_NUM_OPS) ? result : -1;