Add an INT with C...
Posted: Thu Feb 20, 2003 12:00 am
Hello:
I am trying to add the INT 20H to the Interrupt Table for an real mode OS, I did it with ASM yet, but now I like do it with C:
extern void putch(char);
ISR20H(void);
main() {
putch('M');
putch('I');
putch('S');
putch('I');
putch('S');
putch(' ');
putch('1');
putch('.');
putch('0');
putch('.');
putch(13);
putch(10);
asm xor ax, ax;
asm mov ss, ax;
asm mov ax, cs;
asm cli;
asm mov bx, offset ISR20H;
asm mov word [ss:80h], bx;
asm mov word [ss:82h], ax;
asm sti;
asm int 20h;
while(1) {}}
ISR20H(void) {
putch('I');
putch('N');
putch('T');
putch(' ');
putch('2');
putch('0');
putch('H');
putch(13);
putch(10); }
I compile the file that have the putch() rutine with:
tasm -mx k_lib.asm
And then I compile the kernel with:
tcc -mt -B kernel.c k_lib.obj
Finally, I use exe2bin to create a .COM file that I load with my boot program (I've tasted it with other files and it is working nice).
I can't display the text "INT 20H".
Some one know where my error is?
Thank you
I am trying to add the INT 20H to the Interrupt Table for an real mode OS, I did it with ASM yet, but now I like do it with C:
extern void putch(char);
ISR20H(void);
main() {
putch('M');
putch('I');
putch('S');
putch('I');
putch('S');
putch(' ');
putch('1');
putch('.');
putch('0');
putch('.');
putch(13);
putch(10);
asm xor ax, ax;
asm mov ss, ax;
asm mov ax, cs;
asm cli;
asm mov bx, offset ISR20H;
asm mov word [ss:80h], bx;
asm mov word [ss:82h], ax;
asm sti;
asm int 20h;
while(1) {}}
ISR20H(void) {
putch('I');
putch('N');
putch('T');
putch(' ');
putch('2');
putch('0');
putch('H');
putch(13);
putch(10); }
I compile the file that have the putch() rutine with:
tasm -mx k_lib.asm
And then I compile the kernel with:
tcc -mt -B kernel.c k_lib.obj
Finally, I use exe2bin to create a .COM file that I load with my boot program (I've tasted it with other files and it is working nice).
I can't display the text "INT 20H".
Some one know where my error is?
Thank you