请教我这样读IO为什么读出来的结果是错的?
大家都说用EVC可以内嵌汇编来读写IO , 但是我测试了下读cmos时间的秒却发现结果总是错 ,到底wince.net能不能这样操作IO呢?谢谢。读系统时间当向70号端口发送0的时候从71号端口返回的应该是当前秒的大小。
//写IO
void CIO1Dlg::OutPortByte(int addr,BYTE prnch)
{
#if defined(x86)
_asm
{
push eax
push edx
mov edx,addr
mov al,prnch
out dx,al
pop edx
pop eax
}
#endif
}
//读IO
BYTE CIO1Dlg::InPortByte(int addr)
{
BYTE tb =0 ;
//printf("InPortByte %d\n",tb);
#if defined(x86)
_asm
{
push eax
push edx
mov edx,addr
in al,dx
mov tb,al
pop edx
pop eax
}
#endif
//printf("InPortByte %d\n",tb);
return tb;
}
//读取cmos时间的秒
void CIO1Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
OutPortByte(70,0);
m_Edit.Format(_T("%d") , InPortByte(71));
UpdateData(false);
}