created 06/20/2003

Chapter 12 Programming Exercises


For these programming exercises, use only those instructions that have been discussed so far in these notes:

and andi nor or ori sll srl xor xori

In the Settings menu of SPIM set Bare Machine ON, Allow Pseudo Instructions OFF, Load Trap File OFF, Delayed Branches ON, Delayed Loads ON, Mapped IO OFF, Quiet OFF.

Run the programs by setting the value of the PC to 0x400000 and then single stepping (pushing F10) or by multiple stepping (push F11 and enter a number of steps). Observing the results in the SPIM window.


*Exercise 1

Start out a program with the instruction that puts a single one-bit into register one:

ori   $1,$0,0x01

Now, by using only shift instructions and register to register logic instructions, put the pattern 0xFFFFFFFF into register $1. Don't use another andi, ori or xori instruction. You will need to use more registers than $1. See how few instructions you can do this in. My program has 11 instructions.

Click here to go back to the main menu.


End of Exercises