Example #1
0
static int assemble(RAsm *a, RAsmOp *op, const char *buf) {
	int opcode = armass_assemble (buf, a->pc, true);
	if (opcode==-1)
		return -1;
	r_mem_copyendian (op->buf, (void *)&opcode, 2, a->big_endian);
	return armthumb_length (opcode);
}
Example #2
0
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 {
Example #3
0
// XXX: This is wrong, some opcodes are 32bit in thumb mode
static int assemble(RAsm *a, RAsmOp *op, const char *buf) {
	int opcode = armass_assemble (buf, a->pc, (a->bits==16)?1:0);
	if (opcode==-1)
		return -1;
	if (a->bits==32)
		r_mem_copyendian (op->buf, (void *)&opcode, 4, a->big_endian);
	else r_mem_copyendian (op->buf, (void *)&opcode, 2, a->big_endian);
	return (a->bits/8);
}
Example #4
0
static int assemble(RAsm *a, RAsmOp *op, const char *buf) {
	const int is_thumb = a->bits==16? 1: 0;
	int opsize;
	ut32 opcode = armass_assemble (buf, a->pc, is_thumb);
	if (opcode==UT32_MAX)
		return -1;
	if (is_thumb) {
		const int o = opcode>>16;
		opsize = (o&0x80 && ((o&0xe0)==0xe0))? 4: 2;
		r_mem_copyendian (op->buf, (void *)&opcode,
			opsize, a->big_endian);
	} else {
Example #5
0
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 {