outp(int addr, unsigned char val)
{
__asm
{
push edx
mov edx, DWORD PTR addr
mov al, BYTE PTR val
out dx, al
pop edx
}
}
然后应用上面的读取和输出函数进行位操作
1、
unsigned int val = inp(a_porta0);
outp(a_porta0, val | (1 << 1));//端口bit1操作
2:
unsigned int val = inp(a_porta0);
outp(a_porta0, val | (1 << 2));//端口bit2操作