Reputation: 11
I am a computer science student, and for the life of me cannot find what an AND instruction does in MIPS.
Can anyone shed some light on it for me?
for instance what is the difference between:
ADD $t3, $t2, $t1
or
AND $t3, $t2, $t1
thanks in advance
Upvotes: 1
Views: 15342
Reputation: 4331
before understanding what this means for MIPS machines, you have to understand what AND and ADD mean:
if you the number 11 represented in bits:
....00001011 this is 11 in a computer.
and the number 5 ....00000101 this is 5 in a computer.
Write them below each other:
00001011
00000101
For the AND operation, you go through every column and write into the result column a 1 only if there are 1s in both lines: 00000001
This means 11 AND 5 = 1
On the other hand 11 ADD 5 = 16
If you want to read more about this you should lookt at 'logical AND operator' in google or what ever search engine you like!
Upvotes: 0
Reputation: 445
ADD performs arithmetic addition.
ADD $t3, $t2, $t1
will perform the following operation
$t3 = $t2 + $t1
Example: If $t2 was 00101011 and $t1 was 10010010, then the result would be:
00101011
10010010 +
----------
10111101
Whereas AND performs bitwise AND:
AND $t3, $t2, $t1
will perform the following:
$t3 = $t2 & $t1
Example:
00101011
10010010 &
----------
00000010
Upvotes: 1