CS 270
|
logic.c
.
Some functions are provided for you. You will add functions to complete the implementation. Most of the functions should be several lines. The complexity lies in understanding the pieces of the simulator and how they fit together. There will be a fair amount of duplicated or similar code that you may wish to extract into separate functions. The LC-3 Datapath diagram and LC-3 Visualizer may help identify shared elements used by different instructions.
cd
there.P8.XXX.tar
file. This will create a subdirectory
P8
containing all of the files for the project.
tar -xvpf P8.XXX.tar
cd P8
and do all your work in that directoryMakefile
and make sure the variable GCC
is appropriate for your C compiler. Also, verify that sed
in in your $PATH
. This will be OK for the department linux
machines.install.c.MASTER
and
mysim-tk.MASTER
and look for the string
abs_path_to_install_dir
. It occurs once in each file. ./fixPath install.c mysim-tk
Examine the files install.c
and mysim-tk
and
verify the string has been replaced by the path to this directory.
This script uses sed
and will not work if it is not in your
$PATH
or is not available. In this case, you may use an
editor to update the files.mysim
using the command
make
You should see the following on linux.
gcc -g -std=c11 -Wall -c -DSTACK_OPS -DDEBUG Debug.c
gcc -g -std=c11 -Wall -c -DSTACK_OPS -DDEBUG install.c
gcc -g -std=c11 -Wall -c -DSTACK_OPS -DDEBUG logic.c
gcc -g -std=c11 -Wall Debug.o install.o logic.o P8.a -o mysim
./mysim-tk -norun
or
./mysim -norun
if you prefer the command line version.0x200
. The is the LC-3 operating
system code. You will not be able to execute this code until you complete
the missing instructions.lc3as
.
.ORIG x3000
NOT R1,R7
NOT R6,R2
HALT
.END
Add additional instructions to your test program as you implement them.NOT
).logic_execute_instruction()
to handle this LC-3 instruction.
Then add the function header and body to implement this instruction.
For this assignment, you can assume that all input programs are correct in the following ways:
TEST! TEST! TEST! Once you are happy, execute the simulator without the
-norun
. The OS will now load and print out the welcome message.
This is a good test of your work because many (but not all) of the LC-3
instructions are used in the OS. You can also set up regression tests
that compare the output of ~cs270/lc3tools/lc3sim with mysim.
You may find it useful to run your simulator and the class simulator (from ~cs270/lc3tools) side by side and single step both of them and compare what you see.
If you like to do debugging with printf()
, you may do so, but you
will NOT be able to use the GUI version of the simulator. This is
because printf()
is used to to send data from the simulator to
the GUI and your printf()
may cause the GUI to die.
The command line version of the simulator (mysim
) has no
problems with additional output. However, grading WILL be affected,
so you must turn off any degugging in the code you submit!
Even though you do not have all the source code, you may use gdb for debugging.
If you are comfortable with the console lc3 simulator, you may use gdb as you were shown in earlier recitations. Simply do the following:
gdb mysim
logic.c
. This is the only file you are modifying for this
assignment. The general gdb syntax is break functionName
run -norun
This start the lc3 simulator, but does not
execute any LC3 code. The lc3 simulator program is running, but will halt
at any mysim breakpoints you have set.continue
to return control to the LC3 console.If you prefer the GUI version of the lc3 simulator, you may still use gdb but you will need to do several additional steps.
mysim-tk
). ps -fu yourLogin | grep mysim
and you will see several processes listed. One will be the grep
,
one will be the mysim-tk
and the third will be the actual
simulator mysim
. The process ID will be the first number on the
line.logic.c
. This is the only file you are modifying for this
assignment. The general gdb syntax is break functionName
continue
This resumes the lc3 simulator.continue
to return control to the LC3 GUI.mysim.tar
using the
checkin
program or the Checkin tab of the web page.
This file may created by executing make submission
.
The mysim.tar
file should only contain your logic.c
file.
Type:
~cs270/bin/checkin P8 mysim.tar
We will check that the program compiles and test the execution of the remaining instructions and the operating system.