slide4 - Computer Architecture CPSC 321 E. J. Kim Over view...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Computer Architecture CPSC 321 E. J. Kim Over view Logical I nstructions Shifts Bitwise Oper ations Up until now, weve done arithmetic ( add , sub,addi ), memory access ( lw and sw ), and branches and jumps. All of these instructions view contents of register as a single quantity (such as a signed or unsigned integer) New Perspective : View contents of register as 32 bits rather than as a single 32-bit number Since registers are composed of 32 bits, we may want to access individual bits (or groups of bits) rather than the whole. I ntroduce two new classes of instructions: Logical Operators Shift I nstructions Logical Oper ator s Two basic logical operators: AND: outputs 1 only if both inputs are 1 OR: outputs 1 if at least one input is 1 Logical Oper ator s Truth Table: standard table listing all possible combinations of inputs and resultant output for each Truth Table for AND and OR A B AND OR 1 1 1 1 Two basic logical oper ator s: AND: outputs 1 only if both inputs are 1 OR: outputs 1 if at least one input is 1 Logical Oper ator s I nstruction Names: and , or : Both of these expect the third argument to be a register andi , ori : Both of these expect the third argument to be an immediate MI PS Logical Operators are all bitwise , meaning that bit 0 of the output is produced by the respective bit 0s of the inputs, bit 1 by the bit 1s, etc. Uses for Logical Oper ator s Note that ANDing a bit with 0 produces a 0 at the output while ANDing a bit with 1 produces the original bit. This can be used to create a mask . Example: 1011 0110 1010 0100 0011 1101 1001 1010 0000 0000 0000 0000 0000 1111 1111 1111 The result of ANDing these two is: 0000 0000 0000 0000 0000 1101 1001 1010 The second bit string in the example is called a mask . I t is used to isolate the rightmost 12 bits of the first bit string by masking out the rest of the string (e.g. setting it to all 0s). Uses for Logical Oper ator s Thus, the and operator can be used to set certain portions of a bit string to 0s, while leaving the rest alone. I n particular, if the first bitstring in the above example were in $t0, then the following instruction would mask it: andi $t0,$t0,0xFFF Similarly, note that OR ing a bit with 1 produces a 1 at the output while OR ing a bit with 0 produces the original bit.ing a bit with 0 produces the original bit....
View Full Document

Page1 / 34

slide4 - Computer Architecture CPSC 321 E. J. Kim Over view...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online