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

📄 coproc.cpp

📁 RISC processor ARM-7 emulator
💻 CPP
字号:
/*************************************************************************
    Copyright (C) 2002,2003,2004,2005 Wei Qin
    See file COPYING for more information.

    This program is free software; you can redistribute it and/or modify    
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
*************************************************************************/

#include <cstdio>
#include <armemul.h>
#include "coproc.h"
#include "emu_device.hpp"

#ifdef _MODULARIZE_
#define EMU(_x) emu->_x
#else
#define EMU(_x) _x
#endif

using namespace emulator;

/*RN and RD is switched for MLA*/
void impl_cpld(IMPL_FORMALS)
{
	//r0 contains the device id
	dev_id_t id = READ_REG(0);

	// r1 contains the address
	dev_addr_t addr = READ_REG(1);

	dev_data_t data;

	if (inst & 0X100) {
		if (EMU(dev_master->receive(id, data, addr))) {
			WRITE_REG(0, data);
		}
		else { // blocked, yield
			EMU(stop());
		}
	}
	else if (EMU(dev_master->receive(id, data))) {
		WRITE_REG(0, data);
	}
	else { // blocked, yield
		EMU(stop());
	}

	EMULATOR_STUB(cpld,inst);
}

void impl_cpst(IMPL_FORMALS)
{

	// r0 contains the device id
	dev_id_t id = READ_REG(0);

	// r2 contains the address
	dev_addr_t addr = READ_REG(2);

	// r1 contains the value to write
	dev_data_t data = READ_REG(1);

	if (inst & 0X100) {
		if (!EMU(dev_master->send(id, data, addr)))
			EMU(stop());
	}
	else if (!EMU(dev_master->send(id, data))) {
		EMU(stop());
	}

	EMULATOR_STUB(cpst, inst);
}

char *disasm_cpld(arm_inst_t inst, arm_addr_t addr, char *buf)
{
	buf += sprintf(buf, "coproc ld");
	return buf;
}

char *disasm_cpst(arm_inst_t inst, arm_addr_t addr, char *buf)
{
	buf += sprintf(buf, "coproc st");
	return buf;
}

⌨️ 快捷键说明

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