Logical
Operation
Logical
|
and
|
and
$1,$2,$3
|
$1
= $2 & $3
|
3
register operands; Logical AND
|
or
|
or
$1,$2,$3
|
$1
= $2 | $3
|
3
register operands; Logical OR
|
|
not
|
nor
$1,$1,$0
|
0=1/
1=0
|
convert
1 to 0
convert
0 to 1
|
|
and
immediate
|
andi $1,$0,100
|
$1
= 100
|
Logical
AND register, constant
|
|
or
immediate
|
ori
$1,$0,100
|
$1
=100
|
Logical
OR register, constant
|
|
shift
left logical
|
sll
$1,$2,10
|
$1
= $2 << 10
|
Shift
left by constant
|
|
shift
right logical
|
srl
$1,$2,10
|
$1
= $2 >> 10
|
Shift
right by constant
|
·
Example : 1.)
sll $t0,$t0,16 srl $t0,$t0,24
0101 0110 0111 1000 0000 0000 0000 0000 #sll
0000 0000 0000 0000 0000 0000 0101 0110 #srl
2.)
if $t1 contains 00000000 00000000 00000000
00101100
$t2
contains 00000000 00000000 00000000
00001010
What
is the final content of $8 after this instruction is performed?
1.
and $t0, $t1, $t2 # reg $t0 = $t1 & $t2
2.
or $t0,
$t1, $t2 # reg $t0 = $t1 & $t2
Solution:
For the AND operation, $t0 contains
00000000 00000000 00000000
00001000
For the OR operation, $t0 contains
00000000 00000000 00000000 00101110
By : Chong Cai Ning B031210080
0 comments:
Post a Comment