using gcc plz help

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.
Post Reply
codemastersnake

using gcc plz help

Post by codemastersnake »

Hello everyone!

Well I have decided to shift to gcc and ld for developing my OS....

I am creating a RM OS and don't know how to use gcc and ld for creating a DOS COM file i.e. raw binary file that can be loaded into memory as it is fo exeution...

I am presently using turbo C++ for that...
I use:

tcc -c -r- -mt -2 file.cpp

this gives me file.obj

then I use:

tlink /t file kstart, kernel.bin

I also have a ksatrt.asm file which calls main() which I compiled and used above....

this gives me kernel.bin file. But I don't know how to use gcc for 16bit RM OS... Ihave tried many shots in dark but no one got right....

please help.....
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:using gcc plz help

Post by Brendan »

Hi,
Codemaster Snake wrote:I am creating a RM OS and don't know how to use gcc and ld for creating a DOS COM file i.e. raw binary file that can be loaded into memory as it is fo exeution...
I don't think there is a version of GCC that can produce 16 bit/real mode code (it's 32 bit or 64 bit only).

On Linux platforms, try the "BIN86" package (see http://www.cix.co.uk/~mayday/). This includes a C compiler, assembler, LD, etc all designed for producing real mode code. I'm not sure if there's a DOS/Windows port or not (I assume it can be compiled with CYGWIN on Windows)...


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
raywill

Re:using gcc plz help

Post by raywill »

Yes,I got similar problem.
As gcc does not generate 16 bits code,that adds me lots of problem.

I suggest giving up the idea of building a real mode OS.
Protected mode is a little ugly ,but useful,isn't it :-)
codemastersnake

Re:using gcc plz help

Post by codemastersnake »

So this means that I'kll have to switch my OS to PM to be able to use it with gcc...

That's a hell of a kind of problem... No I'll have to dig the **** of PM programming and then write my OS from the sctrach again.... :(
codemastersnake

Re:using gcc plz help

Post by codemastersnake »

Plz can anyone explain me this script:

Code: Select all

/* Link.ld */
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.text 0x100000 :
{
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(4096);
}

.data :
{
__CTOR_LIST__ = .; LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) *(.ctors) LONG(0) __CTOR_END__ = .; 
__DTOR_LIST__ = .; LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) *(.dtors) LONG(0) __DTOR_END__ = .; 

data = .; _data = .; __data = .;
*(.data)
. = ALIGN(4096);
}

.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
. = ALIGN(4096);
}

end = .; _end = .; __end = .;
} 
INPUT(KStub.o Support.o OStream.o Interrupt.o kernel.o IStream.o Video.o string.o keyboard.o kbInt.o)
OUTPUT(bin\Kernel.bin)
AR

Re:using gcc plz help

Post by AR »

Code: Select all

OUTPUT_FORMAT("binary")
Flat binary output

Code: Select all

ENTRY(start)
Symbol where execution starts (ie. entrypoint)

Code: Select all

.text 0x100000
Text (ie. code) segment starting at 0x10000 physical/virtual

Code: Select all

*(.text)
All .text segments from all source files

Code: Select all

. = ALIGN(4096);
Segment ends on a page boundary

Code: Select all

__CTOR_LIST__ = .; LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) *(.ctors) LONG(0) __CTOR_END__ = .;
Global constructor list, the other is the destructor list

Code: Select all

INPUT(KStub.o Support.o OStream.o Interrupt.o kernel.o IStream.o Video.o string.o keyboard.o kbInt.o)
Haven't seen this before but it clearly declares what object files are to be linked

Code: Select all

OUTPUT(bin\Kernel.bin)
Haven't seen this before either but it clearly declares the output file
codemastersnake

Re:using gcc plz help

Post by codemastersnake »

So this means that I can use this only with 32bit protected mode OS.
Post Reply