CSE 378, Autumn 1997 | Assignment #2 | Due: Wednesday, Oct 15th, 1997 |
Because reading assembly language programs can be difficult, it is very important when writing assembly language programs to provide explanatory comments in your code. Please do so for this assignment.
Your procedure MUST be named problem1 so that it can be tested easily. We have provided some code that you can use to help out with testing your procedure. You should load 3 files into spim or xspim in order to use our test code: "lib.s", "p1main.s", and the file you create that contains your procedure. Our test code implements a procedure called main, which sets up the appropriate arguments and then calls your procedure problem1. When your procedure returns, then main prints out the value returned by your code. The correct result that our test code should print is 53.
2. Write a leaf procedure in MIPS assembly language
that converts a character string of decimal ASCII digits into the
integer value represented by the string. For example, the input
string "2739" should be converted into the integer 2739.
Your procedure will take one argument: a pointer to the null
terminated string of ASCII digits in register $a0. Your
procedure will return in register $v0 the integer value
represented by the string. Your procedure does not need to
handle negative numbers. If a non-digit character appears
in the string, your procedure should return the value -1
in register $v0. There is a table in Chapter 3 of your book
that describes the value associated with each ASCII character.
Your procedure MUST be named problem2 so that it
can be tested easily.
We have provided some code that you can use to help out with
testing your procedure. You should load 3 files into spim
or xspim in order to use our test code: "lib.s", "p2main.s",
and the file you create that contains your procedure.
Our test code implements a procedure called
main, which sets up the appropriate arguments and then calls
your procedure problem2. When your procedure returns,
then main prints out the value returned by your code.
The correct result that our test code should print is 36107.
3. (extra credit)
Write a leaf procedure in MIPS assembly that determines whether
the machine is little or big endian. Your procedure will not
take any arguments. Your procedure should return in register $v0
the value 0 if the machine is little endian, and the value 1 if
the machine is big endian.
The protocol for testing your procedure is the same as for the
previous two questions.
The assembly files that we provide for you are located in the spim library directory. Adding the following command to your .cshrc file will give you access to these files.
source /cse/courses/cse378/97au/bin/spim-setupFor more information on getting started with spim and xspim, see the course help documents web pages.