Page 2 of 2

Re:using gcc, nasm and ld

Posted: Fri Jul 11, 2003 9:19 am
by Fosur
Yes...The answer is:

[SECTION .text]

and as I read from nasm doc SECTION directive is same as SEGMENT directive. I dont understand why is it necessarry to use this directive but when I put this line at the beginning of my code it worked well.. Thanks to everyone...

And as learned:
__attribute__ ((packed)) is used in djgpp gcc to instruct the compiler
not to place extra bytes in the structure in an attempt to align it..
1-Where can I find such tips? Is there a good tutorial or manual for djgpp??Because such things may couse some correct codes not worked..

2-And for gcc, I think its help (gcc --help) doesnt show all the options. For ins. -Wall and -fno_leading_underscores is not written in its help. Also a good tutorial for gcc will be appreciated...

3-And as a last question. Does Bochs not lets modifiying gs or fs register?? Because, I use that registers in my A20 test function and it gives int 13 error when I change the value of gs...
...
mov ax, 0ffffh
mov gs, ax
...

Re:using gcc, nasm and ld

Posted: Fri Jul 11, 2003 10:51 pm
by Chris Giese
Fosur wrote: And as for another question, tlink(my ex linker) warns me for the functions not implemented (I mean when I call an extern function, and at linking step if linker cant find such a function it gives error that such a function not implemented). I couldnt find any parameter for ld to warn me for those kinda functions. Is there such a parameter for ld??
ld does this by default. If it can't resolve all symbols, it prints an error message and deletes the output file, just like TLINK.

The reason it doesn't work here is because you said "ld -i ..." (same as "ld -d ..."). This performs a partial link: the output is a relocatable file, like the input files, and there is no warning or error message for unresolved external symbols. You probably shouldn't use this option :)

I also don't understand why you need to use SECTION .text.
I thought NASM did this automatically -- maybe it's a bug in NASM? I will experiment with this and talk to the NASM developers.

Re:using gcc, nasm and ld

Posted: Sat Jul 12, 2003 2:54 am
by Solar
Fosur wrote: 2-And for gcc, I think its help (gcc --help) doesnt show all the options. For ins. -Wall and -fno_leading_underscores is not written in its help. Also a good tutorial for gcc will be appreciated...
In the shell, try "info gcc" instead. Neither "gcc --help" nor "man gcc" give all the info.

http://www.gnu.org/manual/manual.html has online manuals on all GNU software, including gcc, as, ld, and binutils.
3-And as a last question. Does Bochs not lets modifiying gs or fs register?? Because, I use that registers in my A20 test function and it gives int 13 error when I change the value of gs...
gs and fs have been introduced into the IA-32 architecture at a later point of time; probably Bochs doesn't support it yet, or you have Bochs configured to emulate an older CPU generation.

Sorry, can't find the reference right now or I would provide a link.

Re:using gcc, nasm and ld

Posted: Sat Jul 12, 2003 3:57 am
by Tim
GS and FS are part of the basic 80386 architecture, and Bochs handles them fine.

Re:using gcc, nasm and ld

Posted: Sat Jul 12, 2003 10:28 am
by Solar
Right. Art of Assembly, chapter 4.5 - fs and gs were introduced by the 386. Sorry, I was mixing up generations there. :-[

Re:using gcc, nasm and ld

Posted: Mon Aug 04, 2003 5:09 pm
by Dragon88
ok, little off topic here, but how do i get gcc to compile asm files, and recognize them as such? I've tried using '#include"asmfile.s" ', but gcc treats the asm as c. I've also tried giving the filenames as args to gcc, but then i can't use -c and end up with a dos exe, rather than the flat binary i want (that is what -c does, isn't it?)

Re:using gcc, nasm and ld

Posted: Mon Aug 04, 2003 5:22 pm
by Tim
Just give it an .s file -- it should recognise it as assembly from the extension.

Maybe it's begin case-sensitive, and expecting .S (not .s).

-c compiles a source file to an object file -- that is, from .c or .s to .o. The linker combines these .o files into whatever format (DOS EXE, flat binary, etc.). Without the -c flag, gcc will perform the linker step automatically.

PS: you'd be better off posting these separate questions in threads of their own, not tacked onto somebody else's question.