views:

109

answers:

1

Is there any way to print data using bios in c. I know in assembly you can use int 0x10, but is there any equivalent for C?

+1  A: 

It depends whether an OS is already running or not.
If yes, it depends on the OS which is running. But usually, if using C, a C stdlib should be available. So use printf(), and/or stdout...

If no OS is available, then it depends on the CPU mode.

If the CPU is running in real mode, then use the 10h BIOS interrupt.
You can do it even in C. Most C compilers allows inline assembly.
For GCC, for instance, use the __asm keyword.

If you're in 32 bits protected mode, you need to manage video manually, as BIOS interrupts are no longer available.

In such a case, printing data is just writing into to memory area which contains the video buffer. The you need to know in which video mode you are, so you can write data in the correct format, and what's the memory address of the memory buffer.
In such a case, simply declares a char pointer to the memory area, and writes characters...

Macmade
Well, you can also switch back to real mode, call the BIOS interrupt then switch back to protected mode. But that's a bit agricultural.
caf
«Agricultural» First time I hear it, but I just love that, given the context! : )
Macmade