Page 1 of 1
.INC Files to .BIN?
Posted: Wed Aug 08, 2007 3:30 pm
by eboyd
Hey I've been working through some tutorials, and I've been compiling
my .inc files and outputting them as .bin files. Everything is working fine,
so I'm just going to assume that's the right format, right?
Posted: Wed Aug 08, 2007 3:34 pm
by pcmattman
INC files are usually included from assembly code. Shouldn't you be compiling ASM files into your final binary, with the INC files used as includes?
Posted: Wed Aug 08, 2007 6:07 pm
by SpooK
This is a common misconception due to thinking within higher-level constraints.
The extension of the file doesn't matter, the contents do. The only exception to this is when IDEs and picky compilers/assemblers make such a seemingly useless distinction.
The file extension is merely a way for the "human" to keep track of their code. Traditionally, you have a main set of .ASM files and supporting .INC files... much like .C and .H files, respectively, for the C programming language.
Bottom line, do things however you want/can... but make sure you (and others if that's the case) can figure out what is going on with your source code.
Posted: Thu Aug 09, 2007 12:27 am
by pcmattman
SpooK wrote:
The file extension is merely a way for the "human" to keep track of their code. Traditionally, you have a main set of .ASM files and supporting .INC files... much like .C and .H files, respectively, for the C programming language.
Hence the reason I suggested to use ASM files instead of INC files.
This is a common misconception due to thinking within higher-level constraints.
I said
usually. Also, it's better to use INC files as include files so that someone else who looks at your code can understand what's happening.
Posted: Thu Aug 09, 2007 8:35 am
by eboyd
I'm using both ASM and INC files. When Spook mentioned "picky" compilers, that's more along the lines of what I was asking. I figured it was similar to .c, .cpp and .h files, but wasn't sure.
And having an OOP background I'm not used to picking the "out-putted" format for my files. Using command line compilers like NASM is very different from firing up DevC++ or VisualStudio.
This is what was confusing to me:
Code: Select all
c:\nasm\src\nasm -f bin boot.asm -o boot.bin
c:\nasm\src\nasm -f bin gdt.inc -o gdt.bin
In the second line, I was just following what I figured was a naming convention common to all assembly files.
Posted: Thu Aug 09, 2007 3:22 pm
by pcmattman
eboyd wrote:This is what was confusing to me:
Code: Select all
c:\nasm\src\nasm -f bin boot.asm -o boot.bin
c:\nasm\src\nasm -f bin gdt.inc -o gdt.bin
The first line is building a complete flat binary, as in an executable. The second line will do the same. I think that you want to be working with object files for the second file (so you can link it in with C)?
Posted: Thu Aug 09, 2007 4:21 pm
by B.E
eboyd wrote:I'm using both ASM and INC files. When Spook mentioned "picky" compilers, that's more along the lines of what I was asking. I figured it was similar to .c, .cpp and .h files, but wasn't sure.
And having an OOP background I'm not used to picking the "out-putted" format for my files. Using command line compilers like NASM is very different from firing up DevC++ or VisualStudio.
This is what was confusing to me:
Code: Select all
c:\nasm\src\nasm -f bin boot.asm -o boot.bin
c:\nasm\src\nasm -f bin gdt.inc -o gdt.bin
In the second line, I was just following what I figured was a naming convention common to all assembly files.
if boot.asm includes (or if gdt.inc is set up to be an included file) gdt.inc, Then there is no need to compile gdt.inc as the assembler "adds" the text of gdt.inc to boot.asm as though it were one file. Then the assembler compiles the result.