Page 1 of 1

Help me How to ?

Posted: Mon Feb 18, 2002 12:00 am
by Anonymous
I am using Turbo C (version 3), I compiled the following program (kernel.c)

tcc -c -mt kernel.c
then I linked using tlink
tlink kernel.obj
then I used exe2bin
exe2bin kernel.exe kernel.com
Now I runned the file kernel.com, it is running but output is not Hello (some
invalid ascii characters). The offset address of the string "Hello" is illegal
when I debugged the code kernel.com using debug.

Is the method used to compile the kernel is wrong ? If yes How to compile it ?
Is there any problem with the code ?
It is possible to use Turbo C to develop a real mode kernel ?
I like to develop a real mode kernel using C.
plz provide me some links related to this.

main()
{
print("Hello");
}
print(char *disp_char)
{
int i;
for(i=0;i<5;i++)
{
_AH = 0x09; //prints a char.
_AL = disp_char[i];
_BL = 2;
_BH = 0;
_CX = 1;
asm int 0x10;

_AH = 0x15; // get current video mode
asm int 0x10;

_AH = 3; // get current x,y position
asm int 0x10;

_DL = _DL+1; // move cursor to next position
_BH = 0;
_AH = 2;
asm int 0x10;
}
}

RE:Help me How to ?

Posted: Tue Feb 19, 2002 12:00 am
by J. Weeks
>Now I runned the file kernel.com, it is running but output is not Hello (some
>invalid ascii characters). The offset address of the string "Hello" is illegal
>when I debugged the code kernel.com using debug.

You're loading kernel.com as a boot sector?
If so, then you're offsets wont be right unless
you provide an offset argument on the command line
analogous to "-tText 0x7c00" in GCC.

Or, set your data segment to 0x07c0.

Remember, you code is loaded at offset 0x7c0 (that
is right, isn't it? It's been a while...)

>is the method used to compile the kernel is wrong ? If yes How to compile it ?
>Is there any problem with the code ?
>It is possible to use Turbo C to develop a real mode kernel ?

Yeah, it's definitly possible.

>I like to develop a real mode kernel using C.
>plz provide me some links related to this.

Cheers, dude! It's nice to see some work on
real mode kernels. It's always good to have a
stable base of real mode knowledge before
jumping into a pmode kernel (it's a shame most
people don't follow your path).

Jeff

RE:Help

Posted: Wed Feb 20, 2002 12:00 am
by Anonymous
>On 2002-02-19 09:26:33, J. Weeks wrote:
>>Now I runned the file kernel.com, it is running but output is not Hello (some
>>invalid ascii characters). The offset address of the string "Hello" is illegal
>>when I debugged the code kernel.com using debug.
>
>You're loading kernel.com as a boot sector?
>If so, then you're offsets wont be right unless
>you provide an offset argument on the command line
>analogous to "-tText 0x7c00" in GCC.
>
>Or, set your data segment to 0x07c0.
>
>Remember, you code is loaded at offset 0x7c0 (that
>is right, isn't it? It's been a while...)
>
>>is the method used to compile the kernel is wrong ? If yes How to compile it ?
>>Is there any problem with the code ?
>>It is possible to use Turbo C to develop a real mode kernel ?
>
>Yeah, it's definitly possible.
>
>>I like to develop a real mode kernel using C.
>>plz provide me some links related to this.
>
>Cheers, dude! It's nice to see some work on
>real mode kernels. It's always good to have a
>stable base of real mode knowledge before
>jumping into a pmode kernel (it's a shame most
>people don't follow your path).
>
>Jeff

Hi, kernel.com is the file loaded from bootsector.
How can i give the starting segment and offset values to
the turbo c compiler ?

RE:Help

Posted: Thu Feb 21, 2002 12:00 am
by J. Weeks
>Hi, kernel.com is the file loaded from bootsector.
>How can i give the starting segment and offset values to
>the turbo c compiler ?

Ahhh... I thought you were coding that as your
bootsector... if not, then the whole 0x7c0 stuff
is irrelavent.

I still think it's probably an issue of jumping
to the wrong area in memory, though. In real
mode, you usually do end up getting a lot of
garbage on the screen in such an instance.

Check to make sure that where you load your
kernel.com is available memory (not overriding
the real mode ints, or any bios code) and make
sure that you are, indeed, jumping to that
very same address - you'll no doubt need a far
jump (jmp segment:offset).

Hope that helps,
Jeff

Got it !!!

Posted: Sun Feb 24, 2002 12:00 am
by Anonymous
>On 2002-02-21 22:54:03, J. Weeks wrote:
>>Hi, kernel.com is the file loaded from bootsector.
>>How can i give the starting segment and offset values to
>>the turbo c compiler ?
>
>Ahhh... I thought you were coding that as your
>bootsector... if not, then the whole 0x7c0 stuff
>is irrelavent.
>
>I still think it's probably an issue of jumping
>to the wrong area in memory, though. In real
>mode, you usually do end up getting a lot of
>garbage on the screen in such an instance.
>
>Check to make sure that where you load your
>kernel.com is available memory (not overriding
>the real mode ints, or any bios code) and make
>sure that you are, indeed, jumping to that
>very same address - you'll no doubt need a far
>jump (jmp segment:offset).
>
>Hope that helps,
>Jeff

This time I used a .exe boot loader and i compiled
the file kernel.c into kernel.exe. Every thing is
OK.
Thanks Jeff.