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.
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...
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.
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.
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.
Every good solution is obvious once you've found it.
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?)
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.