Page 327 - Embedded Microprocessor Systems Real World Design
P. 327
Adding the next pair of digits (in the 2’s position):
0 + 1 + 1 (the carry from the last add) = 0 with a carry
4’s digit: 0 + 1 + 1 (carry) = 0 with a carry
8’s digit: 1 + 0 + 1 (carry) = 0 with a carry
This is illustrated as follows:
Carry: 1111
1001
+0111
-
10000 = 16.
We can add hex numbers the same way:
9 + 7 = 0 with a carry of 1, or lol6 or 1610
In hex, a carry occurs when the sum of two digits exceeds F16.The following are a couple
of examples:
Carry: 100
020516 = 51710
&E0716= 359110
1OOC16= 410810
Carry: 111
267816 = 984810
+h%416 = 43,69010
Dl2216 = 53,53810
Negative Numbers and Computer Representation of Numbers
In the examples so far, we’ve worked with 4bit values and added digits as needed when a
result grew beyond that. In a computer, numbers are represented as a multiple of hex digits
usually 2,4, or 8 digits. The number of digits is dependent on the word size of the computer
(Most microprocessors can concatenate words to make bigger values, but that is unimpor-
tant for this discussion). An &bit machine will use 2 hex digits, a 16-bit machine will use 4
digits, and a 32-bit machine will use 8 digits. So the value 2A16 would be represented as
follows:
8 bit: 2A
16 bit: 002A
32 bit: 0000002A
This may seem like an insignificant point since all three numbers are the same. The only
difference between them is the number of leading zeros in front of the significant digits.
However, the word width is important when dealing with negative numbers.
308 Appendix B