Question: C. Project You are to implement of a simple console-oriented simulator for the LC-3 in C using your SDC simulator from the labs as a




C. Project You are to implement of a simple console-oriented simulator for the LC-3 in C using your SDC simulator from the labs as a starting point. Your program should take the name of a *.hex file as a command line parameter, load it into memory, initialize the control unit, and run a command loop. Commands can cause program execution and other functions. Phase 1 of the project only needs to load the *.hex file into memory; Phase 2 includes handling the simulator commands and executing instructions. D. Simulating The LC-3 Architecture As in the SDC simulator , the LC-3 CPU should be modeled as a value of type struct CPU, allocated in the main program. Routines that need the CPU should be passed a pointer to the CPU value. A Word is typedef'ed to be a short int, 16 bits on the fourier machine. An Address is also 16 bits but it is an unsigned short int (compare with the unsigned char used for the SDC). Represent the CPU's memory as an array of Word values indexed by Address values. Represent the general purpose registers as an array of Word values indexed by register numbers (0 7). The PC is an Address; the IR is a Word. Below is a skeleton declaration for the CPU structure. Rather than mandate that you represent (e.g.) the condition code with a certain datatype, I've used typedef to give a name for the datatypes ConditionCode, Opcode, Flag, and Reg You can just replace the ??? with whatever you decide to use (like char or int etc). C. Project You are to implement of a simple console-oriented simulator for the LC-3 in C using your SDC simulator from the labs as a starting point. Your program should take the name of a *.hex file as a command line parameter, load it into memory, initialize the control unit, and run a command loop. Commands can cause program execution and other functions. Phase 1 of the project only needs to load the *.hex file into memory; Phase 2 includes handling the simulator commands and executing instructions. D. Simulating The LC-3 Architecture As in the SDC simulator , the LC-3 CPU should be modeled as a value of type struct CPU, allocated in the main program. Routines that need the CPU should be passed a pointer to the CPU value. A Word is typedef'ed to be a short int, 16 bits on the fourier machine. An Address is also 16 bits but it is an unsigned short int (compare with the unsigned char used for the SDC). Represent the CPU's memory as an array of Word values indexed by Address values. Represent the general purpose registers as an array of Word values indexed by register numbers (0 7). The PC is an Address; the IR is a Word. Below is a skeleton declaration for the CPU structure. Rather than mandate that you represent (e.g.) the condition code with a certain datatype, I've used typedef to give a name for the datatypes ConditionCode, Opcode, Flag, and Reg You can just replace the ??? with whatever you decide to use (like char or int etc)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
