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]

  We've seen that memory is always addressed by a combination of a segment
  value and a relative offset. The segment value always comes from one of
  the four segment registers.

  In contrast, the relative offset can be specified in many different ways.
  (See Figure 2-9.) For each machine instruction that accesses memory, the
  8086 computes an effective address by combining one, two, or three of the
  following:

  .  The value in BX or BP

  .  The value in SI or DI

  .  A relative-offset value, called a displacement, that is part of the
     instruction itself


  Name               Effective Address           Example            Comments
  ----------------------------------------------------------------------------------------------
  Immediate          Value "addressed" is part   mov ax,1234h       Stores 1234H in AX.
                     of the 8086 instruction

  Direct             Specified as part of the    mov ax,[1234h]     Copies the value at 1234H
                     8086 instruction                               into AX. The default segment
                                                                    register is DS.

  Register indirect  Contained in BX, SI, DI, or mov ax,[bx]        Copies the value at the
                     BP                                             offset contained in BX into
                                                                    AX. The default segment
                                                                    register for [BX], [SI], and
                                                                    [DI] is DS; for [BP] the
                                                                    default is SS.

  Based              The sum of a displacement   mov ax,[bx+2]      Copies the value 2 bytes
                     (part of the instruction)   or mov ax,2[bx]    past the offset contained in
                     and the value in BX or BP                      BX into AX. The default
                                                                    segment register for [BX] is
                                                                    DS; for [BP] the default is
                                                                    SS.

  Indexed            The sum of a displacement   mov ax,[si+2]      Copies the value 2 bytes
                     and the value in SI or DI   or mov ax,2[si]    past the offset contained in
                                                                    SI into AX. The default
                                                                    segment register is DS.
  Based indexed      The sum of a displacement,  mov ax,[bp+si+2]   The offset is the sum of the
                     the value in SI or DI, and  or mov ax,2[bp+si] values in BP and SI, plus 2.
                     the value in BX or BP       or                 When BX is used, the default
                                                 mov ax,2[bp][si]   segment register is DS; when
                                                                    BP is used, the default is
                                                                    SS.

  String addressing  Source string: register     movsb              Copies the string from
                     indirect using SI                              memory at DS:[SI] to
                     Destination string:                            ES:[DI].
                     register indirect using DI
  ----------------------------------------------------------------------------------------------


  Figure 2-9.  8086 Addressing Modes. In assembly language, some
  instructions can be specified in several different ways.

  Each of the various ways of forming an effective address has its uses. You
  can use the Immediate and Direct methods when you know the offset of a
  particular memory location in advance. You must use one of the remaining
  methods when you can't tell what an address will be until your program
  executes. In the chapters ahead, you'll see examples of most of the
  different 8086 addressing modes.

  The notation used in specifying 8086 addresses is straightforward.
  Brackets, [ ], are used to indicate that the enclosed item specifies a
  relative offset. This is a key element of memory addressing: Without
  brackets, the actual value stored in the register is used in whatever
  operation is specified.

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