帮我看看这段串口编程的程序

来源:百度知道 编辑:UC知道 时间:2024/05/05 10:50:51
void OpenPort()//①
{//②
unsigned char ucTemp;//③
InitCom();//④

asyncoldvect=getvect(0x0c);//⑥
disable();//⑦
inportb(0x3f8);//⑧
inportb(0x3fe);//⑨
inportb(0x3fb);//⑩
inportb(0x3fa);//⑾
outportb(0x3fc,0x08|0x0b);//⑿
outportb(0x3f9,0x01);//⒀
ucTemp=inportb(0x21)&0xef;//⒁
outportb(0x21,ucTemp);//⒂
setvect(0x0c,asyncint);//⒃
enable();//⒄
}//⒅

我想问一下第⒁行(ucTemp=inportb(0x21)&0xef;)中的0x21是什么东西?inportb(0x21)与0xef相与后D4强制性置零,请问D4置0又是什么意思?它的各位表示什么?
你说D4为0,是保留位,请问既然是保留位,那为什么有要对D4进行操作了?

0x21是中断掩码端口。
DO:改位为1时,表示允许接收器数据就绪中断
D1:改位为1时,允许发送保持寄存器空中断
D2:改位为1时,表示接受到有错信息,允许接收器中断
D3:改位为1时,表示允许“猫”状态变化中断
D4-D7,为0,属于保留位
-------------------------------------------------
上面的内容你看看吧!