#ifndef _ARM2X86_MOVL_H_
#define _ARM2X86_MOVL_H_

extern op_table_t	op_movl_Tx_im[Tx_MAX+1];
extern op_table_t	op_movl_tmpx_im[tmp_MAX+1];
extern op_table_t	op_movl_Tx_reg[Tx_MAX+1][16];
extern op_table_t	op_movl_reg_Tx[Tx_MAX+1][16];
extern op_table_t	op_movl_eax_T2;
extern op_table_t	op_movl_trap_im;
extern op_table_t	op_movl_trap_T2;
extern op_table_t	op_movl_T0_T2;

extern int		arm2x86_movl_init();

static __inline__ void
gen_op_movl_Tx_im(ARMul_State *state, uint8_t **tbpp, int *plen, int Tx, ARMword im)
{
	GEN_OP(*tbpp, *plen, op_movl_Tx_im[Tx]);
	if (*tbpp) {
		memcpy(*tbpp, &im, sizeof(im));
		*tbpp += sizeof(im);
	}
	*plen += sizeof(im);
}

static __inline__ void
gen_op_movl_tmpx_im(ARMul_State *state, uint8_t **tbpp, int *plen, int tmpx, ARMword im)
{
	GEN_OP(*tbpp, *plen, op_movl_tmpx_im[tmpx]);
	if (*tbpp) {
		memcpy(*tbpp, &im, sizeof(im));
		*tbpp += sizeof(im);
	}
	*plen += sizeof(im);
}

static __inline__ void
gen_op_movl_Tx_reg(ARMul_State *state, uint8_t **tbpp, int *plen, int Tx, ARMword reg)
{
	GEN_OP(*tbpp, *plen, op_movl_Tx_reg[Tx][reg]);
}

static __inline__ void
gen_op_movl_reg_Tx(ARMul_State *state, uint8_t **tbpp, int *plen, ARMword reg, int Tx)
{
	GEN_OP(*tbpp, *plen, op_movl_reg_Tx[Tx][reg]);
	if (reg == 15) {
		//change pc
		state->trap = 1;
	}
}

static __inline__ void
gen_op_movl_trap_im_use_T2(ARMul_State *state, uint8_t **tbpp, int *plen, ARMword im)
{
	gen_op_movl_Tx_im(state, tbpp, plen, 2, im);
	GEN_OP(*tbpp, *plen, op_movl_trap_T2);
}

static __inline__ void
gen_op_movl_trap_im(ARMul_State *state, uint8_t **tbpp, int *plen, ARMword im)
{
	GEN_OP(*tbpp, *plen, op_movl_trap_im);
	if (*tbpp) {
		memcpy(*tbpp, &im, sizeof(im));
		*tbpp += sizeof(im);
	}
	*plen += sizeof(im);
}

#endif	//_ARM2X86_MOVL_H_
