Download presentation
Presentation is loading. Please wait.
1
MIPS instruction encoding
j 0x400090 “jump” instruction: Address 0x400090: Because this address has only 23 bits, we’ll pad the leading bits by three 0’s, making a total of 26 bits 4. The entire bit pattern is 5. Reorganize in group of 4-bits 6. Hex pattern: 0x
2
CSCI206 - Computer Organization & Programming
Signed Integers zyBook: 5.5
3
How to actually do add or sub?
If the registers r1, r2, hold values 3, -2, how does the operation add $r3, $r1, $r2 work? In general, how does compute do x = 4 + (-3)
4
How are numbers represented?
A 3-bit system would have 8 different values, -4 through 3, how do we operate such that 3 + (-2) == 1? 011 + (???) = 001 -4 -3 -2 -1 1 2 3 ? 000 001 010 011
5
How to represent signed integers
1. Sign Magnitude The leading bit represents the sign, 0 for positive, 1 for negative, followed by the value (magnitude). -127 1 -126
6
How to represent signed integers
2. 1’s Complement The leading bit represents the sign, invert the rest of the bits if a negative value. -0 1 -1
7
How to represent signed integers
3. 2’s Complement The leading bit represents the sign, invert the rest of the bits if a negative value, and add 1 to the last bit. -1 1 -2 -9
8
How to represent signed integers
4. Biased (excess) B = 3 p x 000 -3 001 -2 010 -1 011 100 1 101 2 110 3 111 4 B = 127 p x -127 128 -126 127 9 A bias value, B, is usually chosen to be roughly in the middle of the range. The actual value x of a bit pattern p is x = p - B. Given x, the bit pattern should be p = x + B.
9
Number Encoding Summary
Sign Magnitude first digit is sign (0=positive), remaining digits are magnitude 1’s Complement first digit is sign, remaining bits are magnitude. Negative numbers are stored inverted. 2’s Complement Same as 1’st complement, but negative numbers are inverted + 1. Biased redefine zero to be in the middle of the range. The distance from the virtual zero is the magnitude. Stop, do activity
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.