CSE 378 HomeWork 1

Spring 2009
Due: Monday 4/6
Turnin: https://catalysttools.washington.edu/collectit/dropbox/zahorjan/5621

Purpose

This assignment is a warm up. It's intended to reinforce the facts that instructions are bit strings; that the assembler provides a language that makes producing those bit strings a little easier; that hexadecimal is a joy compared to bit strings. It's also intended to give you a tiny bit of experience writing short sequences of instructions. Finally, it verifies that you can set up the Cebollita software and launch it before its use becomes critical.

We're taking only a quick look at these topics here - we'll do more once we've covered enough of the instruction set that you can write some interesting code.

Hand in your answers to all but the last question as a pdf file. Hand in your answer to the last question as a file named hw1.s.

Paper and Pencil Questions

  1. Here are four MIPS instructions, given as 32 bits. Disassemble them, that is, give assembly language equivalents. (I'm inserting blanks every 4 bits to make everyone's life a little easier.)
    0000 0000 1000 0101 0001 0000 0010 0000
    0000 0000 1100 0111 0001 1000 0010 0000
    0000 0000 0110 0010 0001 1000 0010 0010
    0000 0000 0000 0011 0001 1000 1000 0011
    

    Reference Information You'll need to decode instructions. Sources of information are: the green card, just under the text front cover; appendix B.10 of the text; the full MIPS instruction set description in MIPS32 Architecture for Programmers, Volume II, a copy of which is linked from the miscellaneous documentation page for this course; the Cebollita Instruction Encoding and Operation Specification.

  2. Now just write the four instructions in hex(adecimal). (This is a bit of getting used to hex. That's all.)

  3. Look at your answer to question 1 (the assembler instructions). Write their effect as an easy-for-humans-to-read expression. Use a form like this:
    $12 = $10 - 100*$11 + 3
    which would mean "multiply the contents of register 11 by 100, subtract that from the contents of register 10, add 3, and assign the result to register 12". Note that we're assuming here we care only about the "final result," not any intermediate results that might be computed. (For example, the code might have used register 21 to hold 100*$11, but we're not mentioning that in this answer.)

Cebollita Setup

  1. Follow the directions on the "Setup and Downloads" page linked from the Cebollita home page to download, install, and set up Cebollita.

    Do this on whatever machine(s) you're going to want to run on. (Remember that the companion tool, SMOK, will run only on Windows. Cebollita runs anywhere, though.) Follow the instructions up through the "Testing the Installation" section. This will require that you have set up your CLASSPATH environment variable, and established the various cebXXX aliases.

  2. Now navigate to any old directory (and, in particular, out of the myPrograms directory the Cebollita install had you go into). Write, assemble, link, and execute code that puts the most negative possible 32-bit (2's complement) number into register 10.
    • Use your favorite editor to create a file, hw1.s. For reasons that will be explained shortly, your code should come after this (which you can cut and paste into your .s file):
      .text
      	.global	__start
      __start:
      
    • To assemble, say cebasm hw1.s. That should produce file hw1.o.
    • To link, say ceblink hw1.o. That should produce file a.exe.
    • To "dump" the contents of a.exe, say cebdumpe a.exe That will print some things you won't understand, followed by some things you will (involving the instructions you wrote). You're doing this now just so you know it exists later - there's no more to be gotten out of it than that.
    • Now run your program:
      • Run command cebsim a.exe. A GUI for the simulator should appear.
      • Hit Step a few times. Check to see that your program got the right answer (by looking at the register contents pane). Notice that if you keep hitting step, or hit Run, the processor just keeps execute instructions out into places you didn't put any instructions. That's correct behavior for it (and a bug for you, but one we won't fix right now).

Turn-in

https://catalysttools.washington.edu/collectit/dropbox/zahorjan/5621