今天用C语言写的,以前都是汇编语言。
我先贴出来C语言写的,后面陆续贴出来汇编语言的。
刚刚C语言写的只能读,没法写,老实说,我还没有把移动光标的模块搞好。
所以,没法写。
下面贴代码:
我用的编译器:TC 2.0。
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <conio.h>
int main()
{
int port= 0x70;
int i;
unsigned char temp;
char ch;
while(!kbhit())
{
window(1,1,80,25);
textbackground(BLUE);
textcolor(YELLOW);
clrscr();
printf("Read value from cmos:\n");
printf(" ");
for(i=0;i<256;i++)
{
outp(port,i);
temp=inp(port+1);
if(temp<=15)
{
printf("0%X",temp);
}
else
{
printf("%X",temp);
}
printf(" ");
if((i+1)%16==0)
{
printf("\n");
printf(" ");
}
/*if(kbhit())
{
ch=getch();
if(ch=='q');
{break;}*/
}
}
sleep(1);/*wait for a second*/
}
system("pause");
return 0;
}
运行结果如下(win7下截图):
感觉还不错吧:)
蓝色背景,黄色字体的。
还是按任意键退出。
好了,大家有什么指教,请留言。
互相学习,共同进步嘛。