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.
Want to see the other 1 page(s) in ECE 445 Sabato Notes.docx?JOIN TODAY FOR FREE!