Reffering memory address

Guys i just want to verify whether i am correct. The address in the memory is reffered as segment:offset.The "segment" number is stored in any segment registers like ss, ds,cs,es and where is the number of "offset" stored in any register like si,di,bp,sp .Am i right????
And what does this mean
[code]mov al,[bx]
mov al,[bp] [/code]

Comments

  • : Guys i just want to verify whether i am correct. The address in the
    : memory is reffered as segment:offset.The "segment" number is stored
    : in any segment registers like ss, ds,cs,es and where is the number
    : of "offset" stored in any register like si,di,bp,sp .Am i right????

    That's true. Registers have different uses though, read this:
    http://arl.wustl.edu/~lockwood/class/cse306-s04/books/artofasm/Chapter_4/CH04-1.html#HEADING1-12


    : And what does this mean
    : [code]: mov al,[bx]
    : mov al,[bp] [/code]

    Here a byte is loaded to the al register from the address specified by bx/bp.
    By default, ds (data segment) is used as the segment register with
    general purpose registers and ss (stack segment) is used with sp/bp.
    So the equivalent of the above would be:
    [code]: mov al,[ds:bx]
    mov al,[ss:bp] [/code]
    Don't worry if this doesn't make much sense yet, just keep reading and asking questions :-)
  • anthrax11 what would have happened while addressing a memory if i had
    put the segment in registers like si,di,bp,sp instead of ss,ds,cs,es which are segment registers and vice versa(and stored the offset in segment registers like ss,ds,cs,es).


    And another thing is that in this bit of code
    [code]format mz

    mov ax,cs
    mov ds,ax

    mov ah,09
    mov dx,message
    int 21h

    mov ax,4c00h
    int 21h

    message db "Hello world, I'm learning Assembly !!!", "$"[/code]
    As far as i know the code segment is used to denote the block of memory in which the code is stored and ds is the block of memory which has the data stored in it.So what is the point of first moving cs to ax register and then moving ax to ds register.I know that mov ds,cs cannot be done.I want to understand the logic for this two instruction.

  • anthrax11 what would have happened while addressing a memory if i had
    put the segment in registers like si,di,bp,sp instead of ss,ds,cs,es which are segment registers and vice versa(and stored the offset in segment registers like ss,ds,cs,es).


    And another thing is that in this bit of code
    [code]format mz

    mov ax,cs
    mov ds,ax

    mov ah,09
    mov dx,message
    int 21h

    mov ax,4c00h
    int 21h

    message db "Hello world, I'm learning Assembly !!!", "$"[/code]
    As far as i know the code segment is used to denote the block of memory in which the code is stored and ds is the block of memory which has the data stored in it.So what is the point of first moving cs to ax register and then moving ax to ds register.I know that mov ds,cs cannot be done.I want to understand the logic for this two instruction.
  • : anthrax11 what would have happened while addressing a memory if i
    : had
    : put the segment in registers like si,di,bp,sp instead of ss,ds,cs,es
    : which are segment registers and vice versa(and stored the offset in
    : segment registers like ss,ds,cs,es).

    Well, x86 addressing does not work that way. If you want to address
    something, you use a segment register and another register to make up
    the segment:offset pair. If you fill registers with random data you'll
    end up crashing.


    : And another thing is that in this bit of code
    : [code]: format mz
    :
    : mov ax,cs
    : mov ds,ax
    :
    : mov ah,09
    : mov dx,message
    : int 21h
    :
    : mov ax,4c00h
    : int 21h
    :
    : message db "Hello world, I'm learning Assembly !!!", "$"[/code]:
    : As far as i know the code segment is used to denote the block of
    : memory in which the code is stored and ds is the block of memory
    : which has the data stored in it.So what is the point of first moving
    : cs to ax register and then moving ax to ds register.I know that mov
    : ds,cs cannot be done.I want to understand the logic for this two
    : instruction.

    In .exe files only cs and ss are initialized when the program starts.
    You can't even directly change cs, because it specifies the segment
    where code is being executed. So the first thing that an exe needs to
    do is to set up ds (and es if it is used) to a data segment which it
    will be using. An exe may have more than one data segment, so DOS
    doesn't bother guessing which one you want and leaves that to you.

    In contrast, .com files always use a single segment, because they can
    be no bigger than 64 kilobytes (the size of one segment). That's why
    for these executables ds and es are always initialised by DOS to the
    same segment as the code.

    Because the above program also fits into one segment, we didn't define
    a separate data section for it. The code and data are in the same
    segment, so ds should equal cs.

    I hope that made sense, cause it's late, I'm tired and going to bed :-)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories