MIPS Assembly Language Programming
MIPS Assembly Language Programming
MIPS Assembly Language Programming
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
1.1. REPRESENTING INTEGERS 3<br />
Algorithm 1.1 To convert a binary number to decimal.<br />
• Let X be a binary number, n digits in length, composed of bits Xn−1 · · · X0.<br />
• Let D be a decimal number.<br />
• Let i be a counter.<br />
1. Let D = 0.<br />
2. Let i = 0.<br />
3. While i < n do:<br />
• If Xi == 1 (i.e. if bit i in X is 1), then set D = (D + 2 i ).<br />
• Set i = (i + 1).<br />
Figure 1.2: Examples of Conversion from Binary to Decimal<br />
Binary Decimal<br />
00000000 = 0 = 0 = 0<br />
00000101 = 2 2 + 2 0 = 4 + 1 = 5<br />
00000110 = 2 2 + 2 1 = 4 + 2 = 6<br />
00101101 = 2 5 + 2 3 + 2 2 + 2 0 = 32 + 8 + 4 + 1 = 45<br />
10110000 = 2 7 + 2 5 + 2 4 = 128 + 32 + 16 = 176