c - 我的自定义操作系统内核中的 VGA 显示问题

标签 c assembly x86 osdev vga

我正在开发一个操作系统作为一个业余项目。我使用地址 0xB8000 连接 VGA 显示器,行数设置为 25,列数设置为 80。我使用了以下清屏功能:

void vga_init(void) {

    // Initialise the VGA variables and clear the screen : :
    vga_buffer_pointer = (uint16_t *)  VGA_MEMORY_LOCATION;

    //start clear using 2 pass loop : 
    uint8_t iter_i = 0;
    uint8_t iter_j = 0;

    for(iter_i = 0; iter_i < VGA_ROWS; iter_i ++) {

        for(iter_j = 0; iter_j < VGA_COLS; iter_j++) {
            uint8_t index  = (VGA_COLS *  iter_i) + iter_j;

            vga_buffer_pointer[index] = ((uint16_t)color << 8) | ' ';
        }
    }

    enable_cursor(14,15);
} 

我正在用绿色初始化屏幕。显示只占用qemu终端屏幕的一个端口,如下图:

a busy cat

但我希望整个终端都是绿色的。并且显示应该使用整个终端。非常感谢任何帮助。谢谢

我附上了我的代码要点。

VGA.c

最佳答案

改变:

uint8_t index = (VGA_COLS * iter_i) + iter_j; 

到:

uint16_t index = (VGA_COLS * iter_i) + iter_j; 

uint8_t 不够大,无法进行索引计算,因此它被截断,导致仅显示的一部分被删除。

关于c - 我的自定义操作系统内核中的 VGA 显示问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54500636/

相关文章:

c++ - C 中的函数序言和结尾

c - 为什么在将 C 向下转换从 unsigned int 转换为 unsigned char 时,movl 比 movb 更受欢迎?

linux - "No such file or directory"执行二进制文件时出错

assembly - 像这样的除法错误 - 溢出。要手动处理此错误,请更改中断向量表中 INT 0 的地址

c - 如何检查文件是否正在被另一个应用程序使用?

c++ - 阵列平均

c++ - 对话框关闭时 Win32 应用程序立即退出

c - 我可以使用什么预定义的宏来检测 clang?

assembly - 汇编程序错误。 : Bad instruction

assembly - 确定寄存器值是否等于零的最简单方法是什么?