Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Peter Norton Programmer's Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

  Numeric data. The 8086 and 80386 are able to work with only four simple
  numeric data formats, all of which are integer values. The formats are
  founded on two building blocks: the 8-bit byte and the 16-bit (2-byte)
  word. Both of these basic units are related to the 16-bit processing
  capacity of the 8086. The byte is the more fundamental unit; and when the
  8086 and 80286 address memory, bytes are the basic unit addressed. In a
  single byte, these microprocessors can work with unsigned positive numbers
  ranging in value from 0 through 255 (that is, 28 possibilities). If the
  number is a signed value, one of the 8 bits represents the sign, so only 7
  bits represent the value. Thus a signed byte can represent values ranging
  from -128 through +127. (See Figure 2-2.)

  The 8086 and 80286 can also operate on 16-bit signed and unsigned values,
  or words. Words are stored in memory in two adjacent bytes, with the low-
  order byte preceding the high-order byte. (See the discussion of
  "back-words storage" on page 24.)

                                    Range
  Size        Signed?      Dec                     Hex
  --------------------------------------------------------------------------
   8          No           0 through 255           00H through FFH

   8          Yes          -128 through 0 through  80H through 00H through
                           +127                    7FH

  16          No           0 through 65,535        0000H through FFFFH

  16          Yes          -32,768 through 0       8000H through 0000H
                           through +32,767         through 7FFFH

  32          No           0 through 4,294,967,295 00000000H through
                                                   FFFFFFFFH

  32          Yes          -2,147,483,648 through  00000000H through
                           +2,147,483,647          00000000H through
                                                   7FFFFFFFH
  --------------------------------------------------------------------------

  Figure 2-2.  The six data formats used in the 8086 family. (Only the 80386
  supports 32-bit formats.)

  A word interpreted as an unsigned, positive number can have 216 different
  values ranging from 0 through 65,535. As a signed number, the value can
  range from -32,768 through +32,767.

  The 80386 differs from its predecessors in that it can also work with
  32-bit integer values, or doublewords. A doubleword represents a signed or
  unsigned 4-byte integer with any of 232 (or 4,294,967,295) different
  values.

  Character data. Character data is stored in the standard ASCII format,
  with each character occupying 1 byte. The 8086 family knows nothing about
  ASCII characters and treats them as arbitrary bytes, with one exception:
  The instruction set accommodates decimal addition and subtraction
  performed on binary coded decimal (BCD) characters. The actual arithmetic
  is done in binary, but the combination of the AF flag (see page 33) and a
  few special instructions makes it practical to work on decimal characters
  and get decimal results, which can easily be converted to ASCII.

  --------------------------------------------------------------------------
  Back-Words Storage
    While the PC's memory is addressed in units of individual 8-bit bytes,
    many operations involve 16-bit words. In memory, a 16-bit word is stored
    in any two adjacent 8-bit bytes. The least-significant byte of the word
    is stored in the lower memory location, and the most significant byte is
    stored in the higher memory location. From some points of view, storing
    a word this way is the opposite of what you might expect. Due to the
    backward appearance of this storage scheme, it is sometimes whimsically
    called "back-words" storage.

    --- Higher addresses -------.
    +---------------+
    |  9C   |  E6   |                   Value of word is E69CH
    +---------------+

    --- Higher addresses -------.
    +-------------------------------+
    |  4A   |  5B   |  00   |  12   |   Value of doubleword is 12005B4AH
    +-------------------------------+

    If you are working with bytes and words in memory, you should take care
    not to be confused by back-words storage. The source of the confusion
    has mostly to do with how you write data. For example, if you are
    writing a word value in hex, you write it like this: ABCD. The order of
    significance is the same as if you are writing a decimal number: The
    most significant digit is written first. But a word is stored in memory
    with the lowest address location first. So, in memory, the number ABCD
    appears as CDAB, with the bytes switched.
  --------------------------------------------------------------------------

  See Appendix C for more information on ASCII and the PC family's extended
  ASCII character set.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson