📄 iolib.c
字号:
/*
* iolib.c
*
* There are some user functions,kernel can also...
*/
#include "def.h"
#include "time.h"
#include "sched.h"
#include "stdio.h"
#include "system.h"
void outportb(unsigned short port,unsigned char data)
{
asm(
"movw %0,%%dx;"
"movb %1,%%al;"
"outb %%al,%%dx;"
::"r"(port),"r"(data)
:"%eax","%edx");
}
unsigned char inportb(unsigned short port)
{
unsigned char data=0;
asm(
"movw %1,%%dx;"
"inb %%dx,%%al;"
"movb %%al,%0;"
:"=r"(data)
:"r"(port)
:"%eax","%edx");
return data;
}
/*
*clear screen
*the function is a system call 0x80->0x01
*/
void clrscr()
{
asm(
"pushl %%eax;"
"movl $0x01,%%eax;"
"int $0x80;"
"popl %%eax;"
::
:"%eax");
}
/*
*scroll screen to up
*system call 0x80->0x03
*/
void scrup()
{
asm(
"pushl %%eax;"
"movl $0x03,%%eax;"
"int $0x80;"
"popl %%eax;"
::
:"%eax");
}
void print(char *str)
{
while(*str){
if(*str=='\n'){
setCursor(0,getCursorRow()+1);
str++;
continue;
}
putchar(*str);
str++;
}
}
void memcopy(char *dest,char *source,long nbytes)
{
while(nbytes--)
{
*(dest++) = *(source++);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -