The goal of this assignment is to implement the vm520 virtual machine.
Your code must implement the interfaces I have defined for the virtual machine. The code base you are to work with is available in ~cs520/public/prog7. This includes a sample main.c that illustrates how the interfaces can be used to load and execute an object file. vm520.h defines the interfaces for the virtual machine and vm520.c currently contains stubs for those functions. There is also a Makefile, as well as an assembly language program and the corresponding object file that is used by main.c.
You must implement the following six functions:
When tracing is enabled via the fourth parameter to execute, each processor, immediately prior to executing an instruction, should print to stderr three lines describing the instruction and the current state of the processor (i.e. the contents of its registers). Each line should start with the processor ID displayed in angle brackets (e.g. <3>) followed by a colon and a space. The first two lines should display the contents of the registers, with line one showing r0-r7 and line two showing r8-r15. The register contents should be displayed left to right in increasing register number order, with one space separating each value. The value should be displayed in hex, with leading zeros explicitly printed. The third line should contain the disassembly of the instruction to execute next, in the format produced by the disassemble function.
When the virtual machine is executed with more than one processor, you must take special care to be sure that the three trace lines printed for one processor are printed intact, and are not interrupted by the trace output from another thread.
Here are examples of why a file being loaded as an object file might not be valid:
It is not an error to invoke getWord, putWord, execute or disassemble prior to loading an object file. Those functions will simply operate on the memory as it is.
If there is no object file loaded in memory, then a call to getAddress will fail.
It is not an error to invoke loadObjectFile more than once. Later calls will simply overwrite memory.
When implementing multiple processors, any instruction that writes to memory should lock all of memory for the duration of the write.
Points will be awarded for this assignment in the following manner:
Your program will be graded primarily by testing it for correct functionality. In addition, however, you may lose points if your program is not properly structured and documented. Decompose sub-problems appropriately into functions and do incremental testing. Leave your debugging output in your code, but disabled, when you do your final assignment submission.
By the end of the lab on Friday December 3, you should have completed loadObjectFile, getWord, putWord and disassemble. This will require that you begin working on this prior to coming to lab. In lab we will work on any issues that you are having trouble with.
By the end of the lab on Friday December 10, you should have completed execute without support for multiple processors or support for tracing. In lab we will work on any issues that you are having trouble with.
Your programs will be graded using agate.cs.unh.edu so be sure to test in that environment.
You should only submit vm520.c. Put all of your code in this file.
Your programs should be submitted for grading from
agate.cs.unh.edu.
To turn in this assignment, type:
~cs520/bin/submit prog7 vm520.c
Please submit only this one file. Do not turn in any other files!
Submissions can be checked by typing:
~cs520/bin/scheck prog7
To receive full credit for the assignment, you must turn in your files prior to 8am on Monday December 13. Programming assignments may be handed in late at a penalty of 2 points for one day late, 5 points for two days late, 10 points for three days late, 20 points for four days late, and 40 points for five days late. No program may be turned in more than 5 days late.
Remember: as always you are expected to do your own work on this assignment.
Comments and questions should be directed to hatcher@unh.edu