Problem kernel code
Posted: Fri Oct 03, 2003 11:00 pm
Hi I am back....
I have a kernel (right now it does nothing though). All that it does is print a 'S' character and calls a C function. And this calling is within a while(1) loop(infinite). But bochs reports SP==1 error(stack pointer error) after a going thru the loop for some time. This is the code :
start.asm
---------
extern _Dmain
global _Start
[SEGMENT .text]
_Start:
mov ax, cs
mov ds, ax
mov ss, ax
mov es, ax
mov sp, 0xFFFF
call _Dmain
kernel.c
--------
void summa();
void Dmain()
{
int a = 20; //No use vars
char b = 'S'; //No use vars
while(1)
{
print();
summa();
}
}
void summa()
{
//Function does nothing
}
print.asm
----------global _print
[SEGMENT .text]
_print:
push ebp
mov ebp, esp
mov ah,0x0E
mov al,0x53
int 0x10
pop ebp
ret
link.ld - My linker script
---------------------------
OUTPUT_FORMAT("binary")
ENTRY(_Start)
SECTIONS
{
.text 0x00000000 :
{
*(.text)
}
}
PS: I am in real mode (obvious isn't it?)
I have a kernel (right now it does nothing though). All that it does is print a 'S' character and calls a C function. And this calling is within a while(1) loop(infinite). But bochs reports SP==1 error(stack pointer error) after a going thru the loop for some time. This is the code :
start.asm
---------
extern _Dmain
global _Start
[SEGMENT .text]
_Start:
mov ax, cs
mov ds, ax
mov ss, ax
mov es, ax
mov sp, 0xFFFF
call _Dmain
kernel.c
--------
void summa();
void Dmain()
{
int a = 20; //No use vars
char b = 'S'; //No use vars
while(1)
{
print();
summa();
}
}
void summa()
{
//Function does nothing
}
print.asm
----------global _print
[SEGMENT .text]
_print:
push ebp
mov ebp, esp
mov ah,0x0E
mov al,0x53
int 0x10
pop ebp
ret
link.ld - My linker script
---------------------------
OUTPUT_FORMAT("binary")
ENTRY(_Start)
SECTIONS
{
.text 0x00000000 :
{
*(.text)
}
}
PS: I am in real mode (obvious isn't it?)