No Linker Needed?

Programming, for all ages and all languages.
Post Reply
someprogr
Posts: 7
Joined: Mon Dec 24, 2007 12:44 pm

No Linker Needed?

Post by someprogr »

Can anyone tell me why I was able to assemble this bootloader with NASM, and use it without linking it? I don't undertstand.

Heres the link:
http://www.osdever.net/tutorials/hello_btldr.php
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:

Post by Combuster »

NASM can "link" by itself
"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 ]
Craze Frog
Member
Member
Posts: 368
Joined: Sun Sep 23, 2007 4:52 am

Post by Craze Frog »

A linker takes several object files in format X and combines them into one file in format Y. In your case you only had one object file and format X and Y was the same, so no linking was needed.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

Fasm can also link its self.
User avatar
Red Shaya
Posts: 15
Joined: Wed Oct 03, 2007 4:21 pm
Contact:

Post by Red Shaya »

A linker does as it name implies. It LINKS things between objects.
For example, it links a symbol with an actual address. So when you call the function "kprintf"

Code: Select all

    CALL _kprintf
the linker links the symbol "_printf" from your object with the pointer to the kprintf function in another object (its more complicated, but this simple explanation will do for what I'm trying to say).
When you write a bootloader, you don't refer to any symbolic object outside your bootloader. You just run a small piece of code that has all its references hard coded. For example

Code: Select all

    CALL 07D0h:0
So you don't need a linker to resolve any references.
The Bina OS - More of a challenge then an OS
The Eddie OS - OS for kids and for fun loving adults
Post Reply