代寫C C++ Java Python 視頻講解客服在線客服在線

代做國外C C++ Java程序 Python QQ 2365427650 Email [email protected] 免費咨詢編程問題

« Fifteen Twenty GameA simple GUI »

MIPS Emulator

The aim of this task is to develop a MIPS Emulator in c (not limited), supporting a
limited number of instructions. The Emulator should (at least) be able to convert the
following instructions into bytecode: ADD, ADDI, SRL, BNE. The Emulator should read
MIPS instructions from a text file and produce an output giving the address of
instructions and bytecode of the instruction. Labels should be converted appropriately.
It can be assumed that each line contains an instruction or a label followed by an
instruction. Arguments of an instruction are separated by comma. After translation into
bytecode, the Emulator executes the program from the machine code. Program
Counter and Registers are updated during program execution.
Details
The Emulator should be able to process standard MIPS programs (equivalent to
MARS). A simplified version of the Ethiopian Multiplication is given here as a example:
addi $s0,$zero,0
addi $t1,$zero,0
loop:
addi $t1,$t1,2
add $s0,$s0,$t1
bne $t1,20,loop
srl $s1,$s0,1
Compiled programs will start at address 0x00400000. The Emulator should then
produce the following output for an input as shown above (pairs of address and
instruction in HEX):
0x00400000 0x20100000
0x00400004 0x20090000
0x00400008 0x21290002
0x0040000c 0x02098020
0x00400010 0x20010014
0x00400014 0x1429fffc
0x00400018 0x00108842
After producing the bytecode, the Emulator will start to execute the bytecode from the
machine code. The state of the registers and of the program counter is printed once
the program has completed
Executing 0x00400000 0x20100000
Executing 0x00400004 0x20090000

Executing 0x00400008 0x21290002
Executing 0x0040000c 0x02098020
Executing 0x00400010 0x20010014
Executing 0x00400014 0x1429fffc
Executing 0x00400018 0x00108842
Register:
0: 0
1: 0
2: 0
……
10: 20

16:110
17:55
18:0

31:0
Program counter: 0x0040001c
…DONE !
Task
The program reads instructions from a file named data.txt and places the data into
memory. The function make bytecode() takes care of generating the bytecode. The
function exec bytecode() is used to execute the generated bytecode.
The basic task (16 marks)
• implement the function to make bytecode(). Implement opcode functions for ADD,
ADDI, SRL, BNE
• implement the function to execute bytecode() from bytecode.
• add comments to the completed program
Making scheme
• Provide the code (completed c code or others)
• Explain the general flow of the program
• Correct implementation of bytecode

• Correct implementation of instructions (add, addi, …)
• Correct implementation of branch conditions (bne)
• Correct function of the emulator (test and general programs)
• Code elegance (comments, reduction of repetition, …)
The extra task (4 marks)
If you add some new function and feature in your implementation apart from the
basic task, you may have an extra mark according to your work.
.

  • 相關文章:

發表評論:

◎歡迎參與討論,請在這里發表您的看法、交流您的觀點。

最新評論及回復

最近發表

Powered By Z-Blog 1.8 Walle Build 100427

Copyright 代寫C.

体彩25选5开奖结果