⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arm2x86_mem.c

📁 这是Skyeye 0.9 版本的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
{
	unsigned int	begin=0,end=0;

	OP_BEGIN("get_op_str_T0_T1");
	//ARMul_WriteWord(st, T1, T0);
	__asm__ __volatile__ ("subl	$0x4, %esp");
	__asm__ __volatile__ ("push	%"AREG_T0);
	__asm__ __volatile__ ("push	%"AREG_T1);
	__asm__ __volatile__ ("push	%"AREG_st);
	arm2x86_pfun = (uint32_t)ARMul_WriteWord;
//chy 2005-05-11
#ifndef __CYGWIN__
	__asm__ __volatile__ ("call	*arm2x86_pfun");
#else
	wmb();
	(*arm2x86_pfun)();
#endif
	__asm__ __volatile__ ("addl	$0x10, %esp");
	if (st->abortSig != LOW) {
		st->trap = TRAP_DATA_ABORT;
		//if (st->is_XScale) {
		if (st->abort_model < 2) {
			__asm__ __volatile__ ("ret");
		}
	}
	OP_END("get_op_str_T0_T1");
	*len = end - begin;

	return((uint8_t *)begin);
}

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

	OP_BEGIN("get_op_strh_T0_T1");
	//ARMul_StoreHalfWord(st, T1, T0);
	__asm__ __volatile__ ("subl	$0x4, %esp");
	__asm__ __volatile__ ("push	%"AREG_T0);
	__asm__ __volatile__ ("push	%"AREG_T1);
	__asm__ __volatile__ ("push	%"AREG_st);
	arm2x86_pfun = (uint32_t)ARMul_StoreHalfWord;
//chy 2005-05-11
#ifndef __CYGWIN__
	__asm__ __volatile__ ("call	*arm2x86_pfun");
#else
	wmb();
	(*arm2x86_pfun)();
#endif
	__asm__ __volatile__ ("addl	$0x10, %esp");
	if (st->abortSig != LOW) {
		st->trap = TRAP_DATA_ABORT;
		if (st->abort_model < 2) {
		//if (st->is_XScale) {
			__asm__ __volatile__ ("ret");
		}
	}
	OP_END("get_op_strh_T0_T1");
	*len = end - begin;

	return((uint8_t *)begin);
}

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

	OP_BEGIN("get_op_strb_T0_T1");
	//ARMul_WriteByte(st, T1, T0);
	__asm__ __volatile__ ("subl	$0x4, %esp");
	__asm__ __volatile__ ("push	%"AREG_T0);
	__asm__ __volatile__ ("push	%"AREG_T1);
	__asm__ __volatile__ ("push	%"AREG_st);
	arm2x86_pfun = (uint32_t)ARMul_WriteByte;
//chy 2005-05-11
#ifndef __CYGWIN__
	__asm__ __volatile__ ("call	*arm2x86_pfun");
#else
	wmb();
	(*arm2x86_pfun)();
#endif
	__asm__ __volatile__ ("addl	$0x10, %esp");
	if (st->abortSig != LOW) {
		st->trap = TRAP_DATA_ABORT;
		//if (st->is_XScale) {
		if (st->abort_model < 2) {
			__asm__ __volatile__ ("ret");
		}
	}
	OP_END("get_op_strb_T0_T1");
	*len = end - begin;

	return((uint8_t *)begin);
}

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

	OP_BEGIN("get_op_ldm_T1_T0");
	//T1 = tea_ldm(st, T1, T0);
	__asm__ __volatile__ ("subl	$0x4, %esp");
	__asm__ __volatile__ ("push	%"AREG_T0);
	__asm__ __volatile__ ("push	%"AREG_T1);
	__asm__ __volatile__ ("push	%"AREG_st);
	arm2x86_pfun = (uint32_t)tea_ldm;
//chy 2005-05-11
#ifndef __CYGWIN__
	__asm__ __volatile__ ("call	*arm2x86_pfun");
#else
	wmb();
	(*arm2x86_pfun)();
#endif
	__asm__ __volatile__ ("addl	$0x10, %esp");
	__asm__ __volatile__ ("movl	%eax, %"AREG_T1);
	/*if (st->abortSig != LOW) {
		st->trap = TRAP_DATA_ABORT;
		__asm__ __volatile__ ("ret");
	}*/
	if (st->abortSig != LOW) {
		//if (st->is_XScale) {
		if (!st->abort_model) {
			__asm__ __volatile__ ("ret");
		}
	}
	OP_END("get_op_ldm_T1_T0");
	*len = end - begin;

	return((uint8_t *)begin);
}

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

	OP_BEGIN("get_op_stm_T1_T0");
	//T1 = tea_stm(st, T1, T0);
	__asm__ __volatile__ ("subl	$0x4, %esp");
	__asm__ __volatile__ ("push	%"AREG_T0);
	__asm__ __volatile__ ("push	%"AREG_T1);
	__asm__ __volatile__ ("push	%"AREG_st);
	arm2x86_pfun = (uint32_t)tea_stm;
//chy 2005-05-11
#ifndef __CYGWIN__
	__asm__ __volatile__ ("call	*arm2x86_pfun");
#else
	wmb();
	(*arm2x86_pfun)();
#endif
	__asm__ __volatile__ ("addl	$0x10, %esp");
	__asm__ __volatile__ ("movl	%eax, %"AREG_T1);
	/*if (st->abortSig != LOW) {
		st->trap = TRAP_DATA_ABORT;
		__asm__ __volatile__ ("ret");
	}*/
	if (st->abortSig != LOW) {
		//if (st->is_XScale) {
		if (!st->abort_model) {
			__asm__ __volatile__ ("ret");
		}
	}
	OP_END("get_op_stm_T1_T0");
	*len = end - begin;

	return((uint8_t *)begin);
}

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

	OP_BEGIN("get_op_ldm_user_T1_T0");
	//T1 = tea_ldm_user(st, T1, T0);
	__asm__ __volatile__ ("subl	$0x4, %esp");
	__asm__ __volatile__ ("push	%"AREG_T0);
	__asm__ __volatile__ ("push	%"AREG_T1);
	__asm__ __volatile__ ("push	%"AREG_st);
	arm2x86_pfun = (uint32_t)tea_ldm_user;
//chy 2005-05-11
#ifndef __CYGWIN__
	__asm__ __volatile__ ("call	*arm2x86_pfun");
#else
	wmb();
	(*arm2x86_pfun)();
#endif
	__asm__ __volatile__ ("addl	$0x10, %esp");
	__asm__ __volatile__ ("movl	%eax, %"AREG_T1);
	/*if (st->abortSig != LOW) {
		st->trap = TRAP_DATA_ABORT;
		__asm__ __volatile__ ("ret");
	}*/
	if (st->abortSig != LOW) {
		//if (st->is_XScale) {
		if (!st->abort_model) {
			__asm__ __volatile__ ("ret");
		}
	}
	OP_END("get_op_ldm_user_T1_T0");
	*len = end - begin;

	return((uint8_t *)begin);
}

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

	OP_BEGIN("get_op_stm_user_T1_T0");
	//T1 = tea_stm_user(st, T1, T0);
	__asm__ __volatile__ ("subl	$0x4, %esp");
	__asm__ __volatile__ ("push	%"AREG_T0);
	__asm__ __volatile__ ("push	%"AREG_T1);
	__asm__ __volatile__ ("push	%"AREG_st);
	arm2x86_pfun = (uint32_t)tea_stm_user;
//chy 2005-05-11
#ifndef __CYGWIN__
	__asm__ __volatile__ ("call	*arm2x86_pfun");
#else
	wmb();
	(*arm2x86_pfun)();
#endif
	__asm__ __volatile__ ("addl	$0x10, %esp");
	__asm__ __volatile__ ("movl	%eax, %"AREG_T1);
	/*if (st->abortSig != LOW) {
		st->trap = TRAP_DATA_ABORT;
		__asm__ __volatile__ ("ret");
	}*/
	if (st->abortSig != LOW) {
		//if (st->is_XScale) {
		if (!st->abort_model) {
			__asm__ __volatile__ ("ret");
		}
	}
	OP_END("get_op_stm_user_T1_T0");
	*len = end - begin;

	return((uint8_t *)begin);
}

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

	OP_BEGIN("get_op_signextend_halfword_T0");
	//if (T0 & 1 << (16 - 1))
	//	T0 = (T0 & ((1 << 16) - 1)) - (1 << 16);
	if (T0 & 1 << (16 - 1))
		T0 |= 0xffff0000;
	OP_END("get_op_signextend_halfword_T0");
	*len = end - begin;

	return((uint8_t *)begin);
}

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

	OP_BEGIN("get_op_signextend_byte_T0");
	//if (T0 & 1 << (8 - 1))
	//	T0 = (T0 & ((1 << 8) - 1)) - (1 << 8);
	if (T0 & 1 << (8 - 1))
		T0 |= 0xffffff00;
	OP_END("get_op_signextend_byte_T0");
	*len = end - begin;

	return((uint8_t *)begin);
}

op_table_t	op_ldr_T0_T1;
op_table_t	op_ldr_T2_T1;
op_table_t	op_ldrh_T0_T1;
op_table_t	op_ldrb_T0_T1;
op_table_t	op_ldrb_T2_T1;

op_table_t	op_str_T0_T1;
op_table_t	op_strh_T0_T1;
op_table_t	op_strb_T0_T1;

op_table_t	op_ldm_T1_T0;
op_table_t	op_stm_T1_T0;

op_table_t	op_ldm_user_T1_T0;
op_table_t	op_stm_user_T1_T0;

op_table_t	op_signextend_halfword_T0;
op_table_t	op_signextend_byte_T0;

int
arm2x86_mem_init()
{
	op_ldr_T0_T1.op = get_op_ldr_T0_T1(&op_ldr_T0_T1.len);
	if (op_ldr_T0_T1.len <= 0)
		return(-1);
	op_ldr_T2_T1.op = get_op_ldr_T2_T1(&op_ldr_T2_T1.len);
	if (op_ldr_T2_T1.len <= 0)
		return(-1);
	op_ldrh_T0_T1.op = get_op_ldrh_T0_T1(&op_ldrh_T0_T1.len);
	if (op_ldrh_T0_T1.len <= 0)
		return(-1);
	op_ldrb_T0_T1.op = get_op_ldrb_T0_T1(&op_ldrb_T0_T1.len);
	if (op_ldrb_T0_T1.len <= 0)
		return(-1);
	op_ldrb_T2_T1.op = get_op_ldrb_T2_T1(&op_ldrb_T2_T1.len);
	if (op_ldrb_T2_T1.len <= 0)
		return(-1);

	op_str_T0_T1.op = get_op_str_T0_T1(&op_str_T0_T1.len);
	if (op_str_T0_T1.len <= 0)
		return(-1);
	op_strh_T0_T1.op = get_op_strh_T0_T1(&op_strh_T0_T1.len);
	if (op_strh_T0_T1.len <= 0)
		return(-1);
	op_strb_T0_T1.op = get_op_strb_T0_T1(&op_strb_T0_T1.len);
	if (op_strb_T0_T1.len <= 0)
		return(-1);

	op_ldm_T1_T0.op = get_op_ldm_T1_T0(&op_ldm_T1_T0.len);
	if (op_ldm_T1_T0.len <= 0)
		return(-1);
	op_stm_T1_T0.op = get_op_stm_T1_T0(&op_stm_T1_T0.len);
	if (op_stm_T1_T0.len <= 0)
		return(-1);

	op_ldm_user_T1_T0.op = get_op_ldm_user_T1_T0(&op_ldm_user_T1_T0.len);
	if (op_ldm_user_T1_T0.len <= 0)
		return(-1);
	op_stm_user_T1_T0.op = get_op_stm_user_T1_T0(&op_stm_user_T1_T0.len);
	if (op_stm_user_T1_T0.len <= 0)
		return(-1);

	op_signextend_halfword_T0.op = get_op_signextend_halfword_T0(&op_signextend_halfword_T0.len);
	if (op_signextend_halfword_T0.len <= 0)
		return(-1);
	op_signextend_byte_T0.op = get_op_signextend_byte_T0(&op_signextend_byte_T0.len);
	if (op_signextend_byte_T0.len <= 0)
		return(-1);

	return(0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -