diff options
Diffstat (limited to '')
-rw-r--r-- | dynasm/dasm_arm64.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/dynasm/dasm_arm64.h b/dynasm/dasm_arm64.h index 577b54bc..b2251532 100644 --- a/dynasm/dasm_arm64.h +++ b/dynasm/dasm_arm64.h | |||
@@ -23,6 +23,7 @@ enum { | |||
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_IMM6, DASM_IMM12, DASM_IMM13W, DASM_IMM13X, DASM_IMML, | 25 | DASM_IMM, DASM_IMM6, DASM_IMM12, DASM_IMM13W, DASM_IMM13X, DASM_IMML, |
26 | DASM_VREG, | ||
26 | DASM__MAX | 27 | DASM__MAX |
27 | }; | 28 | }; |
28 | 29 | ||
@@ -39,6 +40,7 @@ enum { | |||
39 | #define DASM_S_RANGE_LG 0x13000000 | 40 | #define DASM_S_RANGE_LG 0x13000000 |
40 | #define DASM_S_RANGE_PC 0x14000000 | 41 | #define DASM_S_RANGE_PC 0x14000000 |
41 | #define DASM_S_RANGE_REL 0x15000000 | 42 | #define DASM_S_RANGE_REL 0x15000000 |
43 | #define DASM_S_RANGE_VREG 0x16000000 | ||
42 | #define DASM_S_UNDEF_LG 0x21000000 | 44 | #define DASM_S_UNDEF_LG 0x21000000 |
43 | #define DASM_S_UNDEF_PC 0x22000000 | 45 | #define DASM_S_UNDEF_PC 0x22000000 |
44 | 46 | ||
@@ -312,13 +314,17 @@ void dasm_put(Dst_DECL, int start, ...) | |||
312 | } | 314 | } |
313 | case DASM_IMML: { | 315 | case DASM_IMML: { |
314 | #ifdef DASM_CHECKS | 316 | #ifdef DASM_CHECKS |
315 | int scale = (p[-2] >> 30); | 317 | int scale = (ins & 3); |
316 | CK((!(n & ((1<<scale)-1)) && (unsigned int)(n>>scale) < 4096) || | 318 | CK((!(n & ((1<<scale)-1)) && (unsigned int)(n>>scale) < 4096) || |
317 | (unsigned int)(n+256) < 512, RANGE_I); | 319 | (unsigned int)(n+256) < 512, RANGE_I); |
318 | #endif | 320 | #endif |
319 | b[pos++] = n; | 321 | b[pos++] = n; |
320 | break; | 322 | break; |
321 | } | 323 | } |
324 | case DASM_VREG: | ||
325 | CK(n < 32, RANGE_VREG); | ||
326 | b[pos++] = n; | ||
327 | break; | ||
322 | } | 328 | } |
323 | } | 329 | } |
324 | } | 330 | } |
@@ -375,7 +381,7 @@ int dasm_link(Dst_DECL, size_t *szp) | |||
375 | case DASM_REL_LG: case DASM_REL_PC: pos++; break; | 381 | case DASM_REL_LG: case DASM_REL_PC: pos++; break; |
376 | case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break; | 382 | case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break; |
377 | case DASM_IMM: case DASM_IMM6: case DASM_IMM12: case DASM_IMM13W: | 383 | case DASM_IMM: case DASM_IMM6: case DASM_IMM12: case DASM_IMM13W: |
378 | case DASM_IMML: pos++; break; | 384 | case DASM_IMML: case DASM_VREG: pos++; break; |
379 | case DASM_IMM13X: pos += 2; break; | 385 | case DASM_IMM13X: pos += 2; break; |
380 | } | 386 | } |
381 | } | 387 | } |
@@ -468,11 +474,14 @@ int dasm_encode(Dst_DECL, void *buffer) | |||
468 | cp[-1] |= (dasm_imm13(n, *b++) << 10); | 474 | cp[-1] |= (dasm_imm13(n, *b++) << 10); |
469 | break; | 475 | break; |
470 | case DASM_IMML: { | 476 | case DASM_IMML: { |
471 | int scale = (p[-2] >> 30); | 477 | int scale = (ins & 3); |
472 | cp[-1] |= (!(n & ((1<<scale)-1)) && (unsigned int)(n>>scale) < 4096) ? | 478 | cp[-1] |= (!(n & ((1<<scale)-1)) && (unsigned int)(n>>scale) < 4096) ? |
473 | ((n << (10-scale)) | 0x01000000) : ((n & 511) << 12); | 479 | ((n << (10-scale)) | 0x01000000) : ((n & 511) << 12); |
474 | break; | 480 | break; |
475 | } | 481 | } |
482 | case DASM_VREG: | ||
483 | cp[-1] |= (n & 0x1f) << (ins & 0x1f); | ||
484 | break; | ||
476 | default: *cp++ = ins; break; | 485 | default: *cp++ = ins; break; |
477 | } | 486 | } |
478 | } | 487 | } |