### Q.5 What types of unsigned data representation (with variable) are available in Assembly Language? Write examples of any two of those types.

In**unsigned**representation, only positive numbers are represented. Instead of the high being interpretted as the sign of the integer, the high order bit is part of the number. An unsigned number has one power of two greater range than a signed number of the same number of bits.

bit pattern | two’s comp | unsigned | ||

000 | 0 | 0 | 0 | 0 |

001 | 1 | 1 | 1 | 1 |

010 | 2 | 2 | 2 | 2 |

011 | 3 | 3 | 3 | 3 |

100 | -0 | -3 | -4 | 4 |

101 | -1 | -2 | -3 | 5 |

110 | -2 | -1 | -2 | 6 |

111 | -3 | -0 | -1 | 7 |

### floating point numbers

Floating point numbers are the computer equivalent
of scientific notation or “engineering notation”. A floating point
number consists of a fraction (binary or decimal) and an exponent
(bianry or decimal). Both the fraction and the exponent each have a sign positive or negative.

In the past, processors tended to have proprietary
floating point formats, although with the development of an IEEE
standard, modern processors use the same format. Floating point
numbers are almost always binary representations, a few early
processors had binary coded decimal representations. Many processors
(especially early mainframes and early microprocessors) did not have any
hardware support for floating point numbers. Even when commonly
available it was often in an optional processing unit such as in the
IBM 360/370 series or coprocessor such as in the Motorola 680x0 and
pre-Pentium Intel 80x86 series.

Hardware floating point support usually consists of two sizes, called

**single precision**for the smaller and**double precision**for the larger. Usually the double precision format had twice as many bits as the single precision format hence, the names single and double. Double precision floating point format offers greater range and precision, while single precision floating point format offers better space compaction and faster processing.**F_floating**

format (single precision floating), DEC VAX, 32 bits, the first bit (high order bit in a register, first bit in memory) is the sign magnitude bit one=negative, zero=positive or zero, followed by 15 bits of an excess 128 binary exponent, followed by a normalized 24-bit fraction with the redundant most significant fraction bit not represented. Zero is represented by all bits being zero allowing the use of a longword CLR to set a F_floating number to zero. Exponent values of 1 through 255 indicate true binary exponents of -127 through 127. An exponent value of zero together with a sign of zero indicate a zero value. An exponent value of zero together with a sign bit of one is taken as reserved which produces a reserved operand fault if used as an operand for a floating point instruction. The magnitude is an approximate range of .29*10

^{-38}through 1.7*10

^{38}. The precision of an F_floating datum is approximately one part in 2

^{23}, or approximately seven decimal digits).

**32 bit floating**

This format single precision floating), AT&T DSP32C, 32 bits, the first bit (high order bit in a register, first bit in memory is the sign magnitude bit (one=negative, zero=positive or zero), followed by 23 bits of a normalized two’s complement fractional part of the mantissa, followed by an eight bit exponent. The magnitude of the mantissa is always normalized to lie between 1 and 2. The floating point value with exponent equal to zero is reserved to represent the number zero (the sign and mantissa bits must also be zero; a zero exponent with a nonzero sign and/or mantissa is called a “dirty zero” and is never generated by hardware; if a dirty zero is an operand, it is treated as a zero). The range of nonzero positive floating point numbers is N = [1 * 2

^{-127}, [2-2

^{-23}] * 2

^{127}] inclusive. The range of nonzero negative floating point numbers is N = [-[1 + 2

^{-23}] * 2

^{-127}, -2 * 2

^{127}] inclusive.

**40 bit floating**

This format (extended single precision floating), AT&T DSP32C, 40 bits, the first bit (high order bit in a register, first bit in memory) is the sign magnitude bit one=negative, zero=positive or zero, followed by 31 bits of a normalized two’s complement fractional part of the mantissa, followed by an eight bit exponent. This is an internal format used by the floating point adder, accumulators, and certain DAU units. This format includes an additional eight guard bits to increase accuracy of intermediate results.

**D_floating**

This format double precision floating, DEC VAX, 64 bits, the first bit (high order bit in a register, first bit in memory) is the sign magnitude bit one=negative, zero=positive or zero), followed by 15 bits of an excess 128 binary exponent, followed by a normalized 48-bit fraction with the redundant most significant fraction bit not represented. Zero is represented by all bits being zero (allowing the use of a quadword CLR to set a D_floating number to zero). Exponent values of 1 through 255 indicate true binary exponents of -127 through 127. An exponent value of zero together with a sign of zero indicate a zero value. An exponent value of zero together with a sign bit of one is taken as reserved which produces a reserved operand fault if used as an operand for a floating point instruction. The magnitude is an approximate range of .29*10

^{-38}through 1.7*10

^{38}. The precision of an D_floating datum is approximately one part in 2

^{55}, or approximately 16 decimal digits.

#### When I use an unsigned integer

you should always use unsigned integers, except in the following cases:1-When the entity you are representing with your variable is inherently a signed value.

2-When dealing with standard C library functions that required an int to be passed to them.

3-In certain weird cases such as I documented here.
Now be advised that many people strongly disagree with me on this topic. Naturally I don’t find their arguments persuasive.

Unsigned integers can be of all sizes,

#### Why I use an unsigned integer

- By using an unsigned integer, you are conveying important information to a reader of your code concerning the expected range of values that a variable may take on.
- They are more efficient.
- Modulus arithmetic is completely defined.
- Overflowing an unsigned data type is defined, whereas overflowing a signed integer type could result in World War 3 starting.
- You can safely perform shift operations.
- You get a larger dynamic range.
- Register values should nearly always be treated as unsigned entities – and embedded systems spend a lot of time dealing with register values.

**Example**Unsigned integers can be of all sizes,

`int`,`long`, and`short`. The range of unsigned integers is through , where k is the number of bits, so for 16 bits the maximum unsigned integer is 65535. Unsigned integer constants are written using the suffix,`u`or`U`:The two suffixes can be combined to write an0xFFFFU 123U 0777u

`unsigned long`:12345678UL 0X8FFF FFFFLU

## Post a Comment