Browse Source

DynASM/ARM64: Fix checks for scaled immediates.

Mike Pall 10 years ago
parent
commit
1b1bd08d3c
1 changed files with 3 additions and 2 deletions
  1. 3 2
      dynasm/dasm_arm64.h

+ 3 - 2
dynasm/dasm_arm64.h

@@ -281,8 +281,9 @@ void dasm_put(Dst_DECL, int start, ...)
 	b[pos++] = ofs;  /* Store pass1 offset estimate. */
 	break;
       case DASM_IMM:
-#ifdef DASM_CHECKS
 	CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I);
+	n >>= ((ins>>10)&31);
+#ifdef DASM_CHECKS
 	if ((ins & 0x8000))
 	  CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I);
 	else
@@ -451,7 +452,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;
 	case DASM_IMM6:
 	  cp[-1] |= ((n&31) << 19) | ((n&32) << 26);