📄 8255_io.c
字号:
/*8255 in I/O mode with Port A and B as Inputs and C as output*/
/*8255_io.c*/
#include<dos.h>
#include<stdio.h>
#define BASE_ADDRESS 0x300
main()
{
unsigned char control_byte, temp;
control_byte=0x92; /*10010010*/
/*This control byte programs the 8255 in the I/O mode with all the
ports in mode 0. Port A and B as inputs and C as output*/
outportb(BASE_ADDRESS+3, control_byte);
/*this loads the control register of the 8255 with number 0x92*/
/*Now any of the 8255 ports can be used.*/
/*to read the port A and B just do the following*/
temp= inportb(BASE_ADDRESS); /*this reads port A*/
temp = inportb(BASE_ADDRESS + 1); /*this reads port B*/
outportb(BASE_ADDRESS+2, temp);
/*this write the contents of temp into port C*/
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -