2.5 Logical OperationsThere are two new logical operations to be studied: shift left and shift right. These are represented by << in C and Java while shift right is represented by >> in C and >>> in Java. In MIPS assembly, the instructions for shift left are sll (shift left logical) and for shift right srl (shift right logical).sll $t2,$s0, 4 #reg $t2 = reg$s0 << 4 bitsThe shamt field in the R-format stands for shift amount and is used in shift instructions. Hence, the machine language version of the instruction above is:|0|0|16|10|4|0| where the format is |op|rs|rt|rd|shamt|function|-The encoding of sll is 0 in both the op and funct fields, rd contains $t2, rt contains $s0, and shamt contains 4. The rs field is unused, and thus is set to 0. Shift left logical provides a bonus benefit. Shifting left by I bits gives the same result as multiplying by 2i. For example, the above s11 shifts by 4, which gives the same result as multiplying 24 or 16.MIPS implements NOT by using NOR with one operand being zero.NOR = NOT(OR)-Masks ?conceal? bits.-NOT takes one operand and places 1 for 0 and 0 for 1. MIP designers decided to (simplicity favors regularity) have two operands by including the NOR instead of NOT.-We can produce a NOT operation from the NOR operation simply by setting one of the operands to 0.-AND and OR sometimes require arithmetic operations so MIPS also as the instructions ANDI and ORI.
STUDYBLUE makes things that make you better at school.
Things like
online flashcards with photos and audio.
Things like personalized quizzes and friendly reminders about when (and what) to study next.
Think of it as a digital backpack™: access to all of your study materials online and on your phone.
STUDYBLUE exists to make studying efficient and effective for every student, for free.
Join us.
“Simply amazing. The flash cards are smooth, there are many different types of studying tools, and there is a great search engine. I praise you on the awesomeness.”
Dennis