#include "armdefs.h"
#include "arm2x86_self.h"

uint8_t *
get_op_mul_T0_T1(int *len)
{
	unsigned int	begin=0, end=0;

	OP_BEGIN("get_op_mul_T0_T1");
	T0 = T0 * T1;
	OP_END("get_op_mul_T0_T1");
	*len = end - begin;

	return((uint8_t *)begin);
}

uint8_t *
get_op_umull_T0_T1(int *len)
{
	unsigned int	begin=0, end=0;

	OP_BEGIN("get_op_umull_T0_T1");
	__asm__ __volatile__ ("movl	%"AREG_T0", %eax");
	__asm__ __volatile__ ("mull	%"AREG_T1);
	__asm__ __volatile__ ("movl	%eax, %"AREG_T0);
	__asm__ __volatile__ ("movl	%edx, %"AREG_T1);
	OP_END("get_op_umull_T0_T1");
	*len = end - begin;

	return((uint8_t *)begin);
}

uint8_t *
get_op_smull_T0_T1(int *len)
{
	unsigned int	begin=0, end=0;

	OP_BEGIN("get_op_smull_T0_T1");
	__asm__ __volatile__ ("movl	%"AREG_T0", %eax");
	__asm__ __volatile__ ("imull	%"AREG_T1);
	__asm__ __volatile__ ("movl	%eax, %"AREG_T0);
	__asm__ __volatile__ ("movl	%edx, %"AREG_T1);
	OP_END("get_op_smull_T0_T1");
	*len = end - begin;

	return((uint8_t *)begin);
}

op_table_t	op_mul_T0_T1;
op_table_t	op_umull_T0_T1;
op_table_t	op_smull_T0_T1;
int
arm2x86_mul_init()
{
	op_mul_T0_T1.op = get_op_mul_T0_T1(&op_mul_T0_T1.len);
	op_umull_T0_T1.op = get_op_umull_T0_T1(&op_umull_T0_T1.len);
	op_smull_T0_T1.op = get_op_smull_T0_T1(&op_smull_T0_T1.len);

	return(0);
}
