mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-27 15:10:53 +00:00
Add cbnz and cbz instruction for arm64 assembler (#15871)
* Add cbz and cbnz instructions * Added cbnz and cbz test case
This commit is contained in:
parent
c3346ff56f
commit
d937bebf67
@ -221,6 +221,37 @@ static ut32 mov(ArmOp *op) {
|
||||
return data;
|
||||
}
|
||||
|
||||
static ut32 cb(ArmOp *op) {
|
||||
ut32 data = UT32_MAX;
|
||||
int k = 0;
|
||||
if (!strncmp (op->mnemonic, "cbnz", 4)) {
|
||||
if (op->operands[0].reg_type & ARM_REG64) {
|
||||
k = 0x000000b5;
|
||||
} else if (op->operands[0].reg_type & ARM_REG32) {
|
||||
k = 0x00000035;
|
||||
} else {
|
||||
return UT32_MAX;
|
||||
}
|
||||
} else if (!strncmp (op->mnemonic, "cbz", 3)) {
|
||||
if (op->operands[0].reg_type & ARM_REG64) {
|
||||
k = 0x000000b4;
|
||||
} else if (op->operands[0].reg_type & ARM_REG32) {
|
||||
k = 0x00000034;
|
||||
} else {
|
||||
return UT32_MAX;
|
||||
}
|
||||
} else {
|
||||
return UT32_MAX;
|
||||
}
|
||||
//printf ("%s %d, %llu\n", op->mnemonic, op->operands[0].reg, op->operands[1].immediate);
|
||||
ut32 imm = op->operands[1].immediate;
|
||||
data = k | (op->operands[0].reg << 24) | ((imm & 0x1c) << 27) | ((imm & 0x1fe0) << 11);
|
||||
data = data | ((imm & 0x1fe000) >> 5);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
static ut32 cmp(ArmOp *op) {
|
||||
ut32 data = UT32_MAX;
|
||||
int k = 0;
|
||||
@ -1023,6 +1054,10 @@ bool arm64ass(const char *str, ut64 addr, ut32 *op) {
|
||||
*op = mov (&ops);
|
||||
return *op != -1;
|
||||
}
|
||||
if (!strncmp (str, "cb", 2)) {
|
||||
*op = cb (&ops);
|
||||
return *op != -1;
|
||||
}
|
||||
if (!strncmp (str, "cmp", 3)) {
|
||||
*op = cmp (&ops);
|
||||
return *op != -1;
|
||||
|
@ -153,3 +153,5 @@ brab=branch with pointer authentication using B key
|
||||
brabz=variant of brabz
|
||||
stadd=atomic add word (arm v8.1)
|
||||
staddl=atomic add dword (arm v8.1)
|
||||
cbnz=compare and branch on non-zero
|
||||
cbz=compare and branch on zero
|
||||
|
@ -258,3 +258,5 @@ a "mrs x3, SP_EL0" 034138d5
|
||||
a "msr 0xc208, x3" 034118d5
|
||||
a "msr SP_EL0, x3" 034118d5
|
||||
a "msr sp_el0, x3" 034118d5
|
||||
a "cbnz w3, 0x1fffd4" a3feff35
|
||||
a "cbz x3, 0x1fffe8" 43ffffb4
|
||||
|
Loading…
Reference in New Issue
Block a user