kit
to the sde/kit
subdirectory is that rooted exactly two directories up from your code. The
example/make.mk
file assumes that the kit
directory
is located at ../../kit
relative to the directory you are in
when you type sde-make
. This is what I did to set up my
directory structure for this lab:
mkdir cs321 chmod og-rx cs321 cd cs321 mkdir sde cd sde cp -r /usr/local/sde/sde/examples . cp -r /usr/local/sde/sde/kit . cd .. ln -s sde/kit ln -s sde/examples mkdir lab2 cd lab2 ln -s ../sde/examples/make.mk mkdir hello cd hello ls ../../kitIf the last command does not show you the contents of the
kit
directory, you do not have the correct directory structure assumed in the
make.mk
file. If followed as above, you should have the following
directory structure:
cs321 ______/ | | \_____ / / \ \ / | | \ lab2 sde kit examples | / \ | | | hello kit examplesNote: You can locate the
sde
directory elsewhere in your home
directory tree as long as the cs321/kit
and
cs321/examples
symlinks point to the appropriate directories.
cs321/lab2/hello
subdirectory. Use the
following commands to copy the "Hello World" assembly code to your directory,
assemble it and run it. Note that the "hello" program in the SDE examples is
a C program while this hello.s program is in
MIPS assembly.
cp /usr/users/mdanfor/public_html/cs321-w07/code/hello/* . sde-make sde-run helloramIf this is the first time you have seen a MIPS assembly program, refer to Appendix A in the book for more details about the allowed syntax. In brief, the code has two sections, a data section for the "Hello world" string and a text portion containing the code to be executed. The
la
instruction loads the address into the register, which is most useful for
arrays and strings. The li
instruction loads a constant into
the register. The syscall
instruction executes the specified
syscall (see page A-44 for the syscall codes).
cs321/lab2
called sum
and change to that directory. Copy the Makefile from hello
and
edit it to change all instances of hello
to sum
.
Create an assembly file called sum.s
that takes two constants
and adds them together.
You can use printf to print the results by adding the following to your
.data
section:
format: .asciiz "The sum is %d\n"and by adding the following to your
.text
section:
la $a0,format # Put format string in $a0 move $a1,$v0 # Put the sum in $a1, $v0 contains the sum jal printf # Call the printf functionEmail your sum.s file to me before noon on Wednesday.