|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bit shift operations:
example |
|
|
hex |
dec. |
|
$r2 |
0000 |
0000 |
0000 |
0000 |
0000 |
0010 |
0001 |
0000 |
210 |
528 |
|
$r3 |
0000 |
0000 |
0000 |
0000 |
0000 |
1000 |
0100 |
0000 |
840 |
2112 |
|
$r4 |
0000 |
0000 |
0000 |
0000 |
0000 |
0000 |
0000 |
1000 |
8 |
8 |
|
$r5 |
|
|
|
|
|
|
|
|
|
|
$r8 |
0000 |
0000 |
0000 |
0000 |
0000 |
0000 |
0100 |
0010 |
42 |
66 |
|
$r9 |
0000 |
0000 |
0000 |
0000 |
0000 |
0000 |
0000 |
0101 |
5 |
5 |
|
example: |
|
|
addi $8,$0,0x42 # put two's comp. hex 42 into register 8 |
|
|
addi $9,$0,5 # put two's comp. 5 into register 9 |
|
|
sll $2,$8,3 # shift bits of reg 8 left by 3, result in reg 2 |
|
sllv $3,$8,$9 # shift bits of reg 8 left by amount in reg 9, |
|
|
|
|
#
result in reg 3 |
|
|
srl $4,$8,3 # shift bits of reg 8 right by 3,
result in reg 4 |
|
srlv $5,$8,$9 # shift bits of reg 8 right by amount in reg 9, |
|
|
|
#
result in reg 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|