Ports.c
资源名称:ports.zip [点击查看]
上传用户:mery1987
上传日期:2007-01-03
资源大小:3k
文件大小:2k
源码类别:
通讯编程
开发平台:
Visual C++
- #include "ports.h"
- //-----------------------------------------------------------------------
- // functions
- // inport - inputs a word from a hardware port
- // inportb - inputs a byte from a hardware port
- // inp - inputs a byte from a hardware port
- // inpw - inputs a word from a hardware port
- //
- // outport - outputs a word to a hardware port
- // outportb - outputs a byte to a hardware port
- // outp - outputs a byte to a hardware port
- // outpw - outputs a word to a hardware port
- //-----------------------------------------------------------------------
- unsigned short inport(unsigned short port)
- {
- asm mov dx,port
- asm in ax,dx
- return _AX;
- }
- unsigned char inportb(unsigned short port)
- {
- asm mov dx,port
- asm in al,dx
- asm xor ah,ah
- return _AX;
- }
- unsigned short inpw(unsigned short port)
- {
- asm mov dx,port
- asm in ax,dx
- return _AX;
- }
- short int inp(unsigned short port)
- {
- asm mov dx,port
- asm in al,dx
- asm xor ah,ah
- return _AX;
- }
- void outport(unsigned short port, unsigned short val)
- {
- asm mov dx, port
- asm mov ax, val
- asm out dx, ax
- }
- void outportb(unsigned short port, unsigned char val)
- {
- asm mov dx, port
- asm mov al, val
- asm out dx, al
- }
- unsigned short outpw(unsigned short port, unsigned short val)
- {
- asm mov dx, port
- asm mov ax, val
- asm out dx, ax
- return (_AX);
- }
- short int outp(unsigned short port, unsigned char val)
- {
- asm mov dx, port
- asm mov al, val
- asm out dx, al
- asm xor ah, ah
- return (_AX);
- }