



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An overview of various decisions and logical operations in the mips instruction set. Topics include shifting and branching, logical operations such as and, or, and not, and data transfer instructions. The document also discusses the use of constant values and the lack of a not operation, as well as conditional branches and compiling if-then-else and while loops.
Typology: Study notes
1 / 6
This page cannot be seen from the preview
Don't miss anything!
Department of Computer Science
Wellesley College
Shift to the left
Shift to the right
Pop up
Push down
Byte, byte, byte
Decisions 3-
Logical operations
add add $s1,$s2,$s3 $s1=$s2 + $s
Arithmetic subtract sub $s1,$s2,$s3 $s1=$s2 - $s
add immediate addi $s1,$s2,100 $s1=$s2 + 100
and and $s1,$s2,$s3 $s1=$s2 & $ s
or or $s1,$s2,$s3 $s1=$s2 | $s
nor nor $s1,$s2,$s3 $s1=~($s2 | $s3)
Logical and immediate andi $s1,$s2,100 $s1=$s2 & 100
or immediate ori $s1,$s2,100 $s1=$s2 | 100
sll sll $s1,$s2,10 $s1=$s2 << 10
srl srl $s1,$s2,10 $s1=$s2 >> 10
Data transfer load word lw $s1,100($s2) $s1=Mem[$s2+100]
store word sw $s1, 100($s2) Mem[$s2+100]=$s
Decisions 3-
sll $t2, $s0, 4
op rs rt rd shamt funct
000000 00000 10000 01010 00100 00000
6 bits 5 bits 5 bits 5 bits 5 bits 6 bits
*R-type (for register) or R-format.
Decisions 3-
Alas, no NOT
*How does this help?
Decisions 3-
Conditional branches
Decisions 3-
Compiling if-then-else clauses
o Let’s try an easy one
if (i == j)
f = g + h;
else
f = g - h;
o We assume variable f to j
correspond to registers
$s0 to $s4.
i==j?
i=j
i≠j
Else:
f=g-h f=g+h
Exit:
Decisions 3-
Compiling while loops
o One only slightly harder
while (save[i] == k)
i += 1;
o We assume that i and k
correspond to registers
$s3 and $r5 and the base
address of save is in $s6.
$t1==k?
$t1=k
$t1≠k
i+=
Exit:
calc addr
of save[i]
ld to $t
Loop:
Decisions 3-