Hi,
Please I need help...
I wrote:
1) Boot.asm
called by BIOS.POST
(16 Bits Code)
->load code from disk to...
7000:0000 - cpu.asm
7000:0200 - library.asm (with some functions like ShowMessage, LoadCode, etc)
7000:0400 - kernel32.asm
7000:0600 - kernel32.c
2) cpu.asm
loaded to (7000:0000) and jumped from boot.asm (1)
->Check the actual cpu that is running the code...
->If it support PM, then call next piece of code
-> them jumps to 7000:0400 (kernel32.asm)
3) kernel32.asm
just call C function
Kernel32.c
just write "Hello world" directly to the memory address
It seem simple, but is where all my problems start!!!!!
Here is my problem
This is 32bits asm code that is attached to a 32 bit C code (DGJPP) - No problem here!
When I call the C function the result is not what expect...
I'm using the bochs emulator to test the code...
It seems that I need to set up some registers... is this the case?
For example what kind o preparation the GRUB boot loader perform???
Please help me!
I want to start using C code without any boot loader...
I want make my own BL....
Problems executing C code
Re: Problems executing C code
Well you need to have a stack setup, so you need a GDT selector in ss and an address within that segment in esp.
Also you jump to 7000:0400 to jump to your 32bit code, offset:address is something you do in real mode not protected mode...
Does your code actually cause a triple fault (i.e. does the emulator reset) or does it just loop?
Jules
Also you jump to 7000:0400 to jump to your 32bit code, offset:address is something you do in real mode not protected mode...
Does your code actually cause a triple fault (i.e. does the emulator reset) or does it just loop?
Jules
Re: Problems executing C code
Code: Select all
_asm
{
mov ax, 10h
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
}
Last edited by cr2 on Sat Sep 13, 2008 9:20 pm, edited 1 time in total.
OS-LUX V0.0
Working on...
Memory management: the Pool
Working on...
Memory management: the Pool
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Problems executing C code
That code won't even run when the cpu mode is something other than protected mode.
Its like, if(this == null) error();
Its like, if(this == null) error();
-
- Member
- Posts: 76
- Joined: Mon Aug 18, 2008 6:17 am
Re: Problems executing C code
Thanks for your reply,
...and I will back!
-----------------------------------
Think it, build it, bit by bit...
...and I will back!
-----------------------------------
Think it, build it, bit by bit...
-
- Member
- Posts: 76
- Joined: Mon Aug 18, 2008 6:17 am
Re: Problems executing C code
Another question,
Relating to the "Bran's Kernel Dev Tut", he sets up the GDT from C code... and I don't see any code changing CPU to the PM... I presume that it was the GRUB job, right?
Thus, the GRUB start in 16Bit, prepare a GDT, goto PM, and load our 32 Bit asm code that was previous linked to the c 32 bit, right???
then, that C code, prepare again (????) a new GDT, etc... and uala, your kernel is running.... is it correct?
Please, I really need to understand this first 'BIG BANG' moment, then ...a lot of thing will coming a live...
Miguel Esteves (InsightSoft)
-------------------------------------
Think it, build it, bit by bit...
Relating to the "Bran's Kernel Dev Tut", he sets up the GDT from C code... and I don't see any code changing CPU to the PM... I presume that it was the GRUB job, right?
Thus, the GRUB start in 16Bit, prepare a GDT, goto PM, and load our 32 Bit asm code that was previous linked to the c 32 bit, right???
then, that C code, prepare again (????) a new GDT, etc... and uala, your kernel is running.... is it correct?
Please, I really need to understand this first 'BIG BANG' moment, then ...a lot of thing will coming a live...
Miguel Esteves (InsightSoft)
-------------------------------------
Think it, build it, bit by bit...
Re: Problems executing C code
Yes, GRUB sets up the A20 Gate and all that good stuff so you automatically get jump-started into PM.Thus, the GRUB start in 16Bit, prepare a GDT, goto PM, and load our 32 Bit asm code that was previous linked to the c 32 bit, right???
then, that C code, prepare again (????) a new GDT, etc... and uala, your kernel is running.... is it correct?