移动文本模式光标不工作 [英] Moving text mode cursor not working
问题描述
我一直在操作系统中我目前正在开发移动文本模式光标。我无法得到它显示在所有。下面是我用更新光标code:
I have been working on moving the text mode cursor in the operating system I am currently developing. I am having trouble getting it to show up at all. Here is the code that I use to update the cursor:
void update_cursor()
{
unsigned char cursor_loc = (y_pos*Cols)+x_pos;
// cursor LOW port to vga INDEX register
outb(0x3D4, 0x0F);
outb(0x3D5, (unsigned char)(cursor_loc));
// cursor HIGH port to vga INDEX register
outb(0x3D4, 0x0E);
outb(0x3D5, (unsigned char)((cursor_loc>>8)));
}
static inline void outb(unsigned short port, unsigned char value)
{
asm volatile ( "outb %0, %1" : : "a"(value), "Nd"(port) );
}
static inline unsigned char inb(unsigned short port)
{
unsigned char ret;
asm volatile ( "inb %1, %0" : "=a"(ret) : "Nd"(port) );
return ret;
}
我用gcc版本4.8.3(GCC)编译我的主要文件。我完全失去了。任何人有任何建议,什么可能是这个问题吗?
如果你想看到完整的源代码就位于这里: https://开头github.com/AnonymousUser1337/Anmu/blob/master/Kernel/kernel.cpp
修改:我使用虚拟框运行
先谢谢了。
推荐答案
您选择错了VGA寄存器。你必须使用为0x0F为低,为0x0E高(你必须0x0A的两个)。
You select wrong VGA registers. You have to use 0x0F for low and 0x0E for high (you have 0x0A for both).
编辑:如果你的光标被禁用,这是如何实现的:
In case your cursor is disabled, this is how to enable it:
void enable_cursor() {
outb(0x3D4, 0x0A);
char curstart = inb(0x3D5) & 0x1F; // get cursor scanline start
outb(0x3D4, 0x0A);
outb(0x3D5, curstart | 0x20); // set enable bit
}
另外,请查阅此链接用于寄存器数量和用途名单。
Also check this link for list of register numbers and usages.
EDIT2:您的光标所在位置的变量是不够宽,存储光标位置。 unsigned char型cursor_loc
应无符号短cursor_loc
。
Your cursor location variable is not wide enough to store the cursor location. unsigned char cursor_loc
should be unsigned short cursor_loc
.
这篇关于移动文本模式光标不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!