summaryrefslogtreecommitdiff
path: root/dynasm/dasm_arm.h
diff options
context:
space:
mode:
Diffstat (limited to 'dynasm/dasm_arm.h')
-rw-r--r--dynasm/dasm_arm.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/dynasm/dasm_arm.h b/dynasm/dasm_arm.h
index b770c2df..d49ecae0 100644
--- a/dynasm/dasm_arm.h
+++ b/dynasm/dasm_arm.h
@@ -22,7 +22,7 @@ enum {
22 DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG, 22 DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG,
23 /* The following actions also have an argument. */ 23 /* The following actions also have an argument. */
24 DASM_REL_PC, DASM_LABEL_PC, 24 DASM_REL_PC, DASM_LABEL_PC,
25 DASM_IMM, DASM_IMM12, DASM_IMM16, DASM_IMML8, DASM_IMML12, 25 DASM_IMM, DASM_IMM12, DASM_IMM16, DASM_IMML8, DASM_IMML12, DASM_IMMV8,
26 DASM__MAX 26 DASM__MAX
27}; 27};
28 28
@@ -250,6 +250,9 @@ void dasm_put(Dst_DECL, int start, ...)
250#endif 250#endif
251 b[pos++] = n; 251 b[pos++] = n;
252 break; 252 break;
253 case DASM_IMMV8:
254 CK((n & 3) == 0, RANGE_I);
255 n >>= 2;
253 case DASM_IMML8: 256 case DASM_IMML8:
254 case DASM_IMML12: 257 case DASM_IMML12:
255 CK(n >= 0 ? ((n>>((ins>>5)&31)) == 0) : 258 CK(n >= 0 ? ((n>>((ins>>5)&31)) == 0) :
@@ -316,7 +319,7 @@ int dasm_link(Dst_DECL, size_t *szp)
316 case DASM_REL_LG: case DASM_REL_PC: pos++; break; 319 case DASM_REL_LG: case DASM_REL_PC: pos++; break;
317 case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break; 320 case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break;
318 case DASM_IMM: case DASM_IMM12: case DASM_IMM16: 321 case DASM_IMM: case DASM_IMM12: case DASM_IMM16:
319 case DASM_IMML8: case DASM_IMML12: pos++; break; 322 case DASM_IMML8: case DASM_IMML12: case DASM_IMMV8: pos++; break;
320 } 323 }
321 } 324 }
322 stop: (void)0; 325 stop: (void)0;
@@ -377,9 +380,13 @@ int dasm_encode(Dst_DECL, void *buffer)
377 } else if ((ins & 0x1000)) { 380 } else if ((ins & 0x1000)) {
378 CK((n & 3) == 0 && -256 <= n && n <= 256, RANGE_REL); 381 CK((n & 3) == 0 && -256 <= n && n <= 256, RANGE_REL);
379 goto patchimml8; 382 goto patchimml8;
380 } else { 383 } else if ((ins & 0x2000) == 0) {
381 CK((n & 3) == 0 && -4096 <= n && n <= 4096, RANGE_REL); 384 CK((n & 3) == 0 && -4096 <= n && n <= 4096, RANGE_REL);
382 goto patchimml12; 385 goto patchimml;
386 } else {
387 CK((n & 3) == 0 && -1020 <= n && n <= 1020, RANGE_REL);
388 n >>= 2;
389 goto patchimml;
383 } 390 }
384 break; 391 break;
385 case DASM_LABEL_LG: 392 case DASM_LABEL_LG:
@@ -399,7 +406,7 @@ int dasm_encode(Dst_DECL, void *buffer)
399 cp[-1] |= n >= 0 ? (0x00800000 | (n & 0x0f) | ((n & 0xf0) << 4)) : 406 cp[-1] |= n >= 0 ? (0x00800000 | (n & 0x0f) | ((n & 0xf0) << 4)) :
400 ((-n & 0x0f) | ((-n & 0xf0) << 4)); 407 ((-n & 0x0f) | ((-n & 0xf0) << 4));
401 break; 408 break;
402 case DASM_IMML12: patchimml12: 409 case DASM_IMML12: case DASM_IMMV8: patchimml:
403 cp[-1] |= n >= 0 ? (0x00800000 | n) : (-n); 410 cp[-1] |= n >= 0 ? (0x00800000 | n) : (-n);
404 break; 411 break;
405 default: *cp++ = ins; break; 412 default: *cp++ = ins; break;