简体   繁体   English

在C中使用BIOS显示数据

[英]Displaying data using BIOS in C

Is there any way to print data using bios in c. 有什么办法可以使用c中的bios打印数据。 I know in assembly you can use int 0x10 , but is there any equivalent for C? 我知道在汇编中您可以使用int 0x10 ,但是C是否有等效项?

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. 但是通常,如果使用C,则C stdlib应该可用。 So use printf(), and/or stdout... 因此,请使用printf()和/或stdout ...

If no OS is available, then it depends on the CPU mode. 如果没有可用的操作系统,则取决于CPU模式。

If the CPU is running in real mode, then use the 10h BIOS interrupt. 如果CPU在实模式下运行,请使用10h BIOS中断。
You can do it even in C. Most C compilers allows inline assembly. 您甚至可以在C语言中执行此操作。大多数C编译器都允许内联汇编。
For GCC, for instance, use the __asm keyword. 例如,对于GCC,请使用__asm关键字。

If you're in 32 bits protected mode, you need to manage video manually, as BIOS interrupts are no longer available. 如果处于32位保护模式,则由于BIOS中断不再可用,因此需要手动管理视频。

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... 在这种情况下,只需声明一个指向存储区的char指针,然后写入字符即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM