Computer Systems Design


Chapter 3: Instructions: Language of the Machine

Homework: Read sections 3.1 3.2 3.3

3.4 Representing instructions in the Computer (MIPS)

Register file

Homework: 3.2.

The fields of a MIPS instruction are quite consistent

    op    rs    rt    rd    shamt  funct   <-- name of field
    6     5     5     5      5      6      <-- number of bits

R-type instruction (R for register)

Example: add $1,$2,$3

I-type (why I?)

    op    rs    rt   address
    6     5     5     16

Examples: lw/sw $1,1000($2)

RISC-like properties of the MIPS architecture.

Branching instruction

slt (set less-then)

Example: slt $3,$8,$2

beq and bne (branch (not) equal)

Examples: beq/bne $1,$2,123

blt (branch if less than)

Examples: blt $5,$8,123

ble (branch if less than or equal)

bgt (branch if greater than)

bge (branch if greater than or equal)

Note: Please do not make the mistake of thinking that

    stl $1,$5,$8
    beq $1,$0,L
is the same as
    stl $1,$8,$5
    bne $1,$0,L

It is not the case that the negation of X < Y is Y < X.

End of Note

Homework: 3.12

J-type instructions (J for jump)

        op   address
        6     26

j (jump)

Example: j 10000

jr (jump register)

Example: jr $10

jal (jump and link)

Example: jal 10000


======== START LECTURE #8 ========

Notes
  1. Can now get to homework solutions right from the home page. A password is still required.
  2. Syllabus added.
  3. Lectures through #7 now on course pages.
  4. Homework solutions through #6 now on course pages.
End of Notes

I type instructions (revisited)

addi (add immediate)

Example: addi $1,$2,100

slti (set less-than immediate)

Example slti $1,$2,50

lui (load upper immediate)

Example: lui $4,123

Homework: 3.1, 3.3, 3.4, and 3.5.

Allan Gottlieb