Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Thanks for the tip! The video code as it is now is still rudimentary as I planned on defeating this problem first.
What annoys me is that printc works flawless and printf (which uses printc) doesn't..
EDIT: It seems to be some relocation problem (?) once inside the isr..
ru2aqare wrote:I don't know what assembly code does your TC generate, but you may have to reload (and upon exit from the interrupt function, restore) the segment registers.
Do a disassembly like that of printf and show us. It's probably a bad segment.
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
Risc wrote:Thanks for the tip! The video code as it is now is still rudimentary as I planned on defeating this problem first.
What annoys me is that printc works flawless and printf (which uses printc) doesn't..
What would happen if the compiled code looked something like this when you are not zeroing bh inside printc? There is no guarantee that's the problem, but it might be:
0000h 0000h 1024 interrupt vector table
0400h 172 BIOS communication area
04ACh 68 reserved by IBM
04F0h 16 user communication area
0500h 256 DOS communication area
EDIT: I'm no expert (as you may have understood by now ) but shouldn't I be able to init all segments to 0 and set the origin to 0x0500? I mean shouldn't 0x0050:0x0000 be the same as 0x0000:0x0500?
EDIT2: Stupid me, it's probably exe2bin that relocates the code..
The DOS communication area isn't the kernel; it's for interacting between the kernel and the programs being run.
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
The segment registers will obviously have whatever you put into them prior to jumping to the kernel. To get a load address of 0x500 you would need to write an assembly language stub, which looked something like this:
text segment para 'text' ;may need modifying - it's a long time since I
;programmed in turbo-c, so I can't
;remember what the naming conventions are
org 500h
call _kmain
call _bsod ;under normal circumstances, you shouldn't
;return from kmain
jmp $
text ends
/*******************************************
Kernel.c
********************************************/
void _kmain()
{
printf( "Hello World" );
}
C:\ tlink stub.obj kernel.obj
The continuous image of a connected set is connected.
Why have you got org 0x50? The org directive refers to the offset.
If you load the segment registers with 0x50 in the boot sector, the kernel will need an org 0. An assembly language stub is not a bad idea, because you will know exactly what you are getting.
Also, any sight of a function called main() could be an open invitation for the linker to try and link in the default stub used in applications development (which, amongst other things, creates the argc and argv[] arguments). Call it kmain, or whatever else takes your fancy.
The continuous image of a connected set is connected.