@@ -225,8 +225,7 @@ static inline ut32 encode1reg(ArmOp *op) {
225225}
226226
227227static inline ut32 encode2regs (ArmOp * op ) {
228- // p/arm/armass64.c:226:37: runtime error: left shift of 5 by 29 places cannot be represented in type 'int'
229- ut32 a0 = op -> operands [1 ].reg ;
228+ ut32 a0 = (ut32 ) op -> operands [1 ].reg & UT32_MAX ;
230229 return ((a0 & 0x7 ) << 29 ) | ((a0 & 0x18 ) << 13 ) | encode1reg (op );
231230}
232231
@@ -1052,10 +1051,12 @@ static ut32 lsop(ArmOp *op, int k, ut64 addr) {
10521051 check_cond (op -> operands [1 ].type == ARM_GPR );
10531052 check_cond (op -> operands [1 ].reg_type & ARM_REG64 );
10541053 k |= encode2regs (op );
1054+ bool uwu = false;
10551055 if (!strcmp (op -> mnemonic , "ldrb" ) || !strcmp (op -> mnemonic , "ldrh" ) || !strcmp (op -> mnemonic , "strb" ) || !strcmp (op -> mnemonic , "strh" )) {
10561056 check_cond (op -> operands [0 ].reg_type & ARM_REG32 );
10571057 } else if (!strcmp (op -> mnemonic , "ldrsw" )) {
10581058 check_cond (op -> operands [0 ].reg_type & ARM_REG64 );
1059+ uwu = true;
10591060 } else { // ldrsh, ldrsb
10601061 if (op -> operands [0 ].reg_type & ARM_REG32 ) {
10611062 k |= 0x00004000 ;
@@ -1129,8 +1130,18 @@ static ut32 lsop(ArmOp *op, int k, ut64 addr) {
11291130 check_cond (n <= 0x1ffe && !(n & 1 ))
11301131 n >>= 1 ;
11311132 } else { // w
1132- check_cond (n <= 0x3ffc && !(n & 3 ));
1133- n >>= 2 ;
1133+ int scale = (op -> operands [0 ].reg_type & ARM_REG64 ) ? 3 : 2 ;
1134+ if (uwu || scale == 2 ) {
1135+ check_cond (n <= 0x3ffc && !(n & 3 ));
1136+ if (uwu ) {
1137+ n >>= 2 ;
1138+ } else {
1139+ n >>= 3 ;
1140+ }
1141+ } else {
1142+ check_cond (n <= 0x7ff8 && !(n & 7 ));
1143+ n >>= 3 ;
1144+ }
11341145 }
11351146 data = k | (n & 0x3f ) << 18 | (n & 0xfc0 ) << 2 | 1 ;
11361147 return data ;
@@ -2159,7 +2170,13 @@ bool arm64ass (const char *str, ut64 addr, ut32 *op) {
21592170 } else if (!strncmp (str , "strh" , 4 )) {
21602171 * op = lsop (& ops , 0x00000078 , -1 );
21612172 } else if (!strncmp (str , "ldr" , 3 )) {
2162- * op = reglsop (& ops , 0x000040f8 );
2173+ * op = UT32_MAX ;
2174+ if (!strstr (str , " w" )) {
2175+ * op = lsop (& ops , 0x000040f8 , -1 );
2176+ }
2177+ if (* op == UT32_MAX ) {
2178+ * op = reglsop (& ops , 0x000040f8 );
2179+ }
21632180 } else if (!strncmp (str , "stur" , 4 )) {
21642181 * op = regsluop (& ops , 0x000000f8 );
21652182 } else if (!strncmp (str , "ldur" , 4 )) {
0 commit comments