Dear all:
    For me, segment is a complex concept, and segment definition is a very difficult work. But segment is also a very important concept in assembly language. There are some basic questions puzzled me a long time:
    1. As i have known, a segment must start at address 0xxx0H, why can segment align type  be  BYTE,WORD, DWORD?
    2. In segment definiton, we can declare 'CLASS' to control segments loading order, but when will we need to order the segments in memory? 
    3. We use GROUP directive to group two or more small segments into one physical segment, but when a segment is a member of segment group, but also assumed by it's own segment name with a segment register, how can we calculate the offser address in the segment.
    ------------------------------------------------------------------------
    .alpha
    gseg  group  dseg, eseg
       
    dseg  segment 
    szMsg1  db  "This is the string in data segment!",13, 10, '$'
    szMsg3  db  13, 10, '$'
    dseg    ends

    eseg  segment 

    szMsg2 db  'This is the string in extra segment!',13, 10, '$'
    i  db  'M'
    eseg ends

    sseg    segment stack 
          db 100h DUP(?)       
    sseg    ends
       
    cseg segment 
    assume cs:cseg,  ss:sseg, es:eseg,ds:gseg
    start:
        mov ax, gseg
        mov ds, ax
        mov ax, eseg
        mov es, ax
       
        lea dx, szMsg1
        mov ah, 9
        int 21h
               
        lea dx, szMsg2
        mov ah, 9
        int 21h
       
        mov ah, 02h
        mov dl, i    ?***** Please Note here
      int 21h
       
        lea dx, szMsg3
        mov ah, 9
        int 21h
                     
        mov ah, 1
        int 21h
        mov ax, 4C00h
        int 21h
    cseg    ends
    end start
  -------------------------------------------------------
In "mov dl, i", what is the offset address  of i? 
Posted on 2008-09-04 02:28:49 by qlmi
1. A segment doesn't need inevitably to start at address 0.
An alignment directive becomes important if a segment joins a previous memory area and the very first offset should have an appropriate aligned value. Default alignment should be 10h (PARA).

2. The final ordering of memory locations is done by the linker. In general it uses the same ordering as the assembler does. I recommend reading the manual for the versatile OpenWatcom-linker WLINK (see directives "OPTION DOSSEG" and "ORDER").

3. With a GROUP directive several segments can be joined together as if they were only one. Start offsets of following segments will receive the last used offsets by previous segments plus the alignment value.

The real number of the offset address of your variable "i" is unimportant. It will be a relative address calculated by the assembler and the linker.
If I am right it should have the relative value:
STARTOFS_dseg + ALIGNMENT_eseg + LENGTH_OF_STRING_szMsg2
Posted on 2008-09-04 05:56:06 by TasmDev

1. A segment doesn't need inevitably to start at address 0.
An alignment directive becomes important if a segment joins a previous memory area and the very first offset should have an appropriate aligned value. Default alignment should be 10h (PARA).

2. The final ordering of memory locations is done by the linker. In general it uses the same ordering as the assembler does. I recommend reading the manual for the versatile OpenWatcom-linker WLINK (see directives "OPTION DOSSEG" and "ORDER").

3. With a GROUP directive several segments can be joined together as if they were only one. Start offsets of following segments will receive the last used offsets by previous segments plus the alignment value.

The real number of the offset address of your variable "i" is unimportant. It will be a relative address calculated by the assembler and the linker.
If I am right it should have the relative value:
STARTOFS_dseg + ALIGNMENT_eseg + LENGTH_OF_STRING_szMsg2

Thanks for your help!
For the nomber 2&3 questions, I have totally understood your answer. But I can't find the manual for the versatile OpenWatcom-linker WLINK, would you please send me a copy of this document via email: miquanlin@163.com?
 
Posted on 2008-09-04 22:02:49 by qlmi
TasmDev :
  Please check your message box on this forum.
Posted on 2008-09-11 10:39:17 by qlmi