移动文本模式光标不工作
Moving text mode cursor not working
我一直致力于在我目前正在开发的操作系统中移动文本模式光标。我很难让它显示出来。下面是我用来更新游标的代码:
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
EDIT:我使用Virtual box来运行它
您选择错误的VGA寄存器。您必须使用0x0F作为低电平,使用0x0E作为高电平(两者都有0x0A)。
编辑:如果你的光标是禁用的,这是如何启用它:
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
}
还可以查看此链接查看寄存器号和用法列表。
Edit2:游标位置变量的宽度不足以存储游标位置。unsigned char cursor_loc
应该是unsigned short cursor_loc
outb函数在错误的地方有端口和值。而不是:
asm volatile ( "outb %0, %1" : : "a"(value), "Nd"(port) );
试题:
asm volatile ("outb %1, %0" : : "dN" (port), "a" (value));
希望有帮助
相关文章:
- QSqlquery prepare()和bindvalue()不工作
- 如何在Qt C++中更改光标
- 导入库可以跨dll版本工作吗
- 以螺旋方式打印矩阵的程序.(工作不好)
- 对象指针在c++中是如何工作的
- 为什么在Windows上的VS 2019和Clang 9中"size_t"在没有标题的情况下工作
- VSOMEIP-2个设备之间的通信(TCP/UDP)不工作
- 为字符串中每 N 个字符插入空格的函数没有按照我认为的方式工作?
- C++为线程工作动态地分割例程
- 为什么我的 std::ref 无法按预期工作?
- 布尔比较运算符是如何在C++中工作的
- SampleConsensusPrerejective(ext.RANSAC)是如何真正工作的
- 不确定要在我的main中放入什么才能使我的代码正常工作
- 为什么std::condition_variable notify_all的工作速度比notify_one快(对于随机请
- <<操作员在下面的行中工作
- 有人能解释一下为什么下界是这样工作的吗C++的
- ExtractIconEx:可以工作,但偶尔会崩溃
- C++中的memset函数工作不正常
- 绘制移动图标,它一直是最顶端的鼠标光标和工作的全屏应用程序
- 移动文本模式光标不工作