static int assemble(RAsm *a, RAsmOp *op, const char *buf) { const bool is_thumb = (a->bits == 16); int opsize; ut32 opcode; if (a->bits == 64) { if (!arm64ass (buf, a->pc, &opcode)) { return -1; } } else { opcode = armass_assemble (buf, a->pc, is_thumb); if (a->bits != 32 && a->bits != 16) { eprintf ("Error: ARM assembler only supports 16 or 32 bits\n"); return -1; } } if (opcode == UT32_MAX) { return -1; } if (is_thumb) { const int o = opcode >> 16; opsize = o > 0? 4: 2; //(o&0x80 && ((o&0xe0)==0xe0))? 4: 2; if (opsize == 4) { if (a->big_endian) { r_write_le32 (op->buf, opcode); } else { r_write_be32 (op->buf, opcode); } } else if (opsize == 2) { r_write_be16 (op->buf, opcode & UT16_MAX); } } else {
static int assemble(RAsm *a, RAsmOp *op, const char *buf) { const bool is_thumb = a->bits==16? true: false; int opsize; ut32 opcode; if (a->bits == 64) { if (!arm64ass (buf, a->pc, &opcode)) { return -1; } } else { opcode = armass_assemble (buf, a->pc, is_thumb); if (a->bits != 32 && a->bits != 16) { eprintf ("Error: ARM assembler only supports 16 or 32 bits\n"); return -1; } } if (opcode == UT32_MAX) return -1; if (is_thumb) { const int o = opcode >> 16; opsize = o>0? 4: 2; //(o&0x80 && ((o&0xe0)==0xe0))? 4: 2; r_mem_copyendian (op->buf, (void *)&opcode, opsize, a->big_endian); } else {