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]

  The tables in Figure B-4 show the decimal equivalent of each hex digit in
  the first five digit positions, which covers the complete address-space
  arithmetic used in the 8086. As we'll demonstrate, you can use these
  tables to convert between hexadecimal and decimal numbers.

      First Position
  Hex                      Dec
  --------------------------------------------------------------------------
  . . . . 0                 0
  . . . . 1                 1
  . . . . 2                 2
  . . . . 3                 3
  . . . . 4                 4
  . . . . 5                 5
  . . . . 6                 6
  . . . . 7                 7
  . . . . 8                 8
  . . . . 9                 9
  . . . . A                10
  . . . . B                11
  . . . . C                12
  . . . . D                13
  . . . . E                14
  . . . . F                15
  --------------------------------------------------------------------------

      Second Position
  Hex                      Dec
  --------------------------------------------------------------------------
  . . . 0 .                  0
  . . . 1 .                 16
  . . . 2 .                 32
  . . . 3 .                 48
  . . . 4 .                 64
  . . . 5 .                 80
  . . . 6 .                 96
  . . . 7 .                112
  . . . 8 .                128
  . . . 9 .                144
  . . . A .                160
  . . . B .                176
  . . . C .                192
  . . . D .                208
  . . . E .                224
  . . . F .                240
  --------------------------------------------------------------------------

      Third Position
  Hex                      Dec
  --------------------------------------------------------------------------
  . . 0 . .                   0
  . . 1 . .                 256
  . . 2 . .                 512
  . . 3 . .                 768
  . . 4 . .                1024
  . . 5 . .                1280
  . . 6 . .                1536
  . . 7 . .                1792
  . . 8 . .                2048
  . . 9 . .                2304
  . . A . .                2560
  . . B . .                2816
  . . C . .                3072
  . . D . .                3328
  . . E . .                3584
  . . F . .                3840
  --------------------------------------------------------------------------

      Fourth Position
  Hex                      Dec
  --------------------------------------------------------------------------
  . 0 . . .                     0
  . 1 . . .                  4096
  . 2 . . .                  8192
  . 3 . . .                12,288
  . 4 . . .                16,384
  . 5 . . .                20,480
  . 6 . . .                24,576
  . 7 . . .                28,672
  . 8 . . .                32,768
  . 9 . . .                36,864
  . A . . .                40,960
  . B . . .                45,056
  . C . . .                49,152
  . D . . .                53,248
  . E . . .                57,344
  . F . . .                61,440
  --------------------------------------------------------------------------

      Fifth Position
  Hex                      Dec
  --------------------------------------------------------------------------
  0 . . . .                      0
  1 . . . .                 65,536
  2 . . . .                131,072
  3 . . . .                196,608
  4 . . . .                262,144
  5 . . . .                327,680
  6 . . . .                393,216
  7 . . . .                458,752
  8 . . . .                524,288
  9 . . . .                589,824
  A . . . .                655,360
  B . . . .                720,896
  C . . . .                786,432
  D . . . .                851,968
  E . . . .                917,504
  F . . . .                983,040
  --------------------------------------------------------------------------

  Figure B-4.  The decimal equivalent of each hex digit position.

  Here is how you use these tables to convert a hex number to a decimal
  number. We'll use number A1B2H as an example. Look up each hex digit in
  the table corresponding to its position and then add the decimal values:

      2         in the first position is           2
      B         in the second position is        176
      1         in the third position is         256
      A         in the fourth position is     40,960
                                              ------
                The total is                  41,394

  To use these tables to convert a decimal number to hex, the process is
  equally simple to perform, but slightly more complicated to describe. Once
  again, we'll work through an example. We'll use the decimal number 1492.

  Work from the table for the fifth position to the table for the first
  position. In the fifth-position table, find the biggest hex digit with a
  value that isn't greater than 1492, write down the hex digit, subtract its
  decimal value from 1492, and continue to the next table with the new value
  (that is, the difference after subtracting). Go from table to table until
  the number remaining is 0. The process is shown in Figure B-5. The result
  is 005D4H, or 5D4H without the leading zeros.

                     Largest           Decimal            Remaining
  Position           Hex Digit          Value             Decimal Number
  --------------------------------------------------------------------------
  Starting                                                1492
  5                      0                0               1492
  4                      0                0               1492
  3                      5             1280                212
  2                      D              208                  4
  1                      4                4                  0
  Result             005D4
  --------------------------------------------------------------------------

  Figure B-5.  Converting the decimal number 1492 into a hexadecimal number.

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