CMPT 295 - Unit - Instruction Set Architecture

I do not like computer jokes…not one bit!

Lecture 24:

Last Lecture

Today’s Menu

Example of another ISA: MIPS

(Transcriber’s note: rest of slide is blank)

Example of an ISA: MIPS

FIGURE A.6.1 MIPS registers and usage conventions.

Register name Number Usage
$zero 0 constant 0
$at 1 reserved for assembler
$v0 2 expression evaluation and results of a function
$v1 3 expression evaluation and results of a function
$a0 4 argument 1
$a1 5 argument 2
$a2 6 argument 3
$a3 7 argument 4
$t0 8 temporary (not preserved across call)
$t1 9 temporary (not preserved across call)
$t2 10 temporary (not preserved across call)
$t3 11 temporary (not preserved across call)
$t5 12 temporary (not preserved across call)
$t6 13 temporary (not preserved across call)
$t7 14 temporary (not preserved across call)
$s0 15 saved temporary (preserved across call)
$s1 16 saved temporary (preserved across call)
$s2 17 saved temporary (preserved across call)
$s3 18 saved temporary (preserved across call)
$s4 19 saved temporary (preserved across call)
$s5 20 saved temporary (preserved across call)
$s6 21 saved temporary (preserved across call)
$s7 22 saved temporary (preserved across call)
$t8 24 temporary (not preserved across call)
$t9 25 temporary (not preserved across call)
$k0 26 reserved for OS kernel
$k1 27 reserved for OS kernel
$gp 28 pointer to global area
$sp 29 stack pointer
$fp 30 frame pointer
$ra 31 return address (used by function call)

Source: Page A-24 in Patterson and Hennessy

MIPS Memory Model

FIGURE 2.13 – The MIPS memory allocation for program and data

These addresses are only a software convention, and not part of the MIPS architecture. The stack pointer is initialized to 7fff fffchex\text{7fff fffc}_{\text{hex}} and grows down toward the segment. At the other end, the program code (“text”) starts at 0040 0000hex\text{0040 0000}_{\text{hex}}. The static data starts at 1000 0000hex\text{1000 0000}_{\text{hex}}. Dynamic data, allocated by malloc in C and by new in Java, is next. It grows up toward the stack and in an area called the heap. The global pointer: $gp, is set to an address to make it easy to access data. It is initialized to 1000 8000hex\text{1000 8000}_{\text{hex}} so it can access from 1000 000hex\text{1000 000}_{\text{hex}} to 1000 ffffhex\text{1000 ffff}_{\text{hex}} using the positive and negative 16-bit offsets from $gp. The information is also found in Column 4 of the MIPS Reference Data Card at the front of the book.

Source: Page 104 in Patterson and Hennessy

Register/Address Label
(top) $sp -> 7fff ffffhex\text{7fff ffff}_{\text{hex}} Stack (arrow pointing down)
  Dynamic data (arrow pointing up)
(between Static Data and Text) $gp -> 1000 8000hex\text{1000 8000}_{\text{hex}}, 1000 0000hex\text{1000 0000}_{\text{hex}} Static Data
(bottom) $pc -> 0040 0000hex\text{0040 0000}_{\text{hex}} Text
(bottom) 0 Reserved

Example of an ISA: MIPS

Activity

Example of an ISA: MIPS

(Sub)set of instructions:

MIPS assembly language instructions Semantic (i.e., Meaning) Corresponding MIPS machine instructions
lw $s1, 20($s2) $s1 = M[$s2 + 20] ?
sw $s1, 20($s2) M[$s2 + 20] = $s1 ?
add $s1, $s2, $s3 $s1 = $s2 + $s3 ?
sub $s1, $s2, $s3 $s1 = $s2 - $s3 ?
beq $s1, $s2, 25 if ($s1 == $s2) go to PC + 4 + 100 ?
j 2500 go to 10000 (2500 * 4 bytes) ?
jal 2500 $ra = PC + 4; go to 10000 ?

Format/syntax of these bit patterns are all the question marks.

A closer look at MIPS’ add instruction

Total: 32 bits

Let’s examine an ISA: MIPS (3 of 3)

Register name Number Usage
$zero 0 constant 0
$at 1 reserved for assembler
$v0 2 expression evaluation and results of a function
$v1 3 expression evaluation and results of a function
$a0 4 argument 1
$a1 5 argument 2
$a2 6 argument 3
$a3 7 argument 4
$t0 8 temporary (not preserved across call)
$t1 9 temporary (not preserved across call)
$t2 10 temporary (not preserved across call)
$t3 11 temporary (not preserved across call)
$t5 12 temporary (not preserved across call)
$t6 13 temporary (not preserved across call)
$t7 14 temporary (not preserved across call)
$s0 15 saved temporary (preserved across call)
$s1 16 saved temporary (preserved across call)
$s2 17 saved temporary (preserved across call)
$s3 18 saved temporary (preserved across call)
$s4 19 saved temporary (preserved across call)
$s5 20 saved temporary (preserved across call)
$s6 21 saved temporary (preserved across call)
$s7 22 saved temporary (preserved across call)
$t8 24 temporary (not preserved across call)
$t9 25 temporary (not preserved across call)
$k0 26 reserved for OS kernel
$k1 27 reserved for OS kernel
$gp 28 pointer to global area
$sp 29 stack pointer
$fp 30 frame pointer
$ra 31 return address (used by function call)

MIPS - Design guidelines

3) In terms of machine instruction format: 1. Create as few of them as possible 2. Have them all of the same length and same format! 3. If we have in different machine instruction formats, then position the fields that have the same purpose in the same location in the format

MIPS ISA designers compromise

Summary

Next lecture