我在文本模式下更新光标位置的函数有问题,函数定义和声明是
#include <sys/io.h>
signed int VGAx = 0,VGAy=0;
void setcursor()
{
uint16_t position = VGAx+VGAy*COLS;
outb(0x0f, 0x03d4);
outb((position<<8)>>8,0x03d5);
outb(0x0e,0x03d4);
outb(position>>8,0x03d5);
}
Run Code Online (Sandbox Code Playgroud)
和文件 sys/io.h
static inline unsigned char inb (unsigned short int port)
{
unsigned char value;
asm ("inb %0, %%al":"=rm"(value):"a"(port));
return value;
}
static inline void outb(unsigned char value, unsigned short int port)
{
asm volatile ("outb %%al, $0"::"rm"(value), "a"(port));
}
Run Code Online (Sandbox Code Playgroud)
使用该功能前光标有时闪烁下划线有时不出现而使用该功能后没有光标出现
这是运行的主要功能
#include <vga/vga.h>
int kmain(){
setcursor()
setbgcolor(BLACK);
clc();
setforecolor(BLUE);
terminal_write('h');
setcursor();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用此功能
void enable_cursor() { …Run Code Online (Sandbox Code Playgroud) 我是初学者 C 程序员,我读到这printf()是一个非常复杂的函数,速度非常慢并且消耗很多 CPU 周期。所以我想知道标准纯 c 库中是否存在任何函数,并且比该函数更快printf()或不更快,以及何时使用该函数以及何时不使用它。我的目标是编写可以在任何计算机和/或嵌入式系统上运行的高效代码