MIPS Assembly Language Programming
MIPS Assembly Language Programming
MIPS Assembly Language Programming
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
4 CHAPTER 1. DATA REPRESENTATION<br />
length n are used, starting from zero, the largest number will be 2 n − 1.<br />
1.1.1.2 Conversion of Decimal to Binary<br />
An algorithm for converting a decimal number to binary notation is given in algorithm<br />
1.2.<br />
Algorithm 1.2 To convert a positive decimal number to binary.<br />
• Let X be an unsigned binary number, n digits in length.<br />
• Let D be a positive decimal number, no larger than 2 n − 1.<br />
• Let i be a counter.<br />
1. Let X = 0 (set all bits in X to 0).<br />
2. Let i = (n − 1).<br />
3. While i ≥ 0 do:<br />
(a) If D ≥ 2 i , then<br />
• Set Xi = 1 (i.e. set bit i of X to 1).<br />
• Set D = (D − 2 i ).<br />
(b) Set i = (i − 1).<br />
1.1.1.3 Addition of Unsigned Binary Numbers<br />
Addition of binary numbers can be done in exactly the same way as addition of<br />
decimal numbers, except that all of the operations are done in binary (base 2) rather<br />
than decimal (base 10). Algorithm 1.3 gives a method which can be used to perform<br />
binary addition.<br />
When algorithm 1.3 terminates, if c is not 0, then an overflow has occurred– the<br />
resulting number is simply too large to be represented by an n-bit unsigned binary<br />
number.