MIPS Items Part 2 Flashcards
SLL or SRL
Shifting left by i bits gives the same result and multiplying by $2^i.
Shifting right is the same as integer division by 2 each bit.
And
$t2: 0000 0000 0000 0000 0000 1101 1100 0000
$t1: 0000 0000 0000 0000 0011 1100 0000 0000
and $t0, $t1, $t2
$t0: 0000 0000 0000 0000 0000 1100 0000 0000
Or
$t2: 0000 0000 0000 0000 0000 1101 1100 0000
$t1: 0000 0000 0000 0000 0011 1100 0000 0000
or $t0, $t1, $t2
$t0: 0000 0000 0000 0000 0011 1101 1100 0000
xor
1100
1010
0110
Standard Bit enumeration
Big Endianess
Big Endian is a convention where the most significant byte (MSB) of a word is stored at the lowest memory address.
Setting, Clearing, inverting bits in MIPS
OR to set, mask ex: 00001
AND to Clear, mask ex: 11110
Invert with XOR, just put the same digit in bit location
Setting, clearing, inverting specific bits in the value in C++
int value = 5; // Binary: 0000 0101
int position = 1;
value = value | (1 «_space;position); // Set the bit at position 1
// Result: Binary 0000 0111 (Decimal: 7)
—- Clear
int value = 7; // Binary: 0000 0111
int position = 1;
value = value & ~(1 «_space;position); // Clear the bit at position 1
// Result: Binary 0000 0101 (Decimal: 5)
—- Invert
int value = 5; // Binary: 0000 0101
int position = 0;
value = value ^ (1 «_space;position); // Invert the bit at position 0
// Result: Binary 0000 0100 (Decimal: 4)
Mask
is a value that allows us to operate with specific bits
&& and & in C++
&& is logical like if ( 5>1 && 4>3)
& is BITWISE AND
int a = 5; // Binary: 0101
int b = 3; // Binary: 0011
int result = a & b; // Binary: 0001 (Decimal: 1)