diff options
author | comex | 2015-02-03 02:52:51 -0500 |
---|---|---|
committer | comex | 2015-02-03 02:52:51 -0500 |
commit | c6c8f4abdabd58f9210e5e06c64a6fc36dbc709c (patch) | |
tree | bfa2b8577a9e9e5b99c967be0ae1722ce68d6df1 /lib/arm64/assemble.h | |
parent | whoops, don't mean to always jump to thumb mode (diff) | |
download | substitute-c6c8f4abdabd58f9210e5e06c64a6fc36dbc709c.tar.gz |
fix ARM64 too, theoretically
Diffstat (limited to 'lib/arm64/assemble.h')
-rw-r--r-- | lib/arm64/assemble.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/arm64/assemble.h b/lib/arm64/assemble.h index 8a98b7b..1dca7eb 100644 --- a/lib/arm64/assemble.h +++ b/lib/arm64/assemble.h @@ -1,9 +1,15 @@ #pragma once #include "dis.h" + +static inline int size_of_MOVi64(uint64_t val) { + int num_nybbles = val == 0 ? 1 : ((64 - __builtin_clzll(val) + 15) / 16); + return 4 * num_nybbles; +} + static inline void MOVi64(void **codep, int Rd, uint64_t val) { int shift_nybbles = 0; do { - int k = shift_nybbles != 0 ? 1 : 0; + int k = shift_nybbles != 0; op32(codep, 0xd2800000 | k << 29 | Rd | (val & 0xffff) << 5 | shift_nybbles << 21); shift_nybbles++; @@ -54,3 +60,7 @@ static inline void BR(void **codep, int reg) { op32(codep, 0xd61f0000 | reg << 5); } +static inline void Bccrel(void **codep, int cc, int offset) { + op32(codep, 0x54000000 | (offset / 4) << 5 | cc); +} + |