在C++下做MIPS模拟器(在线等)

holyender 2006-11-26 06:01:24
小弟新手,不知这个问题怎么解决,大家给个方向-也好
Description
You are to write in C++ an emulator for a simple MIPS machine with the following subset of the MIPS core instruction set as its instruction set:

* lw
* sw
* add
* addi
* sub
* and
* or
* beq
* slt

Your emulator must run on the bsu-cs machine as if it were a Unix command with one command line argument. The command line argument will be the name of a binary file containing MIPS machine language commands. Your emulator must provide 4096 words of instruction memory and a separate block of 4096 words of data memory.

The output of your emulator should be a file named "core.txt" that contains a readable copy of the content of all 32 general purpose registers together with the content of the data memory, 4 words per line. Each line of the data memory content should begin with the 4 hex digit address of the left-most byte on that line.
...全文
530 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
FantasyNES 2006-11-26
  • 打赏
  • 举报
回复
MIPS是RISC处理器吧,这种容易处理,每次都取同样长度的指令。
如果是模拟x86的就烦死了
FantasyNES 2006-11-26
  • 打赏
  • 举报
回复
就是一个指令模拟器,取得指令,解释执行,取下一条指令。。。。

#define LW(xxx) XXXXX

while (running)
{
switch(opcode)
{
case lw:
LW(xxx) ;
break ;

default:
Error() ;
break ;
}
opcode = next_opcode() ;
}

64,683

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧