PPC: Fix range check for scaled immediates in DynASM.

master
Mike Pall 2011-07-02 00:43:19 +02:00
parent 8ccf89718c
commit fe1f9137a9
1 changed files with 4 additions and 1 deletions

View File

@ -233,6 +233,9 @@ void dasm_put(Dst_DECL, int start, ...)
case DASM_IMM:
#ifdef DASM_CHECKS
CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I);
#endif
n >>= ((ins>>10)&31);
#ifdef DASM_CHECKS
if (ins & 0x8000)
CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I);
else
@ -360,7 +363,7 @@ int dasm_encode(Dst_DECL, void *buffer)
break;
case DASM_LABEL_PC: break;
case DASM_IMM:
cp[-1] |= ((n>>((ins>>10)&31)) & ((1<<((ins>>5)&31))-1)) << (ins&31);
cp[-1] |= (n & ((1<<((ins>>5)&31))-1)) << (ins&31);
break;
default: *cp++ = ins; break;
}