sections in this module City College of San Francisco - CS270
Computer Architecture

Module: MIPS-I
module list

Basic MIPS Problems

Problem One:

The NOT instruction in MIPS is a pseudoinstruction. Normally it is implemented using a NOR instruction. Answer the following questions:

  1. Can you implement the operation not  $t0,$t1  where $t0 is set to the bitwise complement of $t1 using the nor instruction? (HINT: you can do this in a single instruction - use $0)
  2. Can you implement not $t0, $t1 using the xor instruction? (HINT: This will take several instructions.)
You can check 1. using the simulator. Simply write a three-line program that defines __start and uses the not instruction. Let's go on to 2:

Let's revisit the truth-table for XOR:

 X   Y  X XOR Y
0
0
0
0
1
1
1
0
1
1
1
0

Look at the highlighted cells in this truth-table (the four cells in the lower right corner). This is a complement operation! Examining this, we can see that the complement of any bit of Y is Y XOR 1 ! Thus, we simply need to XOR $t1 with a 32-bit value that is all ones! This sounds easy, but we must create this value in a register in order to perform our operation. Here is one way:

lui  $at, 0xffff
sra  $at,$at,16

Then the complement of $t1 is simply   xor  $t0, $t1, $at


Prev This page was made entirely with free software on linux:  
the Mozilla Project
and Openoffice.org    
Next

Copyright 20125 Greg Boyd - All Rights Reserved.