⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testport.c

📁 _计算实用教程Visual C++6.0实用教程
💻 C
字号:
/*----------------------------------------------*/
/* testport.c */
/* compile as: gcc -O testport.c */
/* Execution is possible only as a superuser*/
/*----------------------------------------------*/

#include <asm/io.h>
#include <asm/segment.h>
#include <asm/system.h>
#include <unistd.h>

int ioperm();

#define port_add 0x378

void main()
{
unsigned char test_value;
int ret_value;

ret_value=ioperm(data_port, 3, 1); 

if ( ret_value == -1 ) 
                     {
                     printf("Cannot get I/O permission\n");
                     exit(-1);
                     }
outb(0x55,port_add);

test_value=inb(port_add);
printf("\nValue at Data port= %x\n", test_value);

test_value=inb(port_add+1);
printf("\nValue at the Status Port= %x\n", test_value);

test_value=inb(port_add+2);
printf("\nValue at Control Port= %x\n", test_value);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -