Ejemplo n.º 1
0
static int z80OpLength (const ut8 *buf, int len) {
	z80_opcode *op;
	int type = 0, ret = 0;
	if (len < 1)
		return 0;
	op = z80_op;
	if (op[buf[0]].type & Z80_OP_UNK) {
		if (len < 2)
			return 0;
		if (op[buf[0]].type & Z80_ENC0) {
			op = (z80_opcode *)op[buf[0]].op_moar;
			type = op[z80_fddd_branch_index_res(buf[1])].type;
		} else if (op[buf[0]].type & Z80_ENC1) {
			op = (z80_opcode *)op[buf[0]].op_moar;
			type = op[z80_ed_branch_index_res(buf[1])].type;
		}
	} else {
		type = op[buf[0]].type;
	}
	if (type & Z80_OP8)
		ret++;
	if ((type & Z80_ARG8) && !(type & Z80_ARG16))								//XXX
		ret++;
	if (type & Z80_OP16)
		ret += 2;
	if (type & Z80_ARG16)
		ret += 2;
	if (type & Z80_OP24)
		ret += 3;
	if (ret > len)
		return 0;

	return ret;
}
Ejemplo n.º 2
0
static void z80_op_size(const ut8 *data, int len, int *size, int *size_prefix) {
	int type = 0;
	if (len <1) {
		return;
	}
	switch (data[0]) {
	case 0xed:
		if (len > 1) {
			int idx = z80_ed_branch_index_res (data[1]);
			type = ed[idx].type;
		}
		break;
	case 0xcb:
		type = Z80_OP16;
		break;
	case 0xdd:
		if (len >1) {
			type = dd[z80_fddd_branch_index_res(data[1])].type;
		}
		break;
	case 0xfd:
		if (len > 1) {
			type = fd[z80_fddd_branch_index_res(data[1])].type;
		}
		break;
	default:
		type = z80_op[data[0]].type;
		break;
	}

	if (type & Z80_OP8) {
		*size_prefix = 1;
	} else if (type & Z80_OP16) {
		*size_prefix = 2;
	} else if (type & Z80_OP24) {
		*size_prefix = 3;
	}

	if (type & Z80_ARG16) {
		*size = *size_prefix + 2;
	} else if (type & Z80_ARG8) {
		*size = *size_prefix + 1;
	} else {
		*size = *size_prefix;
	}
}
Ejemplo n.º 3
0
static int z80Disass (RAsmOp *op, const ut8 *buf, int len) {
	int ret = z80OpLength (buf, len);
	z80_opcode *z_op;
	char **cb_tab;
	ut8 res;
	if (!ret)
		return ret;
	z_op = z80_op;

	switch (z_op[buf[0]].type) {
		case Z80_OP8:
			sprintf (op->buf_asm, "%s", z_op[buf[0]].name);
			return ret;
		case Z80_OP8^Z80_ARG8:
			sprintf (op->buf_asm, z_op[buf[0]].name, buf[1]);
			return ret;
		case Z80_OP8^Z80_ARG16:
			sprintf (op->buf_asm, z_op[buf[0]].name, buf[1]+(buf[2]<<8));
			return ret;
		case Z80_OP16:
			cb_tab = (char **) z_op[buf[0]].op_moar;
			sprintf (op->buf_asm, "%s", cb_tab[buf[1]]);
			return ret;
		case Z80_OP_UNK^Z80_ENC1:
			z_op = (z80_opcode *)z_op[buf[0]].op_moar;
			res = z80_ed_branch_index_res (buf[1]);
			if (z_op[res].type == Z80_OP16)
				sprintf (op->buf_asm, "%s", z_op[res].name);
			if (z_op[res].type == (Z80_OP16^Z80_ARG16))
				sprintf (op->buf_asm, z_op[res].name, buf[2]+(buf[3]<<8));
			return ret;
		case Z80_OP_UNK^Z80_ENC0:
			z_op = (z80_opcode *)z_op[buf[0]].op_moar;
			res = z80_fddd_branch_index_res (buf[1]);
			if (z_op[res].type == Z80_OP16)
				sprintf (op->buf_asm, "%s", z_op[res].name);
			if (z_op[res].type == (Z80_OP16^Z80_ARG16))
				sprintf (op->buf_asm, z_op[res].name, buf[2]+(buf[3]<<8));
			if (z_op[res].type == (Z80_OP16^Z80_ARG8))
				sprintf (op->buf_asm, z_op[res].name, buf[2], buf[3]);
			if (z_op[res].type == (Z80_OP24^Z80_ARG8)) {
				cb_tab = (char **) z_op[res].op_moar;
				sprintf (op->buf_asm, cb_tab[z80_op_24_branch_index_res (buf[3])], buf[2]);
			}
			if (z_op[res].type == (Z80_OP16^Z80_ARG8^Z80_ARG16))
				sprintf (op->buf_asm, z_op[res].name, buf[2], buf[3]);
	}
	if (!strcmp (op->buf_asm, "invalid"))
		ret = 0;
	return ret;
}