flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > File formats |
Author |
|
DataHunter2009 13 Aug 2005, 01:52
I used to use an example like the one you posted there. I found it later on converted to FASM around here somewhere. I don't have the link anymore. I'm sure someone would post it though.
As for the file formats, I had to use ELF one time for a kernel, but I never really read up on what ELF was. |
|||
13 Aug 2005, 01:52 |
|
Tomasz Grysztar 13 Aug 2005, 10:59
With ld you will probably prefer ELF, though it supports COFF, too.
You above sample converted to fasm looks like: Code: FORMAT ELF SECTION '.text' EXECUTABLE EXTRN _c_main start: call _c_main jmp $ or this way for COFF format: Code: FORMAT COFF SECTION '.text' CODE EXTRN _c_main start: call _c_main jmp $ |
|||
13 Aug 2005, 10:59 |
|
DataHunter2009 13 Aug 2005, 13:06
What exactly is the difference between ELF and COFF? I really only see one difference in code. Are there speed issues aswell?
|
|||
13 Aug 2005, 13:06 |
|
gunblade 13 Aug 2005, 21:43
The only difference between ELF and COFF is the file header. IF one has a smaller header, then it might be faster to run, as theres less data to parse, but thats a tiny difference, if any. Just make sure your kernel doesnt suck, and it'll run fine
Anyway, you have no need to stick to these file formats if your making your own OS. the only reason you'd stick to these is if you wanted to make it able to run other OS's programs on your OS. ie: ReactOS allows you to run windows programs on it. therefore would have to use the coff format (or that other windows one) |
|||
13 Aug 2005, 21:43 |
|
Tomasz Grysztar 13 Aug 2005, 23:44
But I guess he wants to use the object format to link the assembly code with C code into the simple flat binary for the OS. In this aspect it actually doesn't matter whether you use ELF or COFF, since ld supports both.
|
|||
13 Aug 2005, 23:44 |
|
THEWizardGenius 14 Aug 2005, 18:07
I will use ELF (I was planning to use that anyways, unless someone recommended I do otherwise).
Thanks! I see ELF and COFF look pretty much the same in FASM, except that with ELF you type "format elf" and with COFF you type "format coff". I see use32 is not included in the code, which I assume is because both ELF and COFF support 32 bits only (except ELF64). Maybe I shouldn't say file formats. What I meant is "how to make a ELF/COFF object in FASM?" which has been answered sufficiently. Thanks! Maybe someone should write a simple tutorial for using FASM in conjunction with DJGPP (or any other language for that matter). Also one on converting NASM code to FASM. This would be useful for newbies like me (in OS development or for other things). |
|||
14 Aug 2005, 18:07 |
|
THEWizardGenius 14 Aug 2005, 20:44
I guess I forgot to mention I'm using the DOS ld, from the DJGPP binutils. When I tried to link the C object (kernel_c.o) with the assembly object (kernel.o) it didn't recognize the format. Should I switch to COFF, or does anyone know how to use ELF files with this port of ld? Here's the commandline I use:
Code: ld -Ttext 0xFF800000 --oformat binary -o kernel.sys kernel.o kernel_c.o The kernel loads to 0x10000 physical memory (it's in protected mode). When I made a plain binary file with just FASM, I started it with "org 0x10000". How do I do this with ld? Should I change "0xFF800000" to "0x10000" or what? Sorry, if this is really newbish, but I've never had any use for this sort of thing before; I used to program in only assembly, but I want to write my kernel in C and assembly, now! Looking at man pages weren't much help, they are too technical and don't make much sense. If it helps any, these are the tutorials I'm looking at: http://www.pscode.com/vb/scripts/ShowCode.asp txtCodeId=4513&lngWId=3 http://www.osdever.net/bkerndev/Docs/basickernel.htm Thanks, and sorry if I sound newbish! _________________ FASM Rules! OS Dev is fun! Pepsi tastes nasty! Some ants toot! It's over! |
|||
14 Aug 2005, 20:44 |
|
THEWizardGenius 16 Aug 2005, 14:49
After much trial and error, I discovered that ld from the DJGPP binutils for DOS expects MS COFF rather than ELF or COFF.
So I changed "format ELF" to "format MS COFF" and it worked just fine. _________________ FASM Rules! OS Dev is fun! Pepsi tastes nasty! Some ants toot! It's over! |
|||
16 Aug 2005, 14:49 |
|
f0dder 16 Aug 2005, 15:02
You might want to have a look at http://www.mingw.org/ instead of djgpp, at least if you're developing under windows. Or you could use the (free) MS VC2003 toolkit and have your kernel in PE format.
There isn't much reason to use a binary format kernel... "proper" formats allow things like per-section protection, and a this will work until I write it properly "loader" for PE executables is something like 5 assembly instructions more than a flat binary loader... |
|||
16 Aug 2005, 15:02 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.