Below is the file 'ioport.c' from this revision. You can also download the file.

#include <windows.h>
#include "ioport.h"

void outport(unsigned int portid, unsigned int value)
{
  asm("out %%ax,%%dx" : : "a"(value), "d"(portid));
}
void outportb(unsigned int portid, unsigned char value)
{
  asm("out %%al,%%dx" : : "a"(value), "d"(portid));
}

unsigned char inportb(unsigned int portid)
{
  unsigned char value;
  
  asm("in %%dx,%%al" : "=a"(value) : "d"(portid));
  return value;
}

unsigned int inport(unsigned int portid)
{
  int value=0;

  asm("in %%dx,%%ax" : "=a"(value) : "a"(value), "d"(portid));
  return value;
}