6.2 obj: Microsoft OMF Object Files

When you define a segment in an obj file, NASM defines the segment name as a symbol as well, so that you can access the segment address of the segment. So, for example:

segment data

dvar:  dw      1234

segment code

        mov    ax,data        ; get segment address of data
        mov    ds,ax          ; and move it into DS
        inc    word     ; now this reference will work

Why would someone have to do something like this i'm curious,
any idea?
Posted on 2006-12-04 18:43:49 by gavin
imagine you are creatig DOS MZ executable, with code and data segment. you need to set DS to point to data segment. so you need
mov ax, dseg
mov ds,ax
Posted on 2006-12-04 20:52:15 by vid
Nice answer thanks vid.
I was trying to do it in 32bit flat memory mode but it fails ,I later read that it is not allowed :(
Thanks anyway.
Posted on 2006-12-10 12:20:57 by gavin