linker in FreeDOS

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
extremecoder
Member
Member
Posts: 59
Joined: Tue May 23, 2006 11:00 pm

linker in FreeDOS

Post by extremecoder »

I am writing some rmode assembly snippets in FreeDOS and using NASM for that. I am not able to find any linker for that. anybody developed a loader in the FreeDOS environment ?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: linker in FreeDOS

Post by Combuster »

You don't strictly need a linker to make DOS binaries. For example, .com files are flat binaries. And if you're just using assembly, that is probably sufficient.

Code: Select all

org 0100h
start:

<your code here>
then assemble with
nasm myapp.asm -f bin -o myapp.com
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
extremecoder
Member
Member
Posts: 59
Joined: Tue May 23, 2006 11:00 pm

Re: linker in FreeDOS

Post by extremecoder »

sorry that i didn't post the question with fullest details ... I am right now anyway doing it with com only ...
but also I want to practice the assembly with segmentation ... i am not able to do with .com ... for example the following code throws an error when assembling using NASM

[org 16]

SEGMENT TEXT
mov ax, DATA
mov ds, ax
...

SEGMENT DATA
...

when assembling with NASM, i am getting " undefined reference DATA "
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Re: linker in FreeDOS

Post by frank »

Maybe this can help you some. It seems that NASM cannot generate .exe files directly. Maybe one of the linkers on that page will suit you.

If you aren't too attached to NASM then FASM is capable of producing both DOS .exe files and WIN32 .exe files. The syntax for FASM is a little different and may take a bit of time to get used to.
bontanu
Member
Member
Posts: 134
Joined: Thu Aug 18, 2005 11:00 pm
Location: Sol. Earth. Europe. Romania. Bucuresti
Contact:

Re: linker in FreeDOS

Post by bontanu »

You do need a linker even in ASM in order to link in multiple modules even for a COM file. You could insert all code into a single module BUT some people prefer to have multiple LIB's or OBJ's linked.

Linkers and Librarians existed for ASM long before they existed for C and other HLL languages.

The feature of modern assemblers that generates an executable format directly is usefully but one should not overlook the other more common development layout of using multiple OBJ's and linking them.
Ambition is a lame excuse for the ones not brave enough to be lazy; Solar_OS http://www.oby.ro/os/
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: linker in FreeDOS

Post by Dex »

extremecoder
Member
Member
Posts: 59
Joined: Tue May 23, 2006 11:00 pm

Re: linker in FreeDOS

Post by extremecoder »

the problem is FreeDOS does not come with ALINK. also I am using FreeDOS as a VMWare guest. even though I download ALINK, I will not be able to mount USB drives in this DOS and use it ... I have something called WLINK, but that doesn't work ..

the main reason is, I am into developing my own boot loader .. I want to practice assembly by having multiple segments inside the asm code ...
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: linker in FreeDOS

Post by Combuster »

extremecoder wrote:I want to practice assembly by having multiple segments inside the asm code ...
You don't need to practice segmentation by randomly allocating segments in your file - Instead, write a program that uses memory in a segmented fashion, like a graphics app with a backbuffer in system memory, or for the really good work, an audio player for screamtracker (S3M) files.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
bontanu
Member
Member
Posts: 134
Joined: Thu Aug 18, 2005 11:00 pm
Location: Sol. Earth. Europe. Romania. Bucuresti
Contact:

Re: linker in FreeDOS

Post by bontanu »

extremecoder wrote:the problem is FreeDOS does not come with ALINK. also I am using FreeDOS as a VMWare guest. even though I download ALINK, I will not be able to mount USB drives in this DOS and use it ... I have something called WLINK, but that doesn't work ..
...
What I usually do in Virtual PC:
1) Stop FreeDOS VM and make a note of the virtual HDD file it uses
2) Start another "simple" OS like Win98 that has additions installed after adding the FreeDOS virtual HDD to this machine.
3) Drag and drop the needed files from my host desktop to the guest desktop on a folder in the FreeDOS HDD.
4) Stop the "simple" Win98 OS.
5) Start FreeDOS VM and use the new files...

I guess that in VMWare you can do something similar.

Alink is usefully but it does have some quirks and errors.

Another option for creating multi segmented MZ EXE's would be to use the old 16 bits Microsoft LINK.EXE but in this case you would have to use MS-DOS in the VM and have a license for it in order to be correct.
Ambition is a lame excuse for the ones not brave enough to be lazy; Solar_OS http://www.oby.ro/os/
extremecoder
Member
Member
Posts: 59
Joined: Tue May 23, 2006 11:00 pm

Re: linker in FreeDOS

Post by extremecoder »

thank you very much ...
Post Reply