25.12.2012 Views

MIPS Assembly Language Programming

MIPS Assembly Language Programming

MIPS Assembly Language Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1.1. REPRESENTING INTEGERS 7<br />

Figure 1.3 shows the process of negating several numbers. Note that the negation<br />

of zero is zero.<br />

Figure 1.3: Examples of Negation Using Two’s Complement<br />

00000110 = 6<br />

1’s complement 11111001<br />

Add 1 11111010 = -6<br />

11111010 = -6<br />

1’s complement 00000101<br />

Add 1 00000110 = 6<br />

00000000 = 0<br />

1’s complement 11111111<br />

Add 1 00000000 = 0<br />

This representation has several useful properties:<br />

• The leftmost (most significant) bit also serves as a sign bit; if 1, then the number<br />

is negative, if 0, then the number is positive or zero.<br />

• The rightmost (least significant) bit of a number always determines whether or<br />

not the number is odd or even– if bit 0 is 0, then the number is even, otherwise<br />

the number is odd.<br />

• The largest positive number that can be represented in two’s complement notation<br />

in an n-bit binary number is 2 n−1 − 1. For example, if n = 8, then the<br />

largest positive number is 01111111 = 2 7 − 1 = 127.<br />

• Similarly, the “most negative” number is −2 n−1 , so if n = 8, then it is 10000000,<br />

which is −2 7 = − 128. Note that the negative of the most negative number<br />

(in this case, 128) cannot be represented in this notation.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!