Page 1 of 1
HELP with kernel
Posted: Sun Feb 03, 2002 12:23 pm
by dorip
When I compile this code with Borland C++ Builder 5.5 and lik it with it's linker, and run it, it doesn't do anything. Blank Black screen. If i close the window it sais that windows cannnot clos this app .. .. .... ... That's beside the point. If i link it instead with ELINK linker(outputs flat binnaryes form .objs) and put it on a disk(with bootstrap code installed) it puts on the screen 2 wierd chars a big "0" and a small "o".
void main(void) {
char message[] = "Executing the C code";
char *source = message;
char *destination = (char *)0xB8000;
while (*source) {
*destination++ = *source++;
*destination++ = 7; }
for (;;) ; // Hang: There is nowhere to return to
}
What's the problem?
Any help appreciated.
Thanks,
Darie
Re: HELP with kernel
Posted: Sun Feb 03, 2002 8:57 pm
by K.J.
When I compile this code with Borland C++ Builder 5.5 and lik it with it's linker, and run it, it doesn't do anything. Blank Black screen.
This is because you are directly accessing the video memory and Windows won't let you do that. As far as I know, you must set up your kernel to be a true kernel(loaded off a disk by a bootsector or to take over DOS).
If i link it instead with ELINK linker(outputs flat binnaryes form .objs) and put it on a disk(with bootstrap code installed) it puts on the screen 2 wierd chars a big "0" and a small "o".
I don't know anything about ELINK but I had this same kind of problem with my kernel. Your code looks like the example that comes with one of John Fine's bootsectors. If this is so, then you need to set the text entry address to 0xFF800000, I messed around with this with LD(the GNU linker, but it doesn't appear to work with Borland's OBJ format) and in the end used a linker script like this:
OUTPUT_FORMAT("binary")
ENTRY(_main)
SECTIONS
{
.text 0xFF800000
{
*(.text)
}
.data
{
*(.data)
}
.bss
{
*(.bss)
}
}
Then I would link my obj like this:
ld kernel.obj -Tkernel.lnk
That works with LD, I don't know about other linkers though.
K.J.
(also, consider using DJGPP for you C/C++ compiler as it outputs several differnt file formats, many that work with LD. Check it out at:
http://www.delorie.com/djgpp/
)
Re: HELP with kernel
Posted: Mon Feb 04, 2002 4:41 am
by dorip
DJGPP is a good linker and tools, but the borland is just perfect. I don't like the inline asm for DJGPP, and watcom doesn't work with the borland kind of inline asm. JLOC is probably the best but way overcomplicated. Elink is the best or just 1 obj file. When it outputs "0o" i use john fine's bootstrap example.
Thanks anyway