The MIPS R2000

Tom Kelliher, CS26

Sept. 17, 1996

Registers and Addressing

R2000 shows its RISC heritage.

See SPIM S20: A MIPS R2000 Simulator for more information.

R2000 Register Structure

  1. 32 general purpose registers: $0-- $31.

  2. $0 is constant 0.

  3. $31 is written with return address on jal.

  4. Examples of convention uses of remaining registers:

    1. $29 --- stack pointer.

    2. $1 --- reserved for assembler.

    3. $8-- $15 --- caller save.

Addressing

R2000 is a load/store architecture.

How are large constants constructed?

What is PC-relative mode used for?

Accessing memory:

  1. Datum size.

  2. Datum alignment.

Instructions

Instruction formats diagram:

  1. R Format --- Used for ALU instructions.

  2. I Format --- Used for immediate, branch instructions.

  3. J Format --- Used for j, jal instructions.

Assembly Language

Assembly language provides ``virtual machine.''

See Using the SPIM Simulator for more information.

Program Flow Control

The R2000 has no condition codes. Why not?

A few branch examples:

  1. b label --- unconditional branch to label.

  2. beq Rsrc1, Src2, label --- branch on equal. Rsrc1 must refer to a register; Src2 is either a register or an immediate.

  3. bgez Rsrc, label --- Branch on greater than zero.

The bare machine only has two branch instructions: beq, bne!

Sorting Example

Write an assembly language program corresponding to the following:

void bsort(int data[], int n)
{
   int i, j, temp;

   for (i = n - 1; i > 0; --i)
      for (j = 0; j < i; ++j)
         if (data[j] > data[j + 1])
         {
            temp = data[j];
            data[j] = data[j + 1];
            data[j + 1] = temp;
         }
}

Logic Instructions

How are bits set/reset?

How are fields masked?

Subroutines

  1. jal label --- subroutine call.

  2. jr reg --- subroutine return.

  3. Stack frames.

  4. Parameter passing.

R2000 Assembly Language Exercises



Thomas P. Kelliher
Mon Sep 16 23:30:57 EDT 1996
Tom Kelliher