WLINK segments offset

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Groug
Posts: 2
Joined: Sun Apr 09, 2017 11:21 am

WLINK segments offset

Post by Groug »

Hello.

I try to make my bootloader, but have trouble with data address offset after linking.
Here my wlink config:

Code: Select all

FILE MBR.asm.obj
FILE MBR.c.obj
NAME MBR.bin
OUTPUT raw
OPTION nodefaultlibs, quiet, start=_start
DISABLE 1014
ORDER
        clname CODE
        clname DATA
FORMAT dos
If use it, as a result all data addresses in program calculated as offsets from 0000.
If use next:

Code: Select all

FILE MBR.asm.obj
FILE MBR.c.obj
NAME MBR.bin
OUTPUT raw
        offset = 0x7c00
OPTION nodefaultlibs, quiet, start=_start
DISABLE 1014
ORDER
        clname CODE offset = 0x7c00
        clname DATA
FORMAT dos
It only use offset from 0x7c00 for code, but still use offset from 0000 for data.

If use next:

Code: Select all

FILE MBR.asm.obj
FILE MBR.c.obj
NAME MBR.bin
OUTPUT raw
        offset = 0x7c00
OPTION nodefaultlibs, quiet, start=_start
DISABLE 1014
ORDER
        clname CODE offset = 0x7c00
        clname DATA offset = 0x7d00
FORMAT dos
It generates valid program, puts data at offset 0x7d00 and use valid offset, but this version work only if my code < 0x100 byte and use hardcoded offset for data, so that is not good idea.

How I can set wlink to place DATA right after CODE and use global offset 0x7c00?
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: WLINK segments offset

Post by iansjack »

Far be it from me to discourage you from using your favourite compiler, but Open Watcom is not widely used for OS development, which means that it can be a little difficult - compared to the more popular toolsets - to obtain the relevant information. A starting point is http://wiki.osdev.org/Watcom , but you may need to do further research.
Groug
Posts: 2
Joined: Sun Apr 09, 2017 11:21 am

Re: WLINK segments offset

Post by Groug »

iansjack wrote:Far be it from me to discourage you from using your favourite compiler, but Open Watcom is not widely used for OS development, which means that it can be a little difficult - compared to the more popular toolsets - to obtain the relevant information. A starting point is http://wiki.osdev.org/Watcom , but you may need to do further research.
Can you help me find more suitable compiler and linker for this?
I use Watcom because it can without troubles link C with ASM, generate small code and support very old processors as 8086.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: WLINK segments offset

Post by iansjack »

I'm afraid I can't make any suggestions as to a good toolkit for 8086 programming. I haven't written anything for it in decades.

Have you tried the Open Watcom forums? You are more likely to find someon who can help you there. (Although I believe that rdos - a user here - is a Watcom fan. Hopefully he will see your post and reply.)
Post Reply