A.Why? Implementing a computer really helps you understand its structure. B.Outcomes After this project, you should Know how to implement the major parts of a computer in a higher-level language. Know how to access structures via pointers in C. C.Project You are to implement of a simple simulator for the LC-3 in C. As in the simulator you did for the Simple Decimal Computer, you will be given a skeleton of the program; your job is to complete the implementation. Once again, the user interface will be console-oriented. Instead of typing in the program, however, the user will be able to read the program to be executed. This is an individual project. Your program should: Prompt for and read the name of an input le and then read the input le to initialize memory (see below). Run a command loop to execute the program or dump registers/memory. D.Input File You should prompt the user for a le name (complain if the le doesnt exist). Use input.hex as the default lename. (If you cant get the prompting to work correctly, at least read from input.hex.) The le should be a *.hex le (the kind produced by the LC-3 editor on assembling a *.asm le). A *.hex le is a sequence of lines with a four-digit hex number on each line (no leading x or 0x). The rst line species the .ORIG to load the program to. The remaining lines comprise the program. E.g., Assembler File Hex le ORIG x3000 3000 LD R1, X 2203 ADD R1, R1, 1 1261 ST R1, X 3201 HALT F025 X .FILL 17 0011 .END The rest of memory should be initialized to zeros except for the last location, which should be initialized to a HALT instruction. (The textbooks LC3 simulator causes an error if you execute that location.) E.The Command Loop Once the program is read into memory, initialize the program counter (to the .ORIG value), set the IR to all 0s, the condition code to Z, and start a command loop. There are ve commands. The user should enter a carriage return after each command (so h<cr, for example). h for help: Print a summary of the simulator commands. d for dump control unit: Print out the program counter, instruction register, condition code, and data registers. m n n for memory: Print out the values of memory at locations n, n+1, , n. (If nn, then no values get printed out.) The values n and n should be in hex with a leading x. Dont print out the value of a location if the value is zero. If n or n is an illegal address, print an error message and skip the memory dump. An integer: Run that number of instruction cycles (but stop early if you execute a HALT). If the machine is already halted, say so but dont run any instruction cycles. No input, just For LD reg, oset, you say which register youre loading, the oset value, the PC+oset address, and the value at M[PC+oset] youre copying to the register. The output contains all the same information as the sample solutions output. Minor dierences like spacing and case and what order you print things on a line arent relevant. The code should be commented, readable, with good-sized routines (dont have just a main program hundreds of lines long; each routine should do one conceptual thing). For a grade of B The program compiles to an executable, though there may be warnings. The simulator commands h, r, m, <integer, and q should work, though the m command might not do everything it should (check for bad addresses, avoid printing zeros, etc). The simulator has words of the right length, but it may get confused about overow and truncation from int to short int etc. The simulator always reads its hex input from the le input.hex (it doesnt prompt for a name, or it handles the name incorrectly and reads from input.hex instead). 75% of the opcodes should be implemented. (This can range from 75% of the opcodes completely working to all the opcodes 75% working.) Each TRAP counts as a dierent opcode. The code is mostly commented, mostly readable, and there may be a bit of imbalance in routine sizes (but again, not just a main program hundreds of lines long). For a grade of C As for a grade of B but only 33%74% of the opcodes are implemented. The m command doesnt support (or ignores) the memory limit values. (But m
Programming
[Solved] SOLVED:Final Project: LC-3 Simulator
$25
File Name: SOLVED:Final_Project:_LC-3_Simulator.zip
File Size: 339.12 KB
Only logged in customers who have purchased this product may leave a review.
Reviews
There are no reviews yet.