case 2: {
BenkoBox name = getBoxByInstAddr((inst >> 24) & 0x7ff);
int val = ((int)(instr )) & ~(0xffffffff << 24);
+ val = signExtend24(val);
return new Instruction.Literal.Absolute(name, val);
}
instr |= (getBoxAddr(ld.dest)) << 24;
if (ld.value >= (1<<25))
throw new RuntimeException("literals must be less than 2^24");
- instr |= ((long)ld.value);
+ instr |= ((long)ld.value) & ~(0xffffffff << 24);
} else if (d instanceof Instruction.Literal.Relative) {
Instruction.Literal.Relative lr = (Instruction.Literal.Relative)d;
os.write((int)((instr >> (0*8)) & 0xff));
}
+ public static int signExtend24(int val) {
+ if ((val & (1 << 23)) != 0)
+ val = val | (0xffffffff << 24);
+ return val;
+ }
+
}
\ No newline at end of file