| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 
 |  
#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);
} | 
Partager