This preview shows page 1. Sign up to view the full content.
Unformatted text preview: F16 Data types 155 (The subscript indicates the number base, so the range above is expressed in decimal first and in hexadecimal second. Note how the hexadecimal value 'F' represents a binary number of all' 1 's.) This looks like a large range, and indeed is adequate for most purposes, though the programmer must be aware of its limitations. Adding two unsigned numbers near the maximum value within the range will give the wrong answer, since the correct answer cannot be represented within 32 bits. The C flag in the program status register gives the only indication that something has gone wrong and the answer is not to be trusted. If a large number is subtracted from a small number, the result will be negative and cannot be represented by an unsigned integer of any size. Signed integers In many cases it is useful to be able to represent negative numbers as well as positive ones. Here the ARM supports a 2's complement binary notation where the value of the top bit is made negative; in a 32bit signed integer all the bits have the same value as they have in the unsigned case apart from bit 31, which has the value 231 instead of+231. Now the range of numbers is: 2 147 483 64810 to +2 147 483 64710 = 8000000016 to 7FFFFFFF,6 Note that the sign of the number is determined by bit 31 alone, and the positive integer values have exactly the same representation as their unsigned equivalents. The ARM, in common with most processors, uses the 2's complement notation for signed integers because adding or subtracting them requires exactly the same Boolean logic functions as are needed for unsigned integers, so there is no need to have separate instructions (the exception being multiplication with a full 64bit result; here ARM does have separate signed and unsigned instructions). The 'architectural support' for signed integers is the V flag in the program status registers which has no use when the operands are unsigned but indicates an overflow (out of range) error when signed operands are combined. The source operands cannot be out of range since they are represented as 32bit values, but when two numbers near the extremes of the range are added or subtracted, the result could fall outside the range; its 32bit representation w...
View Full
Document
 Spring '09
 Staff

Click to edit the document details