Comp226 - Practical Week 2

Using the Isem Simulator and its Assembler

Welcome to the wonderful world of Assembly Language programming!

  1. In the sample SPARC code directory is a SPARC program called what.s. Run it using tkisem, examine some of the registers etc look at the source code of what.s, and try to work out what it does. You should copy what.s to your own directory and then load it into tkisem to explore it.
    Does the program work if the argument is changed to 5, 1, 0, 10 or 20?
  2. Modify what.s so that it takes two arguments. If the arguments are both the same then the answer should agree with what what.s would get with that one argument. If they are different then you should figure out what your program should do based on the question above. Give your new program a sensible name and save it for later inspection by your tutor.
  3. Modify what.s to obtain sum.s which computes the sum of the the first 3 (or more generally whatever number is in the appropriate register) natural numbers.
  4. Write a SPARC assembler program same.s which places
    0 in %r7 if the contents of %r1, %r2 and %r3 are all different;
    1 in %r7 if the contents of %r1, %r2 and %r3 have some partial repetition;
    2 in %r7 if the contents of %r1, %r2 and %r3 are all the same.
    (Don't try too hard the first time you do this - I'll be happy if you to have to do some debugging).

    Be sure to put some numbers in %r1, %r2 and %r3 and test your program!

There's a lot here to do if this is the first time you've done any assembly language programming, so don't worry too much if you don't get it all done during your first prac, but do come back and finish it this week.

Always keep all your source code as Scott and/or Mike will want to check it.

If you don't have much Unix experience, here's a set of local unix notes that you might find helpful.


Kate and Mike, 2013. COMP226 home page