Page 1 of 1
Newbie Question: extrn
Posted: Mon Jun 28, 2010 11:47 am
by TheDaneProgrammer
Hi OsDevers.
I'm new to OS Developing and Assembler, and I've never got the thing about extrn
. What does it do, and what do I have to specify etc?
I couldn't find anything on Google.
Oliver
Re: Newbie Question: extrn
Posted: Mon Jun 28, 2010 12:05 pm
by cyr1x
It tells the assembler that the label is within a different object file.
This is necessary when you want to link several object files.
Re: Newbie Question: extrn
Posted: Mon Jun 28, 2010 1:51 pm
by Combuster
TheDaneProgrammer wrote:I've never got the thing about extrn
.
It helps if you fix your spelling and search on "ext
ern" instead
Re: Newbie Question: extrn
Posted: Mon Jun 28, 2010 2:06 pm
by JohnWilson
Combuster wrote:It helps if you fix your spelling and search on "ext
ern" instead
I'm guessing it depends on your assembler. I use TASM 5.0 (in MASM mode) and extern gives an error (just tried it) -- all my code uses extrn. But I suppose no one uses TASM any more.
Anyway to answer the OP in a tiny bit of detail, it goes something like this (um, in TASM/MASM, so YMMV if you're using NASM or something):
In one source file:
Code: Select all
foo: public foo
... does something ...
ret
Then in another source file:
There's other stuff for calling other languages but that's the basic form. The type can be "near" or "far" if it's a label for a subroutine, or one of the data sizes ("byte", "word", "dword" etc.) if it's the label of a variable, or various other things that you're less likely to need.
John Wilson
D Bit