go to previous page   go to home page   go to next page hear noise

Answer:

OriginalShift Left Two
0110 11111011 1100
0x6F0xBC

If the original 8-bit pattern represented an integer, then shifting left by two positions is probably a mistake because a significant bit has been lost.


Shifty Program

This program does the shift you just performed in the question. It does it with 32-bit patterns, but for the right-most eight bits the result is the same.

## shiftTwo.asm
## 
## Program to logical shift left a pattern
        .text
        .globl  main

main:
        ori      $8, $0, 0x6F       # put bit pattern into register $8
        sll      $9, $8, 2          # shift left logical by two

## End of file

Running the program does the following. Since this time the shift was done with 32 bits, the high order one-bit was not lost.

Output of Shift Left Two Program

The register display in SPIM has been set to "binary" in the above.


QUESTION 3:

Do you think it would be OK to shift the contents of register $8 and put the result back in register $8 :

        ori      $8, $0, 0x6F       # put bit pattern into register $8
        sll      $8, $8, 2          # shift left logical by two