Numbering System Basics
8 - 4 C2000 Microcontroller Workshop - Numerical Concepts
To load small two's complement numbers into larger registers:
The MSB of the original number must carry to the MSB of the number when represented in the
larger register.
1. Load the small number “right justified” into the larger register.
2. Copy the sign bit (the MSB) of the original number to all unfilled bits to the left in the
register (sign extension).
Consider our two previous values, copied into an 8-bit register:
Examples:
Original No. 0 1 1 0
2
= 6
10
1 1 1 1 0
2
= -2
10
1. Load low 0 1 1 0 1 1 1 1 0
2. Sign Extend 0 0 0 0 0 1 1 0 = 4 + 2 = 6 1 1 1 1 1 1 1 0 = -128 + 64 + ... + 2 = -2
Integer Basics
Integer Basics
Unsigned Binary Integers
0100b = (0*2
3
)+(1*2
2
)+(0*2
1
)+(0*2
0
) = 4
1101b = (1*2
3
)+(1*2
2
)+(0*2
1
)+(1*2
0
) = 13
Signed Binary Integers (2’s Complement)
0100b = (0*-2
3
)+(1*2
2
)+(0*2
1
)+(0*2
0
) = 4
1101b = (1*-2
3
)+(1*2
2
)+(0*2
1
)+(1*2
0
) = -3
2
3
±
2
n-1
2
2
2
1
2
0