problem in printf stuff
Re:problem in printf stuff
I think it could be a GDT thing because how you setup your GDT either lets you write messages to RAM ( what your doing ) or not. )
Re:problem in printf stuff
well i have sorted out the problem
thanx for ur help ;D
thanx for ur help ;D
Re:problem in printf stuff
i dont know i just put a
void start(){
c_main();
}
in the start of my kernel and it started working .. i read something about this in Tim Robinson tutorial that the literal strings comes to the top after compiling and hence the computer crashes so this was the suggestion in the tutorial to write a method in the start and call main ..
by the way thanx for ur help
void start(){
c_main();
}
in the start of my kernel and it started working .. i read something about this in Tim Robinson tutorial that the literal strings comes to the top after compiling and hence the computer crashes so this was the suggestion in the tutorial to write a method in the start and call main ..
by the way thanx for ur help
Re:problem in printf stuff
huh? usually you can just type in what ever function you like...at least with my code
Re:problem in printf stuff
OH...ADD this to the top of your code:
asm( "jmp <your main function>" );
asm( "jmp <your main function>" );
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:problem in printf stuff
hmm ... and pray for the linker to keep it on top ... i prefer well-defined entry points ...Tom wrote: OH...ADD this to the top of your code:
asm( "jmp <your main function>" );
Re:problem in printf stuff
you could do this:
#pragma startup asm( "sti" ) 64 // OOPS edited this, needs to be 64
#pragma startup asm( "sti" ) 64 // OOPS edited this, needs to be 64
Re:problem in printf stuff
I think Tom is asking for trouble there.
The best thing to do is to write a separate .asm file which calls your C entry point (you will also want to set up the stack etc. too). If you put that file first on the linker command line then it is virtually guaranteed to get put in the right place.
Of course, if you're not using flat binary, then it doesn't matter where your entry point is -- you can even start straight into your C function.
The best thing to do is to write a separate .asm file which calls your C entry point (you will also want to set up the stack etc. too). If you put that file first on the linker command line then it is virtually guaranteed to get put in the right place.
Of course, if you're not using flat binary, then it doesn't matter where your entry point is -- you can even start straight into your C function.
Re:problem in printf stuff
I don't know how that asm function got changed to "sti"
but...I ment to do:
...asm( "jmp start" )...
but...I ment to do:
...asm( "jmp start" )...
Re:problem in printf stuff
well actually Tim i m already using a 2nd stage loader to load this c kernel at 00005000 thats why i was avoiding another asm file in between them coz then i will load that file at this place and then again from that file jump to this kernel at some other place ..
well thanx for everyone help
well thanx for everyone help
Re:problem in printf stuff
ok now i have a few more questions:
1. for the printf function i m thinking that if my printf has to print some variable value how does it works then..
coz it should be a general one for all data types mean it should print int , char or string whatever comes in its way .. so if i pass first argument of aprintf , the printed string and second argument, that variable which can either be an int or a char or something else..
so what should be that 2nd argument which can a char or int or anything else..is there a way to do something like that.. hope u understood it
2. i need a getCursor funtion which could return the current cursor position .. if u give me the code plz explain it
thanx
1. for the printf function i m thinking that if my printf has to print some variable value how does it works then..
coz it should be a general one for all data types mean it should print int , char or string whatever comes in its way .. so if i pass first argument of aprintf , the printed string and second argument, that variable which can either be an int or a char or something else..
so what should be that 2nd argument which can a char or int or anything else..is there a way to do something like that.. hope u understood it
2. i need a getCursor funtion which could return the current cursor position .. if u give me the code plz explain it
thanx
Re:problem in printf stuff
look at my fstdio.h in pk0.6...include it and my other files and test this:
void <your main>()
{
start_textmode();
printf( "Gettting Cursor:\n" );
printf( "x=%d, y=%d", cur_cursorX, cur_cursorY );
Freeze();
}
void <your main>()
{
start_textmode();
printf( "Gettting Cursor:\n" );
printf( "x=%d, y=%d", cur_cursorX, cur_cursorY );
Freeze();
}
Re:problem in printf stuff
well Tom thanx but actually i have ur code and when i checked it i didnt understood it thats why i posted the message here .. first u have this in ur code
i have no idea how does this 2nd argument "..." works. plz explain these 3 dots
after that
what is this va_list.. to check this i went to stdarg.h and to tell u the truth i didnt understood a single word of it
now comes the cursor thing..
plz can u explain this and how do u know that sending 0x0f to 0x3D4 works in this way and similarly for the 2nd one .. i mean from where do u get to know this
i know these are alot of questions but plz if u have time explain them in detail or if some one else could do it
thanx for ur help
hey i have one more thing to ask .. like if i m loading my kernel code at 00005000 then i use
jmp dword CODE_SEG:0x5000;
but what if i load it at 50000000??
Code: Select all
static int printf( char *msg, ... )
after that
Code: Select all
va_list args;
now comes the cursor thing..
Code: Select all
// cursor LOW port to vga INDEX register
outportb( 0x3D4, 0x0F );
outportb( 0x3D5, ( UCHAR ) ( position & 0xFF ) );
// cursor HIGH port to vga INDEX register
outportb( 0x3D4, 0x0E );
outportb( 0x3D5, ( UCHAR ) ( ( position >> 8 ) & 0xFF ) );
i know these are alot of questions but plz if u have time explain them in detail or if some one else could do it
thanx for ur help
hey i have one more thing to ask .. like if i m loading my kernel code at 00005000 then i use
jmp dword CODE_SEG:0x5000;
but what if i load it at 50000000??