Browse over 20 million
homework answers & study documents

Accounting

4-Year Strategic Management Plan.

Type

Homework

Rating

Showing Page:
1/4
4 digit HEX number in MIPS
The first one is an hex number it is straightforward to convert it into binary. Every HEX digit can be converted in 4 binary digit as in the
following example
Ex $$_7=2^2+2^1+2^0=0111_$$
For your hex number 0x71014802 is
0x71014802 => 0111 0001 0000 0001 0100 1000 0000 0010
7 1 0 1 4 8 0 2
Regarding to a conversion from decimal to binary I suggest you converting the decimal in hex and then hex to binary, let's do an
example with a decimal (I choose 71014802 DEC)
71014802 => 0x43B9992 => 0000 0100 0011 1011 1001 1001 1001 0010
0 4 3 B 9 9 9 2
another way to convert a decimal number into a binary one is by dividing by two and picking the remainder... but it is a longer procedure
(you can find it here)
Anyway if the opcode is in a fixed position (26-31) the opcode can be simply obtained through a mask and shift right as follow:
opcode=(reg>>26)&0x3F
An algorithm to print a binary number can be like this:
void print_binary(int n) {
while (n) {
char bit = n & 0x1;
putchar (bit+'0');
n >>= 1;
}
putchar('\n');
}
char bits = (num >> (sizeof(num)*8 - 6)) & 0x3F;

Sign up to view the full document!

lock_open Sign Up

Sign up to view the full document!

lock_open Sign Up

Sign up to view the full document!

lock_open Sign Up

Anonymous
Just what I needed. This document gave me a good start on tailoring my own answer.

Anonymous
Documents were of surprisingly high quality, and not like anything I’ve seen on other sites. Very impressed at how even a university level assignment was handled.

Anonymous
Never disappoints. Thanks for being awesome!

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4