关于端口访问的问题.........
hdaq 2003-01-13 03:04:03 我有一个程序,由于硬件的要求(没有驱动的数据采集卡,只告知端口定义),需要使用汇编直接端口读写(且只要求在98和ME下使)。于是照书上的方法用了以下函数:
unsigned short inportw(unsigned short port)
{
_DX = port;
__emit__(0x66, 0xED); // 66ED = opcode for in ax,dx
return _AX;
}
void outportw(unsigned short port, unsigned short value)
{
_DX = port;
_AX = value;
__emit__(0x66, 0xEF); // 66EF = opcode for out dx,ax
}
开始时程序能用,程序也正常,并能从采集卡上读取正确的数据。
但是在程序不断增加一些功能的情况下,就出问题了,只要往程序里加一些代码,编译就会出如下问题:
[Tasm Fatal Error] Out of hash space
对应的出错对话筐为:Connot open file d:\bt\main\.
我的prj在d:\bt\main\下,不知道是什么原因?那个"."又是什么意思?
我把以上的汇编换成:
unsigned short inportw(unsigned short port)
{
asm mov dx,port
asm in ax,dx
return _AX;
}
void outportw(unsigned short port, unsigned short val)
{
asm mov dx, port
asm mov ax, val
asm out dx, ax
}
也是一样,把这两个函数中的汇编去掉,就能编译通过。
还有更改Options下Tasm下的Hash也没有用。
不知道要怎样处理?各位大哥大姐帮帮忙,谢过先了。